12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120 |
- using PaintDotNet;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Base.SettingModel;
- using PaintDotNet.DbOpreate.DbBll;
- using PaintDotNet.DbOpreate.DbModel;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Metis.Setting
- {
- internal partial class ImportExportSettingDialog : PdnBaseForm
- {
- private GroupBox groupBox1;
- private Button button6;
- private Button button5;
- private Button button3;
- private Button button2;
- private GroupBox groupBox2;
- private Button button8;
- private GroupBox groupBox3;
- private RadioButton radioButton2;
- private RadioButton radioButton1;
- private TextBox textBox4;
- private Button button4;
- private GroupBox groupBox4;
- private GroupBox groupBox5;
- private Label label1;
- private TextBox textBox1;
- private CheckBox checkBox1;
- private GroupBox groupBox6;
- private TextBox textBox2;
- private Label label2;
- private Button button7;
- private Button button1;
- private Button button10;
- private Button button9;
- private Button button11;
- /// <summary>
- /// 选择的步
- /// </summary>
- private int chooseStep = 1;
- private ImportExportModel importExportModel;
- /// <summary>
- /// 工具栏组成的结构数据
- /// </summary>
- private List<ProjectData> toolbarModelList = new List<ProjectData>();
- /// <summary>
- /// 工作流程组成的结构数据
- /// </summary>
- private List<ProjectData> workFlowModelList = new List<ProjectData>();
- private PaintDotNet.CustomControl.TreeViewEnhanced treeView1;
- /// <summary>
- /// 脚本组成的结构数据
- /// </summary>
- private List<ProjectData> stepModelList = new List<ProjectData>();
- /// <summary>
- /// 压缩中间数据目录
- /// </summary>
- private string temporaryFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Temp\\";
- /// <summary>
- /// 解压中间数据目录
- /// </summary>
- private string unZipTemporaryFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\UnZipTemp\\";
- private Dictionary<string, string> originalPathDict = new Dictionary<string, string>();
- private Dictionary<string, string> newPathDict = new Dictionary<string, string>();
- private Dictionary<string, string> importPathDict = new Dictionary<string, string>();
- /// <summary>
- /// (导出)选择的树状信息
- /// </summary>
- private List<string> checkDataList = new List<string>();
- /// <summary>
- /// (导出)二级结构选择
- /// </summary>
- private Dictionary<string, List<string>> checkSecondData = new Dictionary<string, List<string>>();
- /// <summary>
- /// (导入)选择的树状信息
- /// </summary>
- private List<string> importCheckDataList = new List<string>();
- /// <summary>
- /// (导入)二级结构选择
- /// </summary>
- private Dictionary<string, List<string>> importCheckSecondData = new Dictionary<string, List<string>>();
- public ImportExportSettingDialog()
- {
- InitializeComponent();
- InitializeLanguageText();
- #region [默认展示第一步]
- button1_Click(null, null);
- #endregion
- #region [获取二级结构数据]
- this.getSonData();
- #endregion
- #region [读取树状图结构]
- this.getTreeData();
- #endregion
- #region [组织树状图]
- this.treeView1.CheckBoxes = true;
- this.treeView1.ItemHeight = 18;
- this.createTreeView();
- #endregion
- #region [生成中间文件夹]
- this.createDefaultDirectory();
- #endregion
- }
- private void InitializeLanguageText()
- {
- this.radioButton2.Text = PdnResources.GetString("export");
- this.radioButton1.Text = PdnResources.GetString("Import");
- this.groupBox3.Text = PdnResources.GetString("Menu.Setting.Text");
- this.groupBox5.Text = PdnResources.GetString("Menu.Setting.Text");
- this.label1.Text = PdnResources.GetString("Import");
- this.checkBox1.Text = PdnResources.GetString("OverrideCurrentData");
- this.button1.Text = PdnResources.GetString("Menu.firststep.text");
- this.button2.Text = PdnResources.GetString("Menu.Secondstep.text");
- this.button3.Text = PdnResources.GetString("Menu.thirdstep.text");
- this.button6.Text = PdnResources.GetString("Menu.Previous.text");
- this.button5.Text = PdnResources.GetString("Menu.Nextstep.text");
- this.groupBox2.Text = PdnResources.GetString("Menu.operation.text");
- this.groupBox4.Text = PdnResources.GetString("Menu.Setting.Text");
- this.button8.Text = PdnResources.GetString("Menu.File.Close.Text");
- this.button9.Text = PdnResources.GetString("Menu.LabelAction.SelectAllLabel.Text");
- this.button10.Text = PdnResources.GetString("Menu.Binaryoperation.Objecthandling.unselectall.text");
- this.button11.Text = PdnResources.GetString("Menu.finish.text");
- this.button4.Text = PdnResources.GetString("Menu.LabelAction.LabelSelect.Text");
- this.Text = PdnResources.GetString("ImportAndExportSet");
- }
- private void InitializeComponent()
- {
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button6 = new System.Windows.Forms.Button();
- this.button5 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.button1 = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.button11 = new System.Windows.Forms.Button();
- this.button10 = new System.Windows.Forms.Button();
- this.button9 = new System.Windows.Forms.Button();
- this.button8 = new System.Windows.Forms.Button();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.button4 = new System.Windows.Forms.Button();
- this.textBox4 = new System.Windows.Forms.TextBox();
- this.radioButton2 = new System.Windows.Forms.RadioButton();
- this.radioButton1 = new System.Windows.Forms.RadioButton();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.treeView1 = new PaintDotNet.CustomControl.TreeViewEnhanced();
- this.groupBox5 = new System.Windows.Forms.GroupBox();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- this.groupBox6 = new System.Windows.Forms.GroupBox();
- this.button7 = new System.Windows.Forms.Button();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.label2 = new System.Windows.Forms.Label();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.groupBox3.SuspendLayout();
- this.groupBox4.SuspendLayout();
- this.groupBox5.SuspendLayout();
- this.groupBox6.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox1.Controls.Add(this.button6);
- this.groupBox1.Controls.Add(this.button5);
- this.groupBox1.Controls.Add(this.button3);
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.button1);
- this.groupBox1.Location = new System.Drawing.Point(12, 10);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(115, 445);
- this.groupBox1.TabIndex = 2;
- this.groupBox1.TabStop = false;
- //
- // button6
- //
- this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.button6.Location = new System.Drawing.Point(20, 383);
- this.button6.Name = "button6";
- this.button6.Size = new System.Drawing.Size(75, 23);
- this.button6.TabIndex = 4;
- this.button6.Text = "上一步";
- this.button6.UseVisualStyleBackColor = true;
- this.button6.Click += new System.EventHandler(this.button6_Click);
- //
- // button5
- //
- this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.button5.Location = new System.Drawing.Point(20, 412);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(75, 23);
- this.button5.TabIndex = 3;
- this.button5.Text = "下一步";
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(20, 89);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(75, 23);
- this.button3.TabIndex = 2;
- this.button3.Text = "第三步";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(20, 59);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(75, 23);
- this.button2.TabIndex = 1;
- this.button2.Text = "第二步";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(20, 29);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 0;
- this.button1.Text = "第一步";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.button11);
- this.groupBox2.Controls.Add(this.button10);
- this.groupBox2.Controls.Add(this.button9);
- this.groupBox2.Controls.Add(this.button8);
- this.groupBox2.Location = new System.Drawing.Point(133, 12);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(604, 58);
- this.groupBox2.TabIndex = 3;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "操作";
- //
- // button11
- //
- this.button11.Location = new System.Drawing.Point(512, 20);
- this.button11.Name = "button11";
- this.button11.Size = new System.Drawing.Size(75, 23);
- this.button11.TabIndex = 4;
- this.button11.Text = "完成";
- this.button11.UseVisualStyleBackColor = true;
- this.button11.Click += new System.EventHandler(this.button11_Click);
- //
- // button10
- //
- this.button10.Location = new System.Drawing.Point(431, 20);
- this.button10.Name = "button10";
- this.button10.Size = new System.Drawing.Size(75, 23);
- this.button10.TabIndex = 3;
- this.button10.Text = "全不选";
- this.button10.UseVisualStyleBackColor = true;
- this.button10.Click += new System.EventHandler(this.button10_Click);
- //
- // button9
- //
- this.button9.Location = new System.Drawing.Point(350, 20);
- this.button9.Name = "button9";
- this.button9.Size = new System.Drawing.Size(75, 23);
- this.button9.TabIndex = 2;
- this.button9.Text = "全选";
- this.button9.UseVisualStyleBackColor = true;
- this.button9.Click += new System.EventHandler(this.button9_Click);
- //
- // button8
- //
- this.button8.Location = new System.Drawing.Point(512, 20);
- this.button8.Name = "button8";
- this.button8.Size = new System.Drawing.Size(75, 23);
- this.button8.TabIndex = 1;
- this.button8.Text = "关闭";
- this.button8.UseVisualStyleBackColor = true;
- this.button8.Click += new System.EventHandler(this.button8_Click);
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.button4);
- this.groupBox3.Controls.Add(this.textBox4);
- this.groupBox3.Controls.Add(this.radioButton2);
- this.groupBox3.Controls.Add(this.radioButton1);
- this.groupBox3.Location = new System.Drawing.Point(133, 76);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(604, 379);
- this.groupBox3.TabIndex = 4;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "设置";
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(512, 64);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(75, 21);
- this.button4.TabIndex = 13;
- this.button4.Text = "选择";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // textBox4
- //
- this.textBox4.Location = new System.Drawing.Point(24, 65);
- this.textBox4.Name = "textBox4";
- this.textBox4.ReadOnly = true;
- this.textBox4.Size = new System.Drawing.Size(482, 21);
- this.textBox4.TabIndex = 12;
- //
- // radioButton2
- //
- this.radioButton2.AutoSize = true;
- this.radioButton2.Location = new System.Drawing.Point(24, 109);
- this.radioButton2.Name = "radioButton2";
- this.radioButton2.Size = new System.Drawing.Size(47, 16);
- this.radioButton2.TabIndex = 1;
- this.radioButton2.TabStop = true;
- this.radioButton2.Text = "导出";
- this.radioButton2.UseVisualStyleBackColor = true;
- this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_Check);
- //
- // radioButton1
- //
- this.radioButton1.AutoSize = true;
- this.radioButton1.Checked = true;
- this.radioButton1.Location = new System.Drawing.Point(24, 30);
- this.radioButton1.Name = "radioButton1";
- this.radioButton1.Size = new System.Drawing.Size(47, 16);
- this.radioButton1.TabIndex = 0;
- this.radioButton1.TabStop = true;
- this.radioButton1.Text = "导入";
- this.radioButton1.UseVisualStyleBackColor = true;
- this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_Check);
- //
- // groupBox4
- //
- this.groupBox4.Controls.Add(this.treeView1);
- this.groupBox4.Location = new System.Drawing.Point(133, 76);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(604, 379);
- this.groupBox4.TabIndex = 14;
- this.groupBox4.TabStop = false;
- this.groupBox4.Text = "设置";
- //
- // treeView1
- //
- this.treeView1.Location = new System.Drawing.Point(189, 13);
- this.treeView1.Name = "treeView1";
- this.treeView1.Size = new System.Drawing.Size(227, 360);
- this.treeView1.TabIndex = 16;
- this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
- //
- // groupBox5
- //
- this.groupBox5.Controls.Add(this.checkBox1);
- this.groupBox5.Controls.Add(this.textBox1);
- this.groupBox5.Controls.Add(this.label1);
- this.groupBox5.Location = new System.Drawing.Point(133, 76);
- this.groupBox5.Name = "groupBox5";
- this.groupBox5.Size = new System.Drawing.Size(604, 379);
- this.groupBox5.TabIndex = 15;
- this.groupBox5.TabStop = false;
- this.groupBox5.Text = "设置";
- //
- // checkBox1
- //
- this.checkBox1.AutoSize = true;
- this.checkBox1.Location = new System.Drawing.Point(24, 110);
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.Size = new System.Drawing.Size(96, 16);
- this.checkBox1.TabIndex = 2;
- this.checkBox1.Text = "覆盖当前数据";
- this.checkBox1.UseVisualStyleBackColor = true;
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(24, 65);
- this.textBox1.Name = "textBox1";
- this.textBox1.ReadOnly = true;
- this.textBox1.Size = new System.Drawing.Size(462, 21);
- this.textBox1.TabIndex = 1;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(22, 34);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(77, 12);
- this.label1.TabIndex = 0;
- this.label1.Text = "从......导入";
- //
- // groupBox6
- //
- this.groupBox6.Controls.Add(this.button7);
- this.groupBox6.Controls.Add(this.textBox2);
- this.groupBox6.Controls.Add(this.label2);
- this.groupBox6.Location = new System.Drawing.Point(133, 76);
- this.groupBox6.Name = "groupBox6";
- this.groupBox6.Size = new System.Drawing.Size(604, 379);
- this.groupBox6.TabIndex = 16;
- this.groupBox6.TabStop = false;
- this.groupBox6.Text = "设置";
- //
- // button7
- //
- this.button7.Location = new System.Drawing.Point(512, 62);
- this.button7.Name = "button7";
- this.button7.Size = new System.Drawing.Size(75, 23);
- this.button7.TabIndex = 2;
- this.button7.Text = "选择";
- this.button7.UseVisualStyleBackColor = true;
- this.button7.Click += new System.EventHandler(this.button7_Click);
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(24, 65);
- this.textBox2.Name = "textBox2";
- this.textBox2.ReadOnly = true;
- this.textBox2.Size = new System.Drawing.Size(471, 21);
- this.textBox2.TabIndex = 1;
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(22, 34);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(125, 12);
- this.label2.TabIndex = 0;
- this.label2.Text = "选择配置文件存放位置";
- //
- // ImportExportSettingDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(749, 467);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox5);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.groupBox6);
- this.Controls.Add(this.groupBox4);
- this.Controls.Add(this.groupBox2);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "ImportExportSettingDialog";
- this.Text = "导入导出向导";
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.groupBox4, 0);
- this.Controls.SetChildIndex(this.groupBox6, 0);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox5, 0);
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.groupBox1.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- this.groupBox3.PerformLayout();
- this.groupBox4.ResumeLayout(false);
- this.groupBox5.ResumeLayout(false);
- this.groupBox5.PerformLayout();
- this.groupBox6.ResumeLayout(false);
- this.groupBox6.PerformLayout();
- this.ResumeLayout(false);
- }
- /// <summary>
- /// 初始化UI
- /// </summary>
- private void InitializeUI() {
- switch (this.chooseStep) {
- case 1:
- this.groupBox3.Visible = true;
- this.groupBox4.Visible = false;
- this.groupBox5.Visible = false;
- this.groupBox6.Visible = false;
- this.button1.BackColor = Color.Black;
- this.button1.ForeColor = Color.White;
- this.button2.BackColor = Color.White;
- this.button2.ForeColor = Color.Black;
- this.button3.BackColor = Color.White;
- this.button3.ForeColor = Color.Black;
- this.button6.Enabled = false;
- this.button5.Enabled = true;
- this.button8.Visible = true;
- this.button9.Visible = false;
- this.button10.Visible = false;
- this.button11.Visible = false;
- break;
- case 2:
- this.groupBox3.Visible = false;
- this.groupBox4.Visible = true;
- this.groupBox5.Visible = false;
- this.groupBox6.Visible = false;
- this.button1.BackColor = Color.White;
- this.button1.ForeColor = Color.Black;
- this.button2.BackColor = Color.Black;
- this.button2.ForeColor = Color.White;
- this.button3.BackColor = Color.White;
- this.button3.ForeColor = Color.Black;
- this.button6.Enabled = true;
- this.button5.Enabled = true;
- this.button8.Visible = true;
- this.button9.Visible = true;
- this.button10.Visible = true;
- this.button11.Visible = false;
- break;
- case 3:
- this.groupBox3.Visible = false;
- this.groupBox4.Visible = false;
- if (this.radioButton1.Checked)
- {
- this.groupBox5.Visible = true;
- this.groupBox6.Visible = false;
- }
- else if (this.radioButton2.Checked)
- {
- this.groupBox5.Visible = false;
- this.groupBox6.Visible = true;
- }
- this.button1.BackColor = Color.White;
- this.button1.ForeColor = Color.Black;
- this.button2.BackColor = Color.White;
- this.button2.ForeColor = Color.Black;
- this.button3.BackColor = Color.Black;
- this.button3.ForeColor = Color.White;
- this.button5.Enabled = false;
- this.button6.Enabled = true;
- this.button8.Visible = false;
- this.button9.Visible = false;
- this.button10.Visible = false;
- this.button11.Visible = true;
- break;
- }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button8_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 导入按钮选择
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton2_Check(object sender, EventArgs e)
- {
- clearData();
- }
- /// <summary>
- /// 导入按钮选择
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton1_Check(object sender, EventArgs e)
- {
- clearData();
- }
- /// <summary>
- /// 清理之前的数据
- /// </summary>
- private void clearData()
- {
- checkDataList.Clear();
- checkSecondData.Clear();
- importCheckDataList.Clear();
- importCheckSecondData.Clear();
- }
- /// <summary>
- /// 导入选择
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- if (!radioButton1.Checked) {
- MessageBox.Show(PdnResources.GetString("PleaseFelectFile") + "!");
- return;
- }
- OpenFileDialog dialog = new OpenFileDialog();
- dialog.Multiselect = false; //该值确定是否可以选择多个文件
- dialog.Filter = "压缩包(*.zip)|*.zip";
- if (dialog.ShowDialog() != DialogResult.OK)
- {
- return;
- }
- string file = dialog.FileName;
- this.textBox4.Text = file;
- this.textBox1.Text = file;
- if (!file.EndsWith(".zip")) {
- MessageBox.Show(PdnResources.GetString("PleaseSelectZip") + "!");
- return;
- }
- clearData();
- #region [将文件解压到中间文件]
- if (ZipHandleHelper.decompressionZip(file, unZipTemporaryFilePath))
- {
- List<string> allFileList = FileOperationHelper.GetAllDirectoryList(unZipTemporaryFilePath);
- #region [校验应勾选的树状信息]
- if (allFileList.Contains("CameraParam"))
- {
- this.importCheckDataList.Add("camera");
- }
- if (allFileList.Contains("Config"))
- {
- this.importCheckDataList.Add("generalSetting");
- }
- if (allFileList.Contains("Hotkey"))
- {
- this.importCheckDataList.Add("hotkey");
- }
- if (allFileList.Contains("Label"))
- {
- this.importCheckDataList.Add("label");
- }
- if (allFileList.Contains("Measure"))
- {
- this.importCheckDataList.Add("measure");
- }
- if (allFileList.Contains("ModuleManage"))
- {
- this.importCheckDataList.Add("reportModel");
- }
- if (allFileList.Contains("ParameterSaving"))
- {
- this.importCheckDataList.Add("parameter");
- }
- if (allFileList.Contains("Ruler"))
- {
- this.importCheckDataList.Add("ruler");
- }
- if (allFileList.Contains("Shortcutbar"))
- {
- this.importCheckDataList.Add("shortcutbar");
- }
- if (allFileList.Contains("Toolbar"))
- {
- this.importCheckDataList.Add("toolbar");
- string filePath = unZipTemporaryFilePath + "Toolbar\\Toolbar.xml";
- var importToolBar = XmlSerializeHelper.DESerializer<ToolbarModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- List<string> secondDataList = new List<string>();
- foreach (var item in importToolBar.Flows)
- {
- secondDataList.Add(item.Name);
- }
- importCheckSecondData.Add("toolbar", secondDataList);
- addTreeView(4,secondDataList);
- }
- if (allFileList.Contains("WorkFlow"))
- {
- this.importCheckDataList.Add("workFlow");
- string filePath = unZipTemporaryFilePath + "WorkFlow\\WorkFlow.xml";
- var importWorkFlow = XmlSerializeHelper.DESerializer<WorkFlowModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- List<string> secondDataList = new List<string>();
- foreach (var item in importWorkFlow.Flows)
- {
- secondDataList.Add(item.Name);
- }
- addTreeView(12, secondDataList);
- importCheckSecondData.Add("workFlow", secondDataList);
- }
- //脚本
- if (allFileList.Contains("ScriptStep"))
- {
- this.importCheckDataList.Add("scriptStep");
- string filePath = unZipTemporaryFilePath + "ScriptStep\\ScriptStep.xml";
- List<mic_script> importMicScriptList = XmlSerializeHelper.DESerializer<List<mic_script>>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- List<string> secondDataList = new List<string>();
- foreach (var item in importMicScriptList)
- {
- secondDataList.Add(item.name);
- }
- addTreeView(10, secondDataList);
- importCheckSecondData.Add("scriptStep", secondDataList);
- }
- #endregion
- }
- else {
- MessageBox.Show("解压文件失败,请稍后再试!");
- return;
- }
- #endregion
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="type"></param>
- /// <param name="secondDataList"></param>
- private void addTreeView(int type,List<string> secondDataList)
- {
- this.treeView1.Nodes[type - 1].Nodes.Clear();
- foreach (var item in secondDataList) {
- TreeNode node = new TreeNode();
- node.Text = item;
- node.Name = item;
- this.treeView1.Nodes[type - 1].Nodes.Add(node);
- }
- }
- /// <summary>
- /// 导出选择
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button7_Click(object sender, EventArgs e)
- {
- SaveFileDialog exe = new SaveFileDialog();
- exe.Filter = "Compressed Package(*.zip)|*.zip";
- exe.FilterIndex = 0;
- exe.RestoreDirectory = true;
- //exe.CreatePrompt = true;
- exe.Title = "Export Compressed Package";
- exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
- exe.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + "参数导出";
- DialogResult dr = exe.ShowDialog();
- if (dr != DialogResult.OK)
- {
- return;
- }
- this.textBox2.Text = exe.FileName;
- }
- /// <summary>
- /// 点击第一步
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- this.chooseStep = 1;
- InitializeUI();
- }
- /// <summary>
- /// 点击第二步
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- // 导出默认全部选中 导入则根据导入时拥有的情况来选择
- if (radioButton2.Checked)
- {
- AllChecked();
- }
- else if (radioButton1.Checked) {
- CancelAllChecked();
- if (string.IsNullOrEmpty(textBox4.Text))
- {
- MessageBox.Show(PdnResources.GetString("PleaseSelectZipFirst") + "!");
- return;
- }
- this.treeView1.AfterCheck -= new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
- foreach (TreeNode node in treeView1.Nodes) {
- switch (node.Name) {
- case "1":
- if (importCheckDataList.Contains("camera")) {
- node.Checked = true;
- }
- break;
- case "2":
- if (importCheckDataList.Contains("measure"))
- {
- node.Checked = true;
- }
- break;
- case "3":
- if (importCheckDataList.Contains("label"))
- {
- node.Checked = true;
- }
- break;
- case "4":
- if (importCheckDataList.Contains("toolbar"))
- {
- node.Checked = true;
- RecursiveNodeCheck(node, 4);
- }
- break;
- case "5":
- if (importCheckDataList.Contains("shortcutbar"))
- {
- node.Checked = true;
- }
- break;
- case "6":
- if (importCheckDataList.Contains("hotkey"))
- {
- node.Checked = true;
- }
- break;
- case "7":
- if (importCheckDataList.Contains("reportModel"))
- {
- node.Checked = true;
- }
- break;
- case "8":
- if (importCheckDataList.Contains("ruler"))
- {
- node.Checked = true;
- }
- break;
- case "9":
- if (importCheckDataList.Contains("parameter"))
- {
- node.Checked = true;
- }
- break;
- case "10":
- if (importCheckDataList.Contains("scriptStep"))
- {
- node.Checked = true;
- RecursiveNodeCheck(node, 10);
- }
- break;
- case "11":
- if (importCheckDataList.Contains("generalSetting"))
- {
- node.Checked = true;
- }
- break;
- case "12":
- if (importCheckDataList.Contains("workFlow"))
- {
- node.Checked = true;
- RecursiveNodeCheck(node, 12);
- }
- break;
- }
- }
- this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
- }
- this.chooseStep = 2;
- InitializeUI();
- }
- /// <summary>
- /// 点击第三步
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- //假如不按套路出牌 直接跳到第三步 模拟第二步点击
- if (this.chooseStep == 1)
- {
- button2_Click(sender, e);
- }
- foreach (TreeNode item in this.treeView1.Nodes)
- {
- if (!item.Checked) {
- continue;
- }
- switch (item.Name) {
- case "1":
- this.checkDataList.Add("camera");
- break;
- case "2":
- this.checkDataList.Add("measure");
- break;
- case "3":
- this.checkDataList.Add("label");
- break;
- case "4":
- this.checkDataList.Add("toolbar");
- break;
- case "5":
- this.checkDataList.Add("shortcutbar");
- break;
- case "6":
- this.checkDataList.Add("hotkey");
- break;
- case "7":
- this.checkDataList.Add("reportModel");
- break;
- case "8":
- this.checkDataList.Add("ruler");
- break;
- case "9":
- this.checkDataList.Add("parameter");
- break;
- case "10":
- this.checkDataList.Add("scriptStep");
- break;
- case "11":
- this.checkDataList.Add("generalSetting");
- break;
- case "12":
- this.checkDataList.Add("workFlow");
- break;
- }
- if (item.Nodes.Count > 0)
- {
- RecursiveDataCheck(item);
- }
- }
- this.chooseStep = 3;
- InitializeUI();
- }
- /// <summary>
- /// 递归将所需子集选中
- /// </summary>
- /// <param name="node"></param>
- private void RecursiveNodeCheck(TreeNode node,int type)
- {
- switch (type) {
- case 4:
- foreach (TreeNode treeNode in node.Nodes)
- {
- if (importCheckSecondData["toolbar"].Contains(treeNode.Text)) {
- treeNode.Checked = true;
- }
- }
- break;
- case 10:
- foreach (TreeNode treeNode in node.Nodes)
- {
- if (importCheckSecondData["scriptStep"].Contains(treeNode.Text))
- {
- treeNode.Checked = true;
- }
- }
- break;
- case 12:
- foreach (TreeNode treeNode in node.Nodes)
- {
- if (importCheckSecondData["workFlow"].Contains(treeNode.Text))
- {
- treeNode.Checked = true;
- }
- }
- break;
- }
- }
- /// <summary>
- /// 递归查询子集点击
- /// </summary>
- /// <param name="node"></param>
- private void RecursiveDataCheck(TreeNode node)
- {
- List<string> list = new List<string>();
- foreach (TreeNode item in node.Nodes)
- {
- if (!item.Checked) {
- continue;
- }
- list.Add(item.Text);
- }
- if (list.Count > 0)
- {
- if (checkSecondData.ContainsKey(node.Name))
- {
- checkSecondData[node.Name] = list;
- }
- else {
- checkSecondData.Add(node.Name, list);
- }
- }
- }
- /// <summary>
- /// 点击上一步
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button6_Click(object sender, EventArgs e)
- {
- switch (this.chooseStep)
- {
- case 1:
- break;
- case 2:
- button1.Focus();
- button1_Click(sender, e);
- break;
- case 3:
- button2.Focus();
- button2_Click(sender, e);
- break;
- }
- }
- /// <summary>
- /// 点击下一步
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button5_Click(object sender, EventArgs e)
- {
- switch (this.chooseStep)
- {
- case 1:
- button2.Focus();
- button2_Click(sender, e);
- break;
- case 2:
- button3.Focus();
- button3_Click(sender, e);
- break;
- case 3:
- break;
- }
- }
- /// <summary>
- /// 获取二级数据
- /// </summary>
- private void getSonData() {
- #region [工具栏]
- ToolbarModel toolbarModel = Startup.instance.toolbarModel;
- foreach (var item in toolbarModel.Flows)
- {
- ProjectData sonData = new ProjectData();
- sonData.ProjectID = Guid.NewGuid().ToString();
- sonData.ProjectName = item.Name;
- sonData.ProjectParentID = "4";
- sonData.isCheck = true;
- this.toolbarModelList.Add(sonData);
- }
- #endregion
- #region [工作流程]
- WorkFlowModel workFlowModel = Startup.instance.workFlowModel;
- foreach (var item in workFlowModel.Flows)
- {
- ProjectData sonData = new ProjectData();
- sonData.ProjectID = Guid.NewGuid().ToString();
- sonData.ProjectName = item.Name;
- sonData.ProjectParentID = "12";
- sonData.isCheck = true;
- this.workFlowModelList.Add(sonData);
- }
- #endregion
- #region [脚本]
- List<mic_script> list = mic_script_BLL.FindAll();
- foreach (var item in list)
- {
- ProjectData sonData = new ProjectData();
- sonData.ProjectID = Guid.NewGuid().ToString();
- sonData.ProjectName = item.name;
- sonData.ProjectParentID = "10";
- sonData.isCheck = true;
- this.stepModelList.Add(sonData);
- }
- #endregion
- }
- /// <summary>
- /// 读取树状图结构
- /// </summary>
- private void getTreeData()
- {
- string filePath = Application.StartupPath + "\\Config\\"+ Startup.instance.SettingPrefix + "\\ImportExportModel.xml";
- //文件不在 生成默认文件
- if (!File.Exists(filePath))
- {
- importExportModel = new ImportExportModel();
- #region [生成实体类结构]
- for (int i = 1; i <= 12; i++) {
- ProjectData data = new ProjectData();
- data.ProjectID = i.ToString();
- #region [分别处理]
- switch (i)
- {
- case 1:
- data.ProjectName = "预览属性";
- break;
- case 2:
- data.ProjectName = "测量属性";
- break;
- case 3:
- data.ProjectName = "标注属性";
- break;
- case 4:
- data.ProjectName = "工具栏";
- data.sonDataList = this.toolbarModelList;
- break;
- case 5:
- data.ProjectName = "快捷栏";
- break;
- case 6:
- data.ProjectName = "快捷键";
- break;
- case 7:
- data.ProjectName = "报告模板";
- break;
- case 8:
- data.ProjectName = "比例尺";
- break;
- case 9:
- data.ProjectName = "功能参数";
- break;
- case 10:
- data.ProjectName = "脚本信息";
- data.sonDataList = this.stepModelList;
- break;
- case 11:
- data.ProjectName = "常规设置";
- break;
- case 12:
- data.ProjectName = "工作流程";
- data.sonDataList = this.workFlowModelList;
- break;
- }
- #endregion
- importExportModel.AllProjectList.Add(data);
- }
- #endregion
- string importExportXml = XmlSerializeHelper.XmlSerialize(importExportModel);
- FileOperationHelper.WriteStringToFile(importExportXml, filePath, FileMode.Create);
- }
- else {
- importExportModel = XmlSerializeHelper.DESerializer<ImportExportModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- //替换最新的工具栏 工作流程 脚本
- foreach (var item in importExportModel.AllProjectList) {
- switch (item.ProjectID) {
- case "4":
- item.sonDataList = toolbarModelList;
- break;
- case "10":
- item.sonDataList = stepModelList;
- break;
- case "12":
- item.sonDataList = workFlowModelList;
- break;
- }
- }
- }
- }
- /// <summary>
- /// 组织树状图
- /// </summary>
- private void createTreeView() {
- foreach (var item in importExportModel.AllProjectList)
- {
- TreeNode treeNode = new TreeNode();
- treeNode.Text = item.ProjectName;
- treeNode.Name = item.ProjectID;
- #region [如果含有子集 开始递归搞起]
- if (item.sonDataList != null && item.sonDataList.Count > 0) {
- RecursiveDataView(treeNode, item);
- }
- #endregion
- treeNode.Expand();
- treeView1.Nodes.Add(treeNode);
- }
- }
- private void RecursiveDataView(TreeNode node, ProjectData data) {
- foreach (var item in data.sonDataList) {
- TreeNode treeNode = new TreeNode();
- treeNode.Text = item.ProjectName;
- treeNode.Name = item.ProjectID;
- if (item.sonDataList != null && item.sonDataList.Count > 0)
- {
- RecursiveDataView(treeNode, item);
- }
- node.Nodes.Add(treeNode);
- }
- }
- /// <summary>
- /// 全选
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button9_Click(object sender, EventArgs e)
- {
- this.treeView1.AfterCheck -= new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
- AllChecked();
- this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
- }
- /// <summary>
- /// 全不选
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button10_Click(object sender, EventArgs e)
- {
- this.treeView1.AfterCheck -= new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
- CancelAllChecked();
- this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
- }
- /// <summary>
- /// 节点选中
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void treeViewChecked(object sender, TreeViewEventArgs e)
- {
- this.treeView1.AfterCheck -= new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
- CheckParentNode(e.Node);
- if (e.Node.Nodes.Count > 0)
- {
- CheckAllChildNodes(e.Node, e.Node.Checked);
- }
- this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewChecked);
- }
- #region [节点选中相关方法]
- /// <summary>
- /// 全选
- /// </summary>
- private void AllChecked()
- {
- foreach (TreeNode e in this.treeView1.Nodes) {
- e.Checked = true;
- if (e.Nodes.Count > 0)
- {
- CheckAllChildNodes(e, true);
- }
- }
- }
- /// <summary>
- /// 取消全选
- /// </summary>
- private void CancelAllChecked()
- {
- foreach (TreeNode e in this.treeView1.Nodes)
- {
- e.Checked = false;
- if (e.Nodes.Count > 0)
- {
- CheckAllChildNodes(e, false);
- }
- }
- }
- /// <summary>
- /// 改变所有子节点的状态
- /// </summary>
- /// <param name="pn"></param>
- /// <param name="IsChecked"></param>
- private void CheckAllChildNodes(TreeNode pn, bool IsChecked)
- {
- foreach (TreeNode tn in pn.Nodes)
- {
- tn.Checked = IsChecked;
- if (tn.Nodes.Count > 0)
- {
- CheckAllChildNodes(tn, IsChecked);
- }
- }
- }
- /// <summary>
- /// 改变父节点的选中状态,此处为所有子节点不选中时才取消父节点选中,可以根据需要修改
- /// </summary>
- /// <param name="curNode"></param>
- private void CheckParentNode(TreeNode curNode)
- {
- bool bChecked = false;
- if (curNode.Parent != null)
- {
- foreach (TreeNode node in curNode.Parent.Nodes)
- {
- if (node.Checked)
- {
- bChecked = true;
- break;
- }
- }
- if (bChecked)
- {
- curNode.Parent.Checked = true;
- CheckParentNode(curNode.Parent);
- }
- else
- {
- curNode.Parent.Checked = false;
- CheckParentNode(curNode.Parent);
- }
- }
- }
- #endregion
- /// <summary>
- /// 完成
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button11_Click(object sender, EventArgs e)
- {
- if (radioButton1.Checked)
- {
- #region [开始导入]
- ProgressThreadProcClass procClass = new ProgressThreadProcClass();
- int itemCount = 100;
- ProgressThreadProcClass.IFileTransferProgressEvents progressEvents = new ProgressThreadProcClass.IFileTransferProgressEvents();
- System.Threading.ThreadStart copyThreadProc =
- delegate ()
- {
- try
- {
- foreach (var item in originalPathDict)
- {
- 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"))
- {
- continue;
- }
- FileOperationHelper.CopyDirectory(importPathDict[item.Key], item.Value, true);
- }
- #region [快捷键特殊处理下]
- if (checkDataList.Contains("hotkey"))
- {
- string toolBarPath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\";
- string importBarPath = importPathDict["hotkey"] + "Hotkey.xml";
- FileOperationHelper.CopyDirectory(importBarPath, toolBarPath, true);
- }
- #endregion
- #region [常规设置特殊处理下]
- if (checkDataList.Contains("generalSetting"))
- {
- string toolBarPath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\";
- string importBarPath = importPathDict["generalSetting"] + "Config.xml";
- FileOperationHelper.CopyDirectory(importBarPath, toolBarPath, true);
- }
- #endregion
- #region [测量特殊处理下]
- if (checkDataList.Contains("measure"))
- {
- string toolBarPath = originalPathDict["generalSetting"];
- string importSettingPath = importPathDict["measure"] + "Config.xml";
- var importNowSetting = XmlSerializeHelper.DESerializer<ConfigModel>(FileOperationHelper.ReadStringFromFile(importSettingPath, FileMode.Open));
- Startup.instance.configModel.MarkpointWidth = importNowSetting.MarkpointWidth;
- string toolXml = XmlSerializeHelper.XmlSerialize(Startup.instance.configModel);
- FileOperationHelper.WriteStringToFile(toolXml, toolBarPath, FileMode.Create);
- FileOperationHelper.DeleteFolder(originalPathDict["measure"] + "Config.xml");
- }
- #endregion
- #region [脚本信息特殊处理下]
- if (checkDataList.Contains("scriptStep")) {
- string filePath = unZipTemporaryFilePath + "ScriptStep\\ScriptStep.xml";
- List<mic_script> importMicScriptList = XmlSerializeHelper.DESerializer<List<mic_script>>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- List<string> needImportDataList = new List<string>();
- if (checkSecondData.ContainsKey("10"))
- {
- needImportDataList = checkSecondData["10"];
- }
- #region [如果覆盖 则清除数据]
- if (checkBox1.Checked)
- {
- List<mic_script> mainList = mic_script_BLL.FindAll();
- List<mic_script_step> secondList = mic_script_step_BLL.FindAll();
- List<mic_script_step_param> thirdList = mic_script_step_param_BLL.FindAll();
- foreach (var item in mainList)
- {
- mic_script_BLL.Del(item.id);
- }
- foreach (var item in secondList)
- {
- mic_script_step_BLL.Del(item.id);
- }
- foreach (var item in thirdList)
- {
- mic_script_step_param_BLL.Del(item.id);
- }
- }
- #endregion
- foreach (var item in importMicScriptList)
- {
- if (!needImportDataList.Contains(item.name)) {
- continue;
- }
- mic_script script = new mic_script();
- script.name = item.name;
- mic_script_BLL.Add(script);
- foreach (var s in item.sonList) {
- mic_script_step mic_Script_Step = new mic_script_step();
- mic_Script_Step.automatic = s.automatic;
- mic_Script_Step.menu_id = s.menu_id;
- mic_Script_Step.script_id = script.id;
- mic_Script_Step.step_name = s.step_name;
- mic_Script_Step.step_sort = s.step_sort;
- mic_script_step_BLL.Add(mic_Script_Step);
- foreach (var m in s.sonList) {
- mic_script_step_param param = new mic_script_step_param();
- param.param_key = m.param_key;
- param.param_type = m.param_type;
- param.param_value = m.param_value;
- param.script_id = script.id;
- param.step_id = mic_Script_Step.script_id;
- param.value = m.value;
- mic_script_step_param_BLL.Add(param);
- }
- }
- }
- }
- #endregion
- #region [快捷栏特殊处理下]
- if (checkDataList.Contains("shortcutbar"))
- {
- string toolBarPath = originalPathDict["shortcutbar"];
- var nowToolBar = XmlSerializeHelper.DESerializer<ShortcutbarModel>(FileOperationHelper.ReadStringFromFile(toolBarPath, FileMode.Open));
- string importBarPath = importPathDict["shortcutbar"] + "Shortcutbar.xml";
- var importToolBar = XmlSerializeHelper.DESerializer<ShortcutbarModel>(FileOperationHelper.ReadStringFromFile(importBarPath, FileMode.Open));
- if (checkBox1.Checked)
- {
- nowToolBar = importToolBar;
- }
- else
- {
- foreach (var item in importToolBar.Menus)
- {
- nowToolBar.Menus.Add(item);
- }
- }
- Startup.instance.shortcutbarModel = nowToolBar;
- string toolXml = XmlSerializeHelper.XmlSerialize(nowToolBar);
- FileOperationHelper.WriteStringToFile(toolXml, toolBarPath, FileMode.Create);
- }
- #endregion
- #region [标尺特殊处理下]
- if (checkDataList.Contains("ruler"))
- {
- string filePath = unZipTemporaryFilePath + "Ruler\\Ruler.xml";
- List<mic_rulers> importRulerList = XmlSerializeHelper.DESerializer<List<mic_rulers>>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- List<mic_rulers> allRulerList = mic_rulers_BLL.FindAll();
- if (checkBox1.Checked) {
- foreach (var item in allRulerList) {
- mic_rulers_BLL.Del(item.id);
- }
- }
- foreach (var item in importRulerList)
- {
- mic_rulers rulers = new mic_rulers();
- rulers.gain_multiple = item.gain_multiple;
- rulers.microscope = item.objective_lens;
- rulers.physical_length = item.physical_length;
- rulers.objective_lens = item.objective_lens;
- rulers.pixel_length = item.pixel_length;
- rulers.ruler_camera = item.ruler_camera;
- rulers.ruler_connector = item.ruler_connector;
- rulers.ruler_eyepiece = item.ruler_eyepiece;
- rulers.ruler_height = item.ruler_height;
- rulers.ruler_name = item.ruler_name;
- rulers.ruler_type = item.ruler_type;
- rulers.ruler_units = item.ruler_units;
- rulers.ruler_width = item.ruler_width;
- rulers.ruler_zoom = item.ruler_zoom;
- mic_rulers_BLL.Add(rulers);
- }
- }
- #endregion
- #region [工具栏特殊处理下]
- if (checkDataList.Contains("toolbar")) {
- string toolBarPath = originalPathDict["toolbar"];
- var nowToolBar = XmlSerializeHelper.DESerializer<ToolbarModel>(FileOperationHelper.ReadStringFromFile(toolBarPath, FileMode.Open));
- string importBarPath = importPathDict["toolbar"] + "Toolbar.xml";
- var importToolBar = XmlSerializeHelper.DESerializer<ToolbarModel>(FileOperationHelper.ReadStringFromFile(importBarPath, FileMode.Open));
- #region [如果覆盖 则清除数据]
- List<ToolbarModel.Flow> list = new List<ToolbarModel.Flow>();
- foreach (var item in importToolBar.Flows)
- {
- if (checkSecondData["4"].Contains(item.Name))
- {
- continue;
- }
- list.Add(item);
- }
- foreach (var item in list)
- {
- importToolBar.Flows.Remove(item);
- }
- if (checkBox1.Checked)
- {
- nowToolBar = importToolBar;
- }
- else {
- foreach (var item in importToolBar.Flows)
- {
- nowToolBar.Flows.Add(item);
- }
- }
- #endregion
- Startup.instance.toolbarModel = nowToolBar;
- string toolXml = XmlSerializeHelper.XmlSerialize(nowToolBar);
- FileOperationHelper.WriteStringToFile(toolXml, toolBarPath, FileMode.Create);
- }
- #endregion
- #region [工作流程特殊处理下]
- if (checkDataList.Contains("workFlow"))
- {
- string filePath = originalPathDict["workFlow"];
- var workFlowModel = XmlSerializeHelper.DESerializer<WorkFlowModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- string importWorkFlowPath = importPathDict["workFlow"] + "WorkFlow.xml";
- var importWorkFlow = XmlSerializeHelper.DESerializer<WorkFlowModel>(FileOperationHelper.ReadStringFromFile(importWorkFlowPath, FileMode.Open));
- #region [[如果覆盖 则清除数据]
- List<WorkFlowModel.Flow> list = new List<WorkFlowModel.Flow>();
- foreach (var item in importWorkFlow.Flows)
- {
- if (checkSecondData["12"].Contains(item.Name))
- {
- continue;
- }
- list.Add(item);
- }
- foreach (var item in list)
- {
- importWorkFlow.Flows.Remove(item);
- }
- if (checkBox1.Checked)
- {
- workFlowModel = importWorkFlow;
- }
- else {
- foreach (var item in importWorkFlow.Flows)
- {
- workFlowModel.Flows.Add(item);
- }
- }
- #endregion
- string workFlowModelXml = XmlSerializeHelper.XmlSerialize(workFlowModel);
- FileOperationHelper.WriteStringToFile(workFlowModelXml, filePath, FileMode.Create);
- }
- #endregion
- if (checkDataList.Contains("parameter"))
- {
- //晶粒度单独处理下
- string GrainSizePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\";
- FileOperationHelper.CopyDirectory(importPathDict["parameter"] + "\\GrainSizeAnalysisModel.xml", GrainSizePath, true);
- }
- if (checkDataList.Contains("generalSetting"))
- {
- //常规设置需要单独处理下
- string userInfoFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\";
- FileOperationHelper.CopyDirectory(importPathDict["generalSetting"] + "\\UserInfo.xml", userInfoFilePath, true);
- string setUpFilePath = Application.StartupPath + @"\Config\" + Startup.instance.SettingPrefix + @"\SetUp\";
- FileOperationHelper.CopyDirectory(importPathDict["generalSetting"] + "\\GuideStyle.xml", setUpFilePath, true);
- }
- }
- catch (Exception ex)
- {
- }
- finally
- {
- progressEvents.EndOperation(OperationResult.Finished);
- }
- };
- procClass.StartProgressAction(this, itemCount, copyThreadProc, progressEvents, null);
- MessageBox.Show(PdnResources.GetString("ImportSuccessful") + "!");
- #endregion
- }
- else if (radioButton2.Checked) {
- #region [开始导出]
- if (string.IsNullOrEmpty(textBox2.Text))
- {
- MessageBox.Show("请先选择要导出文件的路径!");
- return;
- }
- ProgressThreadProcClass procClass = new ProgressThreadProcClass();
- int itemCount = 100;
- ProgressThreadProcClass.IFileTransferProgressEvents progressEvents = new ProgressThreadProcClass.IFileTransferProgressEvents();
- System.Threading.ThreadStart copyThreadProc =
- delegate ()
- {
- try
- {
- string choosePath = this.textBox2.Text;
- foreach (var item in originalPathDict)
- {
- if (!checkDataList.Contains(item.Key))
- {
- continue;
- }
- FileOperationHelper.CopyDirectory(item.Value, newPathDict[item.Key], false);
- }
- #region [脚本信息特殊处理]
- if (checkDataList.Contains("scriptStep"))
- {
- List<mic_script> mainList = mic_script_BLL.FindAll();
- List<mic_script_step> secondList = mic_script_step_BLL.FindAll();
- List<mic_script_step_param> thirdList = mic_script_step_param_BLL.FindAll();
- if (checkSecondData.ContainsKey("10")) {
- List<string> hasDataList = checkSecondData["10"];
- List<mic_script> shouldExportDataList = new List<mic_script>();
- foreach (var item in mainList)
- {
- if (!hasDataList.Contains(item.name)) {
- continue;
- }
- var mic = item;
- mic.sonList = secondList.Where(m => m.script_id == mic.id).ToList();
- foreach (var s in mic.sonList) {
- s.sonList = thirdList.Where(m => m.script_id == mic.id && m.step_id == s.id).ToList();
- }
- shouldExportDataList.Add(mic);
- }
- string scriptExportXml = XmlSerializeHelper.XmlSerialize(shouldExportDataList);
- FileOperationHelper.WriteStringToFile(scriptExportXml, newPathDict["scriptStep"] + "ScriptStep.xml", FileMode.Create);
- }
- }
- #endregion
- #region [标尺信息特殊处理]
- if (checkDataList.Contains("ruler"))
- {
- List<mic_rulers> mainList = mic_rulers_BLL.FindAll();
- string scriptExportXml = XmlSerializeHelper.XmlSerialize(mainList);
- FileOperationHelper.WriteStringToFile(scriptExportXml, newPathDict["ruler"] + "Ruler.xml", FileMode.Create);
- }
- #endregion
- #region [获取二级数据]
- if (checkSecondData.ContainsKey("4"))
- {
- var toolbarModel = XmlSerializeHelper.DESerializer<ToolbarModel>(FileOperationHelper.ReadStringFromFile(newPathDict["toolbar"] + "\\Toolbar.xml", FileMode.Open));
- List<ToolbarModel.Flow> list = new List<ToolbarModel.Flow>();
- foreach (var item in toolbarModel.Flows)
- {
- if (checkSecondData["4"].Contains(item.Name))
- {
- continue;
- }
- list.Add(item);
- }
- foreach (var item in list)
- {
- toolbarModel.Flows.Remove(item);
- }
- string toolbarModelXml = XmlSerializeHelper.XmlSerialize(toolbarModel);
- FileOperationHelper.WriteStringToFile(toolbarModelXml, newPathDict["toolbar"] + "\\Toolbar.xml", FileMode.Create);
- }
- if (checkSecondData.ContainsKey("12"))
- {
- var workFlowModel = XmlSerializeHelper.DESerializer<WorkFlowModel>(FileOperationHelper.ReadStringFromFile(newPathDict["workFlow"] + "\\WorkFlow.xml", FileMode.Open));
- List<WorkFlowModel.Flow> list = new List<WorkFlowModel.Flow>();
- foreach (var item in workFlowModel.Flows)
- {
- if (checkSecondData["12"].Contains(item.Name))
- {
- continue;
- }
- list.Add(item);
- }
- foreach (var item in list)
- {
- workFlowModel.Flows.Remove(item);
- }
- string workFlowModelXml = XmlSerializeHelper.XmlSerialize(workFlowModel);
- FileOperationHelper.WriteStringToFile(workFlowModelXml, newPathDict["workFlow"] + "\\WorkFlow.xml", FileMode.Create);
- }
- #endregion
- if (checkDataList.Contains("measure"))
- {
- //测量标记点单独处理下
- string pointPath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml";
- FileOperationHelper.CopyDirectory(pointPath, newPathDict["measure"], false);
- }
- if (checkDataList.Contains("parameter"))
- {
- //晶粒度单独处理下
- string GrainSizePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
- FileOperationHelper.CopyDirectory(GrainSizePath, newPathDict["parameter"], true);
- }
- if (checkDataList.Contains("generalSetting"))
- {
- //常规设置需要单独处理下
- string userInfoFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\UserInfo.xml";
- FileOperationHelper.CopyDirectory(userInfoFilePath, newPathDict["generalSetting"], true);
- string setUpFilePath = Application.StartupPath + @"\Config\" + Startup.instance.SettingPrefix + @"\SetUp\GuideStyle.xml";
- FileOperationHelper.CopyDirectory(setUpFilePath, newPathDict["generalSetting"], true);
- }
- ZipHandleHelper.createZip(temporaryFilePath, choosePath);
- }
- catch (Exception)
- {
- }
- finally
- {
- progressEvents.EndOperation(OperationResult.Finished);
- }
- };
- procClass.StartProgressAction(this, itemCount, copyThreadProc, progressEvents, null);
- MessageBox.Show("导出成功!");
- #endregion
- }
- this.Close();
- }
- /// <summary>
- /// 生成默认的中间数据文件夹
- /// </summary>
- private void createDefaultDirectory() {
- //生成一个临时文件夹 用于存放各种xml
- //先删除之前的
- FileOperationHelper.DeleteFolder(unZipTemporaryFilePath);
- FileOperationHelper.DeleteFolder(temporaryFilePath);
- //生成新的
- Directory.CreateDirectory(temporaryFilePath);
- #region [相机设置]
- string cameraFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\CameraParam\\";
- string temporaryCameraFilePath = $"{temporaryFilePath}\\CameraParam\\";
- Directory.CreateDirectory(temporaryCameraFilePath);
- originalPathDict.Add("camera", cameraFilePath);
- newPathDict.Add("camera", temporaryCameraFilePath);
- string importTemporaryCameraFilePath = $"{unZipTemporaryFilePath}\\CameraParam\\";
- importPathDict.Add("camera", importTemporaryCameraFilePath);
- #endregion
- #region [测量参数]
- string measure = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Measure\\";
- string temporaryMeasureFilePath = $"{temporaryFilePath}\\Measure\\";
- Directory.CreateDirectory(temporaryMeasureFilePath);
- originalPathDict.Add("measure", measure);
- newPathDict.Add("measure", temporaryMeasureFilePath);
- string importTemporaryMeasureFilePath = $"{unZipTemporaryFilePath}\\Measure\\";
- importPathDict.Add("measure", importTemporaryMeasureFilePath);
- #endregion
- #region [标注参数]
- string label = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Label\\";
- string temporaryLabelFilePath = $"{temporaryFilePath}\\Label\\";
- Directory.CreateDirectory(temporaryLabelFilePath);
- originalPathDict.Add("label", label);
- newPathDict.Add("label", temporaryLabelFilePath);
- string importTemporaryLabelFilePath = $"{unZipTemporaryFilePath}\\Label\\";
- importPathDict.Add("label", importTemporaryLabelFilePath);
- #endregion
- #region [工具栏]
- string toolbar = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Toolbar.xml";
- string temporaryToolbarFilePath = $"{temporaryFilePath}\\Toolbar\\";
- Directory.CreateDirectory(temporaryToolbarFilePath);
- originalPathDict.Add("toolbar", toolbar);
- newPathDict.Add("toolbar", temporaryToolbarFilePath);
- string importTemporaryToolbarFilePath = $"{unZipTemporaryFilePath}\\Toolbar\\";
- importPathDict.Add("toolbar", importTemporaryToolbarFilePath);
- #endregion
- #region [快捷栏]
- string shortcutbar = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Shortcutbar.xml";
- string temporaryShortcutbarFilePath = $"{temporaryFilePath}\\Shortcutbar\\";
- Directory.CreateDirectory(temporaryShortcutbarFilePath);
- originalPathDict.Add("shortcutbar", shortcutbar);
- newPathDict.Add("shortcutbar", temporaryShortcutbarFilePath);
- string importTemporaryShortcutbarFilePath = $"{unZipTemporaryFilePath}\\Shortcutbar\\";
- importPathDict.Add("shortcutbar", importTemporaryShortcutbarFilePath);
- #endregion
- #region [快捷键]
- string hotkey = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Hotkey.xml";
- string temporaryHotkeyFilePath = $"{temporaryFilePath}\\Hotkey\\";
- Directory.CreateDirectory(temporaryHotkeyFilePath);
- originalPathDict.Add("hotkey", hotkey);
- newPathDict.Add("hotkey", temporaryHotkeyFilePath);
- string importTemporaryHotkeyFilePath = $"{unZipTemporaryFilePath}\\Hotkey\\";
- importPathDict.Add("hotkey", importTemporaryHotkeyFilePath);
- #endregion
- #region [报告模板]
- string reportModel = Application.StartupPath + "\\ModuleManage\\";
- string temporaryReportModelPath = $"{temporaryFilePath}\\ModuleManage\\";
- Directory.CreateDirectory(temporaryReportModelPath);
- originalPathDict.Add("reportModel", reportModel);
- newPathDict.Add("reportModel", temporaryReportModelPath);
- string importTemporaryReportModelPath = $"{unZipTemporaryFilePath}\\ModuleManage\\";
- importPathDict.Add("reportModel", importTemporaryReportModelPath);
- #endregion
- #region [比例尺]
- string temporaryRulerFilePath = $"{temporaryFilePath}\\Ruler\\";
- Directory.CreateDirectory(temporaryRulerFilePath);
- newPathDict.Add("ruler", temporaryRulerFilePath);
- string importTemporaryRulerFilePath = $"{unZipTemporaryFilePath}\\Ruler\\";
- importPathDict.Add("ruler", importTemporaryRulerFilePath);
- #endregion
- #region [功能参数]
- string parameter = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\ParameterSaving\\";
- string temporaryParameterFilePath = $"{temporaryFilePath}\\ParameterSaving\\";
- Directory.CreateDirectory(temporaryParameterFilePath);
- originalPathDict.Add("parameter", parameter);
- newPathDict.Add("parameter", temporaryParameterFilePath);
- string importTemporaryParameterFilePath = $"{unZipTemporaryFilePath}\\ParameterSaving\\";
- importPathDict.Add("parameter", importTemporaryParameterFilePath);
- #endregion
- #region [脚本信息]
- string temporaryScriptStepPath = $"{temporaryFilePath}\\ScriptStep\\";
- Directory.CreateDirectory(temporaryScriptStepPath);
- newPathDict.Add("scriptStep", temporaryScriptStepPath);
- string importTemporaryScriptStepPath = $"{temporaryScriptStepPath}\\ScriptStep\\";
- importPathDict.Add("scriptStep", importTemporaryScriptStepPath);
- #endregion
- #region [常规设置]
- string generalSetting = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml";
- string temporaryGeneralSettingPath = $"{temporaryFilePath}\\Config\\";
- Directory.CreateDirectory(temporaryGeneralSettingPath);
- originalPathDict.Add("generalSetting", generalSetting);
- newPathDict.Add("generalSetting", temporaryGeneralSettingPath);
- string importTemporaryGeneralSettingPath = $"{unZipTemporaryFilePath}\\Config\\";
- importPathDict.Add("generalSetting", importTemporaryGeneralSettingPath);
- #endregion
- #region [工作流程]
- string workFlow = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkFlow.xml";
- string temporaryWorkFlowPath = $"{temporaryFilePath}\\WorkFlow\\";
- Directory.CreateDirectory(temporaryWorkFlowPath);
- originalPathDict.Add("workFlow", workFlow);
- newPathDict.Add("workFlow", temporaryWorkFlowPath);
- string importTemporaryWorkFlowPath = $"{unZipTemporaryFilePath}\\WorkFlow\\";
- importPathDict.Add("workFlow", importTemporaryWorkFlowPath);
- #endregion
- }
- }
- }
|