This commit is contained in:
parent
2542586eb4
commit
0d9fc6d170
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
|
@ -10,19 +11,24 @@ namespace Reseter2
|
|||
{
|
||||
private string Name { get; set; }
|
||||
private string Description { get; set; }
|
||||
private string Ip { get; set; }
|
||||
private IPAddress Ip { get; set; }
|
||||
|
||||
public CompId(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
|
||||
public CompId(IPAddress ip)
|
||||
{
|
||||
this.Ip = ip;
|
||||
}
|
||||
public CompId(string name, string description)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Description = description;
|
||||
}
|
||||
|
||||
public CompId(string name, string description, string ip)
|
||||
public CompId(string name, string description, IPAddress ip)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Description = description;
|
||||
|
|
@ -35,6 +41,22 @@ namespace Reseter2
|
|||
return Name;
|
||||
}
|
||||
|
||||
public IPAddress GetIP()
|
||||
{
|
||||
return Ip;
|
||||
}
|
||||
|
||||
public void SetIP(IPAddress ip)
|
||||
{
|
||||
Ip = ip;
|
||||
}
|
||||
|
||||
public string GetResetName()
|
||||
{
|
||||
if (Name != null) return Name;
|
||||
return Ip.ToString();
|
||||
}
|
||||
|
||||
public string GetDescription()
|
||||
{
|
||||
return Description;
|
||||
|
|
|
|||
|
|
@ -103,31 +103,33 @@
|
|||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.flowLayoutPanel1.AutoScroll = true;
|
||||
this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.flowLayoutPanel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 67);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(394, 380);
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(394, 650);
|
||||
this.flowLayoutPanel1.TabIndex = 4;
|
||||
this.flowLayoutPanel1.WrapContents = false;
|
||||
//
|
||||
// timer1
|
||||
//
|
||||
this.timer1.Enabled = true;
|
||||
this.timer1.Interval = 300;
|
||||
this.timer1.Interval = 1000;
|
||||
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.ClientSize = new System.Drawing.Size(394, 447);
|
||||
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.ClientSize = new System.Drawing.Size(394, 717);
|
||||
this.Controls.Add(this.flowLayoutPanel1);
|
||||
this.Controls.Add(this.toolStrip1);
|
||||
this.Controls.Add(this.bt_reset);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.tb_comp);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.Text = "Reseter2";
|
||||
this.toolStrip1.ResumeLayout(false);
|
||||
this.toolStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
|
@ -9,6 +10,9 @@ namespace Reseter2
|
|||
internal interface IComp
|
||||
{
|
||||
string GetName();
|
||||
string GetResetName();
|
||||
IPAddress GetIP();
|
||||
void SetIP(IPAddress ip);
|
||||
string GetDescription();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,14 @@ namespace Reseter2
|
|||
resetertask = reseterTask;
|
||||
}
|
||||
public abstract Task<PingResult> Tick();
|
||||
public abstract void Stop();
|
||||
public abstract void Next();
|
||||
public void Stop() {
|
||||
resetertask.StatusTask = new StatusRebootStop(resetertask);
|
||||
}
|
||||
public void RebootReturn()
|
||||
{
|
||||
resetertask.StatusTask = new StatusPreReboot(resetertask);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -11,10 +12,12 @@ namespace Reseter2
|
|||
{
|
||||
public long Ping { get; set; }
|
||||
public int TimeoutPing { get; set; }
|
||||
public PingResult(long ping, int timeoutPing)
|
||||
public IPAddress Ip;
|
||||
public PingResult(long ping, int timeoutPing, IPAddress ip)
|
||||
{
|
||||
Ping = ping;
|
||||
TimeoutPing = timeoutPing;
|
||||
Ip = ip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net;
|
||||
|
||||
namespace Reseter2
|
||||
{
|
||||
|
|
@ -12,6 +13,7 @@ namespace Reseter2
|
|||
{
|
||||
private string NameOrAddress;
|
||||
private int TimeoutCount;
|
||||
private IPAddress Ip;
|
||||
|
||||
public Pinger(string nameOrAddress)
|
||||
{
|
||||
|
|
@ -31,6 +33,7 @@ namespace Reseter2
|
|||
PingReply reply = pinger.Send(this.NameOrAddress);
|
||||
pingable = reply.Status == IPStatus.TimedOut;
|
||||
ping = reply.RoundtripTime;
|
||||
Ip = reply.Address;
|
||||
}
|
||||
catch (PingException)
|
||||
{
|
||||
|
|
@ -44,7 +47,7 @@ namespace Reseter2
|
|||
}
|
||||
}
|
||||
if (pingable) TimeoutCount++;
|
||||
return new PingResult(ping, TimeoutCount);
|
||||
return new PingResult(ping, TimeoutCount, Ip);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
|
|
@ -10,26 +11,22 @@ namespace Reseter2
|
|||
class ReseterTask
|
||||
{
|
||||
private Task<PingResult> task;
|
||||
private IComp Comp;
|
||||
public IComp Comp { get; }
|
||||
public AStatusTask StatusTask { get; set; }
|
||||
private TaskControl taskControl;
|
||||
private Pinger Pingers;
|
||||
public delegate void DataEvents(string ping, string timeout);
|
||||
public event DataEvents DataChange;
|
||||
public Stopwatch sw = new Stopwatch();
|
||||
|
||||
|
||||
|
||||
public ReseterTask(IComp comp, TaskControl taskCntrl)
|
||||
{
|
||||
Comp = comp;
|
||||
taskControl = taskCntrl;
|
||||
StatusTask = new StatusPreReboot(this);
|
||||
Pingers = new Pinger(Comp.GetName());
|
||||
DataChange += taskControl.DataContrl;
|
||||
Pingers = new Pinger(Comp.GetResetName());
|
||||
}
|
||||
public string GetName()
|
||||
{
|
||||
return Comp.GetName();
|
||||
}
|
||||
|
||||
|
||||
public async Task Tick()
|
||||
{
|
||||
if (task != null)
|
||||
|
|
@ -37,16 +34,34 @@ namespace Reseter2
|
|||
if (task.IsCompleted){
|
||||
//this.DataContrl(Ping().ToString(), Timeout().ToString());
|
||||
PingResult pingResult = await task;
|
||||
taskControl.DataContrl(pingResult.Ping.ToString() + "ms", pingResult.TimeoutPing.ToString());
|
||||
taskControl.DataContrl(pingResult.Ping.ToString() + "ms", pingResult.TimeoutPing.ToString(), pingResult.Ip, sw.Elapsed);
|
||||
StatusTask.Next();
|
||||
task = Task.Run(StatusTask.Tick);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
task = Task.Run(StatusTask.Tick);
|
||||
|
||||
}
|
||||
|
||||
taskControl.TimeContrl(sw.Elapsed);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return Comp.GetName();
|
||||
}
|
||||
|
||||
public void RebootStop()
|
||||
{
|
||||
StatusTask.Stop();
|
||||
}
|
||||
|
||||
public void RebootReturn()
|
||||
{
|
||||
StatusTask.RebootReturn();
|
||||
}
|
||||
|
||||
public void SetNameStage(string nameStage)
|
||||
|
|
|
|||
|
|
@ -61,7 +61,11 @@
|
|||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="reseter.cs" />
|
||||
<Compile Include="ReseteTask.cs" />
|
||||
<Compile Include="Shutdown.cs" />
|
||||
<Compile Include="StatusReboot.cs" />
|
||||
<Compile Include="StatusRebooting.cs" />
|
||||
<Compile Include="StatusRebootStop.cs" />
|
||||
<Compile Include="StatusRebootSucces.cs" />
|
||||
<Compile Include="StausPreReboot.cs" />
|
||||
<Compile Include="TaskControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Reseter2
|
||||
{
|
||||
class Shutdown
|
||||
{
|
||||
public static void Restart()
|
||||
{
|
||||
StartShutDown("-f -r -t 5");
|
||||
}
|
||||
public static void RestartPC(string param)
|
||||
{
|
||||
StartShutDown("-f -r -t 5" + param);
|
||||
}
|
||||
public static void LogOff()
|
||||
{
|
||||
StartShutDown("-l");
|
||||
}
|
||||
|
||||
public static void Shut()
|
||||
{
|
||||
StartShutDown("-f -s -t 5");
|
||||
}
|
||||
private static void StartShutDown(string param)
|
||||
{
|
||||
ProcessStartInfo proc = new ProcessStartInfo();
|
||||
proc.FileName = "cmd";
|
||||
proc.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
proc.Arguments = "/C shutdown " + param;
|
||||
Process.Start(proc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,40 +3,35 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
|
||||
|
||||
namespace Reseter2
|
||||
{
|
||||
internal class StatusReboot : AStatusTask
|
||||
{
|
||||
private int TimeCount;
|
||||
private PingResult PingResult = new PingResult(0, 0, null);
|
||||
public StatusReboot(ReseterTask reseterTask) : base(reseterTask)
|
||||
{
|
||||
// resetertask.SetNameStage("Перезагрузка");
|
||||
resetertask.SetNameStage("Отправляем команду перезагрузки");
|
||||
//Shutdown.RestartPC(reseterTask.Comp.GetName());
|
||||
}
|
||||
|
||||
public override Task<PingResult> Tick()
|
||||
{
|
||||
|
||||
PingResult result = resetertask.Ping();
|
||||
if (result.Ping == 0)
|
||||
PingResult = resetertask.Ping();
|
||||
return Task.FromResult(PingResult);
|
||||
}
|
||||
public override void Next()
|
||||
{
|
||||
if (PingResult.Ping == 0)
|
||||
{
|
||||
TimeCount++;
|
||||
}
|
||||
if (TimeCount > 2)
|
||||
{
|
||||
resetertask.StatusTask = new StatusPreReboot(resetertask);
|
||||
resetertask.StatusTask = new StatusRebooting(resetertask);
|
||||
}
|
||||
return Task.FromResult(result);
|
||||
// return resetertask.DataContrl(pingResult.Ping.ToString(), pingResult.Ping.ToString());
|
||||
|
||||
}
|
||||
public override void Next()
|
||||
{
|
||||
|
||||
}
|
||||
public override void Stop()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Reseter2
|
||||
{
|
||||
internal class StatusRebootStop : AStatusTask
|
||||
{
|
||||
private PingResult PingResult;
|
||||
public StatusRebootStop(ReseterTask reseterTask) : base(reseterTask)
|
||||
{
|
||||
resetertask.SetNameStage("Перезагрузка остановленна");
|
||||
PingResult = resetertask.Ping();
|
||||
reseterTask.sw.Stop();
|
||||
}
|
||||
|
||||
public override Task<PingResult> Tick()
|
||||
{
|
||||
return Task.FromResult(PingResult);
|
||||
}
|
||||
public override void Next()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Reseter2
|
||||
{
|
||||
internal class StatusRebootSucces : AStatusTask
|
||||
{
|
||||
private PingResult PingResult;
|
||||
public StatusRebootSucces(ReseterTask reseterTask) : base(reseterTask)
|
||||
{
|
||||
resetertask.SetNameStage("Успешно перезагруженно");
|
||||
PingResult = resetertask.Ping();
|
||||
reseterTask.sw.Stop();
|
||||
}
|
||||
|
||||
public override Task<PingResult> Tick()
|
||||
{
|
||||
return Task.FromResult(PingResult);
|
||||
}
|
||||
public override void Next()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Reseter2
|
||||
{
|
||||
internal class StatusRebooting : AStatusTask
|
||||
{
|
||||
private int TimeCount;
|
||||
private PingResult PingResult = new PingResult(0, 0, null);
|
||||
public StatusRebooting(ReseterTask reseterTask) : base(reseterTask)
|
||||
{
|
||||
resetertask.SetNameStage("Перезагрузка");
|
||||
|
||||
}
|
||||
|
||||
public override Task<PingResult> Tick()
|
||||
{
|
||||
PingResult = resetertask.Ping();
|
||||
return Task.FromResult(PingResult);
|
||||
}
|
||||
public override void Next()
|
||||
{
|
||||
if (PingResult.Ping > 0)
|
||||
{
|
||||
TimeCount++;
|
||||
}
|
||||
if (TimeCount > 10)
|
||||
{
|
||||
resetertask.StatusTask = new StatusPreReboot(resetertask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,30 +9,32 @@ namespace Reseter2
|
|||
internal class StatusPreReboot : AStatusTask
|
||||
{
|
||||
private int time;
|
||||
private PingResult PingResult = new PingResult(0,0,null);
|
||||
public StatusPreReboot(ReseterTask reseterTask) : base(reseterTask)
|
||||
{
|
||||
resetertask.SetNameStage("Проверка связи");
|
||||
resetertask.sw.Restart();
|
||||
}
|
||||
|
||||
public override Task<PingResult> Tick()
|
||||
{
|
||||
time++;
|
||||
PingResult result = resetertask.Ping();
|
||||
if (result.Ping > 0)
|
||||
{
|
||||
resetertask.StatusTask = new StatusReboot(resetertask);
|
||||
}
|
||||
return Task.FromResult(result);
|
||||
PingResult = resetertask.Ping();
|
||||
return Task.FromResult(PingResult);
|
||||
// return resetertask.DataContrl(pingResult.Ping.ToString(), pingResult.Ping.ToString());
|
||||
|
||||
}
|
||||
public override void Next()
|
||||
{
|
||||
|
||||
if (PingResult.Ping != null)
|
||||
{
|
||||
if (PingResult.Ping > 0)
|
||||
{
|
||||
resetertask.StatusTask = new StatusReboot(resetertask);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public override void Stop()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -40,6 +40,9 @@
|
|||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.button3 = new System.Windows.Forms.Button();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.lb_time = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
|
@ -65,20 +68,20 @@
|
|||
// lb_name
|
||||
//
|
||||
this.lb_name.AutoSize = true;
|
||||
this.lb_name.Location = new System.Drawing.Point(128, 23);
|
||||
this.lb_name.Location = new System.Drawing.Point(121, 23);
|
||||
this.lb_name.Name = "lb_name";
|
||||
this.lb_name.Size = new System.Drawing.Size(57, 13);
|
||||
this.lb_name.Size = new System.Drawing.Size(64, 13);
|
||||
this.lb_name.TabIndex = 2;
|
||||
this.lb_name.Text = "ma001234";
|
||||
this.lb_name.Text = "-------------------";
|
||||
//
|
||||
// lb_ip
|
||||
//
|
||||
this.lb_ip.AutoSize = true;
|
||||
this.lb_ip.Location = new System.Drawing.Point(97, 36);
|
||||
this.lb_ip.Location = new System.Drawing.Point(90, 36);
|
||||
this.lb_ip.Name = "lb_ip";
|
||||
this.lb_ip.Size = new System.Drawing.Size(70, 13);
|
||||
this.lb_ip.TabIndex = 3;
|
||||
this.lb_ip.Text = "10.3.123.123";
|
||||
this.lb_ip.Text = "---------------------";
|
||||
//
|
||||
// lb_stage
|
||||
//
|
||||
|
|
@ -92,7 +95,7 @@
|
|||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(74, 49);
|
||||
this.label4.Location = new System.Drawing.Point(173, 36);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(28, 13);
|
||||
this.label4.TabIndex = 5;
|
||||
|
|
@ -101,7 +104,7 @@
|
|||
// lb_ping
|
||||
//
|
||||
this.lb_ping.AutoSize = true;
|
||||
this.lb_ping.Location = new System.Drawing.Point(108, 49);
|
||||
this.lb_ping.Location = new System.Drawing.Point(207, 36);
|
||||
this.lb_ping.Name = "lb_ping";
|
||||
this.lb_ping.Size = new System.Drawing.Size(0, 13);
|
||||
this.lb_ping.TabIndex = 6;
|
||||
|
|
@ -109,7 +112,7 @@
|
|||
// Timeout
|
||||
//
|
||||
this.Timeout.AutoSize = true;
|
||||
this.Timeout.Location = new System.Drawing.Point(173, 49);
|
||||
this.Timeout.Location = new System.Drawing.Point(173, 52);
|
||||
this.Timeout.Name = "Timeout";
|
||||
this.Timeout.Size = new System.Drawing.Size(45, 13);
|
||||
this.Timeout.TabIndex = 7;
|
||||
|
|
@ -118,29 +121,30 @@
|
|||
// lb_timeout
|
||||
//
|
||||
this.lb_timeout.AutoSize = true;
|
||||
this.lb_timeout.Location = new System.Drawing.Point(225, 49);
|
||||
this.lb_timeout.Location = new System.Drawing.Point(224, 52);
|
||||
this.lb_timeout.Name = "lb_timeout";
|
||||
this.lb_timeout.Size = new System.Drawing.Size(0, 13);
|
||||
this.lb_timeout.TabIndex = 8;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(267, 13);
|
||||
this.button1.Location = new System.Drawing.Point(270, 5);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(96, 23);
|
||||
this.button1.TabIndex = 9;
|
||||
this.button1.Text = "Остановить";
|
||||
this.button1.Text = "Закрыть";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Location = new System.Drawing.Point(267, 42);
|
||||
this.button2.Location = new System.Drawing.Point(270, 47);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(96, 23);
|
||||
this.button2.TabIndex = 10;
|
||||
this.button2.Text = "Перезапустить";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
|
|
@ -150,11 +154,42 @@
|
|||
this.pictureBox1.TabIndex = 11;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
this.button3.Location = new System.Drawing.Point(270, 26);
|
||||
this.button3.Name = "button3";
|
||||
this.button3.Size = new System.Drawing.Size(96, 23);
|
||||
this.button3.TabIndex = 12;
|
||||
this.button3.Text = "Пауза";
|
||||
this.button3.UseVisualStyleBackColor = true;
|
||||
this.button3.Click += new System.EventHandler(this.button3_Click);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(73, 52);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(46, 13);
|
||||
this.label3.TabIndex = 13;
|
||||
this.label3.Text = "Таймер";
|
||||
//
|
||||
// lb_time
|
||||
//
|
||||
this.lb_time.AutoSize = true;
|
||||
this.lb_time.Location = new System.Drawing.Point(118, 52);
|
||||
this.lb_time.Name = "lb_time";
|
||||
this.lb_time.Size = new System.Drawing.Size(34, 13);
|
||||
this.lb_time.TabIndex = 14;
|
||||
this.lb_time.Text = "00:00";
|
||||
//
|
||||
// TaskControl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.Controls.Add(this.lb_time);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.button3);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.button1);
|
||||
|
|
@ -189,5 +224,8 @@
|
|||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.Button button3;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label lb_time;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
|
@ -23,14 +24,22 @@ namespace Reseter2
|
|||
public void Intit(ReseterTask res)
|
||||
{
|
||||
reseterTask = res;
|
||||
lb_name.Text = reseterTask.GetName();
|
||||
if (reseterTask.GetName() != null) lb_name.Text = reseterTask.GetName();
|
||||
if (reseterTask.Comp.GetIP() != null) lb_ip.Text = reseterTask.Comp.GetIP().ToString();
|
||||
}
|
||||
|
||||
public void DataContrl(string ping, string timeout)
|
||||
public void DataContrl(string ping, string timeout, IPAddress ip, TimeSpan time)
|
||||
{
|
||||
lb_ping.Text = ping;
|
||||
lb_timeout.Text = timeout;
|
||||
if(ip != null)lb_ip.Text = ip.ToString();
|
||||
lb_time.Text = time.ToString(@"mm\:ss");
|
||||
|
||||
}
|
||||
public void TimeContrl(TimeSpan time)
|
||||
{
|
||||
lb_time.Text = time.ToString(@"mm\:ss");
|
||||
|
||||
}
|
||||
public void SetNameStage(string nameStage)
|
||||
{
|
||||
|
|
@ -45,5 +54,15 @@ namespace Reseter2
|
|||
{
|
||||
Reseter.Clear(reseterTask, this);
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
reseterTask.RebootStop();
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
reseterTask.RebootReturn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection.Emit;
|
||||
using System.Runtime.Remoting.Metadata.W3cXsd2001;
|
||||
using System.Text;
|
||||
|
|
@ -21,8 +22,22 @@ namespace Reseter2
|
|||
}
|
||||
public static void AddTask(String name)
|
||||
{
|
||||
CompId compid = new CompId(name);
|
||||
AddTask(compid);
|
||||
try
|
||||
{
|
||||
IPAddress ip = IPAddress.Parse(name);
|
||||
CompId compid = new CompId(ip);
|
||||
AddTask(compid);
|
||||
}
|
||||
catch (FormatException e)
|
||||
{
|
||||
CompId compid = new CompId(name);
|
||||
AddTask(compid);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public static void AddTask(IComp compName)
|
||||
{
|
||||
|
|
@ -34,18 +49,27 @@ namespace Reseter2
|
|||
list_task.Add(reseterTask);
|
||||
}
|
||||
|
||||
public static void Clear(ReseterTask reseterTask, TaskControl taskControl)
|
||||
public static async void Clear(ReseterTask reseterTask, TaskControl taskControl)
|
||||
{
|
||||
flow_conteiner.Controls.Remove(taskControl);
|
||||
list_task.Remove(reseterTask);
|
||||
|
||||
}
|
||||
public static void Tick()
|
||||
public static async void Tick()
|
||||
{
|
||||
foreach (var item in list_task)
|
||||
try
|
||||
{
|
||||
item.Tick();
|
||||
foreach (var item in list_task)
|
||||
{
|
||||
|
||||
item.Tick();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue