Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement
This commit is contained in:
commit
13a2c4ca63
2 files changed
+47
-10
No files matched your search
@@ -47,16 +47,44 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
|
||||
return EasyTask.CompletedTask;
|
||||
};//成功连接到服务器
|
||||
tcpClient.Closing = (client, e) => { return EasyTask.CompletedTask; };//即将从服务器断开连接。此处仅主动断开才有效。
|
||||
tcpClient.Closed = (client, e) => { return EasyTask.CompletedTask; };//从服务器断开连接,当连接不成功时不会触发。
|
||||
tcpClient.Closing = (client, e) =>
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["State"] = "899";
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
drEmployee.ClearErrors();
|
||||
|
||||
return EasyTask.CompletedTask; };//即将从服务器断开连接。此处仅主动断开才有效。
|
||||
tcpClient.Closed = (client, e) =>
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["State"] = "899";
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
drEmployee.ClearErrors();
|
||||
|
||||
return EasyTask.CompletedTask; };//从服务器断开连接,当连接不成功时不会触发。
|
||||
tcpClient.Received = (client, e) =>
|
||||
{
|
||||
//从服务器收到信息。但是一般byteBlock和requestInfo会根据适配器呈现不同的值。
|
||||
var mes = e.ByteBlock.Span.ToString(Encoding.UTF8);
|
||||
string SYSAPI = e.ByteBlock.Span.ToString(Encoding.ASCII).Substring(0, 5);
|
||||
string DAT = e.ByteBlock.Span.ToString(Encoding.ASCII);
|
||||
|
||||
if (SYSAPI == "SC851")
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
// client.SendAsync("SC851" + "[" + MainWindowViewModel.S01 + "]" + MainWindowViewModel.dt_d.ToJsonString());//数字开关信息
|
||||
|
||||
|
||||
}//数字开关表
|
||||
|
||||
|
||||
// tcpClient.Logger.Info($"客户端接收到信息:{mes}");
|
||||
return EasyTask.CompletedTask;
|
||||
};
|
||||
|
||||
@@ -66,25 +66,34 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
{
|
||||
if (!string.IsNullOrEmpty(comboBoxMachine.Text))
|
||||
{
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
SQLiteHelpers.InsertData("Machines", dr_new);
|
||||
}
|
||||
else
|
||||
{
|
||||
SQLiteHelpers.Update("Machines",dr_new,"name='"+comboBoxMachine.Text+"'",null);
|
||||
}
|
||||
MainWindowViewModel.Machines = SQLiteHelpers.ExecuteDataSet("select * from Machines Order by id", null).Tables[0]; //读取表写入缓存
|
||||
SQLiteHelpers.Close();
|
||||
|
||||
|
||||
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
|
||||
comboBoxMachine.Text = null;
|
||||
TextMachineGroup.Text = null;
|
||||
IP.Text = null;
|
||||
PORT.Text = "7789";
|
||||
comboBoxCOM0.Text = null;
|
||||
BAUD.Text = "57600";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user