|
|
@ -26,6 +26,10 @@ using System.Windows.Media.Imaging; |
|
|
|
using System.Windows.Navigation; |
|
|
|
using System.Windows.Shapes; |
|
|
|
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 |
|
|
|
{ |
|
|
@ -36,13 +40,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
{ |
|
|
|
public DispenseView() |
|
|
|
{ |
|
|
|
InitializeComponent(); |
|
|
|
InitializeComponent(); |
|
|
|
} |
|
|
|
|
|
|
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
|
|
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
|
|
|
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini"); |
|
|
|
DataTable DispenseMac = new DataTable(); |
|
|
|
DataTable DispenseMac = new DataTable(); |
|
|
|
UserControls.DispenseMacInfo[] dispenseMacInfo = new UserControls.DispenseMacInfo[99]; //定义总览信息卡
|
|
|
|
//private string SYS_machines = null;
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e) |
|
|
@ -67,7 +71,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
dispenseMacInfo[i].USER.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("User")).ElementAt(i); |
|
|
|
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].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].macg.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("Groups")).ElementAt(i); |
|
|
|
dispenseMacInfo[i].state.Text = StatenClassConvert.Convert(x); |
|
|
@ -89,21 +94,90 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
dispenseMacInfo[i].mlock.Visibility = Visibility.Collapsed; |
|
|
|
} |
|
|
|
|
|
|
|
//dispenseMacInfo[i].name.Text = Selet_Machines(MainWindowViewModel.Machines, "name", i).ToString();
|
|
|
|
// dispenseMacInfo[i].IMAGE = ;
|
|
|
|
|
|
|
|
//dispenseMacInfo[i].name.Text = Selet_Machines(MainWindowViewModel.Machines, "name", i).ToString();
|
|
|
|
// dispenseMacInfo[i].IMAGE = ;
|
|
|
|
|
|
|
|
MemoryStream memoryStream = new MemoryStream(DispenseMac.AsEnumerable().Select(row => row.Field<byte[]>("DATA")).ElementAt(i)); |
|
|
|
//数据流生成图片显示
|
|
|
|
//数据流生成图片显示
|
|
|
|
BitmapImage bitmapImage = new BitmapImage(); |
|
|
|
bitmapImage.BeginInit(); |
|
|
|
bitmapImage.StreamSource = memoryStream; |
|
|
|
bitmapImage.StreamSource = memoryStream; |
|
|
|
bitmapImage.EndInit(); |
|
|
|
dispenseMacInfo[i].IMAGE.Source = bitmapImage; |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|