|
|
@ -39,7 +39,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
comboBoxCOM0.ItemsSource = ports; |
|
|
|
comboBoxCOM0.Text = Configini.IniReadvalue("SYS", "COM"); |
|
|
|
comboBoxMachine.ItemsSource = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field<string>("name")).ToList();//转换机台
|
|
|
|
|
|
|
|
string[] type_ = { "828", "838" }; |
|
|
|
comboBoxtype.ItemsSource = type_; |
|
|
|
} |
|
|
|
|
|
|
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
|
|
@ -64,6 +65,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
PORT.Text = (Griddata.Columns[4].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
|
|
|
|
comboBoxCOM0.Text = (Griddata.Columns[5].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
|
|
|
|
BAUD.Text = (Griddata.Columns[6].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
|
|
|
|
comboBoxtype.Text = (Griddata.Columns[8].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -71,20 +73,30 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
{ |
|
|
|
if (!string.IsNullOrEmpty(comboBoxMachine.Text)) |
|
|
|
{ |
|
|
|
|
|
|
|
Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数
|
|
|
|
Dictionary<string, object> dr_new = new Dictionary<string, object>();//缓存函数
|
|
|
|
dr_new.Add("Name", comboBoxMachine.Text); |
|
|
|
dr_new.Add("Groups", TextMachineGroup.Text); |
|
|
|
dr_new.Add("IP", IP.Text); |
|
|
|
dr_new.Add("PORT", PORT.Text); |
|
|
|
dr_new.Add("Serial", comboBoxCOM0.Text); |
|
|
|
dr_new.Add("Baud", BAUD.Text); |
|
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
|
|
SQLiteHelpers.Open(); //打开数据库
|
|
|
|
if (SQLiteHelpers.ExecuteDataSet("select * from Machines where name ='" + comboBoxMachine.Text + "'", null).Tables[0].Rows.Count == 0) |
|
|
|
{ |
|
|
|
MainWindowViewModel.Machines.Rows.Add(dr_new); |
|
|
|
DataRow dat_= MainWindowViewModel.Machines.NewRow(); |
|
|
|
dat_.BeginEdit(); |
|
|
|
dat_["Name"] = comboBoxMachine.Text; |
|
|
|
dat_["Groups"] = TextMachineGroup.Text; |
|
|
|
dat_["IP"] = IP.Text; |
|
|
|
dat_["PORT"] = PORT.Text; |
|
|
|
dat_["Serial"] = comboBoxCOM0.Text; |
|
|
|
dat_["Type"] = comboBoxtype.Text; |
|
|
|
dat_["Baud"] = BAUD.Text; |
|
|
|
dat_["ID"] = 999; |
|
|
|
dat_["ERR"] = false; |
|
|
|
dat_["AUTO"] = false; |
|
|
|
dat_["CALL"] = false; |
|
|
|
dat_["LOCK"] = false; |
|
|
|
if (comboBoxtype.Text == "838") |
|
|
|
{ dat_["Desktop"] = true; } |
|
|
|
else { dat_["Desktop"] = false; } |
|
|
|
dat_.EndEdit(); |
|
|
|
MainWindowViewModel.Machines.Rows.Add(dat_); |
|
|
|
DatSteps(MainWindowViewModel.Machines); |
|
|
|
SQLiteHelpers.Delete("Machines", null, null);//
|
|
|
|
for (int x = 0; x < MainWindowViewModel.Machines.Rows.Count; x++) |
|
|
@ -98,20 +110,21 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
Machines_DAT.Add("Groups", MainWindowViewModel.Machines.Rows[x]["Groups"]); |
|
|
|
Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]); |
|
|
|
Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]); |
|
|
|
Machines_DAT.Add("LOCK", "FALSE"); |
|
|
|
Machines_DAT.Add("Type", MainWindowViewModel.Machines.Rows[x]["Type"]); |
|
|
|
SQLiteHelpers.InsertData("Machines", Machines_DAT);//行插入
|
|
|
|
Machines_DAT.Clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
DataRow dr = MainWindowViewModel.Machines.Rows[ID_-1]; |
|
|
|
DataRow dr = MainWindowViewModel.Machines.Rows[ID_]; |
|
|
|
dr.BeginEdit(); |
|
|
|
dr["Name"] = comboBoxMachine.Text; |
|
|
|
dr["Groups"] = TextMachineGroup.Text; |
|
|
|
dr["IP"] = IP.Text; |
|
|
|
dr["PORT"] = PORT.Text; |
|
|
|
dr["Serial"] = comboBoxCOM0.Text; |
|
|
|
dr["Type"] = comboBoxtype.Text; |
|
|
|
dr["Baud"] = BAUD.Text; |
|
|
|
dr.EndEdit(); |
|
|
|
SQLiteHelpers.Delete("Machines", null, null);//
|
|
|
@ -126,6 +139,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
Machines_DAT.Add("Groups", MainWindowViewModel.Machines.Rows[x]["Groups"]); |
|
|
|
Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]); |
|
|
|
Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]); |
|
|
|
Machines_DAT.Add("Type", MainWindowViewModel.Machines.Rows[x]["Type"]); |
|
|
|
Machines_DAT.Add("LOCK", "FALSE"); |
|
|
|
SQLiteHelpers.InsertData("Machines", Machines_DAT);//行插入
|
|
|
|
Machines_DAT.Clear(); |
|
|
@ -153,14 +167,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
MessageBoxResult vr = System.Windows.MessageBox.Show(Properties.Resources.Delete + comboBoxMachine.Text, "SCCM", MessageBoxButton.OKCancel, MessageBoxImage.Question); |
|
|
|
if (vr == MessageBoxResult.OK) // 如果是确定,就执行下面代码
|
|
|
|
{ |
|
|
|
MainWindowViewModel.Machines.Rows.RemoveAt(ID_-1); |
|
|
|
MainWindowViewModel.Machines.Rows.RemoveAt(ID_ - 1); |
|
|
|
DatSteps(MainWindowViewModel.Machines); |
|
|
|
|
|
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
|
|
SQLiteHelpers.Open(); //打开数据库
|
|
|
|
Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数
|
|
|
|
|
|
|
|
SQLiteHelpers.Delete("Machines",null, null);//
|
|
|
|
SQLiteHelpers.Delete("Machines", null, null);//
|
|
|
|
for (int x = 0; x < MainWindowViewModel.Machines.Rows.Count; x++) |
|
|
|
{ |
|
|
|
Machines_DAT.Add("ID", MainWindowViewModel.Machines.Rows[x]["ID"]); |
|
|
@ -196,11 +210,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
{ |
|
|
|
DataRow dr = db.Rows[i]; |
|
|
|
dr.BeginEdit(); |
|
|
|
dr["ID"] = i ; |
|
|
|
dr["ID"] = i; |
|
|
|
dr.EndEdit(); |
|
|
|
} |
|
|
|
} |
|
|
|
private void Test_Click(object sender, RoutedEventArgs e)//测试按钮
|
|
|
|
{ |
|
|
|
if (comboBoxtype.Text == "828") |
|
|
|
{ |
|
|
|
if (!string.IsNullOrEmpty(comboBoxCOM0.Text) && !string.IsNullOrEmpty(BAUD.Text)) |
|
|
|
{ |
|
|
|
textlog.Text = "TEST"; |
|
|
|
textlog.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 255)); |
|
|
|
//------------使用ping类------
|
|
|
|
string host = IP.Text; |
|
|
|
Ping p1 = new Ping(); |
|
|
|
PingReply reply = p1.Send(host); //发送主机名或Ip地址
|
|
|
|
//StringBuilder sbuilder;
|
|
|
|
if (reply.Status == IPStatus.Success) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
textlog.Text = "Link succeed"; |
|
|
|
textlog.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0)); |
|
|
|
} |
|
|
|
catch (Exception) |
|
|
|
{ |
|
|
|
textlog.Text = "Link failed"; |
|
|
|
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 0)); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
textlog.Text = "No links"; |
|
|
|
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0)); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
textlog.Text = "Invalid"; |
|
|
|
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0)); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else if (comboBoxtype.Text == "838") |
|
|
|
{ |
|
|
|
if (!string.IsNullOrEmpty(IP.Text) && !string.IsNullOrEmpty(PORT.Text)) |
|
|
|
{ |
|
|
@ -208,6 +261,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
textlog.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 255)); |
|
|
|
//------------使用ping类------
|
|
|
|
string host = IP.Text; |
|
|
|
try |
|
|
|
{ |
|
|
|
Ping p1 = new Ping(); |
|
|
|
PingReply reply = p1.Send(host); //发送主机名或Ip地址
|
|
|
|
//StringBuilder sbuilder;
|
|
|
@ -240,6 +295,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0)); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception) |
|
|
|
{ |
|
|
|
textlog.Text = "No links"; |
|
|
|
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0)); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (!string.IsNullOrEmpty(comboBoxCOM0.Text)) |
|
|
|
{ |
|
|
|
|
|
|
@ -252,4 +313,5 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|