|
@ -26,6 +26,10 @@ using System.Windows.Media.Imaging; |
|
|
using System.Windows.Navigation; |
|
|
using System.Windows.Navigation; |
|
|
using System.Windows.Shapes; |
|
|
using System.Windows.Shapes; |
|
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper; |
|
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper; |
|
|
|
|
|
using System.Windows.Threading; |
|
|
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
|
|
using System.Xml.Linq; |
|
|
|
|
|
using static System.Windows.Forms.AxHost; |
|
|
|
|
|
|
|
|
namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
{ |
|
|
{ |
|
@ -68,6 +72,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
dispenseMacInfo[i].PORT.Text = DispenseMac.AsEnumerable().Select(row => row.Field<int>("PORT")).ElementAt(i).ToString(); |
|
|
dispenseMacInfo[i].PORT.Text = DispenseMac.AsEnumerable().Select(row => row.Field<int>("PORT")).ElementAt(i).ToString(); |
|
|
dispenseMacInfo[i].PASSWD.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("Password")).ElementAt(i); |
|
|
dispenseMacInfo[i].PASSWD.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("Password")).ElementAt(i); |
|
|
dispenseMacInfo[i].type_.Text = DispenseMac.AsEnumerable().Select(row => row.Field<int>("type")).ElementAt(i).ToString(); |
|
|
dispenseMacInfo[i].type_.Text = DispenseMac.AsEnumerable().Select(row => row.Field<int>("type")).ElementAt(i).ToString(); |
|
|
|
|
|
dispenseMacInfo[i].type_N.Text = StatenClassConvert.Convert(DispenseMac.AsEnumerable().Select(row => row.Field<int>("type")).ElementAt(i)); |
|
|
dispenseMacInfo[i].mac.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("name")).ElementAt(i); |
|
|
dispenseMacInfo[i].mac.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("name")).ElementAt(i); |
|
|
dispenseMacInfo[i].macg.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("Groups")).ElementAt(i); |
|
|
dispenseMacInfo[i].macg.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("Groups")).ElementAt(i); |
|
|
dispenseMacInfo[i].state.Text = StatenClassConvert.Convert(x); |
|
|
dispenseMacInfo[i].state.Text = StatenClassConvert.Convert(x); |
|
@ -100,10 +105,79 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
bitmapImage.EndInit(); |
|
|
bitmapImage.EndInit(); |
|
|
dispenseMacInfo[i].IMAGE.Source = bitmapImage; |
|
|
dispenseMacInfo[i].IMAGE.Source = bitmapImage; |
|
|
DispenseMacView.Children.Add(dispenseMacInfo[i]); |
|
|
DispenseMacView.Children.Add(dispenseMacInfo[i]); |
|
|
|
|
|
|
|
|
|
|
|
CountDown(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void CountDown() |
|
|
|
|
|
{ |
|
|
|
|
|
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每10秒调用一次Tick
|
|
|
|
|
|
{ |
|
|
|
|
|
Interval = TimeSpan.FromSeconds(10)//秒
|
|
|
|
|
|
}; |
|
|
|
|
|
timer1s.Tick += Tick_Event_1S; |
|
|
|
|
|
timer1s.Start(); |
|
|
|
|
|
}//时间周期初始化
|
|
|
|
|
|
async void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < DispenseMac.Rows.Count; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
if (await PingTest(dispenseMacInfo[i].IP.Text)) |
|
|
|
|
|
{ |
|
|
|
|
|
DataRow drEmployee = DispenseMac.Select("IP='" + dispenseMacInfo[i].IP.Text + "'").First(); |
|
|
|
|
|
drEmployee.BeginEdit(); |
|
|
|
|
|
drEmployee["State"] = "802"; |
|
|
|
|
|
drEmployee.EndEdit(); |
|
|
|
|
|
drEmployee.AcceptChanges(); |
|
|
|
|
|
drEmployee.ClearErrors(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string x = DispenseMac.AsEnumerable().Select(row => row.Field<string>("State")).ElementAt(i); |
|
|
|
|
|
bool y = DispenseMac.AsEnumerable().Select(row => row.Field<bool>("LOCK")).ElementAt(i); |
|
|
|
|
|
|
|
|
|
|
|
dispenseMacInfo[i].state.Text = StatenClassConvert.Convert(x); |
|
|
|
|
|
dispenseMacInfo[i].WorkingStatus.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("WorkingStatus")).ElementAt(i); |
|
|
|
|
|
if (x == "899") |
|
|
|
|
|
{ |
|
|
|
|
|
dispenseMacInfo[i].state.Background = new SolidColorBrush(Color.FromRgb(255, 0, 0)); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
dispenseMacInfo[i].state.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255)); |
|
|
|
|
|
} |
|
|
|
|
|
if (y) |
|
|
|
|
|
{ |
|
|
|
|
|
dispenseMacInfo[i].mlock.Visibility = Visibility.Visible; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
dispenseMacInfo[i].mlock.Visibility = Visibility.Collapsed; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async Task<bool> PingTest(string ip) |
|
|
|
|
|
{ |
|
|
|
|
|
bool result = false; |
|
|
|
|
|
Ping pingSender = new Ping(); |
|
|
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
PingReply reply = await pingSender.SendPingAsync(ip, 3000); |
|
|
|
|
|
|
|
|
|
|
|
if (reply.Status == IPStatus.Success) |
|
|
|
|
|
{ |
|
|
|
|
|
result = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
catch (PingException ) |
|
|
|
|
|
{ |
|
|
|
|
|
result = false; |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|