ImportExportSettingDialog.cs 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120
  1. using PaintDotNet;
  2. using PaintDotNet.Base.CommTool;
  3. using PaintDotNet.Base.SettingModel;
  4. using PaintDotNet.DbOpreate.DbBll;
  5. using PaintDotNet.DbOpreate.DbModel;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Windows.Forms;
  16. namespace Metis.Setting
  17. {
  18. internal partial class ImportExportSettingDialog : PdnBaseForm
  19. {
  20. private GroupBox groupBox1;
  21. private Button button6;
  22. private Button button5;
  23. private Button button3;
  24. private Button button2;
  25. private GroupBox groupBox2;
  26. private Button button8;
  27. private GroupBox groupBox3;
  28. private RadioButton radioButton2;
  29. private RadioButton radioButton1;
  30. private TextBox textBox4;
  31. private Button button4;
  32. private GroupBox groupBox4;
  33. private GroupBox groupBox5;
  34. private Label label1;
  35. private TextBox textBox1;
  36. private CheckBox checkBox1;
  37. private GroupBox groupBox6;
  38. private TextBox textBox2;
  39. private Label label2;
  40. private Button button7;
  41. private Button button1;
  42. private Button button10;
  43. private Button button9;
  44. private Button button11;
  45. /// <summary>
  46. /// 选择的步
  47. /// </summary>
  48. private int chooseStep = 1;
  49. private ImportExportModel importExportModel;
  50. /// <summary>
  51. /// 工具栏组成的结构数据
  52. /// </summary>
  53. private List<ProjectData> toolbarModelList = new List<ProjectData>();
  54. /// <summary>
  55. /// 工作流程组成的结构数据
  56. /// </summary>
  57. private List<ProjectData> workFlowModelList = new List<ProjectData>();
  58. private PaintDotNet.CustomControl.TreeViewEnhanced treeView1;
  59. /// <summary>
  60. /// 脚本组成的结构数据
  61. /// </summary>
  62. private List<ProjectData> stepModelList = new List<ProjectData>();
  63. /// <summary>
  64. /// 压缩中间数据目录
  65. /// </summary>
  66. private string temporaryFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Temp\\";
  67. /// <summary>
  68. /// 解压中间数据目录
  69. /// </summary>
  70. private string unZipTemporaryFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\UnZipTemp\\";
  71. private Dictionary<string, string> originalPathDict = new Dictionary<string, string>();
  72. private Dictionary<string, string> newPathDict = new Dictionary<string, string>();
  73. private Dictionary<string, string> importPathDict = new Dictionary<string, string>();
  74. /// <summary>
  75. /// (导出)选择的树状信息
  76. /// </summary>
  77. private List<string> checkDataList = new List<string>();
  78. /// <summary>
  79. /// (导出)二级结构选择
  80. /// </summary>
  81. private Dictionary<string, List<string>> checkSecondData = new Dictionary<string, List<string>>();
  82. /// <summary>
  83. /// (导入)选择的树状信息
  84. /// </summary>
  85. private List<string> importCheckDataList = new List<string>();
  86. /// <summary>
  87. /// (导入)二级结构选择
  88. /// </summary>
  89. private Dictionary<string, List<string>> importCheckSecondData = new Dictionary<string, List<string>>();
  90. public ImportExportSettingDialog()
  91. {
  92. InitializeComponent();
  93. InitializeLanguageText();
  94. #region [默认展示第一步]
  95. button1_Click(null, null);
  96. #endregion
  97. #region [获取二级结构数据]
  98. this.getSonData();
  99. #endregion
  100. #region [读取树状图结构]
  101. this.getTreeData();
  102. #endregion
  103. #region [组织树状图]
  104. this.treeView1.CheckBoxes = true;
  105. this.treeView1.ItemHeight = 18;
  106. this.createTreeView();
  107. #endregion
  108. #region [生成中间文件夹]
  109. this.createDefaultDirectory();
  110. #endregion
  111. }
  112. private void InitializeLanguageText()
  113. {
  114. this.radioButton2.Text = PdnResources.GetString("export");
  115. this.radioButton1.Text = PdnResources.GetString("Import");
  116. this.groupBox3.Text = PdnResources.GetString("Menu.Setting.Text");
  117. this.groupBox5.Text = PdnResources.GetString("Menu.Setting.Text");
  118. this.label1.Text = PdnResources.GetString("Import");
  119. this.checkBox1.Text = PdnResources.GetString("OverrideCurrentData");
  120. this.button1.Text = PdnResources.GetString("Menu.firststep.text");
  121. this.button2.Text = PdnResources.GetString("Menu.Secondstep.text");
  122. this.button3.Text = PdnResources.GetString("Menu.thirdstep.text");
  123. this.button6.Text = PdnResources.GetString("Menu.Previous.text");
  124. this.button5.Text = PdnResources.GetString("Menu.Nextstep.text");
  125. this.groupBox2.Text = PdnResources.GetString("Menu.operation.text");
  126. this.groupBox4.Text = PdnResources.GetString("Menu.Setting.Text");
  127. this.button8.Text = PdnResources.GetString("Menu.File.Close.Text");
  128. this.button9.Text = PdnResources.GetString("Menu.LabelAction.SelectAllLabel.Text");
  129. this.button10.Text = PdnResources.GetString("Menu.Binaryoperation.Objecthandling.unselectall.text");
  130. this.button11.Text = PdnResources.GetString("Menu.finish.text");
  131. this.button4.Text = PdnResources.GetString("Menu.LabelAction.LabelSelect.Text");
  132. this.Text = PdnResources.GetString("ImportAndExportSet");
  133. }
  134. private void InitializeComponent()
  135. {
  136. this.groupBox1 = new System.Windows.Forms.GroupBox();
  137. this.button6 = new System.Windows.Forms.Button();
  138. this.button5 = new System.Windows.Forms.Button();
  139. this.button3 = new System.Windows.Forms.Button();
  140. this.button2 = new System.Windows.Forms.Button();
  141. this.button1 = new System.Windows.Forms.Button();
  142. this.groupBox2 = new System.Windows.Forms.GroupBox();
  143. this.button11 = new System.Windows.Forms.Button();
  144. this.button10 = new System.Windows.Forms.Button();
  145. this.button9 = new System.Windows.Forms.Button();
  146. this.button8 = new System.Windows.Forms.Button();
  147. this.groupBox3 = new System.Windows.Forms.GroupBox();
  148. this.button4 = new System.Windows.Forms.Button();
  149. this.textBox4 = new System.Windows.Forms.TextBox();
  150. this.radioButton2 = new System.Windows.Forms.RadioButton();
  151. this.radioButton1 = new System.Windows.Forms.RadioButton();
  152. this.groupBox4 = new System.Windows.Forms.GroupBox();
  153. this.treeView1 = new PaintDotNet.CustomControl.TreeViewEnhanced();
  154. this.groupBox5 = new System.Windows.Forms.GroupBox();
  155. this.checkBox1 = new System.Windows.Forms.CheckBox();
  156. this.textBox1 = new System.Windows.Forms.TextBox();
  157. this.label1 = new System.Windows.Forms.Label();
  158. this.groupBox6 = new System.Windows.Forms.GroupBox();
  159. this.button7 = new System.Windows.Forms.Button();
  160. this.textBox2 = new System.Windows.Forms.TextBox();
  161. this.label2 = new System.Windows.Forms.Label();
  162. this.groupBox1.SuspendLayout();
  163. this.groupBox2.SuspendLayout();
  164. this.groupBox3.SuspendLayout();
  165. this.groupBox4.SuspendLayout();
  166. this.groupBox5.SuspendLayout();
  167. this.groupBox6.SuspendLayout();
  168. this.SuspendLayout();
  169. //
  170. // groupBox1
  171. //
  172. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  173. | System.Windows.Forms.AnchorStyles.Left)));
  174. this.groupBox1.Controls.Add(this.button6);
  175. this.groupBox1.Controls.Add(this.button5);
  176. this.groupBox1.Controls.Add(this.button3);
  177. this.groupBox1.Controls.Add(this.button2);
  178. this.groupBox1.Controls.Add(this.button1);
  179. this.groupBox1.Location = new System.Drawing.Point(12, 10);
  180. this.groupBox1.Name = "groupBox1";
  181. this.groupBox1.Size = new System.Drawing.Size(115, 445);
  182. this.groupBox1.TabIndex = 2;
  183. this.groupBox1.TabStop = false;
  184. //
  185. // button6
  186. //
  187. this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  188. | System.Windows.Forms.AnchorStyles.Right)));
  189. this.button6.Location = new System.Drawing.Point(20, 383);
  190. this.button6.Name = "button6";
  191. this.button6.Size = new System.Drawing.Size(75, 23);
  192. this.button6.TabIndex = 4;
  193. this.button6.Text = "上一步";
  194. this.button6.UseVisualStyleBackColor = true;
  195. this.button6.Click += new System.EventHandler(this.button6_Click);
  196. //
  197. // button5
  198. //
  199. this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  200. | System.Windows.Forms.AnchorStyles.Right)));
  201. this.button5.Location = new System.Drawing.Point(20, 412);
  202. this.button5.Name = "button5";
  203. this.button5.Size = new System.Drawing.Size(75, 23);
  204. this.button5.TabIndex = 3;
  205. this.button5.Text = "下一步";
  206. this.button5.UseVisualStyleBackColor = true;
  207. this.button5.Click += new System.EventHandler(this.button5_Click);
  208. //
  209. // button3
  210. //
  211. this.button3.Location = new System.Drawing.Point(20, 89);
  212. this.button3.Name = "button3";
  213. this.button3.Size = new System.Drawing.Size(75, 23);
  214. this.button3.TabIndex = 2;
  215. this.button3.Text = "第三步";
  216. this.button3.UseVisualStyleBackColor = true;
  217. this.button3.Click += new System.EventHandler(this.button3_Click);
  218. //
  219. // button2
  220. //
  221. this.button2.Location = new System.Drawing.Point(20, 59);
  222. this.button2.Name = "button2";
  223. this.button2.Size = new System.Drawing.Size(75, 23);
  224. this.button2.TabIndex = 1;
  225. this.button2.Text = "第二步";
  226. this.button2.UseVisualStyleBackColor = true;
  227. this.button2.Click += new System.EventHandler(this.button2_Click);
  228. //
  229. // button1
  230. //
  231. this.button1.Location = new System.Drawing.Point(20, 29);
  232. this.button1.Name = "button1";
  233. this.button1.Size = new System.Drawing.Size(75, 23);
  234. this.button1.TabIndex = 0;
  235. this.button1.Text = "第一步";
  236. this.button1.UseVisualStyleBackColor = true;
  237. this.button1.Click += new System.EventHandler(this.button1_Click);
  238. //
  239. // groupBox2
  240. //
  241. this.groupBox2.Controls.Add(this.button11);
  242. this.groupBox2.Controls.Add(this.button10);
  243. this.groupBox2.Controls.Add(this.button9);
  244. this.groupBox2.Controls.Add(this.button8);
  245. this.groupBox2.Location = new System.Drawing.Point(133, 12);
  246. this.groupBox2.Name = "groupBox2";
  247. this.groupBox2.Size = new System.Drawing.Size(604, 58);
  248. this.groupBox2.TabIndex = 3;
  249. this.groupBox2.TabStop = false;
  250. this.groupBox2.Text = "操作";
  251. //
  252. // button11
  253. //
  254. this.button11.Location = new System.Drawing.Point(512, 20);
  255. this.button11.Name = "button11";
  256. this.button11.Size = new System.Drawing.Size(75, 23);
  257. this.button11.TabIndex = 4;
  258. this.button11.Text = "完成";
  259. this.button11.UseVisualStyleBackColor = true;
  260. this.button11.Click += new System.EventHandler(this.button11_Click);
  261. //
  262. // button10
  263. //
  264. this.button10.Location = new System.Drawing.Point(431, 20);
  265. this.button10.Name = "button10";
  266. this.button10.Size = new System.Drawing.Size(75, 23);
  267. this.button10.TabIndex = 3;
  268. this.button10.Text = "全不选";
  269. this.button10.UseVisualStyleBackColor = true;
  270. this.button10.Click += new System.EventHandler(this.button10_Click);
  271. //
  272. // button9
  273. //
  274. this.button9.Location = new System.Drawing.Point(350, 20);
  275. this.button9.Name = "button9";
  276. this.button9.Size = new System.Drawing.Size(75, 23);
  277. this.button9.TabIndex = 2;
  278. this.button9.Text = "全选";
  279. this.button9.UseVisualStyleBackColor = true;
  280. this.button9.Click += new System.EventHandler(this.button9_Click);
  281. //
  282. // button8
  283. //
  284. this.button8.Location = new System.Drawing.Point(512, 20);
  285. this.button8.Name = "button8";
  286. this.button8.Size = new System.Drawing.Size(75, 23);
  287. this.button8.TabIndex = 1;
  288. this.button8.Text = "关闭";
  289. this.button8.UseVisualStyleBackColor = true;
  290. this.button8.Click += new System.EventHandler(this.button8_Click);
  291. //
  292. // groupBox3
  293. //
  294. this.groupBox3.Controls.Add(this.button4);
  295. this.groupBox3.Controls.Add(this.textBox4);
  296. this.groupBox3.Controls.Add(this.radioButton2);
  297. this.groupBox3.Controls.Add(this.radioButton1);
  298. this.groupBox3.Location = new System.Drawing.Point(133, 76);
  299. this.groupBox3.Name = "groupBox3";
  300. this.groupBox3.Size = new System.Drawing.Size(604, 379);
  301. this.groupBox3.TabIndex = 4;
  302. this.groupBox3.TabStop = false;
  303. this.groupBox3.Text = "设置";
  304. //
  305. // button4
  306. //
  307. this.button4.Location = new System.Drawing.Point(512, 64);
  308. this.button4.Name = "button4";
  309. this.button4.Size = new System.Drawing.Size(75, 21);
  310. this.button4.TabIndex = 13;
  311. this.button4.Text = "选择";
  312. this.button4.UseVisualStyleBackColor = true;
  313. this.button4.Click += new System.EventHandler(this.button4_Click);
  314. //
  315. // textBox4
  316. //
  317. this.textBox4.Location = new System.Drawing.Point(24, 65);
  318. this.textBox4.Name = "textBox4";
  319. this.textBox4.ReadOnly = true;
  320. this.textBox4.Size = new System.Drawing.Size(482, 21);
  321. this.textBox4.TabIndex = 12;
  322. //
  323. // radioButton2
  324. //
  325. this.radioButton2.AutoSize = true;
  326. this.radioButton2.Location = new System.Drawing.Point(24, 109);
  327. this.radioButton2.Name = "radioButton2";
  328. this.radioButton2.Size = new System.Drawing.Size(47, 16);
  329. this.radioButton2.TabIndex = 1;
  330. this.radioButton2.TabStop = true;
  331. this.radioButton2.Text = "导出";
  332. this.radioButton2.UseVisualStyleBackColor = true;
  333. this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_Check);
  334. //
  335. // radioButton1
  336. //
  337. this.radioButton1.AutoSize = true;
  338. this.radioButton1.Checked = true;
  339. this.radioButton1.Location = new System.Drawing.Point(24, 30);
  340. this.radioButton1.Name = "radioButton1";
  341. this.radioButton1.Size = new System.Drawing.Size(47, 16);
  342. this.radioButton1.TabIndex = 0;
  343. this.radioButton1.TabStop = true;
  344. this.radioButton1.Text = "导入";
  345. this.radioButton1.UseVisualStyleBackColor = true;
  346. this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_Check);
  347. //
  348. // groupBox4
  349. //
  350. this.groupBox4.Controls.Add(this.treeView1);
  351. this.groupBox4.Location = new System.Drawing.Point(133, 76);
  352. this.groupBox4.Name = "groupBox4";
  353. this.groupBox4.Size = new System.Drawing.Size(604, 379);
  354. this.groupBox4.TabIndex = 14;
  355. this.groupBox4.TabStop = false;
  356. this.groupBox4.Text = "设置";
  357. //
  358. // treeView1
  359. //
  360. this.treeView1.Location = new System.Drawing.Point(189, 13);
  361. this.treeView1.Name = "treeView1";
  362. this.treeView1.Size = new System.Drawing.Size(227, 360);
  363. this.treeView1.TabIndex = 16;
  364. this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
  365. //
  366. // groupBox5
  367. //
  368. this.groupBox5.Controls.Add(this.checkBox1);
  369. this.groupBox5.Controls.Add(this.textBox1);
  370. this.groupBox5.Controls.Add(this.label1);
  371. this.groupBox5.Location = new System.Drawing.Point(133, 76);
  372. this.groupBox5.Name = "groupBox5";
  373. this.groupBox5.Size = new System.Drawing.Size(604, 379);
  374. this.groupBox5.TabIndex = 15;
  375. this.groupBox5.TabStop = false;
  376. this.groupBox5.Text = "设置";
  377. //
  378. // checkBox1
  379. //
  380. this.checkBox1.AutoSize = true;
  381. this.checkBox1.Location = new System.Drawing.Point(24, 110);
  382. this.checkBox1.Name = "checkBox1";
  383. this.checkBox1.Size = new System.Drawing.Size(96, 16);
  384. this.checkBox1.TabIndex = 2;
  385. this.checkBox1.Text = "覆盖当前数据";
  386. this.checkBox1.UseVisualStyleBackColor = true;
  387. //
  388. // textBox1
  389. //
  390. this.textBox1.Location = new System.Drawing.Point(24, 65);
  391. this.textBox1.Name = "textBox1";
  392. this.textBox1.ReadOnly = true;
  393. this.textBox1.Size = new System.Drawing.Size(462, 21);
  394. this.textBox1.TabIndex = 1;
  395. //
  396. // label1
  397. //
  398. this.label1.AutoSize = true;
  399. this.label1.Location = new System.Drawing.Point(22, 34);
  400. this.label1.Name = "label1";
  401. this.label1.Size = new System.Drawing.Size(77, 12);
  402. this.label1.TabIndex = 0;
  403. this.label1.Text = "从......导入";
  404. //
  405. // groupBox6
  406. //
  407. this.groupBox6.Controls.Add(this.button7);
  408. this.groupBox6.Controls.Add(this.textBox2);
  409. this.groupBox6.Controls.Add(this.label2);
  410. this.groupBox6.Location = new System.Drawing.Point(133, 76);
  411. this.groupBox6.Name = "groupBox6";
  412. this.groupBox6.Size = new System.Drawing.Size(604, 379);
  413. this.groupBox6.TabIndex = 16;
  414. this.groupBox6.TabStop = false;
  415. this.groupBox6.Text = "设置";
  416. //
  417. // button7
  418. //
  419. this.button7.Location = new System.Drawing.Point(512, 62);
  420. this.button7.Name = "button7";
  421. this.button7.Size = new System.Drawing.Size(75, 23);
  422. this.button7.TabIndex = 2;
  423. this.button7.Text = "选择";
  424. this.button7.UseVisualStyleBackColor = true;
  425. this.button7.Click += new System.EventHandler(this.button7_Click);
  426. //
  427. // textBox2
  428. //
  429. this.textBox2.Location = new System.Drawing.Point(24, 65);
  430. this.textBox2.Name = "textBox2";
  431. this.textBox2.ReadOnly = true;
  432. this.textBox2.Size = new System.Drawing.Size(471, 21);
  433. this.textBox2.TabIndex = 1;
  434. //
  435. // label2
  436. //
  437. this.label2.AutoSize = true;
  438. this.label2.Location = new System.Drawing.Point(22, 34);
  439. this.label2.Name = "label2";
  440. this.label2.Size = new System.Drawing.Size(125, 12);
  441. this.label2.TabIndex = 0;
  442. this.label2.Text = "选择配置文件存放位置";
  443. //
  444. // ImportExportSettingDialog
  445. //
  446. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  447. this.ClientSize = new System.Drawing.Size(749, 467);
  448. this.Controls.Add(this.groupBox3);
  449. this.Controls.Add(this.groupBox5);
  450. this.Controls.Add(this.groupBox1);
  451. this.Controls.Add(this.groupBox6);
  452. this.Controls.Add(this.groupBox4);
  453. this.Controls.Add(this.groupBox2);
  454. this.MaximizeBox = false;
  455. this.MinimizeBox = false;
  456. this.Name = "ImportExportSettingDialog";
  457. this.Text = "导入导出向导";
  458. this.Controls.SetChildIndex(this.groupBox2, 0);
  459. this.Controls.SetChildIndex(this.groupBox4, 0);
  460. this.Controls.SetChildIndex(this.groupBox6, 0);
  461. this.Controls.SetChildIndex(this.groupBox1, 0);
  462. this.Controls.SetChildIndex(this.groupBox5, 0);
  463. this.Controls.SetChildIndex(this.groupBox3, 0);
  464. this.groupBox1.ResumeLayout(false);
  465. this.groupBox2.ResumeLayout(false);
  466. this.groupBox3.ResumeLayout(false);
  467. this.groupBox3.PerformLayout();
  468. this.groupBox4.ResumeLayout(false);
  469. this.groupBox5.ResumeLayout(false);
  470. this.groupBox5.PerformLayout();
  471. this.groupBox6.ResumeLayout(false);
  472. this.groupBox6.PerformLayout();
  473. this.ResumeLayout(false);
  474. }
  475. /// <summary>
  476. /// 初始化UI
  477. /// </summary>
  478. private void InitializeUI() {
  479. switch (this.chooseStep) {
  480. case 1:
  481. this.groupBox3.Visible = true;
  482. this.groupBox4.Visible = false;
  483. this.groupBox5.Visible = false;
  484. this.groupBox6.Visible = false;
  485. this.button1.BackColor = Color.Black;
  486. this.button1.ForeColor = Color.White;
  487. this.button2.BackColor = Color.White;
  488. this.button2.ForeColor = Color.Black;
  489. this.button3.BackColor = Color.White;
  490. this.button3.ForeColor = Color.Black;
  491. this.button6.Enabled = false;
  492. this.button5.Enabled = true;
  493. this.button8.Visible = true;
  494. this.button9.Visible = false;
  495. this.button10.Visible = false;
  496. this.button11.Visible = false;
  497. break;
  498. case 2:
  499. this.groupBox3.Visible = false;
  500. this.groupBox4.Visible = true;
  501. this.groupBox5.Visible = false;
  502. this.groupBox6.Visible = false;
  503. this.button1.BackColor = Color.White;
  504. this.button1.ForeColor = Color.Black;
  505. this.button2.BackColor = Color.Black;
  506. this.button2.ForeColor = Color.White;
  507. this.button3.BackColor = Color.White;
  508. this.button3.ForeColor = Color.Black;
  509. this.button6.Enabled = true;
  510. this.button5.Enabled = true;
  511. this.button8.Visible = true;
  512. this.button9.Visible = true;
  513. this.button10.Visible = true;
  514. this.button11.Visible = false;
  515. break;
  516. case 3:
  517. this.groupBox3.Visible = false;
  518. this.groupBox4.Visible = false;
  519. if (this.radioButton1.Checked)
  520. {
  521. this.groupBox5.Visible = true;
  522. this.groupBox6.Visible = false;
  523. }
  524. else if (this.radioButton2.Checked)
  525. {
  526. this.groupBox5.Visible = false;
  527. this.groupBox6.Visible = true;
  528. }
  529. this.button1.BackColor = Color.White;
  530. this.button1.ForeColor = Color.Black;
  531. this.button2.BackColor = Color.White;
  532. this.button2.ForeColor = Color.Black;
  533. this.button3.BackColor = Color.Black;
  534. this.button3.ForeColor = Color.White;
  535. this.button5.Enabled = false;
  536. this.button6.Enabled = true;
  537. this.button8.Visible = false;
  538. this.button9.Visible = false;
  539. this.button10.Visible = false;
  540. this.button11.Visible = true;
  541. break;
  542. }
  543. }
  544. /// <summary>
  545. /// 关闭
  546. /// </summary>
  547. /// <param name="sender"></param>
  548. /// <param name="e"></param>
  549. private void button8_Click(object sender, EventArgs e)
  550. {
  551. this.Close();
  552. }
  553. /// <summary>
  554. /// 导入按钮选择
  555. /// </summary>
  556. /// <param name="sender"></param>
  557. /// <param name="e"></param>
  558. private void radioButton2_Check(object sender, EventArgs e)
  559. {
  560. clearData();
  561. }
  562. /// <summary>
  563. /// 导入按钮选择
  564. /// </summary>
  565. /// <param name="sender"></param>
  566. /// <param name="e"></param>
  567. private void radioButton1_Check(object sender, EventArgs e)
  568. {
  569. clearData();
  570. }
  571. /// <summary>
  572. /// 清理之前的数据
  573. /// </summary>
  574. private void clearData()
  575. {
  576. checkDataList.Clear();
  577. checkSecondData.Clear();
  578. importCheckDataList.Clear();
  579. importCheckSecondData.Clear();
  580. }
  581. /// <summary>
  582. /// 导入选择
  583. /// </summary>
  584. /// <param name="sender"></param>
  585. /// <param name="e"></param>
  586. private void button4_Click(object sender, EventArgs e)
  587. {
  588. if (!radioButton1.Checked) {
  589. MessageBox.Show(PdnResources.GetString("PleaseFelectFile") + "!");
  590. return;
  591. }
  592. OpenFileDialog dialog = new OpenFileDialog();
  593. dialog.Multiselect = false; //该值确定是否可以选择多个文件
  594. dialog.Filter = "压缩包(*.zip)|*.zip";
  595. if (dialog.ShowDialog() != DialogResult.OK)
  596. {
  597. return;
  598. }
  599. string file = dialog.FileName;
  600. this.textBox4.Text = file;
  601. this.textBox1.Text = file;
  602. if (!file.EndsWith(".zip")) {
  603. MessageBox.Show(PdnResources.GetString("PleaseSelectZip") + "!");
  604. return;
  605. }
  606. clearData();
  607. #region [将文件解压到中间文件]
  608. if (ZipHandleHelper.decompressionZip(file, unZipTemporaryFilePath))
  609. {
  610. List<string> allFileList = FileOperationHelper.GetAllDirectoryList(unZipTemporaryFilePath);
  611. #region [校验应勾选的树状信息]
  612. if (allFileList.Contains("CameraParam"))
  613. {
  614. this.importCheckDataList.Add("camera");
  615. }
  616. if (allFileList.Contains("Config"))
  617. {
  618. this.importCheckDataList.Add("generalSetting");
  619. }
  620. if (allFileList.Contains("Hotkey"))
  621. {
  622. this.importCheckDataList.Add("hotkey");
  623. }
  624. if (allFileList.Contains("Label"))
  625. {
  626. this.importCheckDataList.Add("label");
  627. }
  628. if (allFileList.Contains("Measure"))
  629. {
  630. this.importCheckDataList.Add("measure");
  631. }
  632. if (allFileList.Contains("ModuleManage"))
  633. {
  634. this.importCheckDataList.Add("reportModel");
  635. }
  636. if (allFileList.Contains("ParameterSaving"))
  637. {
  638. this.importCheckDataList.Add("parameter");
  639. }
  640. if (allFileList.Contains("Ruler"))
  641. {
  642. this.importCheckDataList.Add("ruler");
  643. }
  644. if (allFileList.Contains("Shortcutbar"))
  645. {
  646. this.importCheckDataList.Add("shortcutbar");
  647. }
  648. if (allFileList.Contains("Toolbar"))
  649. {
  650. this.importCheckDataList.Add("toolbar");
  651. string filePath = unZipTemporaryFilePath + "Toolbar\\Toolbar.xml";
  652. var importToolBar = XmlSerializeHelper.DESerializer<ToolbarModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  653. List<string> secondDataList = new List<string>();
  654. foreach (var item in importToolBar.Flows)
  655. {
  656. secondDataList.Add(item.Name);
  657. }
  658. importCheckSecondData.Add("toolbar", secondDataList);
  659. addTreeView(4,secondDataList);
  660. }
  661. if (allFileList.Contains("WorkFlow"))
  662. {
  663. this.importCheckDataList.Add("workFlow");
  664. string filePath = unZipTemporaryFilePath + "WorkFlow\\WorkFlow.xml";
  665. var importWorkFlow = XmlSerializeHelper.DESerializer<WorkFlowModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  666. List<string> secondDataList = new List<string>();
  667. foreach (var item in importWorkFlow.Flows)
  668. {
  669. secondDataList.Add(item.Name);
  670. }
  671. addTreeView(12, secondDataList);
  672. importCheckSecondData.Add("workFlow", secondDataList);
  673. }
  674. //脚本
  675. if (allFileList.Contains("ScriptStep"))
  676. {
  677. this.importCheckDataList.Add("scriptStep");
  678. string filePath = unZipTemporaryFilePath + "ScriptStep\\ScriptStep.xml";
  679. List<mic_script> importMicScriptList = XmlSerializeHelper.DESerializer<List<mic_script>>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  680. List<string> secondDataList = new List<string>();
  681. foreach (var item in importMicScriptList)
  682. {
  683. secondDataList.Add(item.name);
  684. }
  685. addTreeView(10, secondDataList);
  686. importCheckSecondData.Add("scriptStep", secondDataList);
  687. }
  688. #endregion
  689. }
  690. else {
  691. MessageBox.Show("解压文件失败,请稍后再试!");
  692. return;
  693. }
  694. #endregion
  695. }
  696. /// <summary>
  697. ///
  698. /// </summary>
  699. /// <param name="type"></param>
  700. /// <param name="secondDataList"></param>
  701. private void addTreeView(int type,List<string> secondDataList)
  702. {
  703. this.treeView1.Nodes[type - 1].Nodes.Clear();
  704. foreach (var item in secondDataList) {
  705. TreeNode node = new TreeNode();
  706. node.Text = item;
  707. node.Name = item;
  708. this.treeView1.Nodes[type - 1].Nodes.Add(node);
  709. }
  710. }
  711. /// <summary>
  712. /// 导出选择
  713. /// </summary>
  714. /// <param name="sender"></param>
  715. /// <param name="e"></param>
  716. private void button7_Click(object sender, EventArgs e)
  717. {
  718. SaveFileDialog exe = new SaveFileDialog();
  719. exe.Filter = "Compressed Package(*.zip)|*.zip";
  720. exe.FilterIndex = 0;
  721. exe.RestoreDirectory = true;
  722. //exe.CreatePrompt = true;
  723. exe.Title = "Export Compressed Package";
  724. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  725. exe.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + "参数导出";
  726. DialogResult dr = exe.ShowDialog();
  727. if (dr != DialogResult.OK)
  728. {
  729. return;
  730. }
  731. this.textBox2.Text = exe.FileName;
  732. }
  733. /// <summary>
  734. /// 点击第一步
  735. /// </summary>
  736. /// <param name="sender"></param>
  737. /// <param name="e"></param>
  738. private void button1_Click(object sender, EventArgs e)
  739. {
  740. this.chooseStep = 1;
  741. InitializeUI();
  742. }
  743. /// <summary>
  744. /// 点击第二步
  745. /// </summary>
  746. /// <param name="sender"></param>
  747. /// <param name="e"></param>
  748. private void button2_Click(object sender, EventArgs e)
  749. {
  750. // 导出默认全部选中 导入则根据导入时拥有的情况来选择
  751. if (radioButton2.Checked)
  752. {
  753. AllChecked();
  754. }
  755. else if (radioButton1.Checked) {
  756. CancelAllChecked();
  757. if (string.IsNullOrEmpty(textBox4.Text))
  758. {
  759. MessageBox.Show(PdnResources.GetString("PleaseSelectZipFirst") + "!");
  760. return;
  761. }
  762. this.treeView1.AfterCheck -= new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
  763. foreach (TreeNode node in treeView1.Nodes) {
  764. switch (node.Name) {
  765. case "1":
  766. if (importCheckDataList.Contains("camera")) {
  767. node.Checked = true;
  768. }
  769. break;
  770. case "2":
  771. if (importCheckDataList.Contains("measure"))
  772. {
  773. node.Checked = true;
  774. }
  775. break;
  776. case "3":
  777. if (importCheckDataList.Contains("label"))
  778. {
  779. node.Checked = true;
  780. }
  781. break;
  782. case "4":
  783. if (importCheckDataList.Contains("toolbar"))
  784. {
  785. node.Checked = true;
  786. RecursiveNodeCheck(node, 4);
  787. }
  788. break;
  789. case "5":
  790. if (importCheckDataList.Contains("shortcutbar"))
  791. {
  792. node.Checked = true;
  793. }
  794. break;
  795. case "6":
  796. if (importCheckDataList.Contains("hotkey"))
  797. {
  798. node.Checked = true;
  799. }
  800. break;
  801. case "7":
  802. if (importCheckDataList.Contains("reportModel"))
  803. {
  804. node.Checked = true;
  805. }
  806. break;
  807. case "8":
  808. if (importCheckDataList.Contains("ruler"))
  809. {
  810. node.Checked = true;
  811. }
  812. break;
  813. case "9":
  814. if (importCheckDataList.Contains("parameter"))
  815. {
  816. node.Checked = true;
  817. }
  818. break;
  819. case "10":
  820. if (importCheckDataList.Contains("scriptStep"))
  821. {
  822. node.Checked = true;
  823. RecursiveNodeCheck(node, 10);
  824. }
  825. break;
  826. case "11":
  827. if (importCheckDataList.Contains("generalSetting"))
  828. {
  829. node.Checked = true;
  830. }
  831. break;
  832. case "12":
  833. if (importCheckDataList.Contains("workFlow"))
  834. {
  835. node.Checked = true;
  836. RecursiveNodeCheck(node, 12);
  837. }
  838. break;
  839. }
  840. }
  841. this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
  842. }
  843. this.chooseStep = 2;
  844. InitializeUI();
  845. }
  846. /// <summary>
  847. /// 点击第三步
  848. /// </summary>
  849. /// <param name="sender"></param>
  850. /// <param name="e"></param>
  851. private void button3_Click(object sender, EventArgs e)
  852. {
  853. //假如不按套路出牌 直接跳到第三步 模拟第二步点击
  854. if (this.chooseStep == 1)
  855. {
  856. button2_Click(sender, e);
  857. }
  858. foreach (TreeNode item in this.treeView1.Nodes)
  859. {
  860. if (!item.Checked) {
  861. continue;
  862. }
  863. switch (item.Name) {
  864. case "1":
  865. this.checkDataList.Add("camera");
  866. break;
  867. case "2":
  868. this.checkDataList.Add("measure");
  869. break;
  870. case "3":
  871. this.checkDataList.Add("label");
  872. break;
  873. case "4":
  874. this.checkDataList.Add("toolbar");
  875. break;
  876. case "5":
  877. this.checkDataList.Add("shortcutbar");
  878. break;
  879. case "6":
  880. this.checkDataList.Add("hotkey");
  881. break;
  882. case "7":
  883. this.checkDataList.Add("reportModel");
  884. break;
  885. case "8":
  886. this.checkDataList.Add("ruler");
  887. break;
  888. case "9":
  889. this.checkDataList.Add("parameter");
  890. break;
  891. case "10":
  892. this.checkDataList.Add("scriptStep");
  893. break;
  894. case "11":
  895. this.checkDataList.Add("generalSetting");
  896. break;
  897. case "12":
  898. this.checkDataList.Add("workFlow");
  899. break;
  900. }
  901. if (item.Nodes.Count > 0)
  902. {
  903. RecursiveDataCheck(item);
  904. }
  905. }
  906. this.chooseStep = 3;
  907. InitializeUI();
  908. }
  909. /// <summary>
  910. /// 递归将所需子集选中
  911. /// </summary>
  912. /// <param name="node"></param>
  913. private void RecursiveNodeCheck(TreeNode node,int type)
  914. {
  915. switch (type) {
  916. case 4:
  917. foreach (TreeNode treeNode in node.Nodes)
  918. {
  919. if (importCheckSecondData["toolbar"].Contains(treeNode.Text)) {
  920. treeNode.Checked = true;
  921. }
  922. }
  923. break;
  924. case 10:
  925. foreach (TreeNode treeNode in node.Nodes)
  926. {
  927. if (importCheckSecondData["scriptStep"].Contains(treeNode.Text))
  928. {
  929. treeNode.Checked = true;
  930. }
  931. }
  932. break;
  933. case 12:
  934. foreach (TreeNode treeNode in node.Nodes)
  935. {
  936. if (importCheckSecondData["workFlow"].Contains(treeNode.Text))
  937. {
  938. treeNode.Checked = true;
  939. }
  940. }
  941. break;
  942. }
  943. }
  944. /// <summary>
  945. /// 递归查询子集点击
  946. /// </summary>
  947. /// <param name="node"></param>
  948. private void RecursiveDataCheck(TreeNode node)
  949. {
  950. List<string> list = new List<string>();
  951. foreach (TreeNode item in node.Nodes)
  952. {
  953. if (!item.Checked) {
  954. continue;
  955. }
  956. list.Add(item.Text);
  957. }
  958. if (list.Count > 0)
  959. {
  960. if (checkSecondData.ContainsKey(node.Name))
  961. {
  962. checkSecondData[node.Name] = list;
  963. }
  964. else {
  965. checkSecondData.Add(node.Name, list);
  966. }
  967. }
  968. }
  969. /// <summary>
  970. /// 点击上一步
  971. /// </summary>
  972. /// <param name="sender"></param>
  973. /// <param name="e"></param>
  974. private void button6_Click(object sender, EventArgs e)
  975. {
  976. switch (this.chooseStep)
  977. {
  978. case 1:
  979. break;
  980. case 2:
  981. button1.Focus();
  982. button1_Click(sender, e);
  983. break;
  984. case 3:
  985. button2.Focus();
  986. button2_Click(sender, e);
  987. break;
  988. }
  989. }
  990. /// <summary>
  991. /// 点击下一步
  992. /// </summary>
  993. /// <param name="sender"></param>
  994. /// <param name="e"></param>
  995. private void button5_Click(object sender, EventArgs e)
  996. {
  997. switch (this.chooseStep)
  998. {
  999. case 1:
  1000. button2.Focus();
  1001. button2_Click(sender, e);
  1002. break;
  1003. case 2:
  1004. button3.Focus();
  1005. button3_Click(sender, e);
  1006. break;
  1007. case 3:
  1008. break;
  1009. }
  1010. }
  1011. /// <summary>
  1012. /// 获取二级数据
  1013. /// </summary>
  1014. private void getSonData() {
  1015. #region [工具栏]
  1016. ToolbarModel toolbarModel = Startup.instance.toolbarModel;
  1017. foreach (var item in toolbarModel.Flows)
  1018. {
  1019. ProjectData sonData = new ProjectData();
  1020. sonData.ProjectID = Guid.NewGuid().ToString();
  1021. sonData.ProjectName = item.Name;
  1022. sonData.ProjectParentID = "4";
  1023. sonData.isCheck = true;
  1024. this.toolbarModelList.Add(sonData);
  1025. }
  1026. #endregion
  1027. #region [工作流程]
  1028. WorkFlowModel workFlowModel = Startup.instance.workFlowModel;
  1029. foreach (var item in workFlowModel.Flows)
  1030. {
  1031. ProjectData sonData = new ProjectData();
  1032. sonData.ProjectID = Guid.NewGuid().ToString();
  1033. sonData.ProjectName = item.Name;
  1034. sonData.ProjectParentID = "12";
  1035. sonData.isCheck = true;
  1036. this.workFlowModelList.Add(sonData);
  1037. }
  1038. #endregion
  1039. #region [脚本]
  1040. List<mic_script> list = mic_script_BLL.FindAll();
  1041. foreach (var item in list)
  1042. {
  1043. ProjectData sonData = new ProjectData();
  1044. sonData.ProjectID = Guid.NewGuid().ToString();
  1045. sonData.ProjectName = item.name;
  1046. sonData.ProjectParentID = "10";
  1047. sonData.isCheck = true;
  1048. this.stepModelList.Add(sonData);
  1049. }
  1050. #endregion
  1051. }
  1052. /// <summary>
  1053. /// 读取树状图结构
  1054. /// </summary>
  1055. private void getTreeData()
  1056. {
  1057. string filePath = Application.StartupPath + "\\Config\\"+ Startup.instance.SettingPrefix + "\\ImportExportModel.xml";
  1058. //文件不在 生成默认文件
  1059. if (!File.Exists(filePath))
  1060. {
  1061. importExportModel = new ImportExportModel();
  1062. #region [生成实体类结构]
  1063. for (int i = 1; i <= 12; i++) {
  1064. ProjectData data = new ProjectData();
  1065. data.ProjectID = i.ToString();
  1066. #region [分别处理]
  1067. switch (i)
  1068. {
  1069. case 1:
  1070. data.ProjectName = "预览属性";
  1071. break;
  1072. case 2:
  1073. data.ProjectName = "测量属性";
  1074. break;
  1075. case 3:
  1076. data.ProjectName = "标注属性";
  1077. break;
  1078. case 4:
  1079. data.ProjectName = "工具栏";
  1080. data.sonDataList = this.toolbarModelList;
  1081. break;
  1082. case 5:
  1083. data.ProjectName = "快捷栏";
  1084. break;
  1085. case 6:
  1086. data.ProjectName = "快捷键";
  1087. break;
  1088. case 7:
  1089. data.ProjectName = "报告模板";
  1090. break;
  1091. case 8:
  1092. data.ProjectName = "比例尺";
  1093. break;
  1094. case 9:
  1095. data.ProjectName = "功能参数";
  1096. break;
  1097. case 10:
  1098. data.ProjectName = "脚本信息";
  1099. data.sonDataList = this.stepModelList;
  1100. break;
  1101. case 11:
  1102. data.ProjectName = "常规设置";
  1103. break;
  1104. case 12:
  1105. data.ProjectName = "工作流程";
  1106. data.sonDataList = this.workFlowModelList;
  1107. break;
  1108. }
  1109. #endregion
  1110. importExportModel.AllProjectList.Add(data);
  1111. }
  1112. #endregion
  1113. string importExportXml = XmlSerializeHelper.XmlSerialize(importExportModel);
  1114. FileOperationHelper.WriteStringToFile(importExportXml, filePath, FileMode.Create);
  1115. }
  1116. else {
  1117. importExportModel = XmlSerializeHelper.DESerializer<ImportExportModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  1118. //替换最新的工具栏 工作流程 脚本
  1119. foreach (var item in importExportModel.AllProjectList) {
  1120. switch (item.ProjectID) {
  1121. case "4":
  1122. item.sonDataList = toolbarModelList;
  1123. break;
  1124. case "10":
  1125. item.sonDataList = stepModelList;
  1126. break;
  1127. case "12":
  1128. item.sonDataList = workFlowModelList;
  1129. break;
  1130. }
  1131. }
  1132. }
  1133. }
  1134. /// <summary>
  1135. /// 组织树状图
  1136. /// </summary>
  1137. private void createTreeView() {
  1138. foreach (var item in importExportModel.AllProjectList)
  1139. {
  1140. TreeNode treeNode = new TreeNode();
  1141. treeNode.Text = item.ProjectName;
  1142. treeNode.Name = item.ProjectID;
  1143. #region [如果含有子集 开始递归搞起]
  1144. if (item.sonDataList != null && item.sonDataList.Count > 0) {
  1145. RecursiveDataView(treeNode, item);
  1146. }
  1147. #endregion
  1148. treeNode.Expand();
  1149. treeView1.Nodes.Add(treeNode);
  1150. }
  1151. }
  1152. private void RecursiveDataView(TreeNode node, ProjectData data) {
  1153. foreach (var item in data.sonDataList) {
  1154. TreeNode treeNode = new TreeNode();
  1155. treeNode.Text = item.ProjectName;
  1156. treeNode.Name = item.ProjectID;
  1157. if (item.sonDataList != null && item.sonDataList.Count > 0)
  1158. {
  1159. RecursiveDataView(treeNode, item);
  1160. }
  1161. node.Nodes.Add(treeNode);
  1162. }
  1163. }
  1164. /// <summary>
  1165. /// 全选
  1166. /// </summary>
  1167. /// <param name="sender"></param>
  1168. /// <param name="e"></param>
  1169. private void button9_Click(object sender, EventArgs e)
  1170. {
  1171. this.treeView1.AfterCheck -= new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
  1172. AllChecked();
  1173. this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
  1174. }
  1175. /// <summary>
  1176. /// 全不选
  1177. /// </summary>
  1178. /// <param name="sender"></param>
  1179. /// <param name="e"></param>
  1180. private void button10_Click(object sender, EventArgs e)
  1181. {
  1182. this.treeView1.AfterCheck -= new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
  1183. CancelAllChecked();
  1184. this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
  1185. }
  1186. /// <summary>
  1187. /// 节点选中
  1188. /// </summary>
  1189. /// <param name="sender"></param>
  1190. /// <param name="e"></param>
  1191. private void treeViewChecked(object sender, TreeViewEventArgs e)
  1192. {
  1193. this.treeView1.AfterCheck -= new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
  1194. CheckParentNode(e.Node);
  1195. if (e.Node.Nodes.Count > 0)
  1196. {
  1197. CheckAllChildNodes(e.Node, e.Node.Checked);
  1198. }
  1199. this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
  1200. }
  1201. #region [节点选中相关方法]
  1202. /// <summary>
  1203. /// 全选
  1204. /// </summary>
  1205. private void AllChecked()
  1206. {
  1207. foreach (TreeNode e in this.treeView1.Nodes) {
  1208. e.Checked = true;
  1209. if (e.Nodes.Count > 0)
  1210. {
  1211. CheckAllChildNodes(e, true);
  1212. }
  1213. }
  1214. }
  1215. /// <summary>
  1216. /// 取消全选
  1217. /// </summary>
  1218. private void CancelAllChecked()
  1219. {
  1220. foreach (TreeNode e in this.treeView1.Nodes)
  1221. {
  1222. e.Checked = false;
  1223. if (e.Nodes.Count > 0)
  1224. {
  1225. CheckAllChildNodes(e, false);
  1226. }
  1227. }
  1228. }
  1229. /// <summary>
  1230. /// 改变所有子节点的状态
  1231. /// </summary>
  1232. /// <param name="pn"></param>
  1233. /// <param name="IsChecked"></param>
  1234. private void CheckAllChildNodes(TreeNode pn, bool IsChecked)
  1235. {
  1236. foreach (TreeNode tn in pn.Nodes)
  1237. {
  1238. tn.Checked = IsChecked;
  1239. if (tn.Nodes.Count > 0)
  1240. {
  1241. CheckAllChildNodes(tn, IsChecked);
  1242. }
  1243. }
  1244. }
  1245. /// <summary>
  1246. /// 改变父节点的选中状态,此处为所有子节点不选中时才取消父节点选中,可以根据需要修改
  1247. /// </summary>
  1248. /// <param name="curNode"></param>
  1249. private void CheckParentNode(TreeNode curNode)
  1250. {
  1251. bool bChecked = false;
  1252. if (curNode.Parent != null)
  1253. {
  1254. foreach (TreeNode node in curNode.Parent.Nodes)
  1255. {
  1256. if (node.Checked)
  1257. {
  1258. bChecked = true;
  1259. break;
  1260. }
  1261. }
  1262. if (bChecked)
  1263. {
  1264. curNode.Parent.Checked = true;
  1265. CheckParentNode(curNode.Parent);
  1266. }
  1267. else
  1268. {
  1269. curNode.Parent.Checked = false;
  1270. CheckParentNode(curNode.Parent);
  1271. }
  1272. }
  1273. }
  1274. #endregion
  1275. /// <summary>
  1276. /// 完成
  1277. /// </summary>
  1278. /// <param name="sender"></param>
  1279. /// <param name="e"></param>
  1280. private void button11_Click(object sender, EventArgs e)
  1281. {
  1282. if (radioButton1.Checked)
  1283. {
  1284. #region [开始导入]
  1285. ProgressThreadProcClass procClass = new ProgressThreadProcClass();
  1286. int itemCount = 100;
  1287. ProgressThreadProcClass.IFileTransferProgressEvents progressEvents = new ProgressThreadProcClass.IFileTransferProgressEvents();
  1288. System.Threading.ThreadStart copyThreadProc =
  1289. delegate ()
  1290. {
  1291. try
  1292. {
  1293. foreach (var item in originalPathDict)
  1294. {
  1295. if (!checkDataList.Contains(item.Key) || item.Key.Equals("toolbar") || item.Key.Equals("shortcutbar") || item.Key.Equals("ruler") || item.Key.Equals("scriptStep") || item.Key.Equals("workFlow"))
  1296. {
  1297. continue;
  1298. }
  1299. FileOperationHelper.CopyDirectory(importPathDict[item.Key], item.Value, true);
  1300. }
  1301. #region [快捷键特殊处理下]
  1302. if (checkDataList.Contains("hotkey"))
  1303. {
  1304. string toolBarPath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\";
  1305. string importBarPath = importPathDict["hotkey"] + "Hotkey.xml";
  1306. FileOperationHelper.CopyDirectory(importBarPath, toolBarPath, true);
  1307. }
  1308. #endregion
  1309. #region [常规设置特殊处理下]
  1310. if (checkDataList.Contains("generalSetting"))
  1311. {
  1312. string toolBarPath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\";
  1313. string importBarPath = importPathDict["generalSetting"] + "Config.xml";
  1314. FileOperationHelper.CopyDirectory(importBarPath, toolBarPath, true);
  1315. }
  1316. #endregion
  1317. #region [测量特殊处理下]
  1318. if (checkDataList.Contains("measure"))
  1319. {
  1320. string toolBarPath = originalPathDict["generalSetting"];
  1321. string importSettingPath = importPathDict["measure"] + "Config.xml";
  1322. var importNowSetting = XmlSerializeHelper.DESerializer<ConfigModel>(FileOperationHelper.ReadStringFromFile(importSettingPath, FileMode.Open));
  1323. Startup.instance.configModel.MarkpointWidth = importNowSetting.MarkpointWidth;
  1324. string toolXml = XmlSerializeHelper.XmlSerialize(Startup.instance.configModel);
  1325. FileOperationHelper.WriteStringToFile(toolXml, toolBarPath, FileMode.Create);
  1326. FileOperationHelper.DeleteFolder(originalPathDict["measure"] + "Config.xml");
  1327. }
  1328. #endregion
  1329. #region [脚本信息特殊处理下]
  1330. if (checkDataList.Contains("scriptStep")) {
  1331. string filePath = unZipTemporaryFilePath + "ScriptStep\\ScriptStep.xml";
  1332. List<mic_script> importMicScriptList = XmlSerializeHelper.DESerializer<List<mic_script>>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  1333. List<string> needImportDataList = new List<string>();
  1334. if (checkSecondData.ContainsKey("10"))
  1335. {
  1336. needImportDataList = checkSecondData["10"];
  1337. }
  1338. #region [如果覆盖 则清除数据]
  1339. if (checkBox1.Checked)
  1340. {
  1341. List<mic_script> mainList = mic_script_BLL.FindAll();
  1342. List<mic_script_step> secondList = mic_script_step_BLL.FindAll();
  1343. List<mic_script_step_param> thirdList = mic_script_step_param_BLL.FindAll();
  1344. foreach (var item in mainList)
  1345. {
  1346. mic_script_BLL.Del(item.id);
  1347. }
  1348. foreach (var item in secondList)
  1349. {
  1350. mic_script_step_BLL.Del(item.id);
  1351. }
  1352. foreach (var item in thirdList)
  1353. {
  1354. mic_script_step_param_BLL.Del(item.id);
  1355. }
  1356. }
  1357. #endregion
  1358. foreach (var item in importMicScriptList)
  1359. {
  1360. if (!needImportDataList.Contains(item.name)) {
  1361. continue;
  1362. }
  1363. mic_script script = new mic_script();
  1364. script.name = item.name;
  1365. mic_script_BLL.Add(script);
  1366. foreach (var s in item.sonList) {
  1367. mic_script_step mic_Script_Step = new mic_script_step();
  1368. mic_Script_Step.automatic = s.automatic;
  1369. mic_Script_Step.menu_id = s.menu_id;
  1370. mic_Script_Step.script_id = script.id;
  1371. mic_Script_Step.step_name = s.step_name;
  1372. mic_Script_Step.step_sort = s.step_sort;
  1373. mic_script_step_BLL.Add(mic_Script_Step);
  1374. foreach (var m in s.sonList) {
  1375. mic_script_step_param param = new mic_script_step_param();
  1376. param.param_key = m.param_key;
  1377. param.param_type = m.param_type;
  1378. param.param_value = m.param_value;
  1379. param.script_id = script.id;
  1380. param.step_id = mic_Script_Step.script_id;
  1381. param.value = m.value;
  1382. mic_script_step_param_BLL.Add(param);
  1383. }
  1384. }
  1385. }
  1386. }
  1387. #endregion
  1388. #region [快捷栏特殊处理下]
  1389. if (checkDataList.Contains("shortcutbar"))
  1390. {
  1391. string toolBarPath = originalPathDict["shortcutbar"];
  1392. var nowToolBar = XmlSerializeHelper.DESerializer<ShortcutbarModel>(FileOperationHelper.ReadStringFromFile(toolBarPath, FileMode.Open));
  1393. string importBarPath = importPathDict["shortcutbar"] + "Shortcutbar.xml";
  1394. var importToolBar = XmlSerializeHelper.DESerializer<ShortcutbarModel>(FileOperationHelper.ReadStringFromFile(importBarPath, FileMode.Open));
  1395. if (checkBox1.Checked)
  1396. {
  1397. nowToolBar = importToolBar;
  1398. }
  1399. else
  1400. {
  1401. foreach (var item in importToolBar.Menus)
  1402. {
  1403. nowToolBar.Menus.Add(item);
  1404. }
  1405. }
  1406. Startup.instance.shortcutbarModel = nowToolBar;
  1407. string toolXml = XmlSerializeHelper.XmlSerialize(nowToolBar);
  1408. FileOperationHelper.WriteStringToFile(toolXml, toolBarPath, FileMode.Create);
  1409. }
  1410. #endregion
  1411. #region [标尺特殊处理下]
  1412. if (checkDataList.Contains("ruler"))
  1413. {
  1414. string filePath = unZipTemporaryFilePath + "Ruler\\Ruler.xml";
  1415. List<mic_rulers> importRulerList = XmlSerializeHelper.DESerializer<List<mic_rulers>>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  1416. List<mic_rulers> allRulerList = mic_rulers_BLL.FindAll();
  1417. if (checkBox1.Checked) {
  1418. foreach (var item in allRulerList) {
  1419. mic_rulers_BLL.Del(item.id);
  1420. }
  1421. }
  1422. foreach (var item in importRulerList)
  1423. {
  1424. mic_rulers rulers = new mic_rulers();
  1425. rulers.gain_multiple = item.gain_multiple;
  1426. rulers.microscope = item.objective_lens;
  1427. rulers.physical_length = item.physical_length;
  1428. rulers.objective_lens = item.objective_lens;
  1429. rulers.pixel_length = item.pixel_length;
  1430. rulers.ruler_camera = item.ruler_camera;
  1431. rulers.ruler_connector = item.ruler_connector;
  1432. rulers.ruler_eyepiece = item.ruler_eyepiece;
  1433. rulers.ruler_height = item.ruler_height;
  1434. rulers.ruler_name = item.ruler_name;
  1435. rulers.ruler_type = item.ruler_type;
  1436. rulers.ruler_units = item.ruler_units;
  1437. rulers.ruler_width = item.ruler_width;
  1438. rulers.ruler_zoom = item.ruler_zoom;
  1439. mic_rulers_BLL.Add(rulers);
  1440. }
  1441. }
  1442. #endregion
  1443. #region [工具栏特殊处理下]
  1444. if (checkDataList.Contains("toolbar")) {
  1445. string toolBarPath = originalPathDict["toolbar"];
  1446. var nowToolBar = XmlSerializeHelper.DESerializer<ToolbarModel>(FileOperationHelper.ReadStringFromFile(toolBarPath, FileMode.Open));
  1447. string importBarPath = importPathDict["toolbar"] + "Toolbar.xml";
  1448. var importToolBar = XmlSerializeHelper.DESerializer<ToolbarModel>(FileOperationHelper.ReadStringFromFile(importBarPath, FileMode.Open));
  1449. #region [如果覆盖 则清除数据]
  1450. List<ToolbarModel.Flow> list = new List<ToolbarModel.Flow>();
  1451. foreach (var item in importToolBar.Flows)
  1452. {
  1453. if (checkSecondData["4"].Contains(item.Name))
  1454. {
  1455. continue;
  1456. }
  1457. list.Add(item);
  1458. }
  1459. foreach (var item in list)
  1460. {
  1461. importToolBar.Flows.Remove(item);
  1462. }
  1463. if (checkBox1.Checked)
  1464. {
  1465. nowToolBar = importToolBar;
  1466. }
  1467. else {
  1468. foreach (var item in importToolBar.Flows)
  1469. {
  1470. nowToolBar.Flows.Add(item);
  1471. }
  1472. }
  1473. #endregion
  1474. Startup.instance.toolbarModel = nowToolBar;
  1475. string toolXml = XmlSerializeHelper.XmlSerialize(nowToolBar);
  1476. FileOperationHelper.WriteStringToFile(toolXml, toolBarPath, FileMode.Create);
  1477. }
  1478. #endregion
  1479. #region [工作流程特殊处理下]
  1480. if (checkDataList.Contains("workFlow"))
  1481. {
  1482. string filePath = originalPathDict["workFlow"];
  1483. var workFlowModel = XmlSerializeHelper.DESerializer<WorkFlowModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  1484. string importWorkFlowPath = importPathDict["workFlow"] + "WorkFlow.xml";
  1485. var importWorkFlow = XmlSerializeHelper.DESerializer<WorkFlowModel>(FileOperationHelper.ReadStringFromFile(importWorkFlowPath, FileMode.Open));
  1486. #region [[如果覆盖 则清除数据]
  1487. List<WorkFlowModel.Flow> list = new List<WorkFlowModel.Flow>();
  1488. foreach (var item in importWorkFlow.Flows)
  1489. {
  1490. if (checkSecondData["12"].Contains(item.Name))
  1491. {
  1492. continue;
  1493. }
  1494. list.Add(item);
  1495. }
  1496. foreach (var item in list)
  1497. {
  1498. importWorkFlow.Flows.Remove(item);
  1499. }
  1500. if (checkBox1.Checked)
  1501. {
  1502. workFlowModel = importWorkFlow;
  1503. }
  1504. else {
  1505. foreach (var item in importWorkFlow.Flows)
  1506. {
  1507. workFlowModel.Flows.Add(item);
  1508. }
  1509. }
  1510. #endregion
  1511. string workFlowModelXml = XmlSerializeHelper.XmlSerialize(workFlowModel);
  1512. FileOperationHelper.WriteStringToFile(workFlowModelXml, filePath, FileMode.Create);
  1513. }
  1514. #endregion
  1515. if (checkDataList.Contains("parameter"))
  1516. {
  1517. //晶粒度单独处理下
  1518. string GrainSizePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\";
  1519. FileOperationHelper.CopyDirectory(importPathDict["parameter"] + "\\GrainSizeAnalysisModel.xml", GrainSizePath, true);
  1520. }
  1521. if (checkDataList.Contains("generalSetting"))
  1522. {
  1523. //常规设置需要单独处理下
  1524. string userInfoFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\";
  1525. FileOperationHelper.CopyDirectory(importPathDict["generalSetting"] + "\\UserInfo.xml", userInfoFilePath, true);
  1526. string setUpFilePath = Application.StartupPath + @"\Config\" + Startup.instance.SettingPrefix + @"\SetUp\";
  1527. FileOperationHelper.CopyDirectory(importPathDict["generalSetting"] + "\\GuideStyle.xml", setUpFilePath, true);
  1528. }
  1529. }
  1530. catch (Exception ex)
  1531. {
  1532. }
  1533. finally
  1534. {
  1535. progressEvents.EndOperation(OperationResult.Finished);
  1536. }
  1537. };
  1538. procClass.StartProgressAction(this, itemCount, copyThreadProc, progressEvents, null);
  1539. MessageBox.Show(PdnResources.GetString("ImportSuccessful") + "!");
  1540. #endregion
  1541. }
  1542. else if (radioButton2.Checked) {
  1543. #region [开始导出]
  1544. if (string.IsNullOrEmpty(textBox2.Text))
  1545. {
  1546. MessageBox.Show("请先选择要导出文件的路径!");
  1547. return;
  1548. }
  1549. ProgressThreadProcClass procClass = new ProgressThreadProcClass();
  1550. int itemCount = 100;
  1551. ProgressThreadProcClass.IFileTransferProgressEvents progressEvents = new ProgressThreadProcClass.IFileTransferProgressEvents();
  1552. System.Threading.ThreadStart copyThreadProc =
  1553. delegate ()
  1554. {
  1555. try
  1556. {
  1557. string choosePath = this.textBox2.Text;
  1558. foreach (var item in originalPathDict)
  1559. {
  1560. if (!checkDataList.Contains(item.Key))
  1561. {
  1562. continue;
  1563. }
  1564. FileOperationHelper.CopyDirectory(item.Value, newPathDict[item.Key], false);
  1565. }
  1566. #region [脚本信息特殊处理]
  1567. if (checkDataList.Contains("scriptStep"))
  1568. {
  1569. List<mic_script> mainList = mic_script_BLL.FindAll();
  1570. List<mic_script_step> secondList = mic_script_step_BLL.FindAll();
  1571. List<mic_script_step_param> thirdList = mic_script_step_param_BLL.FindAll();
  1572. if (checkSecondData.ContainsKey("10")) {
  1573. List<string> hasDataList = checkSecondData["10"];
  1574. List<mic_script> shouldExportDataList = new List<mic_script>();
  1575. foreach (var item in mainList)
  1576. {
  1577. if (!hasDataList.Contains(item.name)) {
  1578. continue;
  1579. }
  1580. var mic = item;
  1581. mic.sonList = secondList.Where(m => m.script_id == mic.id).ToList();
  1582. foreach (var s in mic.sonList) {
  1583. s.sonList = thirdList.Where(m => m.script_id == mic.id && m.step_id == s.id).ToList();
  1584. }
  1585. shouldExportDataList.Add(mic);
  1586. }
  1587. string scriptExportXml = XmlSerializeHelper.XmlSerialize(shouldExportDataList);
  1588. FileOperationHelper.WriteStringToFile(scriptExportXml, newPathDict["scriptStep"] + "ScriptStep.xml", FileMode.Create);
  1589. }
  1590. }
  1591. #endregion
  1592. #region [标尺信息特殊处理]
  1593. if (checkDataList.Contains("ruler"))
  1594. {
  1595. List<mic_rulers> mainList = mic_rulers_BLL.FindAll();
  1596. string scriptExportXml = XmlSerializeHelper.XmlSerialize(mainList);
  1597. FileOperationHelper.WriteStringToFile(scriptExportXml, newPathDict["ruler"] + "Ruler.xml", FileMode.Create);
  1598. }
  1599. #endregion
  1600. #region [获取二级数据]
  1601. if (checkSecondData.ContainsKey("4"))
  1602. {
  1603. var toolbarModel = XmlSerializeHelper.DESerializer<ToolbarModel>(FileOperationHelper.ReadStringFromFile(newPathDict["toolbar"] + "\\Toolbar.xml", FileMode.Open));
  1604. List<ToolbarModel.Flow> list = new List<ToolbarModel.Flow>();
  1605. foreach (var item in toolbarModel.Flows)
  1606. {
  1607. if (checkSecondData["4"].Contains(item.Name))
  1608. {
  1609. continue;
  1610. }
  1611. list.Add(item);
  1612. }
  1613. foreach (var item in list)
  1614. {
  1615. toolbarModel.Flows.Remove(item);
  1616. }
  1617. string toolbarModelXml = XmlSerializeHelper.XmlSerialize(toolbarModel);
  1618. FileOperationHelper.WriteStringToFile(toolbarModelXml, newPathDict["toolbar"] + "\\Toolbar.xml", FileMode.Create);
  1619. }
  1620. if (checkSecondData.ContainsKey("12"))
  1621. {
  1622. var workFlowModel = XmlSerializeHelper.DESerializer<WorkFlowModel>(FileOperationHelper.ReadStringFromFile(newPathDict["workFlow"] + "\\WorkFlow.xml", FileMode.Open));
  1623. List<WorkFlowModel.Flow> list = new List<WorkFlowModel.Flow>();
  1624. foreach (var item in workFlowModel.Flows)
  1625. {
  1626. if (checkSecondData["12"].Contains(item.Name))
  1627. {
  1628. continue;
  1629. }
  1630. list.Add(item);
  1631. }
  1632. foreach (var item in list)
  1633. {
  1634. workFlowModel.Flows.Remove(item);
  1635. }
  1636. string workFlowModelXml = XmlSerializeHelper.XmlSerialize(workFlowModel);
  1637. FileOperationHelper.WriteStringToFile(workFlowModelXml, newPathDict["workFlow"] + "\\WorkFlow.xml", FileMode.Create);
  1638. }
  1639. #endregion
  1640. if (checkDataList.Contains("measure"))
  1641. {
  1642. //测量标记点单独处理下
  1643. string pointPath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml";
  1644. FileOperationHelper.CopyDirectory(pointPath, newPathDict["measure"], false);
  1645. }
  1646. if (checkDataList.Contains("parameter"))
  1647. {
  1648. //晶粒度单独处理下
  1649. string GrainSizePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  1650. FileOperationHelper.CopyDirectory(GrainSizePath, newPathDict["parameter"], true);
  1651. }
  1652. if (checkDataList.Contains("generalSetting"))
  1653. {
  1654. //常规设置需要单独处理下
  1655. string userInfoFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\UserInfo.xml";
  1656. FileOperationHelper.CopyDirectory(userInfoFilePath, newPathDict["generalSetting"], true);
  1657. string setUpFilePath = Application.StartupPath + @"\Config\" + Startup.instance.SettingPrefix + @"\SetUp\GuideStyle.xml";
  1658. FileOperationHelper.CopyDirectory(setUpFilePath, newPathDict["generalSetting"], true);
  1659. }
  1660. ZipHandleHelper.createZip(temporaryFilePath, choosePath);
  1661. }
  1662. catch (Exception)
  1663. {
  1664. }
  1665. finally
  1666. {
  1667. progressEvents.EndOperation(OperationResult.Finished);
  1668. }
  1669. };
  1670. procClass.StartProgressAction(this, itemCount, copyThreadProc, progressEvents, null);
  1671. MessageBox.Show("导出成功!");
  1672. #endregion
  1673. }
  1674. this.Close();
  1675. }
  1676. /// <summary>
  1677. /// 生成默认的中间数据文件夹
  1678. /// </summary>
  1679. private void createDefaultDirectory() {
  1680. //生成一个临时文件夹 用于存放各种xml
  1681. //先删除之前的
  1682. FileOperationHelper.DeleteFolder(unZipTemporaryFilePath);
  1683. FileOperationHelper.DeleteFolder(temporaryFilePath);
  1684. //生成新的
  1685. Directory.CreateDirectory(temporaryFilePath);
  1686. #region [相机设置]
  1687. string cameraFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\CameraParam\\";
  1688. string temporaryCameraFilePath = $"{temporaryFilePath}\\CameraParam\\";
  1689. Directory.CreateDirectory(temporaryCameraFilePath);
  1690. originalPathDict.Add("camera", cameraFilePath);
  1691. newPathDict.Add("camera", temporaryCameraFilePath);
  1692. string importTemporaryCameraFilePath = $"{unZipTemporaryFilePath}\\CameraParam\\";
  1693. importPathDict.Add("camera", importTemporaryCameraFilePath);
  1694. #endregion
  1695. #region [测量参数]
  1696. string measure = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Measure\\";
  1697. string temporaryMeasureFilePath = $"{temporaryFilePath}\\Measure\\";
  1698. Directory.CreateDirectory(temporaryMeasureFilePath);
  1699. originalPathDict.Add("measure", measure);
  1700. newPathDict.Add("measure", temporaryMeasureFilePath);
  1701. string importTemporaryMeasureFilePath = $"{unZipTemporaryFilePath}\\Measure\\";
  1702. importPathDict.Add("measure", importTemporaryMeasureFilePath);
  1703. #endregion
  1704. #region [标注参数]
  1705. string label = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\";
  1706. string temporaryLabelFilePath = $"{temporaryFilePath}\\Label\\";
  1707. Directory.CreateDirectory(temporaryLabelFilePath);
  1708. originalPathDict.Add("label", label);
  1709. newPathDict.Add("label", temporaryLabelFilePath);
  1710. string importTemporaryLabelFilePath = $"{unZipTemporaryFilePath}\\Label\\";
  1711. importPathDict.Add("label", importTemporaryLabelFilePath);
  1712. #endregion
  1713. #region [工具栏]
  1714. string toolbar = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Toolbar.xml";
  1715. string temporaryToolbarFilePath = $"{temporaryFilePath}\\Toolbar\\";
  1716. Directory.CreateDirectory(temporaryToolbarFilePath);
  1717. originalPathDict.Add("toolbar", toolbar);
  1718. newPathDict.Add("toolbar", temporaryToolbarFilePath);
  1719. string importTemporaryToolbarFilePath = $"{unZipTemporaryFilePath}\\Toolbar\\";
  1720. importPathDict.Add("toolbar", importTemporaryToolbarFilePath);
  1721. #endregion
  1722. #region [快捷栏]
  1723. string shortcutbar = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Shortcutbar.xml";
  1724. string temporaryShortcutbarFilePath = $"{temporaryFilePath}\\Shortcutbar\\";
  1725. Directory.CreateDirectory(temporaryShortcutbarFilePath);
  1726. originalPathDict.Add("shortcutbar", shortcutbar);
  1727. newPathDict.Add("shortcutbar", temporaryShortcutbarFilePath);
  1728. string importTemporaryShortcutbarFilePath = $"{unZipTemporaryFilePath}\\Shortcutbar\\";
  1729. importPathDict.Add("shortcutbar", importTemporaryShortcutbarFilePath);
  1730. #endregion
  1731. #region [快捷键]
  1732. string hotkey = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Hotkey.xml";
  1733. string temporaryHotkeyFilePath = $"{temporaryFilePath}\\Hotkey\\";
  1734. Directory.CreateDirectory(temporaryHotkeyFilePath);
  1735. originalPathDict.Add("hotkey", hotkey);
  1736. newPathDict.Add("hotkey", temporaryHotkeyFilePath);
  1737. string importTemporaryHotkeyFilePath = $"{unZipTemporaryFilePath}\\Hotkey\\";
  1738. importPathDict.Add("hotkey", importTemporaryHotkeyFilePath);
  1739. #endregion
  1740. #region [报告模板]
  1741. string reportModel = Application.StartupPath + "\\ModuleManage\\";
  1742. string temporaryReportModelPath = $"{temporaryFilePath}\\ModuleManage\\";
  1743. Directory.CreateDirectory(temporaryReportModelPath);
  1744. originalPathDict.Add("reportModel", reportModel);
  1745. newPathDict.Add("reportModel", temporaryReportModelPath);
  1746. string importTemporaryReportModelPath = $"{unZipTemporaryFilePath}\\ModuleManage\\";
  1747. importPathDict.Add("reportModel", importTemporaryReportModelPath);
  1748. #endregion
  1749. #region [比例尺]
  1750. string temporaryRulerFilePath = $"{temporaryFilePath}\\Ruler\\";
  1751. Directory.CreateDirectory(temporaryRulerFilePath);
  1752. newPathDict.Add("ruler", temporaryRulerFilePath);
  1753. string importTemporaryRulerFilePath = $"{unZipTemporaryFilePath}\\Ruler\\";
  1754. importPathDict.Add("ruler", importTemporaryRulerFilePath);
  1755. #endregion
  1756. #region [功能参数]
  1757. string parameter = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\ParameterSaving\\";
  1758. string temporaryParameterFilePath = $"{temporaryFilePath}\\ParameterSaving\\";
  1759. Directory.CreateDirectory(temporaryParameterFilePath);
  1760. originalPathDict.Add("parameter", parameter);
  1761. newPathDict.Add("parameter", temporaryParameterFilePath);
  1762. string importTemporaryParameterFilePath = $"{unZipTemporaryFilePath}\\ParameterSaving\\";
  1763. importPathDict.Add("parameter", importTemporaryParameterFilePath);
  1764. #endregion
  1765. #region [脚本信息]
  1766. string temporaryScriptStepPath = $"{temporaryFilePath}\\ScriptStep\\";
  1767. Directory.CreateDirectory(temporaryScriptStepPath);
  1768. newPathDict.Add("scriptStep", temporaryScriptStepPath);
  1769. string importTemporaryScriptStepPath = $"{temporaryScriptStepPath}\\ScriptStep\\";
  1770. importPathDict.Add("scriptStep", importTemporaryScriptStepPath);
  1771. #endregion
  1772. #region [常规设置]
  1773. string generalSetting = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml";
  1774. string temporaryGeneralSettingPath = $"{temporaryFilePath}\\Config\\";
  1775. Directory.CreateDirectory(temporaryGeneralSettingPath);
  1776. originalPathDict.Add("generalSetting", generalSetting);
  1777. newPathDict.Add("generalSetting", temporaryGeneralSettingPath);
  1778. string importTemporaryGeneralSettingPath = $"{unZipTemporaryFilePath}\\Config\\";
  1779. importPathDict.Add("generalSetting", importTemporaryGeneralSettingPath);
  1780. #endregion
  1781. #region [工作流程]
  1782. string workFlow = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkFlow.xml";
  1783. string temporaryWorkFlowPath = $"{temporaryFilePath}\\WorkFlow\\";
  1784. Directory.CreateDirectory(temporaryWorkFlowPath);
  1785. originalPathDict.Add("workFlow", workFlow);
  1786. newPathDict.Add("workFlow", temporaryWorkFlowPath);
  1787. string importTemporaryWorkFlowPath = $"{unZipTemporaryFilePath}\\WorkFlow\\";
  1788. importPathDict.Add("workFlow", importTemporaryWorkFlowPath);
  1789. #endregion
  1790. }
  1791. }
  1792. }