@@ -81,11 +81,15 @@ namespace BPASmartClient.Message | |||
{ | |||
if (!DPLogInfo.ContainsKey(id)) | |||
DPLogInfo.TryAdd(id, info); | |||
Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}:{info}"); | |||
//ExLogInfo = $"{DateTime.Now.ToString("HH:mm:ss")}:{info} \n\r {ExLogInfo}"; | |||
if (DeviceProcessLogNotify != null) DeviceProcessLogNotify(id,info); | |||
} | |||
else | |||
DPLogInfo[id] = $"{DateTime.Now.ToString("HH:mm:ss")}:{info} \n\r {DPLogInfo[id]}"; | |||
Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}:{info}"); | |||
if (DeviceProcessLogNotify != null) DeviceProcessLogNotify(id, info); | |||
//Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}:{info}"); | |||
// //ExLogInfo = $"{DateTime.Now.ToString("HH:mm:ss")}:{info} \n\r {ExLogInfo}"; | |||
// if (DeviceProcessLogNotify != null) DeviceProcessLogNotify(id,info); | |||
} | |||
#endregion | |||
#region 设备告警日志 | |||
@@ -117,16 +121,13 @@ namespace BPASmartClient.Message | |||
{ | |||
if (DPAlarmInfo.ContainsKey(id)) | |||
{ | |||
string mes=string.Empty; | |||
string mes = string.Empty; | |||
DPAlarmInfo.Remove(id, out mes); | |||
if (AlarmLogNotify != null) AlarmLogNotify(); | |||
} | |||
} | |||
else | |||
DPLogInfo[id] = $"{DateTime.Now.ToString("HH:mm:ss")}:{info} \n\r {DPLogInfo[id]}"; | |||
Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}:{info}"); | |||
if (DeviceProcessLogNotify != null) DeviceProcessLogNotify(info); | |||
} | |||
#endregion | |||
#region 查找设备ID | |||
@@ -24,7 +24,7 @@ namespace BPASmartClient.ViewModel | |||
public class LogViewModel : ObservableObject | |||
{ | |||
public DispatcherTimer dispatcherTimer; | |||
public string ClientId= System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString(); | |||
public string ClientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString(); | |||
private ObservableCollection<LogModel> _LogModels; | |||
public ObservableCollection<LogModel> LogDataGrid | |||
{ | |||
@@ -45,27 +45,27 @@ namespace BPASmartClient.ViewModel | |||
private LogViewModel() | |||
{ | |||
logHelper.Fun_InitLog(System.AppDomain.CurrentDomain.BaseDirectory); | |||
if (LogDataGrid==null) LogDataGrid = new ObservableCollection<LogModel>(); | |||
if (LogDataGrid == null) LogDataGrid = new ObservableCollection<LogModel>(); | |||
//一般日志 | |||
MessageLog.GetInstance.InfoNotify = new Action<string>((s) => | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
LogDataGrid.Insert(0,new LogModel { message = s,type = "Info" }); | |||
LogDataGrid.Insert(0, new LogModel { message = s, type = "Info" }); | |||
logHelper.GetLogConfigInstance().WriteLog(LogLevel.INFO, s); | |||
})); | |||
}); | |||
//设备日志 | |||
MessageLog.GetInstance.DeviceProcessLogNotify = new Action<string,string>((id,s) => | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
LogDataGrid.Insert(0, new LogModel { message = s, type = "DeviceLog" }); | |||
logHelper.GetLogConfigInstance().WriteLog(LogLevel.DEBUG, s); | |||
})); | |||
}); | |||
MessageLog.GetInstance.DeviceProcessLogNotify = new Action<string, string>((id, s) => | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
LogDataGrid.Insert(0, new LogModel { message = s, type = "DeviceLog" }); | |||
logHelper.GetLogConfigInstance().WriteLog(LogLevel.DEBUG, s); | |||
})); | |||
}); | |||
//设备告警日志 | |||
MessageLog.GetInstance.DeviceAlarmLogNotify = new Action<string, string>((id, s) => | |||
@@ -82,7 +82,7 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
LogDataGrid.Insert(0,new LogModel { message = s,type = "Error" }); | |||
LogDataGrid.Insert(0, new LogModel { message = s, type = "Error" }); | |||
logHelper.GetLogConfigInstance().WriteLog(LogLevel.ERROR, s); | |||
DataVClient.GetInstance().HttpAddLog(new LogTable | |||
{ | |||
@@ -94,13 +94,7 @@ namespace BPASmartClient.ViewModel | |||
}); | |||
})); | |||
}); | |||
MessageLog.GetInstance.DeviceProcessLogNotify = new Action<string>((s) => | |||
{ | |||
Application.Current?.Dispatcher.Invoke(new Action(() => | |||
{ | |||
LogDataGrid.Insert(0, new LogModel { message = s, type = "Device" });//设备消息 | |||
})); | |||
}); | |||
ExcelCommand = new RelayCommand(() => | |||
{ | |||
ExcellOrder(); | |||
@@ -113,10 +107,10 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
if (LogDataGrid.Count > 100) | |||
{ | |||
LogDataGrid.RemoveAt(LogDataGrid.Count-1); | |||
LogDataGrid.RemoveAt(LogDataGrid.Count - 1); | |||
} | |||
})); | |||
}; | |||
dispatcherTimer.Interval = TimeSpan.FromSeconds(10); | |||
dispatcherTimer.Start(); | |||
@@ -3,13 +3,13 @@ | |||
<appSettings> | |||
<!--通用配置--> | |||
<!--1:且时且多冰淇淋咖啡机,2:且时且多煮面机,3:海科煮面机测试店铺--> | |||
<add key="ClientId" value="111"/> | |||
<add key="ClientId" value="10"/> | |||
<!--<add key="ApolloUri" value="http://10.2.1.21:28080"/> | |||
<add key="OrderServiceUri" value="http://10.2.1.26:21527/order/"/> | |||
<add key="StockServiceUri" value="http://10.2.1.26:21527/stock/"/>--> | |||
<!--<add key="ApolloUri" value="https://bpa.black-pa.com:28080"/>--> | |||
<add key="ClientId" value="2"/> | |||
<!--<add key="ClientId" value="2"/>--> | |||
<!--开发环境--> | |||
<add key="ApolloUri" value="http://10.2.1.21:28080"/> | |||
@@ -25,16 +25,16 @@ | |||
<add key="StockServiceUri" value="https://witt.black-pa.com/stock/"/> | |||
<add key="DataVServiceUri" value="https://bpa.black-pa.com:21527/datav"/>--> | |||
<!--阿里云上报启动方式:API 或者 LOCAL--> | |||
<!--API :通过客户端ID,调用接口查询“设备连接信息”--> | |||
<!--LOCAL:直接使用下方本地“设备连接信息”--> | |||
<add key="StartupMode" value="API"/> | |||
<add key="ProductKey" value="grgpECHSL7q"/> | |||
<add key="DeviceName" value="qsqd"/> | |||
<add key="DeviceSecret" value="3c0f2390943bff4fece523af22655196"/> | |||
<!--外设配置--> | |||
<add key="COM_Coffee" value="COM3"/> | |||
<!--阿里云上报启动方式:API 或者 LOCAL--> | |||
<!--API :通过客户端ID,调用接口查询“设备连接信息”--> | |||
<!--LOCAL:直接使用下方本地“设备连接信息”--> | |||
<add key="StartupMode" value="API"/> | |||
<add key="ProductKey" value="grgpECHSL7q"/> | |||
<add key="DeviceName" value="qsqd"/> | |||
<add key="DeviceSecret" value="3c0f2390943bff4fece523af22655196"/> | |||
<!--外设配置--> | |||
<add key="COM_Coffee" value="COM3"/> | |||
<add key="BAUD_Coffee" value="115200"/> | |||
<add key="COM_IceCream" value="COM12"/> | |||
<add key="BAUD_IceCream" value="9600"/> | |||