123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005 |
- using Resources;
- using SmartCoalApplication.Base;
- using SmartCoalApplication.Base.CommTool;
- using SmartCoalApplication.Base.MeasureModel;
- using SmartCoalApplication.Core;
- using SmartCoalApplication.PluginAssemblys;
- 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 SmartCoalApplication.MeasureProcedure
- {
- internal partial class MeasureProcedureImport : PdnBaseForm
- {
- #region [组件]
- 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 GroupBox groupBox6;
- private TextBox textBox2;
- private Label label2;
- private Button button7;
- private Button button1;
- private Button button10;
- private Button button9;
- private Button button11;
- #endregion
- private AppWorkspace appWorkspace;
- /// <summary>
- /// 测试规程树状图
- /// </summary>
- private SmartCoalApplication.Core.CustomControl.TreeViewEnhanced treeView1;
- /// <summary>
- /// 选择的步
- /// </summary>
- private int chooseStep = 1;
- private MeasureMaintenanceTypeList measureMaintenanceTypeList;
- private MeasureMaintenanceTypeList importMeasureMaintenanceTypeList;
- /// <summary>
- /// 压缩中间数据目录
- /// </summary>
- private string temporaryFilePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MidData\\Temp\\";
- /// <summary>
- /// 解压中间数据目录
- /// </summary>
- private string unZipTemporaryFilePath = Application.StartupPath + "\\Config\\MidData" + Program.instance.SettingPrefix + "\\UnZipTemp\\";
- /// <summary>
- /// 测试规程文件路径
- /// </summary>
- private string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MeasureMaintenanceTypeList.xml";
- /// <summary>
- /// 测试规程检验项目文件路径
- /// </summary>
- private string rulerFilePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MeasureMaintenanceType\\";
- public MeasureProcedureImport(AppWorkspace appWorkspace)
- {
- InitializeComponent();
- InitializeLanguageText();
- this.appWorkspace = appWorkspace;
- #region [获取测试规程]
- if (!System.IO.File.Exists(filePath))
- {
- measureMaintenanceTypeList = new MeasureMaintenanceTypeList();
- measureMaintenanceTypeList.measureMaintenanceTypeList = new List<MeasureMaintenanceType>();
- }
- else
- {
- measureMaintenanceTypeList = XmlSerializeHelper.DESerializer<MeasureMaintenanceTypeList>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- }
- #endregion
- #region [组织树状图]
- this.treeView1.CheckBoxes = true;
- this.treeView1.ItemHeight = 18;
- this.createTreeView();
- this.button1_Click(null, null);
- #endregion
- #region [生成中间文件夹]
- this.createDefaultDirectory();
- #endregion
- }
- #region [初始化]
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- 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.groupBox5 = new System.Windows.Forms.GroupBox();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- 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.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.groupBox4 = new System.Windows.Forms.GroupBox();
- this.treeView1 = new SmartCoalApplication.Core.CustomControl.TreeViewEnhanced();
- 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.SuspendLayout();
- this.groupBox5.SuspendLayout();
- this.groupBox1.SuspendLayout();
- this.groupBox6.SuspendLayout();
- this.groupBox4.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.SuspendLayout();
- //
- // 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, 67);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(604, 409);
- this.groupBox3.TabIndex = 19;
- 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;
- //
- // 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_CheckedChanged);
- //
- // groupBox5
- //
- this.groupBox5.Controls.Add(this.textBox1);
- this.groupBox5.Controls.Add(this.label1);
- this.groupBox5.Location = new System.Drawing.Point(133, 78);
- this.groupBox5.Name = "groupBox5";
- this.groupBox5.Size = new System.Drawing.Size(604, 398);
- this.groupBox5.TabIndex = 21;
- this.groupBox5.TabStop = false;
- this.groupBox5.Text = "设置";
- //
- // 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 = "从......导入";
- //
- // 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, 2);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(115, 474);
- this.groupBox1.TabIndex = 17;
- 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, 412);
- 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, 441);
- 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);
- //
- // 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, 78);
- this.groupBox6.Name = "groupBox6";
- this.groupBox6.Size = new System.Drawing.Size(604, 379);
- this.groupBox6.TabIndex = 22;
- 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 = "选择配置文件存放位置";
- //
- // groupBox4
- //
- this.groupBox4.Controls.Add(this.treeView1);
- this.groupBox4.Location = new System.Drawing.Point(133, 78);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(604, 379);
- this.groupBox4.TabIndex = 20;
- 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.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick);
- //
- // 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, 2);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(604, 58);
- this.groupBox2.TabIndex = 18;
- 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 EventHandler(button8_Click);
- //
- // MeasureProcedureImport
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(742, 478);
- 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 = "MeasureProcedureImport";
- 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.groupBox3.ResumeLayout(false);
- this.groupBox3.PerformLayout();
- this.groupBox5.ResumeLayout(false);
- this.groupBox5.PerformLayout();
- this.groupBox1.ResumeLayout(false);
- this.groupBox6.ResumeLayout(false);
- this.groupBox6.PerformLayout();
- this.groupBox4.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- this.ResumeLayout(false);
- }
-
- /// <summary>
- /// 语言包
- /// </summary>
- 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.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");
- this.button7.Text = PdnResources.GetString("Menu.LabelAction.LabelSelect.Text");
- }
- /// <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>
- private void createTreeView()
- {
- this.treeView1.Nodes.Clear();
- foreach (var item in measureMaintenanceTypeList.measureMaintenanceTypeList)
- {
- TreeNode treeNode = new TreeNode();
- treeNode.Text = item.measureMaintenanceName;
- treeNode.Name = item.measureMaintenanceTypeId;
- treeNode.Expand();
- treeView1.Nodes.Add(treeNode);
- }
- }
- #endregion
- /// <summary>
- /// 点击文字选中
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- e.Node.Checked = true;
- }
- /// <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 (radioButton1.Checked)
- {
- if (string.IsNullOrEmpty(textBox4.Text))
- {
- MessageBox.Show(PdnResources.GetString("SelectFileFirst") + "!");
- return;
- }
- }
- AllChecked();
- this.chooseStep = 2;
- InitializeUI();
- }
- /// <summary>
- /// 点击第三步
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- if (radioButton1.Checked)
- {
- if (string.IsNullOrEmpty(textBox4.Text))
- {
- MessageBox.Show(PdnResources.GetString("SelectFileFirst") + "!");
- return;
- }
- }
- //假如不按套路出牌 直接跳到第三步 模拟第二步点击
- if (this.chooseStep == 1)
- {
- button2_Click(sender, e);
- }
- this.chooseStep = 3;
- InitializeUI();
- }
- /// <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 button9_Click(object sender, EventArgs e)
- {
- AllChecked();
- }
- /// <summary>
- /// 全不选
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button10_Click(object sender, EventArgs e)
- {
- CancelAllChecked();
- }
- #region [节点选中相关方法]
- /// <summary>
- /// 全选
- /// </summary>
- private void AllChecked()
- {
- foreach (TreeNode e in this.treeView1.Nodes)
- {
- e.Checked = true;
- }
- }
- /// <summary>
- /// 取消全选
- /// </summary>
- private void CancelAllChecked()
- {
- foreach (TreeNode e in this.treeView1.Nodes)
- {
- e.Checked = false;
- }
- }
- #endregion
- /// <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 createDefaultDirectory()
- {
- //生成一个临时文件夹 用于存放各种xml
- //先删除之前的
- FileOperationHelper.DeleteFolder(unZipTemporaryFilePath);
- FileOperationHelper.DeleteFolder(temporaryFilePath);
- //生成新的
- Directory.CreateDirectory(temporaryFilePath);
- System.IO.Directory.CreateDirectory(temporaryFilePath + "\\ruleFile");
- ////复制测试规程总文件
- //FileOperationHelper.CopyDirectory(this.filePath, temporaryFilePath, false);
- //FileOperationHelper.CopyDirectory(this.rulerFilePath, temporaryFilePath + "\\ruleFile\\", false);
- }
- /// <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;
- }
- #region [将文件解压到中间文件]
- if (ZipHandleHelper.decompressionZip(file, unZipTemporaryFilePath))
- {
- this.importMeasureMaintenanceTypeList = XmlSerializeHelper.DESerializer<MeasureMaintenanceTypeList>(FileOperationHelper.ReadStringFromFile(unZipTemporaryFilePath + "\\ruleFile\\MeasureMaintenanceTypeList.xml", FileMode.Open));
- this.treeView1.Nodes.Clear();
- foreach (var item in this.importMeasureMaintenanceTypeList.measureMaintenanceTypeList)
- {
- TreeNode treeNode = new TreeNode();
- treeNode.Text = item.measureMaintenanceName;
- treeNode.Name = item.measureMaintenanceTypeId;
- treeNode.Expand();
- treeView1.Nodes.Add(treeNode);
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("zipFail") + "!");
- return;
- }
- #endregion
- }
- /// <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 button11_Click(object sender, EventArgs e)
- {
- List<string> checkList = new List<string>();
- foreach (TreeNode item in this.treeView1.Nodes)
- {
- if (!item.Checked)
- {
- continue;
- }
- checkList.Add(item.Name);
- }
- 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 checkList)
- {
- var realMeasureMaintenanceTypeList = this.importMeasureMaintenanceTypeList.measureMaintenanceTypeList.Where(m => m.measureMaintenanceTypeId.Equals(item)).FirstOrDefault();
- if (realMeasureMaintenanceTypeList == null)
- {
- continue;
- }
- var hadMeasureMaintenanceTypeList = this.measureMaintenanceTypeList.measureMaintenanceTypeList.Where(m => m.measureMaintenanceName.Equals(realMeasureMaintenanceTypeList.measureMaintenanceName)).FirstOrDefault();
- if (hadMeasureMaintenanceTypeList != null)
- {
- string fileName = RecursionData(realMeasureMaintenanceTypeList.measureMaintenanceName);
- FileOperationHelper.reNameFile(unZipTemporaryFilePath + "ruleFile\\" + realMeasureMaintenanceTypeList.measureMaintenanceName + ".xml", unZipTemporaryFilePath + "\\ruleFile\\" + fileName + ".xml");
- FileOperationHelper.CopyDirectory(unZipTemporaryFilePath + "ruleFile\\" + fileName + ".xml", rulerFilePath, false);
- realMeasureMaintenanceTypeList.measureMaintenanceName = fileName;
- }
- else {
- FileOperationHelper.CopyDirectory(unZipTemporaryFilePath + "\\ruleFile\\" + realMeasureMaintenanceTypeList.measureMaintenanceName + ".xml", rulerFilePath, false);
- }
- this.measureMaintenanceTypeList.measureMaintenanceTypeList.Add(realMeasureMaintenanceTypeList);
-
- }
- string stageModelXml = XmlSerializeHelper.XmlSerialize<MeasureMaintenanceTypeList>(this.measureMaintenanceTypeList);
- FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
- }
- catch (Exception ex)
- {
- }
- finally
- {
- progressEvents.EndOperation(OperationResult.Finished);
- }
- };
- procClass.StartProgressAction(this, itemCount, copyThreadProc, progressEvents, null);
- FileOperationHelper.DeleteFolder(unZipTemporaryFilePath);
- MessageBox.Show(PdnResources.GetString("importSuccess") + "!");
- #endregion
- }
- else if (radioButton2.Checked)
- {
- #region [开始导出]
- if (string.IsNullOrEmpty(textBox2.Text))
- {
- MessageBox.Show(PdnResources.GetString("selectfilepath") + "!");
- 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;
- MeasureMaintenanceTypeList thisMeasureMaintenanceTypeList = new MeasureMaintenanceTypeList();
- thisMeasureMaintenanceTypeList.measureMaintenanceTypeList = new List<MeasureMaintenanceType>();
- foreach (var item in checkList)
- {
- var realMeasureMaintenanceTypeList = this.measureMaintenanceTypeList.measureMaintenanceTypeList.Where(m => m.measureMaintenanceTypeId.Equals(item)).FirstOrDefault();
- if (realMeasureMaintenanceTypeList == null)
- {
- continue;
- }
- thisMeasureMaintenanceTypeList.measureMaintenanceTypeList.Add(realMeasureMaintenanceTypeList);
- FileOperationHelper.CopyDirectory($"{this.rulerFilePath}{realMeasureMaintenanceTypeList.measureMaintenanceName}.xml", temporaryFilePath + "\\ruleFile\\", false);
- }
- string filePath = temporaryFilePath + "\\ruleFile\\MeasureMaintenanceTypeList.xml";
- string stageModelXml = XmlSerializeHelper.XmlSerialize<MeasureMaintenanceTypeList>(thisMeasureMaintenanceTypeList);
- FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
- ZipHandleHelper.createZip(temporaryFilePath, choosePath);
- }
- catch (Exception)
- {
- }
- finally
- {
- progressEvents.EndOperation(OperationResult.Finished);
- }
- };
- procClass.StartProgressAction(this, itemCount, copyThreadProc, progressEvents, null);
- MessageBox.Show(PdnResources.GetString("exportSuccess") + "!");
- #endregion
- }
- this.Close();
- }
- /// <summary>
- /// 递归赋名称
- /// </summary>
- /// <param name="name"></param>
- /// <returns></returns>
- private string RecursionData(string name)
- {
- name += "-导入";
- var hadMeasureMaintenanceTypeList = this.measureMaintenanceTypeList.measureMaintenanceTypeList.Where(m => m.measureMaintenanceName.Equals(name)).FirstOrDefault();
- if (hadMeasureMaintenanceTypeList != null)
- {
- name = RecursionData(name);
- }
- return name;
- }
- /// <summary>
- /// 选中导入
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton1_CheckedChanged(object sender, EventArgs e)
- {
- createTreeView();
- }
- }
- }
|