Browse Source

历史查询功能

master
Administrator 2 months ago
parent
commit
d35420bed1
  1. 41
      UserClass/AsyncTcpClient.cs

41
UserClass/AsyncTcpClient.cs

@ -258,7 +258,7 @@ namespace SunlightAggregationManager.UserClass
data_.Add("Notification", Newtonsoft.Json.JsonConvert.SerializeObject(resultTable));
ret = JsonSerializer.Serialize(data_);
}
if (Command == "InfoMachine")//回复Notification请求的信息
if (Command == "InfoMachine")//回复InfoMachine请求的信息
{
string t_ = deserialized.GetValue("Type").ToString()!;
string? m_ =null, f_ = "*";
@ -295,6 +295,45 @@ namespace SunlightAggregationManager.UserClass
//格式化返回信息
ret = JsonSerializer.Serialize(data_);
}
if (Command == "InfoMachineHistory")//回复InfoMachineHistory请求的信息
{
string t_ = deserialized.GetValue("Type").ToString()!;
string? m_ = null, f_ = "*";
if (deserialized.TryGetValue("MachinName", out var MachinName) && MachinName != null) m_ = MachinName.ToString();
if (deserialized.TryGetValue("Field", out var Field) && Field != null) f_ = Field.ToString();
if (t_ == "80")
{
DataTable resultTable = await MainWindowViewModel.dataBase.ExecuteQueryAsync("SELECT " +
f_ + " FROM [dbo].[DyeSolutionHistory] WHERE DispenseStartTime >'" + DateTime.Now.AddDays(-3)+
"' and DispenseMachine='" + m_ + "'");
data_.Add("Type", "80");
data_.Add("InfoMachine", Newtonsoft.Json.JsonConvert.SerializeObject(resultTable));
}
else if (t_ == "82")
{
DataTable resultTable = await MainWindowViewModel.dataBase.ExecuteQueryAsync("SELECT " +
f_ + " FROM [dbo].[inOutRecords] WHERE Createtime >'" + DateTime.Now.AddDays(-3)+"'");
data_.Add("Type", "82");
data_.Add("InfoMachine", Newtonsoft.Json.JsonConvert.SerializeObject(resultTable));
}
else if (t_ == "90")
{
DataTable resultTable = await MainWindowViewModel.dataBase.ExecuteQueryAsync("SELECT " +
f_ + " FROM [dbo].[DyeSolutionHistory] WHERE DispenseStartTime >'" + DateTime.Now.AddDays(-3) +
"' and DispenseMachine='" + m_ + "'");
data_.Add("Type", "20");
data_.Add("InfoMachine", Newtonsoft.Json.JsonConvert.SerializeObject(resultTable));
}
else
{
data_.Add("InfoMachine", "");
}
//格式化返回信息
ret = JsonSerializer.Serialize(data_);
}
if (Command == "InfoMachinePipes")//回复Notification请求的信息
{
string? m_ = null, f_ = "*";

Loading…
Cancel
Save