From 9385ec0ca04c6b9e45af9d1bbd945cbdf56d2055 Mon Sep 17 00:00:00 2001 From: klavirshik Date: Thu, 22 Aug 2024 19:10:34 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=B0=D0=BB=D0=B8=20=D0=B4=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD?= =?UTF-8?q?=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=20=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D1=82=D1=83=D1=81=D1=8B,=20=D0=BD=D0=B0=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=B9=D0=BA=D0=B8=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C?= =?UTF-8?q?=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D1=8F=D1=8E=D1=82=D1=8C?= =?UTF-8?q?=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Reseter2/Form1.Designer.cs | 143 ++++++++++-------- Reseter2/Form1.cs | 29 +++- Reseter2/Form1.resx | 4 +- Reseter2/History/HistoryList.cs | 15 +- Reseter2/Pinger.cs | 2 +- Reseter2/ReseteTask.cs | 9 +- Reseter2/Reseter2.csproj | 1 + Reseter2/Setting/SGlobalSetting.cs | 8 +- Reseter2/Setting/SSetting.cs | 3 +- Reseter2/Setting/SettingReboot.cs | 24 +++ .../Setting/SettingRebootControl.Designer.cs | 112 +++++++++----- Reseter2/Setting/SettingRebootControl.cs | 24 +++ Reseter2/Setting/SettingSCCM.cs | 11 +- .../Setting/SettingSCCMControl.Designer.cs | 131 ++++++++-------- Reseter2/Setting/SettingSCCMControl.cs | 50 ++++++ Reseter2/Setting/SettingWordsControl.cs | 7 +- Reseter2/StatusCanceled.cs | 2 +- Reseter2/StatusReboot.cs | 14 +- Reseter2/StatusRebootError.cs | 10 +- Reseter2/StatusRebootStop.cs | 2 +- Reseter2/StatusRebootSucces.cs | 2 +- Reseter2/StatusRebooting.cs | 18 ++- Reseter2/StausPreReboot.cs | 7 +- Reseter2/TaskControl.Designer.cs | 2 +- Reseter2/TaskControl.cs | 3 +- Reseter2/TaskControl.resx | 2 +- Reseter2/reseter.cs | 10 +- 27 files changed, 441 insertions(+), 204 deletions(-) create mode 100644 Reseter2/Setting/SettingReboot.cs diff --git a/Reseter2/Form1.Designer.cs b/Reseter2/Form1.Designer.cs index 7098d99..51f5d0e 100644 --- a/Reseter2/Form1.Designer.cs +++ b/Reseter2/Form1.Designer.cs @@ -30,7 +30,6 @@ { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); - this.tb_comp = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.bt_reset = new System.Windows.Forms.Button(); this.timer1 = new System.Windows.Forms.Timer(this.components); @@ -40,8 +39,6 @@ this.tabPage2 = new System.Windows.Forms.TabPage(); this.label2 = new System.Windows.Forms.Label(); this.bt_resetAll = new System.Windows.Forms.Button(); - this.checkControl1 = new Reseter2.CheckControl(); - this.treeView1 = new Reseter2.NewTreeView(); this.imageList1 = new System.Windows.Forms.ImageList(this.components); this.imageList2 = new System.Windows.Forms.ImageList(this.components); this.tabPage3 = new System.Windows.Forms.TabPage(); @@ -55,13 +52,16 @@ this.sm_RebootItem = new System.Windows.Forms.ToolStripMenuItem(); this.sm_SaveItem = new System.Windows.Forms.ToolStripMenuItem(); this.tabPage4 = new System.Windows.Forms.TabPage(); - this.settingRebootControl1 = new Reseter2.Setting.SettingRebootControl(); - this.settingSCCMControl1 = new Reseter2.Setting.SettingSCCMControl(); - this.settingWordsControl1 = new Reseter2.Setting.SettingWordsControl(); this.button4 = new System.Windows.Forms.Button(); this.tabPage5 = new System.Windows.Forms.TabPage(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.label16 = new System.Windows.Forms.Label(); + this.cb_comp = new System.Windows.Forms.ComboBox(); + this.checkControl1 = new Reseter2.CheckControl(); + this.treeView1 = new Reseter2.NewTreeView(); + this.settingRebootControl1 = new Reseter2.Setting.SettingRebootControl(); + this.settingSCCMControl1 = new Reseter2.Setting.SettingSCCMControl(); + this.settingWordsControl1 = new Reseter2.Setting.SettingWordsControl(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage2.SuspendLayout(); @@ -72,13 +72,6 @@ ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // - // tb_comp - // - this.tb_comp.Location = new System.Drawing.Point(67, 12); - this.tb_comp.Name = "tb_comp"; - this.tb_comp.Size = new System.Drawing.Size(207, 20); - this.tb_comp.TabIndex = 0; - // // label1 // this.label1.AutoSize = true; @@ -123,6 +116,7 @@ this.tabControl1.SelectedIndex = 0; this.tabControl1.Size = new System.Drawing.Size(410, 714); this.tabControl1.TabIndex = 4; + this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged); // // tabPage1 // @@ -183,36 +177,6 @@ this.bt_resetAll.UseVisualStyleBackColor = false; this.bt_resetAll.Click += new System.EventHandler(this.bt_resetAll_Click); // - // checkControl1 - // - this.checkControl1.Location = new System.Drawing.Point(14, 7); - this.checkControl1.Name = "checkControl1"; - this.checkControl1.Size = new System.Drawing.Size(18, 18); - this.checkControl1.TabIndex = 2; - // - // treeView1 - // - this.treeView1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.treeView1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.treeView1.HideSelection = false; - this.treeView1.ImageIndex = 0; - this.treeView1.ImageList = this.imageList1; - this.treeView1.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.treeView1.Indent = 27; - this.treeView1.ItemHeight = 24; - this.treeView1.Location = new System.Drawing.Point(3, 32); - this.treeView1.Name = "treeView1"; - this.treeView1.SelectedImageIndex = 0; - this.treeView1.ShowLines = false; - this.treeView1.ShowNodeToolTips = true; - this.treeView1.Size = new System.Drawing.Size(396, 653); - this.treeView1.StateImageList = this.imageList2; - this.treeView1.TabIndex = 0; - this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterCheck); - this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick); - this.treeView1.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseDoubleClick); - this.treeView1.MouseCaptureChanged += new System.EventHandler(this.treeView1_MouseCaptureChanged); - // // imageList1 // this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); @@ -357,27 +321,6 @@ this.tabPage4.Text = "Настройки"; this.tabPage4.UseVisualStyleBackColor = true; // - // settingRebootControl1 - // - this.settingRebootControl1.Location = new System.Drawing.Point(6, 299); - this.settingRebootControl1.Name = "settingRebootControl1"; - this.settingRebootControl1.Size = new System.Drawing.Size(391, 130); - this.settingRebootControl1.TabIndex = 7; - // - // settingSCCMControl1 - // - this.settingSCCMControl1.Location = new System.Drawing.Point(6, 115); - this.settingSCCMControl1.Name = "settingSCCMControl1"; - this.settingSCCMControl1.Size = new System.Drawing.Size(391, 178); - this.settingSCCMControl1.TabIndex = 6; - // - // settingWordsControl1 - // - this.settingWordsControl1.Location = new System.Drawing.Point(6, 6); - this.settingWordsControl1.Name = "settingWordsControl1"; - this.settingWordsControl1.Size = new System.Drawing.Size(391, 103); - this.settingWordsControl1.TabIndex = 5; - // // button4 // this.button4.Location = new System.Drawing.Point(317, 435); @@ -417,15 +360,82 @@ this.label16.TabIndex = 0; this.label16.Text = "Reseter2"; // + // cb_comp + // + this.cb_comp.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.cb_comp.DropDownHeight = 1; + this.cb_comp.FormattingEnabled = true; + this.cb_comp.Items.AddRange(new object[] { + "889", + "fdfd"}); + this.cb_comp.Location = new System.Drawing.Point(67, 11); + this.cb_comp.MaxDropDownItems = 1; + this.cb_comp.Name = "cb_comp"; + this.cb_comp.Size = new System.Drawing.Size(210, 21); + this.cb_comp.Sorted = true; + this.cb_comp.TabIndex = 5; + // + // checkControl1 + // + this.checkControl1.Location = new System.Drawing.Point(14, 7); + this.checkControl1.Name = "checkControl1"; + this.checkControl1.Size = new System.Drawing.Size(18, 18); + this.checkControl1.TabIndex = 2; + // + // treeView1 + // + this.treeView1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.treeView1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.treeView1.HideSelection = false; + this.treeView1.ImageIndex = 0; + this.treeView1.ImageList = this.imageList1; + this.treeView1.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.treeView1.Indent = 27; + this.treeView1.ItemHeight = 24; + this.treeView1.Location = new System.Drawing.Point(3, 32); + this.treeView1.Name = "treeView1"; + this.treeView1.SelectedImageIndex = 0; + this.treeView1.ShowLines = false; + this.treeView1.ShowNodeToolTips = true; + this.treeView1.Size = new System.Drawing.Size(396, 653); + this.treeView1.StateImageList = this.imageList2; + this.treeView1.TabIndex = 0; + this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterCheck); + this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick); + this.treeView1.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseDoubleClick); + this.treeView1.MouseCaptureChanged += new System.EventHandler(this.treeView1_MouseCaptureChanged); + // + // settingRebootControl1 + // + this.settingRebootControl1.Location = new System.Drawing.Point(6, 299); + this.settingRebootControl1.Name = "settingRebootControl1"; + this.settingRebootControl1.Size = new System.Drawing.Size(391, 130); + this.settingRebootControl1.TabIndex = 7; + // + // settingSCCMControl1 + // + this.settingSCCMControl1.Location = new System.Drawing.Point(6, 115); + this.settingSCCMControl1.Name = "settingSCCMControl1"; + this.settingSCCMControl1.Size = new System.Drawing.Size(391, 178); + this.settingSCCMControl1.TabIndex = 6; + // + // settingWordsControl1 + // + this.settingWordsControl1.Location = new System.Drawing.Point(6, 6); + this.settingWordsControl1.Name = "settingWordsControl1"; + this.settingWordsControl1.Size = new System.Drawing.Size(391, 103); + this.settingWordsControl1.TabIndex = 5; + // // Form1 // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.ClientSize = new System.Drawing.Size(410, 753); + this.Controls.Add(this.cb_comp); this.Controls.Add(this.tabControl1); this.Controls.Add(this.bt_reset); this.Controls.Add(this.label1); - this.Controls.Add(this.tb_comp); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "Form1"; this.Text = "Reseter2"; @@ -448,8 +458,6 @@ } #endregion - - private System.Windows.Forms.TextBox tb_comp; private System.Windows.Forms.Label label1; private System.Windows.Forms.Button bt_reset; private System.Windows.Forms.Timer timer1; @@ -481,6 +489,7 @@ private Setting.SettingWordsControl settingWordsControl1; private Setting.SettingRebootControl settingRebootControl1; private Setting.SettingSCCMControl settingSCCMControl1; + private System.Windows.Forms.ComboBox cb_comp; } } diff --git a/Reseter2/Form1.cs b/Reseter2/Form1.cs index 5124c1b..ddd81c9 100644 --- a/Reseter2/Form1.cs +++ b/Reseter2/Form1.cs @@ -24,7 +24,9 @@ namespace Reseter2 private bool FocusContext; private object selectItem; public delegate void saveSetting(); - public event saveSetting Save; + public event saveSetting Save; + public delegate void updateSetting(); + public event updateSetting UpdateSetting; public Form1() { @@ -55,7 +57,17 @@ namespace Reseter2 InitializeComponent(); settingWordsControl1.treeView = treeView1; - this.Save += settingWordsControl1.Save; + this.Save += settingWordsControl1.Save; + this.Save += settingSCCMControl1.Save; + this.Save += settingRebootControl1.Save; + + this.UpdateSetting += settingWordsControl1.UpdateSetting; + this.UpdateSetting += settingSCCMControl1.UpdateSetting; + this.UpdateSetting += settingRebootControl1.UpdateSetting; + + // cb_comp.DropDownStyle = ComboBoxStyle.DropDown; + + checkControl1.updateCheck += CheckControl1_updateCheck; flowLayoutPanel1.AutoScrollMinSize = new Size(0, 683) ; flowLayoutPanel1.VerticalScroll.Visible = true; @@ -80,7 +92,8 @@ namespace Reseter2 private void bt_reset_Click(object sender, EventArgs e) { - Reseter.AddTask(tb_comp.Text) ; + Reseter.AddTask(cb_comp.Text); + tabControl1.SelectedIndex = 0; } private void timer1_Tick(object sender, EventArgs e) @@ -112,6 +125,7 @@ namespace Reseter2 if(selectItem is HistoryItem historyItem) { Reseter.AddTask(historyItem.GetComp()); + tabControl1.SelectedIndex = 0; } } @@ -420,5 +434,14 @@ namespace Reseter2 treeView1.Nodes.AddRange(WordsList.ListNodes()); SGlobalSetting.settingExpand.ExpendAll(treeView1.Nodes); } + + private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) + { + if (tabControl1.SelectedIndex == 3) + { + UpdateSetting(); + } + } } } + diff --git a/Reseter2/Form1.resx b/Reseter2/Form1.resx index 628bd40..81ae244 100644 --- a/Reseter2/Form1.resx +++ b/Reseter2/Form1.resx @@ -128,7 +128,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACk - UQAAAk1TRnQBSQFMAgEBCQEAAYABAQGAAQEBGAEAARgBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAFg + UQAAAk1TRnQBSQFMAgEBCQEAAUABAgFAAQIBGAEAARgBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAFg AwABSAMAAQEBAAEQBgABNhIAAf8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/ AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/kAAB/wF/ Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/ @@ -487,7 +487,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABQ - CgAAAk1TRnQBSQFMAgEBAwEAASABAAEgAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CgAAAk1TRnQBSQFMAgEBAwEAAeABAAHgAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/Reseter2/History/HistoryList.cs b/Reseter2/History/HistoryList.cs index e1bf5df..02b3b28 100644 --- a/Reseter2/History/HistoryList.cs +++ b/Reseter2/History/HistoryList.cs @@ -1,4 +1,5 @@ -using System; +using Reseter2.Setting; +using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; @@ -23,6 +24,7 @@ namespace Reseter2.History HistoryItem historyItem = new HistoryItem(reseterTask); Hitem.Insert(0, historyItem); + ClearFirst(); Update(); return historyItem; @@ -36,5 +38,16 @@ namespace Reseter2.History { Hitem.Clear(); } + + static public void ClearFirst() + { + if(Hitem.Count > SGlobalSetting.settingReboot.sizeHistoryItem) + { + Hitem.RemoveAt(Hitem.Count() - 1); + ClearFirst(); + } + + + } } } diff --git a/Reseter2/Pinger.cs b/Reseter2/Pinger.cs index e8913ed..d60a254 100644 --- a/Reseter2/Pinger.cs +++ b/Reseter2/Pinger.cs @@ -49,7 +49,7 @@ namespace Reseter2 pinger.Dispose(); } } - if (pingable) TimeoutCount++; + if (!succes) TimeoutCount++; return new PingResult(ping, TimeoutCount, Ip, pingable, succes); } diff --git a/Reseter2/ReseteTask.cs b/Reseter2/ReseteTask.cs index f396c3e..252f0ed 100644 --- a/Reseter2/ReseteTask.cs +++ b/Reseter2/ReseteTask.cs @@ -20,7 +20,7 @@ namespace Reseter2 public Stopwatch sw = new Stopwatch(); public PingResult pingResult; public HistoryItem historyItem; - + public ReseterTask(IComp comp, TaskControl taskCntrl) @@ -28,7 +28,6 @@ namespace Reseter2 Comp = comp; taskControl = taskCntrl; - System.Diagnostics.Debug.WriteLine(comp.GetResetName()); if (comp.GetResetName() == null || comp.GetResetName().Length == 0) { //Pingers = new Pinger(""); @@ -37,7 +36,7 @@ namespace Reseter2 Pingers = new Pinger(Comp.GetResetName()); StatusTask = new StatusPreReboot(this); historyItem = HistoryList.Add(this); - StatusTask = new StatusRebootError(this); + StatusTask = new StatusRebootError(this, "Uncorrect"); } else @@ -97,9 +96,9 @@ namespace Reseter2 StatusTask.RebootReturn(); } - public void SetNameStage(string nameStage, int indexImg) + public void SetNameStage(string nameStage, int indexImg, bool pauseOn = true) { - taskControl.SetNameStage(nameStage, indexImg); + taskControl.SetNameStage(nameStage, indexImg, pauseOn); } public PingResult Ping() { diff --git a/Reseter2/Reseter2.csproj b/Reseter2/Reseter2.csproj index 4d984d6..75cc51d 100644 --- a/Reseter2/Reseter2.csproj +++ b/Reseter2/Reseter2.csproj @@ -94,6 +94,7 @@ + UserControl diff --git a/Reseter2/Setting/SGlobalSetting.cs b/Reseter2/Setting/SGlobalSetting.cs index 3105bad..6aca581 100644 --- a/Reseter2/Setting/SGlobalSetting.cs +++ b/Reseter2/Setting/SGlobalSetting.cs @@ -20,6 +20,8 @@ namespace Reseter2.Setting public static SettingWords settingWords = new SettingWords(); public static SettingExpand settingExpand = new SettingExpand(); + public static SettingSCCM settingSCCM = new SettingSCCM(); + public static SettingReboot settingReboot = new SettingReboot(); //public static void LoadSetting() // { @@ -36,6 +38,8 @@ namespace Reseter2.Setting SSetting setting = (SSetting)output; if (setting.settingWords != null) settingWords = setting.settingWords; if (setting.settingExpand != null) settingExpand = setting.settingExpand; + if (setting.settingSCCM != null) settingSCCM = setting.settingSCCM; + if (setting.settingReboot != null) settingReboot = setting.settingReboot; HistoryList.Hitem = setting.historyItems; // return output; @@ -47,7 +51,9 @@ namespace Reseter2.Setting sSetting.settingWords = settingWords; sSetting.historyItems = HistoryList.Hitem; sSetting.settingExpand = settingExpand; - if(Save("res.dat", sSetting)) + sSetting.settingSCCM = settingSCCM; + sSetting.settingReboot = settingReboot; + if (Save("res.dat", sSetting)) { return true; } diff --git a/Reseter2/Setting/SSetting.cs b/Reseter2/Setting/SSetting.cs index c68f398..6a9decd 100644 --- a/Reseter2/Setting/SSetting.cs +++ b/Reseter2/Setting/SSetting.cs @@ -13,6 +13,7 @@ namespace Reseter2.Setting public SettingWords settingWords; public List historyItems; public SettingExpand settingExpand; - + public SettingSCCM settingSCCM; + public SettingReboot settingReboot; } } diff --git a/Reseter2/Setting/SettingReboot.cs b/Reseter2/Setting/SettingReboot.cs new file mode 100644 index 0000000..0cb182b --- /dev/null +++ b/Reseter2/Setting/SettingReboot.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Reseter2.Setting +{ + [Serializable] + internal class SettingReboot + { + public int checkConnect; + public int timeOutReboot; + public int timeCheckBeforReboot; + public int sizeHistoryItem; + public SettingReboot() + { + this.checkConnect = 5; + this.timeOutReboot = 5; + this.timeCheckBeforReboot = 50; + this.sizeHistoryItem = 200; + } + } +} diff --git a/Reseter2/Setting/SettingRebootControl.Designer.cs b/Reseter2/Setting/SettingRebootControl.Designer.cs index 11b18a3..3ae0df7 100644 --- a/Reseter2/Setting/SettingRebootControl.Designer.cs +++ b/Reseter2/Setting/SettingRebootControl.Designer.cs @@ -30,26 +30,30 @@ { this.groupBox3 = new System.Windows.Forms.GroupBox(); this.label15 = new System.Windows.Forms.Label(); - this.textBox9 = new System.Windows.Forms.TextBox(); this.label14 = new System.Windows.Forms.Label(); - this.textBox8 = new System.Windows.Forms.TextBox(); this.label13 = new System.Windows.Forms.Label(); - this.textBox7 = new System.Windows.Forms.TextBox(); this.label12 = new System.Windows.Forms.Label(); - this.textBox6 = new System.Windows.Forms.TextBox(); + this.nb_checkConnect = new System.Windows.Forms.NumericUpDown(); + this.nb_timeOutReboot = new System.Windows.Forms.NumericUpDown(); + this.nb_timeCheckBeforReboot = new System.Windows.Forms.NumericUpDown(); + this.nb_sizeHistoryItem = new System.Windows.Forms.NumericUpDown(); this.groupBox3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nb_checkConnect)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nb_timeOutReboot)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nb_timeCheckBeforReboot)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nb_sizeHistoryItem)).BeginInit(); this.SuspendLayout(); // // groupBox3 // + this.groupBox3.Controls.Add(this.nb_sizeHistoryItem); + this.groupBox3.Controls.Add(this.nb_timeCheckBeforReboot); + this.groupBox3.Controls.Add(this.nb_timeOutReboot); + this.groupBox3.Controls.Add(this.nb_checkConnect); this.groupBox3.Controls.Add(this.label15); - this.groupBox3.Controls.Add(this.textBox9); this.groupBox3.Controls.Add(this.label14); - this.groupBox3.Controls.Add(this.textBox8); this.groupBox3.Controls.Add(this.label13); - this.groupBox3.Controls.Add(this.textBox7); this.groupBox3.Controls.Add(this.label12); - this.groupBox3.Controls.Add(this.textBox6); this.groupBox3.Location = new System.Drawing.Point(3, 3); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(386, 124); @@ -66,13 +70,6 @@ this.label15.TabIndex = 11; this.label15.Text = "Кол-во записей истории"; // - // textBox9 - // - this.textBox9.Location = new System.Drawing.Point(184, 96); - this.textBox9.Name = "textBox9"; - this.textBox9.Size = new System.Drawing.Size(182, 20); - this.textBox9.TabIndex = 10; - // // label14 // this.label14.AutoSize = true; @@ -82,13 +79,6 @@ this.label14.TabIndex = 9; this.label14.Text = "Время контроля после перезагрузки"; // - // textBox8 - // - this.textBox8.Location = new System.Drawing.Point(209, 70); - this.textBox8.Name = "textBox8"; - this.textBox8.Size = new System.Drawing.Size(157, 20); - this.textBox8.TabIndex = 8; - // // label13 // this.label13.AutoSize = true; @@ -98,13 +88,6 @@ this.label13.TabIndex = 7; this.label13.Text = "Время ожидание перезагрузки"; // - // textBox7 - // - this.textBox7.Location = new System.Drawing.Point(184, 44); - this.textBox7.Name = "textBox7"; - this.textBox7.Size = new System.Drawing.Size(182, 20); - this.textBox7.TabIndex = 6; - // // label12 // this.label12.AutoSize = true; @@ -114,12 +97,61 @@ this.label12.TabIndex = 5; this.label12.Text = "Кол-во попыток проверки связи"; // - // textBox6 + // nb_checkConnect // - this.textBox6.Location = new System.Drawing.Point(184, 18); - this.textBox6.Name = "textBox6"; - this.textBox6.Size = new System.Drawing.Size(182, 20); - this.textBox6.TabIndex = 4; + this.nb_checkConnect.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.nb_checkConnect.Location = new System.Drawing.Point(184, 18); + this.nb_checkConnect.Maximum = new decimal(new int[] { + 1000000, + 0, + 0, + 0}); + this.nb_checkConnect.Name = "nb_checkConnect"; + this.nb_checkConnect.Size = new System.Drawing.Size(182, 20); + this.nb_checkConnect.TabIndex = 13; + // + // nb_timeOutReboot + // + this.nb_timeOutReboot.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.nb_timeOutReboot.Location = new System.Drawing.Point(184, 44); + this.nb_timeOutReboot.Maximum = new decimal(new int[] { + 100000, + 0, + 0, + 0}); + this.nb_timeOutReboot.Name = "nb_timeOutReboot"; + this.nb_timeOutReboot.Size = new System.Drawing.Size(182, 20); + this.nb_timeOutReboot.TabIndex = 14; + // + // nb_timeCheckBeforReboot + // + this.nb_timeCheckBeforReboot.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.nb_timeCheckBeforReboot.Location = new System.Drawing.Point(208, 70); + this.nb_timeCheckBeforReboot.Maximum = new decimal(new int[] { + 100000, + 0, + 0, + 0}); + this.nb_timeCheckBeforReboot.Name = "nb_timeCheckBeforReboot"; + this.nb_timeCheckBeforReboot.Size = new System.Drawing.Size(158, 20); + this.nb_timeCheckBeforReboot.TabIndex = 15; + // + // nb_sizeHistoryItem + // + this.nb_sizeHistoryItem.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.nb_sizeHistoryItem.Location = new System.Drawing.Point(184, 96); + this.nb_sizeHistoryItem.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.nb_sizeHistoryItem.Name = "nb_sizeHistoryItem"; + this.nb_sizeHistoryItem.Size = new System.Drawing.Size(182, 20); + this.nb_sizeHistoryItem.TabIndex = 16; // // SettingRebootControl // @@ -130,6 +162,10 @@ this.Size = new System.Drawing.Size(391, 130); this.groupBox3.ResumeLayout(false); this.groupBox3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nb_checkConnect)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nb_timeOutReboot)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nb_timeCheckBeforReboot)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nb_sizeHistoryItem)).EndInit(); this.ResumeLayout(false); } @@ -138,12 +174,12 @@ private System.Windows.Forms.GroupBox groupBox3; private System.Windows.Forms.Label label15; - private System.Windows.Forms.TextBox textBox9; private System.Windows.Forms.Label label14; - private System.Windows.Forms.TextBox textBox8; private System.Windows.Forms.Label label13; - private System.Windows.Forms.TextBox textBox7; private System.Windows.Forms.Label label12; - private System.Windows.Forms.TextBox textBox6; + private System.Windows.Forms.NumericUpDown nb_timeOutReboot; + private System.Windows.Forms.NumericUpDown nb_checkConnect; + private System.Windows.Forms.NumericUpDown nb_sizeHistoryItem; + private System.Windows.Forms.NumericUpDown nb_timeCheckBeforReboot; } } diff --git a/Reseter2/Setting/SettingRebootControl.cs b/Reseter2/Setting/SettingRebootControl.cs index def61dc..a195a3d 100644 --- a/Reseter2/Setting/SettingRebootControl.cs +++ b/Reseter2/Setting/SettingRebootControl.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; +using System.Runtime; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -15,6 +16,29 @@ namespace Reseter2.Setting public SettingRebootControl() { InitializeComponent(); + UpdateSetting(); + } + public void UpdateSetting() + { + if (SGlobalSetting.settingReboot != null) + { + nb_checkConnect.Value = SGlobalSetting.settingReboot.checkConnect; + nb_timeOutReboot.Value = SGlobalSetting.settingReboot.timeOutReboot; + nb_timeCheckBeforReboot.Value = SGlobalSetting.settingReboot.timeCheckBeforReboot; + nb_sizeHistoryItem.Value = SGlobalSetting.settingReboot.sizeHistoryItem; + } + } + + public void Save() + { + SGlobalSetting.settingReboot.checkConnect = (int)nb_checkConnect.Value; + SGlobalSetting.settingReboot.timeOutReboot = (int)nb_timeOutReboot.Value; + SGlobalSetting.settingReboot.timeCheckBeforReboot = (int)nb_timeCheckBeforReboot.Value; + SGlobalSetting.settingReboot.sizeHistoryItem = (int)nb_sizeHistoryItem.Value; + + } + + } } diff --git a/Reseter2/Setting/SettingSCCM.cs b/Reseter2/Setting/SettingSCCM.cs index 6949340..d297288 100644 --- a/Reseter2/Setting/SettingSCCM.cs +++ b/Reseter2/Setting/SettingSCCM.cs @@ -15,7 +15,16 @@ namespace Reseter2.Setting public string password; public bool on; public bool windowsAuth; - + + public SettingSCCM() + { + server = string.Empty; + dataBase = string.Empty; + username = string.Empty; + password = string.Empty; + on = false; + windowsAuth = false; + } } } diff --git a/Reseter2/Setting/SettingSCCMControl.Designer.cs b/Reseter2/Setting/SettingSCCMControl.Designer.cs index dae63e3..fe5b024 100644 --- a/Reseter2/Setting/SettingSCCMControl.Designer.cs +++ b/Reseter2/Setting/SettingSCCMControl.Designer.cs @@ -29,33 +29,33 @@ private void InitializeComponent() { this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.button3 = new System.Windows.Forms.Button(); + this.bt_checkConnect = new System.Windows.Forms.Button(); this.label10 = new System.Windows.Forms.Label(); - this.textBox4 = new System.Windows.Forms.TextBox(); + this.ib_password = new System.Windows.Forms.TextBox(); this.label11 = new System.Windows.Forms.Label(); - this.textBox5 = new System.Windows.Forms.TextBox(); - this.checkBox2 = new System.Windows.Forms.CheckBox(); + this.ib_username = new System.Windows.Forms.TextBox(); + this.cb_windowsAuth = new System.Windows.Forms.CheckBox(); this.label9 = new System.Windows.Forms.Label(); - this.textBox3 = new System.Windows.Forms.TextBox(); + this.ib_dataBase = new System.Windows.Forms.TextBox(); this.label8 = new System.Windows.Forms.Label(); - this.textBox2 = new System.Windows.Forms.TextBox(); - this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.ib_server = new System.Windows.Forms.TextBox(); + this.cb_on = new System.Windows.Forms.CheckBox(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // groupBox2 // - this.groupBox2.Controls.Add(this.button3); + this.groupBox2.Controls.Add(this.bt_checkConnect); this.groupBox2.Controls.Add(this.label10); - this.groupBox2.Controls.Add(this.textBox4); + this.groupBox2.Controls.Add(this.ib_password); this.groupBox2.Controls.Add(this.label11); - this.groupBox2.Controls.Add(this.textBox5); - this.groupBox2.Controls.Add(this.checkBox2); + this.groupBox2.Controls.Add(this.ib_username); + this.groupBox2.Controls.Add(this.cb_windowsAuth); this.groupBox2.Controls.Add(this.label9); - this.groupBox2.Controls.Add(this.textBox3); + this.groupBox2.Controls.Add(this.ib_dataBase); this.groupBox2.Controls.Add(this.label8); - this.groupBox2.Controls.Add(this.textBox2); - this.groupBox2.Controls.Add(this.checkBox1); + this.groupBox2.Controls.Add(this.ib_server); + this.groupBox2.Controls.Add(this.cb_on); this.groupBox2.Location = new System.Drawing.Point(3, 3); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(386, 173); @@ -63,14 +63,14 @@ this.groupBox2.TabStop = false; this.groupBox2.Text = "Параметры поиска"; // - // button3 + // bt_checkConnect // - this.button3.Location = new System.Drawing.Point(263, 143); - this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(112, 23); - this.button3.TabIndex = 11; - this.button3.Text = "Проверить связь"; - this.button3.UseVisualStyleBackColor = true; + this.bt_checkConnect.Location = new System.Drawing.Point(263, 143); + this.bt_checkConnect.Name = "bt_checkConnect"; + this.bt_checkConnect.Size = new System.Drawing.Size(112, 23); + this.bt_checkConnect.TabIndex = 11; + this.bt_checkConnect.Text = "Проверить связь"; + this.bt_checkConnect.UseVisualStyleBackColor = true; // // label10 // @@ -81,12 +81,13 @@ this.label10.TabIndex = 10; this.label10.Text = "Пароль"; // - // textBox4 + // ib_password // - this.textBox4.Location = new System.Drawing.Point(193, 117); - this.textBox4.Name = "textBox4"; - this.textBox4.Size = new System.Drawing.Size(182, 20); - this.textBox4.TabIndex = 9; + this.ib_password.Location = new System.Drawing.Point(193, 117); + this.ib_password.Name = "ib_password"; + this.ib_password.PasswordChar = '•'; + this.ib_password.Size = new System.Drawing.Size(182, 20); + this.ib_password.TabIndex = 9; // // label11 // @@ -97,22 +98,23 @@ this.label11.TabIndex = 8; this.label11.Text = "Логин"; // - // textBox5 + // ib_username // - this.textBox5.Location = new System.Drawing.Point(6, 117); - this.textBox5.Name = "textBox5"; - this.textBox5.Size = new System.Drawing.Size(181, 20); - this.textBox5.TabIndex = 7; + this.ib_username.Location = new System.Drawing.Point(6, 117); + this.ib_username.Name = "ib_username"; + this.ib_username.Size = new System.Drawing.Size(181, 20); + this.ib_username.TabIndex = 7; // - // checkBox2 + // cb_windowsAuth // - this.checkBox2.AutoSize = true; - this.checkBox2.Location = new System.Drawing.Point(10, 82); - this.checkBox2.Name = "checkBox2"; - this.checkBox2.Size = new System.Drawing.Size(157, 17); - this.checkBox2.TabIndex = 6; - this.checkBox2.Text = "Аутентификация Windows"; - this.checkBox2.UseVisualStyleBackColor = true; + this.cb_windowsAuth.AutoSize = true; + this.cb_windowsAuth.Location = new System.Drawing.Point(10, 82); + this.cb_windowsAuth.Name = "cb_windowsAuth"; + this.cb_windowsAuth.Size = new System.Drawing.Size(157, 17); + this.cb_windowsAuth.TabIndex = 6; + this.cb_windowsAuth.Text = "Аутентификация Windows"; + this.cb_windowsAuth.UseVisualStyleBackColor = true; + this.cb_windowsAuth.CheckedChanged += new System.EventHandler(this.cb_windowsAuth_CheckedChanged); // // label9 // @@ -123,12 +125,12 @@ this.label9.TabIndex = 5; this.label9.Text = "База данных"; // - // textBox3 + // ib_dataBase // - this.textBox3.Location = new System.Drawing.Point(193, 55); - this.textBox3.Name = "textBox3"; - this.textBox3.Size = new System.Drawing.Size(182, 20); - this.textBox3.TabIndex = 4; + this.ib_dataBase.Location = new System.Drawing.Point(193, 55); + this.ib_dataBase.Name = "ib_dataBase"; + this.ib_dataBase.Size = new System.Drawing.Size(182, 20); + this.ib_dataBase.TabIndex = 4; // // label8 // @@ -139,22 +141,23 @@ this.label8.TabIndex = 3; this.label8.Text = "Сервер базы данных"; // - // textBox2 + // ib_server // - this.textBox2.Location = new System.Drawing.Point(6, 55); - this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(181, 20); - this.textBox2.TabIndex = 1; + this.ib_server.Location = new System.Drawing.Point(6, 55); + this.ib_server.Name = "ib_server"; + this.ib_server.Size = new System.Drawing.Size(181, 20); + this.ib_server.TabIndex = 1; // - // checkBox1 + // cb_on // - this.checkBox1.AutoSize = true; - this.checkBox1.Location = new System.Drawing.Point(10, 20); - this.checkBox1.Name = "checkBox1"; - this.checkBox1.Size = new System.Drawing.Size(215, 17); - this.checkBox1.TabIndex = 0; - this.checkBox1.Text = "Связь с SCCM (помощь в поиске ПК)"; - this.checkBox1.UseVisualStyleBackColor = true; + this.cb_on.AutoSize = true; + this.cb_on.Location = new System.Drawing.Point(10, 20); + this.cb_on.Name = "cb_on"; + this.cb_on.Size = new System.Drawing.Size(215, 17); + this.cb_on.TabIndex = 0; + this.cb_on.Text = "Связь с SCCM (помощь в поиске ПК)"; + this.cb_on.UseVisualStyleBackColor = true; + this.cb_on.CheckedChanged += new System.EventHandler(this.cb_on_CheckedChanged); // // SettingSCCMControl // @@ -172,16 +175,16 @@ #endregion private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button bt_checkConnect; private System.Windows.Forms.Label label10; - private System.Windows.Forms.TextBox textBox4; + private System.Windows.Forms.TextBox ib_password; private System.Windows.Forms.Label label11; - private System.Windows.Forms.TextBox textBox5; - private System.Windows.Forms.CheckBox checkBox2; + private System.Windows.Forms.TextBox ib_username; + private System.Windows.Forms.CheckBox cb_windowsAuth; private System.Windows.Forms.Label label9; - private System.Windows.Forms.TextBox textBox3; + private System.Windows.Forms.TextBox ib_dataBase; private System.Windows.Forms.Label label8; - private System.Windows.Forms.TextBox textBox2; - private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.TextBox ib_server; + private System.Windows.Forms.CheckBox cb_on; } } diff --git a/Reseter2/Setting/SettingSCCMControl.cs b/Reseter2/Setting/SettingSCCMControl.cs index 559f1d9..0533d38 100644 --- a/Reseter2/Setting/SettingSCCMControl.cs +++ b/Reseter2/Setting/SettingSCCMControl.cs @@ -3,6 +3,7 @@ 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; @@ -15,6 +16,55 @@ namespace Reseter2.Setting public SettingSCCMControl() { InitializeComponent(); + UpdateSetting(); + } + + public void UpdateSetting() + { + if (SGlobalSetting.settingSCCM != null) + { + ib_server.Text = SGlobalSetting.settingSCCM.server; + ib_dataBase.Text = SGlobalSetting.settingSCCM.dataBase; + ib_username.Text = SGlobalSetting.settingSCCM.username; + ib_password.Text = SGlobalSetting.settingSCCM.password; + cb_on.Checked = SGlobalSetting.settingSCCM.on; + + cb_windowsAuth.Checked = SGlobalSetting.settingSCCM.windowsAuth; + SearchControl(cb_on.Checked); + } + } + private void AuthControl(bool enable) + { + ib_username.Enabled = enable; + ib_password.Enabled = enable; + } + private void SearchControl(bool enable) + { + ib_server.Enabled = enable; + ib_dataBase.Enabled = enable; + cb_windowsAuth.Enabled = enable; + bt_checkConnect.Enabled = enable; + AuthControl(!cb_windowsAuth.Checked && enable); + } + + private void cb_on_CheckedChanged(object sender, EventArgs e) + { + SearchControl(cb_on.Checked); + } + + private void cb_windowsAuth_CheckedChanged(object sender, EventArgs e) + { + AuthControl(!cb_windowsAuth.Checked); + } + public void Save() + { + SGlobalSetting.settingSCCM.server = ib_server.Text; + SGlobalSetting.settingSCCM.dataBase = ib_dataBase.Text; + SGlobalSetting.settingSCCM.username = ib_username.Text; + SGlobalSetting.settingSCCM.password = ib_password.Text; + SGlobalSetting.settingSCCM.on = cb_on.Checked; + SGlobalSetting.settingSCCM.windowsAuth = cb_windowsAuth.Checked; + } } } diff --git a/Reseter2/Setting/SettingWordsControl.cs b/Reseter2/Setting/SettingWordsControl.cs index fedddeb..30fc780 100644 --- a/Reseter2/Setting/SettingWordsControl.cs +++ b/Reseter2/Setting/SettingWordsControl.cs @@ -20,7 +20,12 @@ namespace Reseter2.Setting public SettingWordsControl() { InitializeComponent(); - if(SGlobalSetting.settingWords != null) + UpdateSetting(); + } + + public void UpdateSetting() + { + if (SGlobalSetting.settingWords != null) { path.Text = SGlobalSetting.settingWords.PathBase; } diff --git a/Reseter2/StatusCanceled.cs b/Reseter2/StatusCanceled.cs index f0943ad..d19cafc 100644 --- a/Reseter2/StatusCanceled.cs +++ b/Reseter2/StatusCanceled.cs @@ -26,7 +26,7 @@ namespace Reseter2 } public override string GetName() { - return "Отмененно"; + return "Canceled"; } } } \ No newline at end of file diff --git a/Reseter2/StatusReboot.cs b/Reseter2/StatusReboot.cs index f97b0ce..188d618 100644 --- a/Reseter2/StatusReboot.cs +++ b/Reseter2/StatusReboot.cs @@ -1,4 +1,5 @@ using Reseter2.History; +using Reseter2.Setting; using System; using System.Collections.Generic; using System.Linq; @@ -11,6 +12,7 @@ namespace Reseter2 internal class StatusReboot : AStatusTask { private int TimeCount; + private int Timeout; private PingResult PingResult = new PingResult(0, 0, null, false); public StatusReboot(ReseterTask reseterTask) : base(reseterTask) @@ -30,11 +32,19 @@ namespace Reseter2 { TimeCount++; } - if (TimeCount > 3) + if (TimeCount > 2) { - resetertask.StatusTask = new StatusRebooting(resetertask); + resetertask.StatusTask = new StatusRebooting(resetertask, Timeout); HistoryList.Updated(); } + if (Timeout > SGlobalSetting.settingReboot.timeOutReboot) + { + resetertask.StatusTask = new StatusRebootError(resetertask, "Error RST"); + HistoryList.Updated(); + } + Timeout++; + + } public override string GetName() { diff --git a/Reseter2/StatusRebootError.cs b/Reseter2/StatusRebootError.cs index e553a8c..a0382ab 100644 --- a/Reseter2/StatusRebootError.cs +++ b/Reseter2/StatusRebootError.cs @@ -8,10 +8,14 @@ namespace Reseter2 { internal class StatusRebootError : AStatusTask { + private string _error; private PingResult PingResult = new PingResult(0, 0, null, false); - public StatusRebootError(ReseterTask reseterTask) : base(reseterTask) + public StatusRebootError(ReseterTask reseterTask, string error = "Error") : base(reseterTask) { - resetertask.SetNameStage("Ошибка перезагрузки", 5); + _error = error; + string messges = "Ошибка перезагрузки"; + if (error != "Error") messges = messges + "(" + error + ")"; + resetertask.SetNameStage(messges, 5, false); resetertask.historyItem.SetEndTime(DateTime.Now); reseterTask.sw.Stop(); } @@ -26,7 +30,7 @@ namespace Reseter2 public override string GetName() { - return "Error"; + return _error; } } } diff --git a/Reseter2/StatusRebootStop.cs b/Reseter2/StatusRebootStop.cs index e7b9edd..5c4eb0f 100644 --- a/Reseter2/StatusRebootStop.cs +++ b/Reseter2/StatusRebootStop.cs @@ -11,7 +11,7 @@ namespace Reseter2 private PingResult PingResult; public StatusRebootStop(ReseterTask reseterTask) : base(reseterTask) { - resetertask.SetNameStage("Остановленно", 6); + resetertask.SetNameStage("Остановленно", 6, false); PingResult = resetertask.pingResult; resetertask.historyItem.SetEndTime(DateTime.Now); reseterTask.sw.Stop(); diff --git a/Reseter2/StatusRebootSucces.cs b/Reseter2/StatusRebootSucces.cs index b1c3c0a..cca6572 100644 --- a/Reseter2/StatusRebootSucces.cs +++ b/Reseter2/StatusRebootSucces.cs @@ -11,7 +11,7 @@ namespace Reseter2 private PingResult PingResult; public StatusRebootSucces(ReseterTask reseterTask) : base(reseterTask) { - resetertask.SetNameStage("Успешно перезагруженно", 7); + resetertask.SetNameStage("Успешно перезагруженно", 7, false); resetertask.historyItem.SetEndTime(DateTime.Now); PingResult = resetertask.Ping(); resetertask.Comp.SetIP(PingResult.Ip); diff --git a/Reseter2/StatusRebooting.cs b/Reseter2/StatusRebooting.cs index a3cf3f9..cedf65e 100644 --- a/Reseter2/StatusRebooting.cs +++ b/Reseter2/StatusRebooting.cs @@ -1,4 +1,5 @@ using Reseter2.History; +using Reseter2.Setting; using System; using System.Collections.Generic; using System.Linq; @@ -10,11 +11,12 @@ namespace Reseter2 internal class StatusRebooting : AStatusTask { private int TimeCount; + private int Timeout; private PingResult PingResult = new PingResult(0, 0, null, false); - public StatusRebooting(ReseterTask reseterTask) : base(reseterTask) + public StatusRebooting(ReseterTask reseterTask, int timeout = 0) : base(reseterTask) { resetertask.SetNameStage("Перезагрузка", 2); - + Timeout = timeout; } public override Task Tick() @@ -28,11 +30,21 @@ namespace Reseter2 { TimeCount++; } - if (TimeCount > 50) + if (TimeCount > SGlobalSetting.settingReboot.timeCheckBeforReboot) { resetertask.StatusTask = new StatusRebootSucces(resetertask); HistoryList.Updated(); } + if (PingResult.TimedOut == true) + { + Timeout++; + } + if (Timeout > SGlobalSetting.settingReboot.timeOutReboot) + { + resetertask.StatusTask = new StatusRebootError(resetertask, "Error UP"); + HistoryList.Updated(); + } + } public override string GetName() { diff --git a/Reseter2/StausPreReboot.cs b/Reseter2/StausPreReboot.cs index 3dee825..1064de2 100644 --- a/Reseter2/StausPreReboot.cs +++ b/Reseter2/StausPreReboot.cs @@ -1,4 +1,5 @@ using Reseter2.History; +using Reseter2.Setting; using System; using System.Collections.Generic; using System.Linq; @@ -37,16 +38,16 @@ namespace Reseter2 { timeOut++; } - if(timeOut > 2) + if(timeOut > SGlobalSetting.settingReboot.checkConnect) { - resetertask.StatusTask = new StatusRebootError(resetertask); + resetertask.StatusTask = new StatusRebootError(resetertask, "Error NET"); HistoryList.Updated(); } } public override string GetName() { - return "Check net"; + return "Check NET"; } } diff --git a/Reseter2/TaskControl.Designer.cs b/Reseter2/TaskControl.Designer.cs index 4fcd246..8c7c312 100644 --- a/Reseter2/TaskControl.Designer.cs +++ b/Reseter2/TaskControl.Designer.cs @@ -162,7 +162,7 @@ this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(96, 23); this.button3.TabIndex = 12; - this.button3.Text = "Пауза"; + this.button3.Text = "Остановить"; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // diff --git a/Reseter2/TaskControl.cs b/Reseter2/TaskControl.cs index e7f3d97..a4299ef 100644 --- a/Reseter2/TaskControl.cs +++ b/Reseter2/TaskControl.cs @@ -51,10 +51,11 @@ namespace Reseter2 lb_time.Text = time.ToString(@"mm\:ss"); } - public void SetNameStage(string nameStage, int indexImg) + public void SetNameStage(string nameStage, int indexImg, bool pauseOn) { lb_stage.Text = nameStage; pictureBox1.Image = imageList1.Images[indexImg]; + button3.Enabled=pauseOn; } private void label1_Click(object sender, EventArgs e) { diff --git a/Reseter2/TaskControl.resx b/Reseter2/TaskControl.resx index 4e7533e..ad3c453 100644 --- a/Reseter2/TaskControl.resx +++ b/Reseter2/TaskControl.resx @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABk - lAIAAk1TRnQBSQFMAgEBCAEAASABAAEgAQABQAEAAUABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgEAAEB + lAIAAk1TRnQBSQFMAgEBCAEAASgBAAEoAQABQAEAAUABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgEAAEB AgABwAMAAQEBAAEYBgABQAEC/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A /wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A /wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A diff --git a/Reseter2/reseter.cs b/Reseter2/reseter.cs index b702f06..20e2d20 100644 --- a/Reseter2/reseter.cs +++ b/Reseter2/reseter.cs @@ -60,8 +60,14 @@ namespace Reseter2 public static async void Clear(ReseterTask reseterTask, TaskControl taskControl) { - reseterTask.StatusTask = new StatusCanceled(reseterTask); - reseterTask.historyItem.SetEndTime(DateTime.Now); + if(!(reseterTask.StatusTask is StatusRebootError || + reseterTask.StatusTask is StatusRebootStop || + reseterTask.StatusTask is StatusRebootSucces)) + { + reseterTask.StatusTask = new StatusCanceled(reseterTask); + reseterTask.historyItem.SetEndTime(DateTime.Now); + } + HistoryList.Updated(); flow_conteiner.Controls.Remove(taskControl); list_task.Remove(reseterTask);