diff --git a/Reseter2/Form1.Designer.cs b/Reseter2/Form1.Designer.cs index 8761434..77fa06a 100644 --- a/Reseter2/Form1.Designer.cs +++ b/Reseter2/Form1.Designer.cs @@ -36,9 +36,9 @@ this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.timer1 = new System.Windows.Forms.Timer(this.components); - this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); this.toolStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -98,6 +98,17 @@ this.toolStripButton2.Name = "toolStripButton2"; this.toolStripButton2.Size = new System.Drawing.Size(58, 22); this.toolStripButton2.Text = "История"; + this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click); + // + // toolStripButton3 + // + this.toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image"))); + this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton3.Name = "toolStripButton3"; + this.toolStripButton3.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.toolStripButton3.Size = new System.Drawing.Size(86, 22); + this.toolStripButton3.Text = "О программе"; // // flowLayoutPanel1 // @@ -120,16 +131,6 @@ this.timer1.Interval = 1000; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // - // toolStripButton3 - // - this.toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; - this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image"))); - this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButton3.Name = "toolStripButton3"; - this.toolStripButton3.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.toolStripButton3.Size = new System.Drawing.Size(86, 22); - this.toolStripButton3.Text = "О программе"; - // // Form1 // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; diff --git a/Reseter2/Form1.cs b/Reseter2/Form1.cs index 00ddeea..9d4351c 100644 --- a/Reseter2/Form1.cs +++ b/Reseter2/Form1.cs @@ -1,4 +1,5 @@ -using System; +using Reseter2.History; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,6 +13,7 @@ namespace Reseter2 { public partial class Form1 : Form { + private FormHistory formHistory; public Form1() { @@ -35,5 +37,22 @@ namespace Reseter2 { Reseter.Tick(); } + + private void toolStripButton2_Click(object sender, EventArgs e) + { + if (formHistory == null) + { + formHistory = new FormHistory(); + HistoryList.SetControl(formHistory); + formHistory.Show(); + } + else + { + + formHistory.Activate(); + } + + + } } } diff --git a/Reseter2/FormHistory.Designer.cs b/Reseter2/FormHistory.Designer.cs deleted file mode 100644 index 819e3f9..0000000 --- a/Reseter2/FormHistory.Designer.cs +++ /dev/null @@ -1,46 +0,0 @@ -namespace Reseter2 -{ - partial class FormHistory - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.SuspendLayout(); - // - // FormHistory - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(403, 450); - this.Name = "FormHistory"; - this.Text = "FormHistory"; - this.ResumeLayout(false); - - } - - #endregion - } -} \ No newline at end of file diff --git a/Reseter2/FormHistory.cs b/Reseter2/FormHistory.cs deleted file mode 100644 index a4e3d1d..0000000 --- a/Reseter2/FormHistory.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace Reseter2 -{ - public partial class FormHistory : Form - { - public FormHistory() - { - InitializeComponent(); - } - } -} diff --git a/Reseter2/History/FormHistory.Designer.cs b/Reseter2/History/FormHistory.Designer.cs new file mode 100644 index 0000000..010ca8d --- /dev/null +++ b/Reseter2/History/FormHistory.Designer.cs @@ -0,0 +1,79 @@ +namespace Reseter2 +{ + partial class FormHistory + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.button1 = new System.Windows.Forms.Button(); + this.TableHistory = new System.Windows.Forms.DataGridView(); + ((System.ComponentModel.ISupportInitialize)(this.TableHistory)).BeginInit(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button1.Location = new System.Drawing.Point(316, 414); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 0; + this.button1.Text = "button1"; + this.button1.UseVisualStyleBackColor = true; + // + // TableHistory + // + this.TableHistory.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.TableHistory.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.TableHistory.Location = new System.Drawing.Point(0, 0); + this.TableHistory.Name = "TableHistory"; + this.TableHistory.RowHeadersVisible = false; + this.TableHistory.Size = new System.Drawing.Size(403, 409); + this.TableHistory.TabIndex = 1; + // + // FormHistory + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(403, 441); + this.Controls.Add(this.TableHistory); + this.Controls.Add(this.button1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FormHistory"; + this.Text = "FormHistory"; + ((System.ComponentModel.ISupportInitialize)(this.TableHistory)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button button1; + private System.Windows.Forms.DataGridView TableHistory; + } +} \ No newline at end of file diff --git a/Reseter2/History/FormHistory.cs b/Reseter2/History/FormHistory.cs new file mode 100644 index 0000000..38ed664 --- /dev/null +++ b/Reseter2/History/FormHistory.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Reseter2 +{ + public partial class FormHistory : Form + { + private DataTable dataTable; + private DataSet ds; + private DataRow row; + public FormHistory() + { + + InitializeComponent(); + ds = new DataSet(); + dataTable = new DataTable(); + TableHistory.DataSource = dataTable; + dataTable.Columns.Add("Время"); + dataTable.Columns.Add("Имя"); + dataTable.Columns.Add("Статус"); + ds.Tables.Add(dataTable); + row = dataTable.NewRow(); + row[0] = "12"; + row[1] = "123"; + row[2] = "12444"; + dataTable.Rows.Add(row); + } + } +} diff --git a/Reseter2/FormHistory.resx b/Reseter2/History/FormHistory.resx similarity index 100% rename from Reseter2/FormHistory.resx rename to Reseter2/History/FormHistory.resx diff --git a/Reseter2/History/HistoryItem.cs b/Reseter2/History/HistoryItem.cs new file mode 100644 index 0000000..d1b1e36 --- /dev/null +++ b/Reseter2/History/HistoryItem.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Reseter2.History +{ + + + internal class HistoryItem + { + private IComp comp; + private ReseterTask task; + private AStatusTask statusTask; + private DateTime startTime; + public HistoryItem(IComp comp, AStatusTask statusTask, DateTime startTime) + { + this.comp = comp; + this.statusTask = statusTask; + this.startTime = startTime; + } + public HistoryItem(ReseterTask task) + { + this.comp = task.Comp; + this.task = task; + this.statusTask = task.StatusTask; + this.startTime = task.StartTime; + } + public SHistory GetData() + { + return new SHistory(comp.GetName(), startTime.ToShortTimeString(), statusTask.GetName()); + + } + } +} diff --git a/Reseter2/History/HistoryList.cs b/Reseter2/History/HistoryList.cs new file mode 100644 index 0000000..46f187d --- /dev/null +++ b/Reseter2/History/HistoryList.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace Reseter2.History +{ + internal static class HistoryList + { + static private List Hitem; + static private FormHistory formHistory; + static public HistoryItem Add(ReseterTask reseterTask) + { + HistoryItem historyItem = new HistoryItem(reseterTask); + Hitem.Add(historyItem); + return historyItem; + } + static public void SetControl(FormHistory formhistory) + { + formHistory = formhistory; + } + static public void Update() + { + + } + } +} diff --git a/Reseter2/History/SHistory.cs b/Reseter2/History/SHistory.cs new file mode 100644 index 0000000..73d1dda --- /dev/null +++ b/Reseter2/History/SHistory.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Reseter2.History +{ + internal struct SHistory + { + public string Name; + public string StartTime; + public string StatusTask; + public SHistory(string name, string startTime, string statusTask) + { + Name = name; + StartTime = startTime; + StatusTask = statusTask; + } + } +} diff --git a/Reseter2/IStatusTask.cs b/Reseter2/IStatusTask.cs index 232e26f..36c67c2 100644 --- a/Reseter2/IStatusTask.cs +++ b/Reseter2/IStatusTask.cs @@ -15,6 +15,7 @@ namespace Reseter2 } public abstract Task Tick(); public abstract void Next(); + public abstract string GetName(); public void Stop() { resetertask.StatusTask = new StatusRebootStop(resetertask); } diff --git a/Reseter2/ReseteTask.cs b/Reseter2/ReseteTask.cs index e51f13d..f29e5b1 100644 --- a/Reseter2/ReseteTask.cs +++ b/Reseter2/ReseteTask.cs @@ -11,6 +11,7 @@ namespace Reseter2 class ReseterTask { private Task task; + public DateTime StartTime = DateTime.Now; public IComp Comp { get; } public AStatusTask StatusTask { get; set; } private TaskControl taskControl; diff --git a/Reseter2/Reseter2.csproj b/Reseter2/Reseter2.csproj index 07d210e..39c273f 100644 --- a/Reseter2/Reseter2.csproj +++ b/Reseter2/Reseter2.csproj @@ -53,12 +53,15 @@ Form1.cs - + Form - + FormHistory.cs + + + @@ -82,7 +85,7 @@ Form1.cs - + FormHistory.cs @@ -110,8 +113,6 @@ - - - + \ No newline at end of file diff --git a/Reseter2/StatusReboot.cs b/Reseter2/StatusReboot.cs index 05486a0..47539e8 100644 --- a/Reseter2/StatusReboot.cs +++ b/Reseter2/StatusReboot.cs @@ -34,5 +34,9 @@ namespace Reseter2 resetertask.StatusTask = new StatusRebooting(resetertask); } } + public override string GetName() + { + return "Отправляем команду перезагрузки"; + } } } diff --git a/Reseter2/StatusRebootStop.cs b/Reseter2/StatusRebootStop.cs index 3b17068..3a62007 100644 --- a/Reseter2/StatusRebootStop.cs +++ b/Reseter2/StatusRebootStop.cs @@ -23,5 +23,9 @@ namespace Reseter2 public override void Next() { } + public override string GetName() + { + return "Перезагрузка остановленна"; + } } } diff --git a/Reseter2/StatusRebootSucces.cs b/Reseter2/StatusRebootSucces.cs index 2d6b126..0ebcb40 100644 --- a/Reseter2/StatusRebootSucces.cs +++ b/Reseter2/StatusRebootSucces.cs @@ -23,5 +23,9 @@ namespace Reseter2 public override void Next() { } + public override string GetName() + { + return "Успешно перезагруженно"; + } } } diff --git a/Reseter2/StatusRebooting.cs b/Reseter2/StatusRebooting.cs index b8cd21a..afb13e0 100644 --- a/Reseter2/StatusRebooting.cs +++ b/Reseter2/StatusRebooting.cs @@ -32,5 +32,9 @@ namespace Reseter2 resetertask.StatusTask = new StatusRebootSucces(resetertask); } } + public override string GetName() + { + return "Перезагрузка"; + } } } diff --git a/Reseter2/StausPreReboot.cs b/Reseter2/StausPreReboot.cs index ade44a1..bb167a3 100644 --- a/Reseter2/StausPreReboot.cs +++ b/Reseter2/StausPreReboot.cs @@ -33,6 +33,10 @@ namespace Reseter2 } + public override string GetName() + { + return "Проверка связи"; + } } } \ No newline at end of file