MeasureProcedureImport.cs 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005
  1. using Resources;
  2. using SmartCoalApplication.Base;
  3. using SmartCoalApplication.Base.CommTool;
  4. using SmartCoalApplication.Base.MeasureModel;
  5. using SmartCoalApplication.Core;
  6. using SmartCoalApplication.PluginAssemblys;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.IO;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using System.Windows.Forms;
  17. namespace SmartCoalApplication.MeasureProcedure
  18. {
  19. internal partial class MeasureProcedureImport : PdnBaseForm
  20. {
  21. #region [组件]
  22. private GroupBox groupBox1;
  23. private Button button6;
  24. private Button button5;
  25. private Button button3;
  26. private Button button2;
  27. private GroupBox groupBox2;
  28. private Button button8;
  29. private GroupBox groupBox3;
  30. private RadioButton radioButton2;
  31. private RadioButton radioButton1;
  32. private TextBox textBox4;
  33. private Button button4;
  34. private GroupBox groupBox4;
  35. private GroupBox groupBox5;
  36. private Label label1;
  37. private TextBox textBox1;
  38. private GroupBox groupBox6;
  39. private TextBox textBox2;
  40. private Label label2;
  41. private Button button7;
  42. private Button button1;
  43. private Button button10;
  44. private Button button9;
  45. private Button button11;
  46. #endregion
  47. private AppWorkspace appWorkspace;
  48. /// <summary>
  49. /// 测试规程树状图
  50. /// </summary>
  51. private SmartCoalApplication.Core.CustomControl.TreeViewEnhanced treeView1;
  52. /// <summary>
  53. /// 选择的步
  54. /// </summary>
  55. private int chooseStep = 1;
  56. private MeasureMaintenanceTypeList measureMaintenanceTypeList;
  57. private MeasureMaintenanceTypeList importMeasureMaintenanceTypeList;
  58. /// <summary>
  59. /// 压缩中间数据目录
  60. /// </summary>
  61. private string temporaryFilePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MidData\\Temp\\";
  62. /// <summary>
  63. /// 解压中间数据目录
  64. /// </summary>
  65. private string unZipTemporaryFilePath = Application.StartupPath + "\\Config\\MidData" + Program.instance.SettingPrefix + "\\UnZipTemp\\";
  66. /// <summary>
  67. /// 测试规程文件路径
  68. /// </summary>
  69. private string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MeasureMaintenanceTypeList.xml";
  70. /// <summary>
  71. /// 测试规程检验项目文件路径
  72. /// </summary>
  73. private string rulerFilePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MeasureMaintenanceType\\";
  74. public MeasureProcedureImport(AppWorkspace appWorkspace)
  75. {
  76. InitializeComponent();
  77. InitializeLanguageText();
  78. this.appWorkspace = appWorkspace;
  79. #region [获取测试规程]
  80. if (!System.IO.File.Exists(filePath))
  81. {
  82. measureMaintenanceTypeList = new MeasureMaintenanceTypeList();
  83. measureMaintenanceTypeList.measureMaintenanceTypeList = new List<MeasureMaintenanceType>();
  84. }
  85. else
  86. {
  87. measureMaintenanceTypeList = XmlSerializeHelper.DESerializer<MeasureMaintenanceTypeList>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  88. }
  89. #endregion
  90. #region [组织树状图]
  91. this.treeView1.CheckBoxes = true;
  92. this.treeView1.ItemHeight = 18;
  93. this.createTreeView();
  94. this.button1_Click(null, null);
  95. #endregion
  96. #region [生成中间文件夹]
  97. this.createDefaultDirectory();
  98. #endregion
  99. }
  100. #region [初始化]
  101. /// <summary>
  102. /// Required method for Designer support - do not modify
  103. /// the contents of this method with the code editor.
  104. /// </summary>
  105. private void InitializeComponent()
  106. {
  107. this.groupBox3 = new System.Windows.Forms.GroupBox();
  108. this.button4 = new System.Windows.Forms.Button();
  109. this.textBox4 = new System.Windows.Forms.TextBox();
  110. this.radioButton2 = new System.Windows.Forms.RadioButton();
  111. this.radioButton1 = new System.Windows.Forms.RadioButton();
  112. this.groupBox5 = new System.Windows.Forms.GroupBox();
  113. this.textBox1 = new System.Windows.Forms.TextBox();
  114. this.label1 = new System.Windows.Forms.Label();
  115. this.groupBox1 = new System.Windows.Forms.GroupBox();
  116. this.button6 = new System.Windows.Forms.Button();
  117. this.button5 = new System.Windows.Forms.Button();
  118. this.button3 = new System.Windows.Forms.Button();
  119. this.button2 = new System.Windows.Forms.Button();
  120. this.button1 = new System.Windows.Forms.Button();
  121. this.groupBox6 = new System.Windows.Forms.GroupBox();
  122. this.button7 = new System.Windows.Forms.Button();
  123. this.textBox2 = new System.Windows.Forms.TextBox();
  124. this.label2 = new System.Windows.Forms.Label();
  125. this.groupBox4 = new System.Windows.Forms.GroupBox();
  126. this.treeView1 = new SmartCoalApplication.Core.CustomControl.TreeViewEnhanced();
  127. this.groupBox2 = new System.Windows.Forms.GroupBox();
  128. this.button11 = new System.Windows.Forms.Button();
  129. this.button10 = new System.Windows.Forms.Button();
  130. this.button9 = new System.Windows.Forms.Button();
  131. this.button8 = new System.Windows.Forms.Button();
  132. this.groupBox3.SuspendLayout();
  133. this.groupBox5.SuspendLayout();
  134. this.groupBox1.SuspendLayout();
  135. this.groupBox6.SuspendLayout();
  136. this.groupBox4.SuspendLayout();
  137. this.groupBox2.SuspendLayout();
  138. this.SuspendLayout();
  139. //
  140. // groupBox3
  141. //
  142. this.groupBox3.Controls.Add(this.button4);
  143. this.groupBox3.Controls.Add(this.textBox4);
  144. this.groupBox3.Controls.Add(this.radioButton2);
  145. this.groupBox3.Controls.Add(this.radioButton1);
  146. this.groupBox3.Location = new System.Drawing.Point(133, 67);
  147. this.groupBox3.Name = "groupBox3";
  148. this.groupBox3.Size = new System.Drawing.Size(604, 409);
  149. this.groupBox3.TabIndex = 19;
  150. this.groupBox3.TabStop = false;
  151. this.groupBox3.Text = "设置";
  152. //
  153. // button4
  154. //
  155. this.button4.Location = new System.Drawing.Point(512, 64);
  156. this.button4.Name = "button4";
  157. this.button4.Size = new System.Drawing.Size(75, 21);
  158. this.button4.TabIndex = 13;
  159. this.button4.Text = "选择";
  160. this.button4.UseVisualStyleBackColor = true;
  161. this.button4.Click += new System.EventHandler(this.button4_Click);
  162. //
  163. // textBox4
  164. //
  165. this.textBox4.Location = new System.Drawing.Point(24, 65);
  166. this.textBox4.Name = "textBox4";
  167. this.textBox4.ReadOnly = true;
  168. this.textBox4.Size = new System.Drawing.Size(482, 21);
  169. this.textBox4.TabIndex = 12;
  170. //
  171. // radioButton2
  172. //
  173. this.radioButton2.AutoSize = true;
  174. this.radioButton2.Location = new System.Drawing.Point(24, 109);
  175. this.radioButton2.Name = "radioButton2";
  176. this.radioButton2.Size = new System.Drawing.Size(47, 16);
  177. this.radioButton2.TabIndex = 1;
  178. this.radioButton2.TabStop = true;
  179. this.radioButton2.Text = "导出";
  180. this.radioButton2.UseVisualStyleBackColor = true;
  181. //
  182. // radioButton1
  183. //
  184. this.radioButton1.AutoSize = true;
  185. this.radioButton1.Checked = true;
  186. this.radioButton1.Location = new System.Drawing.Point(24, 30);
  187. this.radioButton1.Name = "radioButton1";
  188. this.radioButton1.Size = new System.Drawing.Size(47, 16);
  189. this.radioButton1.TabIndex = 0;
  190. this.radioButton1.TabStop = true;
  191. this.radioButton1.Text = "导入";
  192. this.radioButton1.UseVisualStyleBackColor = true;
  193. this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
  194. //
  195. // groupBox5
  196. //
  197. this.groupBox5.Controls.Add(this.textBox1);
  198. this.groupBox5.Controls.Add(this.label1);
  199. this.groupBox5.Location = new System.Drawing.Point(133, 78);
  200. this.groupBox5.Name = "groupBox5";
  201. this.groupBox5.Size = new System.Drawing.Size(604, 398);
  202. this.groupBox5.TabIndex = 21;
  203. this.groupBox5.TabStop = false;
  204. this.groupBox5.Text = "设置";
  205. //
  206. // textBox1
  207. //
  208. this.textBox1.Location = new System.Drawing.Point(24, 65);
  209. this.textBox1.Name = "textBox1";
  210. this.textBox1.ReadOnly = true;
  211. this.textBox1.Size = new System.Drawing.Size(462, 21);
  212. this.textBox1.TabIndex = 1;
  213. //
  214. // label1
  215. //
  216. this.label1.AutoSize = true;
  217. this.label1.Location = new System.Drawing.Point(22, 34);
  218. this.label1.Name = "label1";
  219. this.label1.Size = new System.Drawing.Size(77, 12);
  220. this.label1.TabIndex = 0;
  221. this.label1.Text = "从......导入";
  222. //
  223. // groupBox1
  224. //
  225. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  226. | System.Windows.Forms.AnchorStyles.Left)));
  227. this.groupBox1.Controls.Add(this.button6);
  228. this.groupBox1.Controls.Add(this.button5);
  229. this.groupBox1.Controls.Add(this.button3);
  230. this.groupBox1.Controls.Add(this.button2);
  231. this.groupBox1.Controls.Add(this.button1);
  232. this.groupBox1.Location = new System.Drawing.Point(12, 2);
  233. this.groupBox1.Name = "groupBox1";
  234. this.groupBox1.Size = new System.Drawing.Size(115, 474);
  235. this.groupBox1.TabIndex = 17;
  236. this.groupBox1.TabStop = false;
  237. //
  238. // button6
  239. //
  240. this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  241. | System.Windows.Forms.AnchorStyles.Right)));
  242. this.button6.Location = new System.Drawing.Point(20, 412);
  243. this.button6.Name = "button6";
  244. this.button6.Size = new System.Drawing.Size(75, 23);
  245. this.button6.TabIndex = 4;
  246. this.button6.Text = "上一步";
  247. this.button6.UseVisualStyleBackColor = true;
  248. this.button6.Click += new System.EventHandler(this.button6_Click);
  249. //
  250. // button5
  251. //
  252. this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  253. | System.Windows.Forms.AnchorStyles.Right)));
  254. this.button5.Location = new System.Drawing.Point(20, 441);
  255. this.button5.Name = "button5";
  256. this.button5.Size = new System.Drawing.Size(75, 23);
  257. this.button5.TabIndex = 3;
  258. this.button5.Text = "下一步";
  259. this.button5.UseVisualStyleBackColor = true;
  260. this.button5.Click += new System.EventHandler(this.button5_Click);
  261. //
  262. // button3
  263. //
  264. this.button3.Location = new System.Drawing.Point(20, 89);
  265. this.button3.Name = "button3";
  266. this.button3.Size = new System.Drawing.Size(75, 23);
  267. this.button3.TabIndex = 2;
  268. this.button3.Text = "第三步";
  269. this.button3.UseVisualStyleBackColor = true;
  270. this.button3.Click += new System.EventHandler(this.button3_Click);
  271. //
  272. // button2
  273. //
  274. this.button2.Location = new System.Drawing.Point(20, 59);
  275. this.button2.Name = "button2";
  276. this.button2.Size = new System.Drawing.Size(75, 23);
  277. this.button2.TabIndex = 1;
  278. this.button2.Text = "第二步";
  279. this.button2.UseVisualStyleBackColor = true;
  280. this.button2.Click += new System.EventHandler(this.button2_Click);
  281. //
  282. // button1
  283. //
  284. this.button1.Location = new System.Drawing.Point(20, 29);
  285. this.button1.Name = "button1";
  286. this.button1.Size = new System.Drawing.Size(75, 23);
  287. this.button1.TabIndex = 0;
  288. this.button1.Text = "第一步";
  289. this.button1.UseVisualStyleBackColor = true;
  290. this.button1.Click += new System.EventHandler(this.button1_Click);
  291. //
  292. // groupBox6
  293. //
  294. this.groupBox6.Controls.Add(this.button7);
  295. this.groupBox6.Controls.Add(this.textBox2);
  296. this.groupBox6.Controls.Add(this.label2);
  297. this.groupBox6.Location = new System.Drawing.Point(133, 78);
  298. this.groupBox6.Name = "groupBox6";
  299. this.groupBox6.Size = new System.Drawing.Size(604, 379);
  300. this.groupBox6.TabIndex = 22;
  301. this.groupBox6.TabStop = false;
  302. this.groupBox6.Text = "设置";
  303. //
  304. // button7
  305. //
  306. this.button7.Location = new System.Drawing.Point(512, 62);
  307. this.button7.Name = "button7";
  308. this.button7.Size = new System.Drawing.Size(75, 23);
  309. this.button7.TabIndex = 2;
  310. this.button7.Text = "选择";
  311. this.button7.UseVisualStyleBackColor = true;
  312. this.button7.Click += new System.EventHandler(this.button7_Click);
  313. //
  314. // textBox2
  315. //
  316. this.textBox2.Location = new System.Drawing.Point(24, 65);
  317. this.textBox2.Name = "textBox2";
  318. this.textBox2.ReadOnly = true;
  319. this.textBox2.Size = new System.Drawing.Size(471, 21);
  320. this.textBox2.TabIndex = 1;
  321. //
  322. // label2
  323. //
  324. this.label2.AutoSize = true;
  325. this.label2.Location = new System.Drawing.Point(22, 34);
  326. this.label2.Name = "label2";
  327. this.label2.Size = new System.Drawing.Size(125, 12);
  328. this.label2.TabIndex = 0;
  329. this.label2.Text = "选择配置文件存放位置";
  330. //
  331. // groupBox4
  332. //
  333. this.groupBox4.Controls.Add(this.treeView1);
  334. this.groupBox4.Location = new System.Drawing.Point(133, 78);
  335. this.groupBox4.Name = "groupBox4";
  336. this.groupBox4.Size = new System.Drawing.Size(604, 379);
  337. this.groupBox4.TabIndex = 20;
  338. this.groupBox4.TabStop = false;
  339. this.groupBox4.Text = "设置";
  340. //
  341. // treeView1
  342. //
  343. this.treeView1.Location = new System.Drawing.Point(189, 13);
  344. this.treeView1.Name = "treeView1";
  345. this.treeView1.Size = new System.Drawing.Size(227, 360);
  346. this.treeView1.TabIndex = 16;
  347. this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick);
  348. //
  349. // groupBox2
  350. //
  351. this.groupBox2.Controls.Add(this.button11);
  352. this.groupBox2.Controls.Add(this.button10);
  353. this.groupBox2.Controls.Add(this.button9);
  354. this.groupBox2.Controls.Add(this.button8);
  355. this.groupBox2.Location = new System.Drawing.Point(133, 2);
  356. this.groupBox2.Name = "groupBox2";
  357. this.groupBox2.Size = new System.Drawing.Size(604, 58);
  358. this.groupBox2.TabIndex = 18;
  359. this.groupBox2.TabStop = false;
  360. this.groupBox2.Text = "操作";
  361. //
  362. // button11
  363. //
  364. this.button11.Location = new System.Drawing.Point(512, 20);
  365. this.button11.Name = "button11";
  366. this.button11.Size = new System.Drawing.Size(75, 23);
  367. this.button11.TabIndex = 4;
  368. this.button11.Text = "完成";
  369. this.button11.UseVisualStyleBackColor = true;
  370. this.button11.Click += new System.EventHandler(this.button11_Click);
  371. //
  372. // button10
  373. //
  374. this.button10.Location = new System.Drawing.Point(431, 20);
  375. this.button10.Name = "button10";
  376. this.button10.Size = new System.Drawing.Size(75, 23);
  377. this.button10.TabIndex = 3;
  378. this.button10.Text = "全不选";
  379. this.button10.UseVisualStyleBackColor = true;
  380. this.button10.Click += new System.EventHandler(this.button10_Click);
  381. //
  382. // button9
  383. //
  384. this.button9.Location = new System.Drawing.Point(350, 20);
  385. this.button9.Name = "button9";
  386. this.button9.Size = new System.Drawing.Size(75, 23);
  387. this.button9.TabIndex = 2;
  388. this.button9.Text = "全选";
  389. this.button9.UseVisualStyleBackColor = true;
  390. this.button9.Click += new System.EventHandler(this.button9_Click);
  391. //
  392. // button8
  393. //
  394. this.button8.Location = new System.Drawing.Point(512, 20);
  395. this.button8.Name = "button8";
  396. this.button8.Size = new System.Drawing.Size(75, 23);
  397. this.button8.TabIndex = 1;
  398. this.button8.Text = "关闭";
  399. this.button8.UseVisualStyleBackColor = true;
  400. this.button8.Click += new EventHandler(button8_Click);
  401. //
  402. // MeasureProcedureImport
  403. //
  404. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  405. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  406. this.ClientSize = new System.Drawing.Size(742, 478);
  407. this.Controls.Add(this.groupBox3);
  408. this.Controls.Add(this.groupBox5);
  409. this.Controls.Add(this.groupBox1);
  410. this.Controls.Add(this.groupBox6);
  411. this.Controls.Add(this.groupBox4);
  412. this.Controls.Add(this.groupBox2);
  413. this.MaximizeBox = false;
  414. this.MinimizeBox = false;
  415. this.Name = "MeasureProcedureImport";
  416. this.Text = "测试规程导入导出";
  417. this.Controls.SetChildIndex(this.groupBox2, 0);
  418. this.Controls.SetChildIndex(this.groupBox4, 0);
  419. this.Controls.SetChildIndex(this.groupBox6, 0);
  420. this.Controls.SetChildIndex(this.groupBox1, 0);
  421. this.Controls.SetChildIndex(this.groupBox5, 0);
  422. this.Controls.SetChildIndex(this.groupBox3, 0);
  423. this.groupBox3.ResumeLayout(false);
  424. this.groupBox3.PerformLayout();
  425. this.groupBox5.ResumeLayout(false);
  426. this.groupBox5.PerformLayout();
  427. this.groupBox1.ResumeLayout(false);
  428. this.groupBox6.ResumeLayout(false);
  429. this.groupBox6.PerformLayout();
  430. this.groupBox4.ResumeLayout(false);
  431. this.groupBox2.ResumeLayout(false);
  432. this.ResumeLayout(false);
  433. }
  434. /// <summary>
  435. /// 语言包
  436. /// </summary>
  437. private void InitializeLanguageText()
  438. {
  439. this.radioButton2.Text = PdnResources.GetString("export");
  440. this.radioButton1.Text = PdnResources.GetString("Import");
  441. this.groupBox3.Text = PdnResources.GetString("Menu.Setting.Text");
  442. this.groupBox5.Text = PdnResources.GetString("Menu.Setting.Text");
  443. this.label1.Text = PdnResources.GetString("Import");
  444. this.button1.Text = PdnResources.GetString("Menu.firststep.text");
  445. this.button2.Text = PdnResources.GetString("Menu.Secondstep.text");
  446. this.button3.Text = PdnResources.GetString("Menu.thirdstep.text");
  447. this.button6.Text = PdnResources.GetString("Menu.Previous.text");
  448. this.button5.Text = PdnResources.GetString("Menu.Nextstep.text");
  449. this.groupBox2.Text = PdnResources.GetString("Menu.operation.text");
  450. this.groupBox4.Text = PdnResources.GetString("Menu.Setting.Text");
  451. this.button8.Text = PdnResources.GetString("Menu.File.Close.Text");
  452. this.button9.Text = PdnResources.GetString("Menu.LabelAction.SelectAllLabel.Text");
  453. this.button10.Text = PdnResources.GetString("Menu.Binaryoperation.Objecthandling.unselectall.text");
  454. this.button11.Text = PdnResources.GetString("Menu.finish.text");
  455. this.button4.Text = PdnResources.GetString("Menu.LabelAction.LabelSelect.Text");
  456. this.Text = PdnResources.GetString("ImportAndExportSet");
  457. this.button7.Text = PdnResources.GetString("Menu.LabelAction.LabelSelect.Text");
  458. }
  459. /// <summary>
  460. /// 初始化UI
  461. /// </summary>
  462. private void InitializeUI()
  463. {
  464. switch (this.chooseStep)
  465. {
  466. case 1:
  467. this.groupBox3.Visible = true;
  468. this.groupBox4.Visible = false;
  469. this.groupBox5.Visible = false;
  470. this.groupBox6.Visible = false;
  471. this.button1.BackColor = Color.Black;
  472. this.button1.ForeColor = Color.White;
  473. this.button2.BackColor = Color.White;
  474. this.button2.ForeColor = Color.Black;
  475. this.button3.BackColor = Color.White;
  476. this.button3.ForeColor = Color.Black;
  477. this.button6.Enabled = false;
  478. this.button5.Enabled = true;
  479. this.button8.Visible = true;
  480. this.button9.Visible = false;
  481. this.button10.Visible = false;
  482. this.button11.Visible = false;
  483. break;
  484. case 2:
  485. this.groupBox3.Visible = false;
  486. this.groupBox4.Visible = true;
  487. this.groupBox5.Visible = false;
  488. this.groupBox6.Visible = false;
  489. this.button1.BackColor = Color.White;
  490. this.button1.ForeColor = Color.Black;
  491. this.button2.BackColor = Color.Black;
  492. this.button2.ForeColor = Color.White;
  493. this.button3.BackColor = Color.White;
  494. this.button3.ForeColor = Color.Black;
  495. this.button6.Enabled = true;
  496. this.button5.Enabled = true;
  497. this.button8.Visible = true;
  498. this.button9.Visible = true;
  499. this.button10.Visible = true;
  500. this.button11.Visible = false;
  501. break;
  502. case 3:
  503. this.groupBox3.Visible = false;
  504. this.groupBox4.Visible = false;
  505. if (this.radioButton1.Checked)
  506. {
  507. this.groupBox5.Visible = true;
  508. this.groupBox6.Visible = false;
  509. }
  510. else if (this.radioButton2.Checked)
  511. {
  512. this.groupBox5.Visible = false;
  513. this.groupBox6.Visible = true;
  514. }
  515. this.button1.BackColor = Color.White;
  516. this.button1.ForeColor = Color.Black;
  517. this.button2.BackColor = Color.White;
  518. this.button2.ForeColor = Color.Black;
  519. this.button3.BackColor = Color.Black;
  520. this.button3.ForeColor = Color.White;
  521. this.button5.Enabled = false;
  522. this.button6.Enabled = true;
  523. this.button8.Visible = false;
  524. this.button9.Visible = false;
  525. this.button10.Visible = false;
  526. this.button11.Visible = true;
  527. break;
  528. }
  529. }
  530. /// <summary>
  531. /// 组织树状图
  532. /// </summary>
  533. private void createTreeView()
  534. {
  535. this.treeView1.Nodes.Clear();
  536. foreach (var item in measureMaintenanceTypeList.measureMaintenanceTypeList)
  537. {
  538. TreeNode treeNode = new TreeNode();
  539. treeNode.Text = item.measureMaintenanceName;
  540. treeNode.Name = item.measureMaintenanceTypeId;
  541. treeNode.Expand();
  542. treeView1.Nodes.Add(treeNode);
  543. }
  544. }
  545. #endregion
  546. /// <summary>
  547. /// 点击文字选中
  548. /// </summary>
  549. /// <param name="sender"></param>
  550. /// <param name="e"></param>
  551. private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  552. {
  553. e.Node.Checked = true;
  554. }
  555. /// <summary>
  556. /// 点击第一步
  557. /// </summary>
  558. /// <param name="sender"></param>
  559. /// <param name="e"></param>
  560. private void button1_Click(object sender, EventArgs e)
  561. {
  562. this.chooseStep = 1;
  563. InitializeUI();
  564. }
  565. /// <summary>
  566. /// 点击第二步
  567. /// </summary>
  568. /// <param name="sender"></param>
  569. /// <param name="e"></param>
  570. private void button2_Click(object sender, EventArgs e)
  571. {
  572. // 导出默认全部选中 导入则根据导入时拥有的情况来选择
  573. if (radioButton1.Checked)
  574. {
  575. if (string.IsNullOrEmpty(textBox4.Text))
  576. {
  577. MessageBox.Show(PdnResources.GetString("SelectFileFirst") + "!");
  578. return;
  579. }
  580. }
  581. AllChecked();
  582. this.chooseStep = 2;
  583. InitializeUI();
  584. }
  585. /// <summary>
  586. /// 点击第三步
  587. /// </summary>
  588. /// <param name="sender"></param>
  589. /// <param name="e"></param>
  590. private void button3_Click(object sender, EventArgs e)
  591. {
  592. if (radioButton1.Checked)
  593. {
  594. if (string.IsNullOrEmpty(textBox4.Text))
  595. {
  596. MessageBox.Show(PdnResources.GetString("SelectFileFirst") + "!");
  597. return;
  598. }
  599. }
  600. //假如不按套路出牌 直接跳到第三步 模拟第二步点击
  601. if (this.chooseStep == 1)
  602. {
  603. button2_Click(sender, e);
  604. }
  605. this.chooseStep = 3;
  606. InitializeUI();
  607. }
  608. /// <summary>
  609. /// 关闭
  610. /// </summary>
  611. /// <param name="sender"></param>
  612. /// <param name="e"></param>
  613. private void button8_Click(object sender, EventArgs e)
  614. {
  615. this.Close();
  616. }
  617. /// <summary>
  618. /// 全选
  619. /// </summary>
  620. /// <param name="sender"></param>
  621. /// <param name="e"></param>
  622. private void button9_Click(object sender, EventArgs e)
  623. {
  624. AllChecked();
  625. }
  626. /// <summary>
  627. /// 全不选
  628. /// </summary>
  629. /// <param name="sender"></param>
  630. /// <param name="e"></param>
  631. private void button10_Click(object sender, EventArgs e)
  632. {
  633. CancelAllChecked();
  634. }
  635. #region [节点选中相关方法]
  636. /// <summary>
  637. /// 全选
  638. /// </summary>
  639. private void AllChecked()
  640. {
  641. foreach (TreeNode e in this.treeView1.Nodes)
  642. {
  643. e.Checked = true;
  644. }
  645. }
  646. /// <summary>
  647. /// 取消全选
  648. /// </summary>
  649. private void CancelAllChecked()
  650. {
  651. foreach (TreeNode e in this.treeView1.Nodes)
  652. {
  653. e.Checked = false;
  654. }
  655. }
  656. #endregion
  657. /// <summary>
  658. /// 点击上一步
  659. /// </summary>
  660. /// <param name="sender"></param>
  661. /// <param name="e"></param>
  662. private void button6_Click(object sender, EventArgs e)
  663. {
  664. switch (this.chooseStep)
  665. {
  666. case 1:
  667. break;
  668. case 2:
  669. button1.Focus();
  670. button1_Click(sender, e);
  671. break;
  672. case 3:
  673. button2.Focus();
  674. button2_Click(sender, e);
  675. break;
  676. }
  677. }
  678. /// <summary>
  679. /// 点击下一步
  680. /// </summary>
  681. /// <param name="sender"></param>
  682. /// <param name="e"></param>
  683. private void button5_Click(object sender, EventArgs e)
  684. {
  685. switch (this.chooseStep)
  686. {
  687. case 1:
  688. button2.Focus();
  689. button2_Click(sender, e);
  690. break;
  691. case 2:
  692. button3.Focus();
  693. button3_Click(sender, e);
  694. break;
  695. case 3:
  696. break;
  697. }
  698. }
  699. /// <summary>
  700. /// 生成中间文件夹
  701. /// </summary>
  702. private void createDefaultDirectory()
  703. {
  704. //生成一个临时文件夹 用于存放各种xml
  705. //先删除之前的
  706. FileOperationHelper.DeleteFolder(unZipTemporaryFilePath);
  707. FileOperationHelper.DeleteFolder(temporaryFilePath);
  708. //生成新的
  709. Directory.CreateDirectory(temporaryFilePath);
  710. System.IO.Directory.CreateDirectory(temporaryFilePath + "\\ruleFile");
  711. ////复制测试规程总文件
  712. //FileOperationHelper.CopyDirectory(this.filePath, temporaryFilePath, false);
  713. //FileOperationHelper.CopyDirectory(this.rulerFilePath, temporaryFilePath + "\\ruleFile\\", false);
  714. }
  715. /// <summary>
  716. /// 选择文件
  717. /// </summary>
  718. /// <param name="sender"></param>
  719. /// <param name="e"></param>
  720. private void button4_Click(object sender, EventArgs e)
  721. {
  722. if (!radioButton1.Checked)
  723. {
  724. MessageBox.Show(PdnResources.GetString("PleaseFelectFile") + "!");
  725. return;
  726. }
  727. OpenFileDialog dialog = new OpenFileDialog();
  728. dialog.Multiselect = false; //该值确定是否可以选择多个文件
  729. dialog.Filter = "压缩包(*.zip)|*.zip";
  730. if (dialog.ShowDialog() != DialogResult.OK)
  731. {
  732. return;
  733. }
  734. string file = dialog.FileName;
  735. this.textBox4.Text = file;
  736. this.textBox1.Text = file;
  737. if (!file.EndsWith(".zip"))
  738. {
  739. MessageBox.Show(PdnResources.GetString("PleaseSelectZip") + "!");
  740. return;
  741. }
  742. #region [将文件解压到中间文件]
  743. if (ZipHandleHelper.decompressionZip(file, unZipTemporaryFilePath))
  744. {
  745. this.importMeasureMaintenanceTypeList = XmlSerializeHelper.DESerializer<MeasureMaintenanceTypeList>(FileOperationHelper.ReadStringFromFile(unZipTemporaryFilePath + "\\ruleFile\\MeasureMaintenanceTypeList.xml", FileMode.Open));
  746. this.treeView1.Nodes.Clear();
  747. foreach (var item in this.importMeasureMaintenanceTypeList.measureMaintenanceTypeList)
  748. {
  749. TreeNode treeNode = new TreeNode();
  750. treeNode.Text = item.measureMaintenanceName;
  751. treeNode.Name = item.measureMaintenanceTypeId;
  752. treeNode.Expand();
  753. treeView1.Nodes.Add(treeNode);
  754. }
  755. }
  756. else
  757. {
  758. MessageBox.Show(PdnResources.GetString("zipFail") + "!");
  759. return;
  760. }
  761. #endregion
  762. }
  763. /// <summary>
  764. /// 导出选择路径
  765. /// </summary>
  766. /// <param name="sender"></param>
  767. /// <param name="e"></param>
  768. private void button7_Click(object sender, EventArgs e)
  769. {
  770. SaveFileDialog exe = new SaveFileDialog();
  771. exe.Filter = "Compressed Package(*.zip)|*.zip";
  772. exe.FilterIndex = 0;
  773. exe.RestoreDirectory = true;
  774. //exe.CreatePrompt = true;
  775. exe.Title = "Export Compressed Package";
  776. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  777. exe.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + "测试规程导出";
  778. DialogResult dr = exe.ShowDialog();
  779. if (dr != DialogResult.OK)
  780. {
  781. return;
  782. }
  783. this.textBox2.Text = exe.FileName;
  784. }
  785. /// <summary>
  786. /// 完成事件
  787. /// </summary>
  788. /// <param name="sender"></param>
  789. /// <param name="e"></param>
  790. private void button11_Click(object sender, EventArgs e)
  791. {
  792. List<string> checkList = new List<string>();
  793. foreach (TreeNode item in this.treeView1.Nodes)
  794. {
  795. if (!item.Checked)
  796. {
  797. continue;
  798. }
  799. checkList.Add(item.Name);
  800. }
  801. if (radioButton1.Checked)
  802. {
  803. #region [开始导入]
  804. ProgressThreadProcClass procClass = new ProgressThreadProcClass();
  805. int itemCount = 100;
  806. ProgressThreadProcClass.IFileTransferProgressEvents progressEvents = new ProgressThreadProcClass.IFileTransferProgressEvents();
  807. System.Threading.ThreadStart copyThreadProc =
  808. delegate ()
  809. {
  810. try
  811. {
  812. foreach (var item in checkList)
  813. {
  814. var realMeasureMaintenanceTypeList = this.importMeasureMaintenanceTypeList.measureMaintenanceTypeList.Where(m => m.measureMaintenanceTypeId.Equals(item)).FirstOrDefault();
  815. if (realMeasureMaintenanceTypeList == null)
  816. {
  817. continue;
  818. }
  819. var hadMeasureMaintenanceTypeList = this.measureMaintenanceTypeList.measureMaintenanceTypeList.Where(m => m.measureMaintenanceName.Equals(realMeasureMaintenanceTypeList.measureMaintenanceName)).FirstOrDefault();
  820. if (hadMeasureMaintenanceTypeList != null)
  821. {
  822. string fileName = RecursionData(realMeasureMaintenanceTypeList.measureMaintenanceName);
  823. FileOperationHelper.reNameFile(unZipTemporaryFilePath + "ruleFile\\" + realMeasureMaintenanceTypeList.measureMaintenanceName + ".xml", unZipTemporaryFilePath + "\\ruleFile\\" + fileName + ".xml");
  824. FileOperationHelper.CopyDirectory(unZipTemporaryFilePath + "ruleFile\\" + fileName + ".xml", rulerFilePath, false);
  825. realMeasureMaintenanceTypeList.measureMaintenanceName = fileName;
  826. }
  827. else {
  828. FileOperationHelper.CopyDirectory(unZipTemporaryFilePath + "\\ruleFile\\" + realMeasureMaintenanceTypeList.measureMaintenanceName + ".xml", rulerFilePath, false);
  829. }
  830. this.measureMaintenanceTypeList.measureMaintenanceTypeList.Add(realMeasureMaintenanceTypeList);
  831. }
  832. string stageModelXml = XmlSerializeHelper.XmlSerialize<MeasureMaintenanceTypeList>(this.measureMaintenanceTypeList);
  833. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  834. }
  835. catch (Exception ex)
  836. {
  837. }
  838. finally
  839. {
  840. progressEvents.EndOperation(OperationResult.Finished);
  841. }
  842. };
  843. procClass.StartProgressAction(this, itemCount, copyThreadProc, progressEvents, null);
  844. FileOperationHelper.DeleteFolder(unZipTemporaryFilePath);
  845. MessageBox.Show(PdnResources.GetString("importSuccess") + "!");
  846. #endregion
  847. }
  848. else if (radioButton2.Checked)
  849. {
  850. #region [开始导出]
  851. if (string.IsNullOrEmpty(textBox2.Text))
  852. {
  853. MessageBox.Show(PdnResources.GetString("selectfilepath") + "!");
  854. return;
  855. }
  856. ProgressThreadProcClass procClass = new ProgressThreadProcClass();
  857. int itemCount = 100;
  858. ProgressThreadProcClass.IFileTransferProgressEvents progressEvents = new ProgressThreadProcClass.IFileTransferProgressEvents();
  859. System.Threading.ThreadStart copyThreadProc =
  860. delegate ()
  861. {
  862. try
  863. {
  864. string choosePath = this.textBox2.Text;
  865. MeasureMaintenanceTypeList thisMeasureMaintenanceTypeList = new MeasureMaintenanceTypeList();
  866. thisMeasureMaintenanceTypeList.measureMaintenanceTypeList = new List<MeasureMaintenanceType>();
  867. foreach (var item in checkList)
  868. {
  869. var realMeasureMaintenanceTypeList = this.measureMaintenanceTypeList.measureMaintenanceTypeList.Where(m => m.measureMaintenanceTypeId.Equals(item)).FirstOrDefault();
  870. if (realMeasureMaintenanceTypeList == null)
  871. {
  872. continue;
  873. }
  874. thisMeasureMaintenanceTypeList.measureMaintenanceTypeList.Add(realMeasureMaintenanceTypeList);
  875. FileOperationHelper.CopyDirectory($"{this.rulerFilePath}{realMeasureMaintenanceTypeList.measureMaintenanceName}.xml", temporaryFilePath + "\\ruleFile\\", false);
  876. }
  877. string filePath = temporaryFilePath + "\\ruleFile\\MeasureMaintenanceTypeList.xml";
  878. string stageModelXml = XmlSerializeHelper.XmlSerialize<MeasureMaintenanceTypeList>(thisMeasureMaintenanceTypeList);
  879. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  880. ZipHandleHelper.createZip(temporaryFilePath, choosePath);
  881. }
  882. catch (Exception)
  883. {
  884. }
  885. finally
  886. {
  887. progressEvents.EndOperation(OperationResult.Finished);
  888. }
  889. };
  890. procClass.StartProgressAction(this, itemCount, copyThreadProc, progressEvents, null);
  891. MessageBox.Show(PdnResources.GetString("exportSuccess") + "!");
  892. #endregion
  893. }
  894. this.Close();
  895. }
  896. /// <summary>
  897. /// 递归赋名称
  898. /// </summary>
  899. /// <param name="name"></param>
  900. /// <returns></returns>
  901. private string RecursionData(string name)
  902. {
  903. name += "-导入";
  904. var hadMeasureMaintenanceTypeList = this.measureMaintenanceTypeList.measureMaintenanceTypeList.Where(m => m.measureMaintenanceName.Equals(name)).FirstOrDefault();
  905. if (hadMeasureMaintenanceTypeList != null)
  906. {
  907. name = RecursionData(name);
  908. }
  909. return name;
  910. }
  911. /// <summary>
  912. /// 选中导入
  913. /// </summary>
  914. /// <param name="sender"></param>
  915. /// <param name="e"></param>
  916. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  917. {
  918. createTreeView();
  919. }
  920. }
  921. }