日志重写
This commit is contained in:
@@ -31,6 +31,7 @@ namespace JinYuan.ControlCenters
|
|||||||
{
|
{
|
||||||
public partial class ControlCenter
|
public partial class ControlCenter
|
||||||
{
|
{
|
||||||
|
private static LoggerHelp _logger = new LoggerHelp();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 打印日志方法
|
/// 打印日志方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -139,7 +140,7 @@ namespace JinYuan.ControlCenters
|
|||||||
DicStationFunction = new Dictionary<string, dgStationFunction>();
|
DicStationFunction = new Dictionary<string, dgStationFunction>();
|
||||||
|
|
||||||
DicStationFunction.Add("电芯进站", FeedingStation);
|
DicStationFunction.Add("电芯进站", FeedingStation);
|
||||||
//DicStationFunction.Add("NG出站", NGStation);
|
DicStationFunction.Add("NG出站", NGStation);
|
||||||
DicStationFunction.Add("电芯出站", BlankingStation);
|
DicStationFunction.Add("电芯出站", BlankingStation);
|
||||||
|
|
||||||
for (int i = 0; i < CommonMethods.ChatLineCount; i++)
|
for (int i = 0; i < CommonMethods.ChatLineCount; i++)
|
||||||
@@ -262,14 +263,14 @@ namespace JinYuan.ControlCenters
|
|||||||
JYResult<byte[]> resByte = CommonMethods.PlcLink.ReadValue<JYResult<byte[]>>($"{pf.VarList[1].VarAddress}", Data_Type.ArrByte, Convert.ToUInt16(pf.VarList[1].OffsetOrLenght));
|
JYResult<byte[]> resByte = CommonMethods.PlcLink.ReadValue<JYResult<byte[]>>($"{pf.VarList[1].VarAddress}", Data_Type.ArrByte, Convert.ToUInt16(pf.VarList[1].OffsetOrLenght));
|
||||||
sw1.Stop();
|
sw1.Stop();
|
||||||
CommonMethods.AddDataMonitorLog(0, $"{pf.GroupName},耗时:{sw1.Elapsed.TotalMilliseconds}ms");
|
CommonMethods.AddDataMonitorLog(0, $"{pf.GroupName},耗时:{sw1.Elapsed.TotalMilliseconds}ms");
|
||||||
LogHelper.Instance.WriteLog( $"读取工位:{pf.GroupName},启动读取字节共耗时:" + sw1.Elapsed.TotalMilliseconds, "循环读取PLC工位");
|
LoggerHelp.WriteLog("循环读取PLC工位" + $"读取工位:{pf.GroupName},启动读取字节共耗时:" + sw1.Elapsed.TotalMilliseconds);
|
||||||
//置位 PLC-防止重复读取
|
//置位 PLC-防止重复读取
|
||||||
CommonMethods.PlcLink.WriteInt16(pf.VarList[0].VarAddress, 2);//置位,读取进行中的标志
|
CommonMethods.PlcLink.WriteInt16(pf.VarList[0].VarAddress, 2);//置位,读取进行中的标志
|
||||||
|
|
||||||
if (resByte == null)
|
if (resByte == null)
|
||||||
{
|
{
|
||||||
CommonMethods.AddDataMonitorLog(0, $"上料工位:{pf.GroupName},起始地址:{pf.VarList[1].VarAddress},得到空字节数组");
|
CommonMethods.AddDataMonitorLog(0, $"上料工位:{pf.GroupName},起始地址:{pf.VarList[1].VarAddress},得到空字节数组");
|
||||||
LogHelper.Instance.WriteLog( $"读取工位:{pf.GroupName},起始地址:{pf.VarList[1].VarAddress},得到空字节数组", "循环读取PLC上料工位");
|
LoggerHelp.WriteLog("循环读取PLC上料工位"+$"读取工位:{pf.GroupName},起始地址:{pf.VarList[1].VarAddress},得到空字节数组");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -286,14 +287,14 @@ namespace JinYuan.ControlCenters
|
|||||||
// }, null);
|
// }, null);
|
||||||
//}
|
//}
|
||||||
//// private Dictionary<string, dgStationFunction> DicStationFunction;
|
//// private Dictionary<string, dgStationFunction> DicStationFunction;
|
||||||
DicStationFunction[pf.GroupName].BeginInvoke(resByte, pf, null, null);//信息解析
|
DicStationFunction[pf.GroupName].BeginInvoke(resByte, pf, null, null);//信息解析
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
CommonMethods.AddLog(true, ex.Message);
|
CommonMethods.AddLog(true, ex.Message);
|
||||||
LogHelper.Instance.WriteEX(ex);
|
LoggerHelp.WriteEX(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Thread.Sleep(200);
|
Thread.Sleep(200);
|
||||||
@@ -1359,7 +1360,7 @@ namespace JinYuan.ControlCenters
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteEX(ex);
|
LoggerHelp.WriteEX(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1842,7 +1843,7 @@ namespace JinYuan.ControlCenters
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
CommonMethods.AddLog(true, "设备状态" + ex.Message);
|
CommonMethods.AddLog(true, "设备状态" + ex.Message);
|
||||||
LogHelper.Instance.WriteEX(ex);
|
LoggerHelp.WriteEX(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -204,11 +204,13 @@ namespace JinYuan.ControlCenters
|
|||||||
if (bArrays == null)
|
if (bArrays == null)
|
||||||
{
|
{
|
||||||
CommonMethods.PlcLink.WriteInt16(pf.VarList[0].VarAddress, 0);//置位0
|
CommonMethods.PlcLink.WriteInt16(pf.VarList[0].VarAddress, 0);//置位0
|
||||||
CommonMethods.AddLog(false, $"电芯进站PLC有触发信号,但无数据!");
|
CommonMethods.AddLog(false, $"电芯进站PLC有触发信号,但无数据!");//存系统日志
|
||||||
LogHelper.Instance.WriteLog($"电芯进站PLC有触发信号,但无数据!", "Info");
|
LoggerHelp.WriteLog($"电芯进站PLC有触发信号,但无数据!", "Info");
|
||||||
}
|
}
|
||||||
if (bArrays.IsSuccess && bArrays.Content != null)
|
if (bArrays.IsSuccess && bArrays.Content != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
sw2.Restart();
|
sw2.Restart();
|
||||||
//解析数据
|
//解析数据
|
||||||
//1257 3个条码
|
//1257 3个条码
|
||||||
@@ -389,7 +391,7 @@ namespace JinYuan.ControlCenters
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteError($"外观检测进站线程数据解析:{ex}", "SysErrorLog");
|
LoggerHelp.WriteLog($"外观检测进站线程数据解析:{ex}", "SysErrorLog");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -485,7 +487,7 @@ namespace JinYuan.ControlCenters
|
|||||||
{
|
{
|
||||||
JYResult result = CommonMethods.PlcLink.WriteValue("D80", 1, Data_Type.Short);//反馈PLC结果
|
JYResult result = CommonMethods.PlcLink.WriteValue("D80", 1, Data_Type.Short);//反馈PLC结果
|
||||||
CommonMethods.AddDataMonitorLog(1, $"服务器连接失败!解决办法:1、请检查MES网络,2、查看服务器是否正常!!");
|
CommonMethods.AddDataMonitorLog(1, $"服务器连接失败!解决办法:1、请检查MES网络,2、查看服务器是否正常!!");
|
||||||
LogHelper.Instance.WriteError($"服务器连接失败:{ex}", "系统报错");
|
LoggerHelp.WriteLog($"服务器连接失败:{ex}", "系统报错");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -501,13 +503,13 @@ namespace JinYuan.ControlCenters
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteError($"电芯进站数据List为空", "SysErrorLog");
|
LoggerHelp.WriteLog($"电芯进站数据List为空", "SysErrorLog");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteError($"外观检测上料保存处理异常:{ex}", "SysErrorLog");
|
LoggerHelp.WriteLog($"外观检测上料保存处理异常:{ex}", "SysErrorLog");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -522,7 +524,7 @@ namespace JinYuan.ControlCenters
|
|||||||
{
|
{
|
||||||
CommonMethods.PlcLink.WriteInt16(pf.VarList[0].VarAddress, 0);//置位0
|
CommonMethods.PlcLink.WriteInt16(pf.VarList[0].VarAddress, 0);//置位0
|
||||||
CommonMethods.AddLog(false, $"NG出站PLC有触发信号,但无数据!");
|
CommonMethods.AddLog(false, $"NG出站PLC有触发信号,但无数据!");
|
||||||
LogHelper.Instance.WriteLog($"NG出站PLC有触发信号,但无数据!", "SysErrorLog");
|
LoggerHelp.WriteLog($"NG出站PLC有触发信号,但无数据!", "SysErrorLog");
|
||||||
}
|
}
|
||||||
#region 预焊机
|
#region 预焊机
|
||||||
//if (bArrays.IsSuccess && bArrays.Content != null)
|
//if (bArrays.IsSuccess && bArrays.Content != null)
|
||||||
@@ -1637,7 +1639,7 @@ namespace JinYuan.ControlCenters
|
|||||||
{
|
{
|
||||||
CommonMethods.PlcLink.WriteInt16(pf.VarList[0].VarAddress, 0);//置位0
|
CommonMethods.PlcLink.WriteInt16(pf.VarList[0].VarAddress, 0);//置位0
|
||||||
CommonMethods.AddLog(false, $"电芯出站PLC有触发信号,但无数据!");
|
CommonMethods.AddLog(false, $"电芯出站PLC有触发信号,但无数据!");
|
||||||
LogHelper.Instance.WriteLog($"电芯出站PLC有触发信号,但无数据!", "SysErrorLog");
|
LoggerHelp.WriteLog($"电芯出站PLC有触发信号,但无数据!", "SysErrorLog");
|
||||||
}
|
}
|
||||||
if (bArrays.IsSuccess && bArrays.Content != null)
|
if (bArrays.IsSuccess && bArrays.Content != null)
|
||||||
{
|
{
|
||||||
@@ -1911,7 +1913,7 @@ namespace JinYuan.ControlCenters
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteError($"外观检测出站线程数据解析:{ex}", "SysErrorLog");
|
LoggerHelp.WriteLog($"外观检测出站线程数据解析:{ex}", "SysErrorLog");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1942,7 +1944,7 @@ namespace JinYuan.ControlCenters
|
|||||||
}
|
}
|
||||||
JYResult result3 = CommonMethods.PlcLink.WriteValue(pf.VarList[0].VarAddress, 0);//置位0
|
JYResult result3 = CommonMethods.PlcLink.WriteValue(pf.VarList[0].VarAddress, 0);//置位0
|
||||||
CommonMethods.AddDataMonitorLog(0, $"发送信息给PLC:{result1.IsSuccess},{MyRes[0]},{MyRes[1]},{MyRes[2]}");
|
CommonMethods.AddDataMonitorLog(0, $"发送信息给PLC:{result1.IsSuccess},{MyRes[0]},{MyRes[1]},{MyRes[2]}");
|
||||||
LogHelper.Instance.WriteLog($"发送信息给PLC:{result1.IsSuccess},{MyRes[0]},{MyRes[1]},{MyRes[2]}");
|
LoggerHelp.WriteLog($"发送信息给PLC:{result1.IsSuccess},{MyRes[0]},{MyRes[1]},{MyRes[2]}");
|
||||||
|
|
||||||
Task.Run(() => { SendDateMQTT.Instance.EnterandExitSendMessge(1); });
|
Task.Run(() => { SendDateMQTT.Instance.EnterandExitSendMessge(1); });
|
||||||
//数据存储 - 异步处理
|
//数据存储 - 异步处理
|
||||||
@@ -2034,12 +2036,12 @@ namespace JinYuan.ControlCenters
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteError($"电芯出站数据List为空", "SysErrorLog");
|
LoggerHelp.WriteLog($"电芯出站数据List为空", "SysErrorLog");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteError($"电芯出站数据保存异常:{ex}", "SysErrorLog");
|
LoggerHelp.WriteLog($"电芯出站数据保存异常:{ex}", "SysErrorLog");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ namespace JinYuan.ControlCenters
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteEX(ex);
|
LoggerHelp.WriteEX(ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ namespace JinYuan.ControlCenters
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteEX(ex);
|
LoggerHelp.WriteEX(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace JinYuan.ControlCenters
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteEX("调用MES设备报警接口", ex);
|
LoggerHelp.WriteEX("调用MES设备报警接口", ex);
|
||||||
}
|
}
|
||||||
return resJson;
|
return resJson;
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ namespace JinYuan.ControlCenters
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteEX("调用MES设备运行状态接口", ex);
|
LoggerHelp.WriteEX("调用MES设备运行状态接口", ex);
|
||||||
}
|
}
|
||||||
return resJson;
|
return resJson;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,12 @@
|
|||||||
<Reference Include="MySql.Data, Version=8.1.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
<Reference Include="MySql.Data, Version=8.1.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\MySql.Data.8.1.0\lib\net462\MySql.Data.dll</HintPath>
|
<HintPath>..\packages\MySql.Data.8.1.0\lib\net462\MySql.Data.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="NLog, Version=6.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\NLog.6.0.2\lib\net46\NLog.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="NLog.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\NLog.Windows.Forms.6.0.2\lib\net35\NLog.Windows.Forms.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="SqlSugar, Version=5.1.4.94, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="SqlSugar, Version=5.1.4.94, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\SqlSugar.5.1.4.94\lib\SqlSugar.dll</HintPath>
|
<HintPath>..\packages\SqlSugar.5.1.4.94\lib\SqlSugar.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -69,6 +75,7 @@
|
|||||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="System.Diagnostics.DiagnosticSource, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.7.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.7.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.IO.Pipelines, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="System.IO.Pipelines, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\System.IO.Pipelines.7.0.0\lib\net462\System.IO.Pipelines.dll</HintPath>
|
<HintPath>..\packages\System.IO.Pipelines.7.0.0\lib\net462\System.IO.Pipelines.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -99,6 +106,7 @@
|
|||||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Transactions" />
|
<Reference Include="System.Transactions" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace JinYuan.DAL
|
|||||||
/// 数据库连接字符串
|
/// 数据库连接字符串
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string connString = string.Empty;
|
public static string connString = string.Empty;
|
||||||
|
private static LoggerHelp _logger = new LoggerHelp();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据库类型
|
/// 数据库类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -39,7 +39,7 @@ namespace JinYuan.DAL
|
|||||||
db.Ado.CommandTimeOut = 3000;//设置执行语法超时时间
|
db.Ado.CommandTimeOut = 3000;//设置执行语法超时时间
|
||||||
db.Aop.OnLogExecuted = (sql, pars) => //SQL执行完事件
|
db.Aop.OnLogExecuted = (sql, pars) => //SQL执行完事件
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteLog($"执行时间:{db.Ado.SqlExecutionTime.TotalMilliseconds}毫秒 \r\nSQL如下:{sql} \r\n参数:{GetParams(pars)} ", "SQL执行");
|
LoggerHelp.WriteLog($"执行时间:{db.Ado.SqlExecutionTime.TotalMilliseconds}毫秒 \r\nSQL如下:{sql} \r\n参数:{GetParams(pars)} ", "SQL执行");
|
||||||
};
|
};
|
||||||
db.Aop.OnLogExecuting = (sql, pars) => //SQL执行前事件
|
db.Aop.OnLogExecuting = (sql, pars) => //SQL执行前事件
|
||||||
{
|
{
|
||||||
@@ -47,7 +47,7 @@ namespace JinYuan.DAL
|
|||||||
};
|
};
|
||||||
db.Aop.OnError = (exp) =>//执行SQL 错误事件
|
db.Aop.OnError = (exp) =>//执行SQL 错误事件
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteError($"SQL错误:{exp.Message}\r\nSQL如下:{exp.Sql}", "SQL执行");
|
LoggerHelp.WriteLog($"SQL错误:{exp.Message}\r\nSQL如下:{exp.Sql}", "SQL执行");
|
||||||
throw new Exception(exp.Message);
|
throw new Exception(exp.Message);
|
||||||
};
|
};
|
||||||
db.Aop.OnDiffLogEvent = (it) => //可以方便拿到 数据库操作前和操作后的数据变化。
|
db.Aop.OnDiffLogEvent = (it) => //可以方便拿到 数据库操作前和操作后的数据变化。
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using JinYuan.DAL;
|
using JinYuan.DAL;
|
||||||
using JinYuan.DAL.Enums;
|
using JinYuan.DAL.Enums;
|
||||||
using JinYuan.DAL.Models;
|
using JinYuan.DAL.Models;
|
||||||
|
using NLog;
|
||||||
using Org.BouncyCastle.Asn1;
|
using Org.BouncyCastle.Asn1;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
@@ -18,6 +19,8 @@ namespace JinYuan.DAL
|
|||||||
|
|
||||||
public class SQLSugarService : ISugarHepler
|
public class SQLSugarService : ISugarHepler
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public void SetConnectionStr(string connectionStr, SqlSugar.DbType dbType= SqlSugar.DbType.SqlServer)
|
public void SetConnectionStr(string connectionStr, SqlSugar.DbType dbType= SqlSugar.DbType.SqlServer)
|
||||||
{
|
{
|
||||||
SQLSugarHelper.connString = connectionStr;
|
SQLSugarHelper.connString = connectionStr;
|
||||||
@@ -856,7 +859,7 @@ namespace JinYuan.DAL
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
LoggerHelp.WriteInfo("aaa");
|
||||||
throw new Exception(ex.Message);
|
throw new Exception(ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
<package id="K4os.Hash.xxHash" version="1.0.8" targetFramework="net462" />
|
<package id="K4os.Hash.xxHash" version="1.0.8" targetFramework="net462" />
|
||||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
|
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
|
||||||
<package id="MySql.Data" version="8.1.0" targetFramework="net472" />
|
<package id="MySql.Data" version="8.1.0" targetFramework="net472" />
|
||||||
|
<package id="NLog" version="6.0.2" targetFramework="net472" />
|
||||||
|
<package id="NLog.Windows.Forms" version="6.0.2" targetFramework="net472" />
|
||||||
<package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net462" />
|
<package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net462" />
|
||||||
<package id="SqlSugar" version="5.1.4.94" targetFramework="net472" />
|
<package id="SqlSugar" version="5.1.4.94" targetFramework="net472" />
|
||||||
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
|
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace JinYuan.Helper
|
|||||||
{
|
{
|
||||||
bool b = DeleteFile(strPata, 30); //删除该目录下 超过 30天的文件
|
bool b = DeleteFile(strPata, 30); //删除该目录下 超过 30天的文件
|
||||||
if (b)
|
if (b)
|
||||||
LogHelper.Instance.WriteLog("已清除30天内过期日志");
|
LoggerHelp.WriteLog("已清除30天内过期日志");
|
||||||
//24小时清一次
|
//24小时清一次
|
||||||
Thread.Sleep(1000 * 60 * 60 * 24);
|
Thread.Sleep(1000 * 60 * 60 * 24);
|
||||||
}
|
}
|
||||||
@@ -75,14 +75,14 @@ namespace JinYuan.Helper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteLog("文件被占用,无法操作!");
|
LoggerHelp.WriteLog("文件被占用,无法操作!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteLog($"文件被占用,无法操作!{err}");
|
LoggerHelp.WriteLog($"文件被占用,无法操作!{err}");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,9 +47,6 @@
|
|||||||
<Reference Include="ICSharpCode.SharpZipLib, Version=1.3.3.11, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
<Reference Include="ICSharpCode.SharpZipLib, Version=1.3.3.11, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\SharpZipLib.1.3.3\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
|
<HintPath>..\packages\SharpZipLib.1.3.3\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="log4net">
|
|
||||||
<HintPath>..\LargeSquareOne\bin\Debug\log4net.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="MathNet.Numerics, Version=4.15.0.0, Culture=neutral, PublicKeyToken=cd8b63ad3d691a37, processorArchitecture=MSIL">
|
<Reference Include="MathNet.Numerics, Version=4.15.0.0, Culture=neutral, PublicKeyToken=cd8b63ad3d691a37, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\MathNet.Numerics.Signed.4.15.0\lib\net461\MathNet.Numerics.dll</HintPath>
|
<HintPath>..\packages\MathNet.Numerics.Signed.4.15.0\lib\net461\MathNet.Numerics.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -65,6 +62,9 @@
|
|||||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="NLog, Version=6.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\NLog.6.0.2\lib\net46\NLog.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="NPOI.Core, Version=2.6.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
<Reference Include="NPOI.Core, Version=2.6.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\NPOI.2.6.1\lib\netstandard2.0\NPOI.Core.dll</HintPath>
|
<HintPath>..\packages\NPOI.2.6.1\lib\netstandard2.0\NPOI.Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -151,10 +151,9 @@
|
|||||||
<Compile Include="IniConfigHelper.cs" />
|
<Compile Include="IniConfigHelper.cs" />
|
||||||
<Compile Include="IniFileHelper.cs" />
|
<Compile Include="IniFileHelper.cs" />
|
||||||
<Compile Include="JsonHelper.cs" />
|
<Compile Include="JsonHelper.cs" />
|
||||||
<Compile Include="Logger.cs" />
|
<Compile Include="LoggerHelp.cs" />
|
||||||
<Compile Include="PLCAlarmParseHelper.cs" />
|
<Compile Include="PLCAlarmParseHelper.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="LogHelper.cs" />
|
|
||||||
<Compile Include="ScanerHook.cs" />
|
<Compile Include="ScanerHook.cs" />
|
||||||
<Compile Include="SendDateMQTT.cs" />
|
<Compile Include="SendDateMQTT.cs" />
|
||||||
<Compile Include="StreamIOHelper.cs" />
|
<Compile Include="StreamIOHelper.cs" />
|
||||||
|
|||||||
@@ -1,188 +0,0 @@
|
|||||||
using JinYuan.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace JinYuan.Helper
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 日志操作类
|
|
||||||
/// </summary>
|
|
||||||
public class LogHelper
|
|
||||||
{
|
|
||||||
private static object singleLock = new object();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// log日志文件路径
|
|
||||||
/// </summary>
|
|
||||||
public static string logFilePath = string.Empty;
|
|
||||||
|
|
||||||
|
|
||||||
public static LogHelper _instance = null;
|
|
||||||
public static LogHelper Instance
|
|
||||||
{
|
|
||||||
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_instance == null)
|
|
||||||
{
|
|
||||||
lock (singleLock)
|
|
||||||
{
|
|
||||||
if (_instance == null)
|
|
||||||
{
|
|
||||||
_instance = new LogHelper();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 初始化
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="configPath"></param>
|
|
||||||
public void InitLog(string configPath)
|
|
||||||
{
|
|
||||||
logFilePath = configPath;
|
|
||||||
if (!Directory.Exists(logFilePath))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(logFilePath);
|
|
||||||
}
|
|
||||||
//if (!File.Exists(logFilePath))
|
|
||||||
//{
|
|
||||||
// File.Create(logFilePath).Close();
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 写日志文件数据库日志文件
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message">消息</param>
|
|
||||||
public void WriteError(string message)
|
|
||||||
{
|
|
||||||
|
|
||||||
AddLog(message, "Error");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteEX(Exception ex)
|
|
||||||
{
|
|
||||||
AddLog(ex.Message + "\r\n" + ex.InnerException + "\r\n" + ex.StackTrace + "\r\n" + ex.Source, "SysErrorLog");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteEX(string ErrorName,Exception ex)
|
|
||||||
{
|
|
||||||
AddLog(ErrorName+ "\r\n"+ex.Message + "\r\n" + ex.InnerException + "\r\n" + ex.StackTrace + "\r\n" + ex.Source, "SysErrorLog");
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 写日志文件数据库日志文件
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ex">消息</param>
|
|
||||||
/// <param name="direName">日志存储目录名称</param>
|
|
||||||
public void WriteError(Exception ex, string direName)
|
|
||||||
{
|
|
||||||
AddLog(ex.Message + "\r\n" + ex.InnerException + "\r\n" + ex.StackTrace + "\r\n" + ex.Source, direName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// /
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message"></param>
|
|
||||||
/// <param name="direName"></param>
|
|
||||||
public void WriteError(string message, string direName)
|
|
||||||
{
|
|
||||||
AddLog(message, direName);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 写日志文件数据库日志文件
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message">消息</param>
|
|
||||||
public void WriteLog(string message)
|
|
||||||
{
|
|
||||||
|
|
||||||
AddLog(message, "Info");
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 写日志文件数据库日志文件
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message">消息</param>
|
|
||||||
/// <param name="direName">日志存储目录名称</param>
|
|
||||||
public void WriteLog(string message, string direName)
|
|
||||||
{
|
|
||||||
|
|
||||||
AddLog(message, direName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 写日志文件数据库日志文件
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message">消息</param>
|
|
||||||
/// <param name="direName">日志存储目录名称</param>
|
|
||||||
private void AddLog(string message, string direName)
|
|
||||||
{
|
|
||||||
string fileLog = logFilePath;
|
|
||||||
if (fileLog == "")
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var applicationName = direName;
|
|
||||||
//从宿主配置文件中获取日志文件全路径
|
|
||||||
//所有的接口日志文件放在一个目录下面,跟web站点的目录分开
|
|
||||||
//日志文件一天放一个,按日期分开
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(applicationName))
|
|
||||||
{
|
|
||||||
applicationName = "Log";
|
|
||||||
}
|
|
||||||
string logFullPath = fileLog + applicationName;
|
|
||||||
|
|
||||||
if (!Directory.Exists(logFullPath))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(logFullPath);
|
|
||||||
}
|
|
||||||
//只保留30天的日志
|
|
||||||
var deletePath = $@"{logFullPath}\{DateTime.Now.AddDays(-30):yyyyMMddHH}.txt";
|
|
||||||
|
|
||||||
if (File.Exists(deletePath))
|
|
||||||
{
|
|
||||||
File.Delete(deletePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
logFullPath = $@"{logFullPath}\{DateTime.Now:yyyyMMddHH}.txt";
|
|
||||||
if (!File.Exists(logFullPath))
|
|
||||||
{
|
|
||||||
using (var fs = new FileStream(logFullPath, FileMode.Create, FileAccess.Write))
|
|
||||||
{
|
|
||||||
StreamWriter sw = new StreamWriter(fs);
|
|
||||||
sw.Close();
|
|
||||||
fs.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
using (StreamWriter writer = new StreamWriter(logFullPath, true))
|
|
||||||
{
|
|
||||||
writer.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
||||||
writer.WriteLine(message);
|
|
||||||
writer.WriteLine(Environment.NewLine);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// ignored
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
|
|
||||||
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", ConfigFileExtension = "config", Watch = true)]
|
|
||||||
public class Logger
|
|
||||||
{
|
|
||||||
private static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("loginfo");
|
|
||||||
private static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror");
|
|
||||||
private static readonly log4net.ILog logmqtt = log4net.LogManager.GetLogger("logmqtt");
|
|
||||||
|
|
||||||
public static void WriteInfo(string info)
|
|
||||||
{
|
|
||||||
Console.WriteLine(info);
|
|
||||||
if (loginfo.IsInfoEnabled)
|
|
||||||
{
|
|
||||||
loginfo.Info(info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void WriteMqtt(string info)
|
|
||||||
{
|
|
||||||
Console.WriteLine(info);
|
|
||||||
if (logmqtt.IsInfoEnabled)
|
|
||||||
{
|
|
||||||
logmqtt.Info(info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void WriteError(string error)
|
|
||||||
{
|
|
||||||
Console.WriteLine(error);
|
|
||||||
if (logerror.IsErrorEnabled)
|
|
||||||
{
|
|
||||||
logerror.Error(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void WriteError(string info, Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine(info);
|
|
||||||
if (logerror.IsErrorEnabled)
|
|
||||||
{
|
|
||||||
logerror.Error(info, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
using NLog;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
public class LoggerHelp
|
||||||
|
{
|
||||||
|
private static readonly NLog.Logger loginfo = LogManager.GetLogger("loginfo");
|
||||||
|
private static readonly NLog.Logger logerror = LogManager.GetLogger("logerror");
|
||||||
|
private static readonly NLog.Logger logmqtt = LogManager.GetLogger("logmqtt");
|
||||||
|
|
||||||
|
private static readonly NLog.Logger logsInfo = LogManager.GetLogger("logsInfo");
|
||||||
|
private static readonly NLog.Logger logsMEStIME = LogManager.GetLogger("logsMEStIME");
|
||||||
|
private static readonly NLog.Logger logsSql = LogManager.GetLogger("logsSql");
|
||||||
|
private static readonly NLog.Logger logsSysErrorLog = LogManager.GetLogger("logsSysErrorLog");
|
||||||
|
private static readonly NLog.Logger logsSysErrorLogcn = LogManager.GetLogger("logsSysErrorLogcn");
|
||||||
|
|
||||||
|
|
||||||
|
public static void WriteInfo(string info) => loginfo.Info(info);
|
||||||
|
|
||||||
|
|
||||||
|
public static void WriteMqtt(string info) => logmqtt.Info(info);
|
||||||
|
|
||||||
|
public static void WriteError(string error) => logerror.Info(error);
|
||||||
|
|
||||||
|
public static void WriteError(string info, Exception ex) => logerror.Error(info, ex);
|
||||||
|
|
||||||
|
|
||||||
|
public static void WriteEX(Exception ex) => logsSysErrorLog.Error(ex.Message + "\r\n" + ex.InnerException + "\r\n" + ex.StackTrace + "\r\n" + ex.Source, "SysErrorLog");
|
||||||
|
|
||||||
|
public static void WriteEX(string ErrorName, Exception ex)
|
||||||
|
{
|
||||||
|
logsSysErrorLog.Error(ErrorName + "\r\n" + ex.Message + "\r\n" + ex.InnerException + "\r\n" + ex.StackTrace + "\r\n" + ex.Source, "SysErrorLog");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 写日志文件数据库日志文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">消息</param>
|
||||||
|
public static void WriteLog(string message)
|
||||||
|
{
|
||||||
|
// logsInfo.IsInfoEnabled = true;
|
||||||
|
logsInfo.Info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 写日志文件数据库日志文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">消息</param>
|
||||||
|
/// <param name="direName">日志存储目录名称</param>
|
||||||
|
public static void WriteLog(string message, string direName)
|
||||||
|
{
|
||||||
|
switch (direName)
|
||||||
|
{
|
||||||
|
case "Info":
|
||||||
|
logsInfo.Info(message, "Info");
|
||||||
|
break;
|
||||||
|
case "SysErrorLog":
|
||||||
|
logsSysErrorLog.Info(message, "SysErrorLog");
|
||||||
|
break;
|
||||||
|
case "SQL执行":
|
||||||
|
logsSql.Info(message);
|
||||||
|
break;
|
||||||
|
case "MESTime":
|
||||||
|
logsMEStIME.Info(message, "MESTime");
|
||||||
|
break;
|
||||||
|
case "系统报错":
|
||||||
|
logsSysErrorLogcn.Info(message, "系统报错");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ namespace JinYuan.Helper
|
|||||||
}
|
}
|
||||||
catch (Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
Logger.WriteError($"发送进出站数据错误,{err.Message}",err);
|
LoggerHelp.WriteError($"发送进出站数据错误,{err.Message}",err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -144,7 +144,7 @@ namespace JinYuan.Helper
|
|||||||
}
|
}
|
||||||
catch (Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
Logger.WriteError($"发送采集项数据错误,{err.Message}",err);
|
LoggerHelp.WriteError($"发送采集项数据错误,{err.Message}",err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ namespace JinYuan.Helper
|
|||||||
{
|
{
|
||||||
if (mqttClient != null)
|
if (mqttClient != null)
|
||||||
{
|
{
|
||||||
Logger.WriteMqtt("MQTT 服务器关闭失败");
|
LoggerHelp.WriteMqtt("MQTT 服务器关闭失败");
|
||||||
mqttClient.ConnectClose();
|
mqttClient.ConnectClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,16 +177,16 @@ namespace JinYuan.Helper
|
|||||||
OperateResult connect = mqttClient.ConnectServer();
|
OperateResult connect = mqttClient.ConnectServer();
|
||||||
if (connect.IsSuccess)
|
if (connect.IsSuccess)
|
||||||
{
|
{
|
||||||
Logger.WriteMqtt("MQTT 连接服务器成功");
|
LoggerHelp.WriteMqtt("MQTT 连接服务器成功");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger.WriteMqtt("MQTT 无法连接到服务器");
|
LoggerHelp.WriteMqtt("MQTT 无法连接到服务器");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
Logger.WriteError($"MQTT 无法连接到服务器: {err.Message}");
|
LoggerHelp.WriteError($"MQTT 无法连接到服务器: {err.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -209,16 +209,16 @@ namespace JinYuan.Helper
|
|||||||
});
|
});
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
Logger.WriteMqtt($"发送消息到主题 [{topic}]: {Message}");
|
LoggerHelp.WriteMqtt($"发送消息到主题 [{topic}]: {Message}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger.WriteMqtt($"发送消息到主题 [{topic}] 失败: {result.Message}");
|
LoggerHelp.WriteMqtt($"发送消息到主题 [{topic}] 失败: {result.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
Logger.WriteError($"MQTT 无法连接到服务器: {err.Message}");
|
LoggerHelp.WriteError($"MQTT 无法连接到服务器: {err.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,22 +234,22 @@ namespace JinYuan.Helper
|
|||||||
OperateResult Result = mqttClient.SubscribeMessage(Topic); // 订阅A的主题
|
OperateResult Result = mqttClient.SubscribeMessage(Topic); // 订阅A的主题
|
||||||
if (Result.IsSuccess)
|
if (Result.IsSuccess)
|
||||||
{
|
{
|
||||||
Logger.WriteMqtt($"订阅成功[{Topic}]");
|
LoggerHelp.WriteMqtt($"订阅成功[{Topic}]");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger.WriteMqtt($"订阅失败[{Topic}]");
|
LoggerHelp.WriteMqtt($"订阅失败[{Topic}]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
Logger.WriteError($"订阅失败[{err.Message}]");
|
LoggerHelp.WriteError($"订阅失败[{err.Message}]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MqttClient_OnMqttMessageReceived(MqttClient client, MqttApplicationMessage message)
|
private static void MqttClient_OnMqttMessageReceived(MqttClient client, MqttApplicationMessage message)
|
||||||
{
|
{
|
||||||
Logger.WriteMqtt($"收到服务器信息[{message.ToString()}]");
|
LoggerHelp.WriteMqtt($"收到服务器信息[{message.ToString()}]");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -284,7 +284,7 @@ namespace JinYuan.Helper
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.WriteError($"方法:上传MQTTServer数据,上传失败: {ex.Message}", ex);
|
LoggerHelp.WriteError($"方法:上传MQTTServer数据,上传失败: {ex.Message}", ex);
|
||||||
}
|
}
|
||||||
return messgeJson;
|
return messgeJson;
|
||||||
}
|
}
|
||||||
@@ -351,7 +351,7 @@ namespace JinYuan.Helper
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.WriteError($"生成Json数据失败: {ex.Message}", ex);
|
LoggerHelp.WriteError($"生成Json数据失败: {ex.Message}", ex);
|
||||||
}
|
}
|
||||||
return messgejson;
|
return messgejson;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<package id="Microsoft.CSharp" version="4.3.0" targetFramework="net472" />
|
<package id="Microsoft.CSharp" version="4.3.0" targetFramework="net472" />
|
||||||
<package id="Microsoft.IO.RecyclableMemoryStream" version="2.3.2" targetFramework="net472" />
|
<package id="Microsoft.IO.RecyclableMemoryStream" version="2.3.2" targetFramework="net472" />
|
||||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
||||||
|
<package id="NLog" version="6.0.2" targetFramework="net472" />
|
||||||
<package id="NPOI" version="2.6.1" targetFramework="net472" />
|
<package id="NPOI" version="2.6.1" targetFramework="net472" />
|
||||||
<package id="SharpZipLib" version="1.3.3" targetFramework="net472" />
|
<package id="SharpZipLib" version="1.3.3" targetFramework="net472" />
|
||||||
<package id="SixLabors.Fonts" version="1.0.0" targetFramework="net472" />
|
<package id="SixLabors.Fonts" version="1.0.0" targetFramework="net472" />
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ namespace JinYuan.MES
|
|||||||
{
|
{
|
||||||
public class MesDataProcess : IMes
|
public class MesDataProcess : IMes
|
||||||
{
|
{
|
||||||
|
private static LoggerHelp _logger = new LoggerHelp();
|
||||||
|
|
||||||
#region 1、登录验证
|
#region 1、登录验证
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 登录MES验证
|
/// 登录MES验证
|
||||||
@@ -80,7 +82,7 @@ namespace JinYuan.MES
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
resJson = $"调用员工权限校验接口发生异常:{ex.Message}";
|
resJson = $"调用员工权限校验接口发生异常:{ex.Message}";
|
||||||
LogHelper.Instance.WriteEX("调用员工权限校验接口", ex);
|
LoggerHelp.WriteEX("调用员工权限校验接口", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -145,9 +147,10 @@ namespace JinYuan.MES
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
resJson = $"设备参数设定值请求接口发生异常:{ex.Message}";
|
resJson = $"设备参数设定值请求接口发生异常:{ex.Message}";
|
||||||
LogHelper.Instance.WriteEX("设备参数设定值请求接口", ex);
|
LoggerHelp.WriteEX("设备参数设定值请求接口", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -207,7 +210,7 @@ namespace JinYuan.MES
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
resJson = $"参数设定值变更接口发生异常:{ex.Message}";
|
resJson = $"参数设定值变更接口发生异常:{ex.Message}";
|
||||||
LogHelper.Instance.WriteEX("参数设定值变更接口", ex);
|
LoggerHelp.WriteEX("参数设定值变更接口", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -262,7 +265,7 @@ namespace JinYuan.MES
|
|||||||
long outTime = sw.ElapsedMilliseconds;
|
long outTime = sw.ElapsedMilliseconds;
|
||||||
if (outTime > 1000)
|
if (outTime > 1000)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteLog($"预焊进站PC<=>MES上传耗时:{outTime}ms,电芯码:{BarCode}", "MESTime");
|
LoggerHelp.WriteLog($"预焊进站PC<=>MES上传耗时:{outTime}ms,电芯码:{BarCode}", "MESTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(result))
|
if (string.IsNullOrEmpty(result))
|
||||||
@@ -296,7 +299,7 @@ namespace JinYuan.MES
|
|||||||
Mesage = "调用进站接口超时或MES无返回信息!";
|
Mesage = "调用进站接口超时或MES无返回信息!";
|
||||||
mesResType = MesResType.B;
|
mesResType = MesResType.B;
|
||||||
resJson = $"产品进站信息(组装)接口发生异常:{ex.Message}";
|
resJson = $"产品进站信息(组装)接口发生异常:{ex.Message}";
|
||||||
LogHelper.Instance.WriteEX("产品进站信息(组装)接口", ex);
|
LoggerHelp.WriteEX("产品进站信息(组装)接口", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -353,7 +356,7 @@ namespace JinYuan.MES
|
|||||||
long outTime = sw.ElapsedMilliseconds;
|
long outTime = sw.ElapsedMilliseconds;
|
||||||
if (outTime > 1000)
|
if (outTime > 1000)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteLog($"钢壳进站PC<=>MES上传耗时:{outTime}ms,钢壳码:{BarCode}", "MESTime");
|
LoggerHelp.WriteLog($"钢壳进站PC<=>MES上传耗时:{outTime}ms,钢壳码:{BarCode}", "MESTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(result))
|
if (string.IsNullOrEmpty(result))
|
||||||
@@ -383,7 +386,7 @@ namespace JinYuan.MES
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
resJson = $"产品进站信息(组装)接口发生异常:{ex.Message}";
|
resJson = $"产品进站信息(组装)接口发生异常:{ex.Message}";
|
||||||
LogHelper.Instance.WriteEX("产品进站信息(组装)接口", ex);
|
LoggerHelp.WriteEX("产品进站信息(组装)接口", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -440,7 +443,7 @@ namespace JinYuan.MES
|
|||||||
long outTime = sw.ElapsedMilliseconds;
|
long outTime = sw.ElapsedMilliseconds;
|
||||||
if (outTime > 1000)
|
if (outTime > 1000)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteLog($"预焊进站PC<=>MES上传耗时:{outTime}ms,电芯码:{listBar[0]},{listBar[1]},{listBar[2]},{listBar[3]}", "MESTime");
|
LoggerHelp.WriteLog($"预焊进站PC<=>MES上传耗时:{outTime}ms,电芯码:{listBar[0]},{listBar[1]},{listBar[2]},{listBar[3]}", "MESTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(result))
|
if (string.IsNullOrEmpty(result))
|
||||||
@@ -475,7 +478,7 @@ namespace JinYuan.MES
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
resJson = $"产品进站信息(组装)接口发生异常:{ex.Message}";
|
resJson = $"产品进站信息(组装)接口发生异常:{ex.Message}";
|
||||||
LogHelper.Instance.WriteEX("产品进站信息(组装)接口", ex);
|
LoggerHelp.WriteEX("产品进站信息(组装)接口", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -555,7 +558,7 @@ namespace JinYuan.MES
|
|||||||
long outTime = sw.ElapsedMilliseconds;
|
long outTime = sw.ElapsedMilliseconds;
|
||||||
if (outTime > 1000)
|
if (outTime > 1000)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteLog($"钢壳进出站PC<=>MES上传耗时:{outTime}ms,钢壳码:{m.CSBYHCODEA}", "MESTime");
|
LoggerHelp.WriteLog($"钢壳进出站PC<=>MES上传耗时:{outTime}ms,钢壳码:{m.CSBYHCODEA}", "MESTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(result))
|
if (string.IsNullOrEmpty(result))
|
||||||
@@ -584,7 +587,7 @@ namespace JinYuan.MES
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
resJson = $"产品出站信息(组装)接口发生异常:{ex.Message}";
|
resJson = $"产品出站信息(组装)接口发生异常:{ex.Message}";
|
||||||
LogHelper.Instance.WriteEX("产品出站信息(组装)接口", ex);
|
LoggerHelp.WriteEX("产品出站信息(组装)接口", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -665,7 +668,7 @@ namespace JinYuan.MES
|
|||||||
long outTime = sw.ElapsedMilliseconds;
|
long outTime = sw.ElapsedMilliseconds;
|
||||||
if (outTime > 1000)
|
if (outTime > 1000)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteLog($"钢壳进出站PC<=>MES上传耗时:{outTime}ms,钢壳码:{m.CSBYHCODEA}", "MESTime");
|
LoggerHelp.WriteLog($"钢壳进出站PC<=>MES上传耗时:{outTime}ms,钢壳码:{m.CSBYHCODEA}", "MESTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(result))
|
if (string.IsNullOrEmpty(result))
|
||||||
@@ -694,7 +697,7 @@ namespace JinYuan.MES
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
resJson = $"产品进出站一体信息(组装)接口发生异常:{ex.Message}";
|
resJson = $"产品进出站一体信息(组装)接口发生异常:{ex.Message}";
|
||||||
LogHelper.Instance.WriteEX("产品进出站一体信息(组装)接口", ex);
|
LoggerHelp.WriteEX("产品进出站一体信息(组装)接口", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -785,7 +788,7 @@ namespace JinYuan.MES
|
|||||||
long outTime = sw.ElapsedMilliseconds;
|
long outTime = sw.ElapsedMilliseconds;
|
||||||
if (outTime > 1000)
|
if (outTime > 1000)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteLog($"外观检出站PC<=>MES上传耗时:{outTime}ms,电芯码:{listBar.CSBYHCODEA}", "MESTime");
|
LoggerHelp.WriteLog($"预焊出站PC<=>MES上传耗时:{outTime}ms,电芯码:{listBar.CSBYHCODEA}", "MESTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(result))
|
if (string.IsNullOrEmpty(result))
|
||||||
@@ -816,7 +819,7 @@ namespace JinYuan.MES
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
resJson = $"产品出站信息(组装)接口发生异常:{ex.Message}";
|
resJson = $"产品出站信息(组装)接口发生异常:{ex.Message}";
|
||||||
LogHelper.Instance.WriteEX("产品出站信息(组装)接口", ex);
|
LoggerHelp.WriteEX("产品出站信息(组装)接口", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -2864,7 +2867,7 @@ namespace JinYuan.MES
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
resJson = $"设备运行状态接口发生异常:{ex.Message}";
|
resJson = $"设备运行状态接口发生异常:{ex.Message}";
|
||||||
LogHelper.Instance.WriteEX("设备运行状态接口", ex);
|
LoggerHelp.WriteEX("设备运行状态接口", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -2933,7 +2936,7 @@ namespace JinYuan.MES
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
resJson = $"调用设备报警信息接口发生异常:{ex.Message}";
|
resJson = $"调用设备报警信息接口发生异常:{ex.Message}";
|
||||||
LogHelper.Instance.WriteEX("调用设备报警信息接口", ex);
|
LoggerHelp.WriteEX("调用设备报警信息接口", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -2976,7 +2979,7 @@ namespace JinYuan.MES
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
resJson = $"调用设备能耗信息接口:{ex.Message}";
|
resJson = $"调用设备能耗信息接口:{ex.Message}";
|
||||||
LogHelper.Instance.WriteEX("调用设备能耗信息接口", ex);
|
LoggerHelp.WriteEX("调用设备能耗信息接口", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -3028,7 +3031,7 @@ namespace JinYuan.MES
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
resJson = $"调用风速接口:{ex.Message}";
|
resJson = $"调用风速接口:{ex.Message}";
|
||||||
LogHelper.Instance.WriteEX("调用风速接口", ex);
|
LoggerHelp.WriteEX("调用风速接口", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using JinYuan.Helper;
|
using JinYuan.Helper;
|
||||||
using JinYuan.Models;
|
using JinYuan.Models;
|
||||||
using JinYuan.VirtualDataLibrary;
|
using JinYuan.VirtualDataLibrary;
|
||||||
|
using PLCCommunication;
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
@@ -38,20 +39,21 @@ namespace LargeSquareOne
|
|||||||
this.dgv_Log.Rows[rowCount].Cells[2].Value = info;
|
this.dgv_Log.Rows[rowCount].Cells[2].Value = info;
|
||||||
// 设置最新行为活动行 (当前行)
|
// 设置最新行为活动行 (当前行)
|
||||||
this.dgv_Log.CurrentCell = this.dgv_Log.Rows[this.dgv_Log.Rows.Count - 1].Cells[0];
|
this.dgv_Log.CurrentCell = this.dgv_Log.Rows[this.dgv_Log.Rows.Count - 1].Cells[0];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
var model = new SysLog()
|
||||||
//存储到数据库
|
|
||||||
CommonMethods.db.AddReturnBool(new SysLog()
|
|
||||||
{
|
{
|
||||||
InsertTime = CurrentTime,
|
InsertTime = CurrentTime,
|
||||||
LogType = "系统日志",
|
LogType = "系统日志",
|
||||||
Note = info,
|
Note = info,
|
||||||
AlarmType = isError ? "错误" : "信息",
|
AlarmType = isError ? "错误" : "信息",
|
||||||
Operater = CommonMethods.currentAdmin.LoginName
|
Operater = CommonMethods.currentAdmin.LoginName
|
||||||
});
|
};
|
||||||
|
//存储到数据库
|
||||||
|
var b = CommonMethods.db.AddReturnBool(model);
|
||||||
|
if (!b)
|
||||||
|
{
|
||||||
|
LoggerHelp.WriteError($"数据库记录失败. 表:SysLog,内容:{model.ToJsonString()}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ namespace LargeSquareOne
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
||||||
LogHelper.Instance.WriteEX(ex);
|
LoggerHelp.WriteEX(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ namespace LargeSquareOne
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
||||||
LogHelper.Instance.WriteEX("获取参数失败", ex);
|
LoggerHelp.WriteEX("获取参数失败", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,7 +331,7 @@ namespace LargeSquareOne
|
|||||||
{
|
{
|
||||||
strErr = "取消变更,采用本地参数配置";
|
strErr = "取消变更,采用本地参数配置";
|
||||||
}
|
}
|
||||||
LogHelper.Instance.WriteLog(strErr);
|
LoggerHelp.WriteLog(strErr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -341,7 +341,7 @@ namespace LargeSquareOne
|
|||||||
{
|
{
|
||||||
strErr = "获取参数失败" + ex.Message;
|
strErr = "获取参数失败" + ex.Message;
|
||||||
|
|
||||||
LogHelper.Instance.WriteEX("获取参数失败", ex);
|
LoggerHelp.WriteEX("获取参数失败", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -489,7 +489,7 @@ namespace LargeSquareOne
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CommonMethods.AddDataMonitorLog(1, "MES参数设置成功");
|
CommonMethods.AddDataMonitorLog(1, "MES参数设置成功");
|
||||||
LogHelper.Instance.WriteLog("MES参数设置成功");
|
LoggerHelp.WriteLog("MES参数设置成功");
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ namespace LargeSquareOne
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteEX(ex);
|
LoggerHelp.WriteEX(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -998,7 +998,7 @@ namespace LargeSquareOne
|
|||||||
private void LoginLocalOut()
|
private void LoginLocalOut()
|
||||||
{
|
{
|
||||||
CommonMethods.AddOPLog(false, $"退出成功,退出用户:{CommonMethods.currentAdmin?.LoginName},权限:{CommonMethods.currentAdmin?.LoginLevel}");
|
CommonMethods.AddOPLog(false, $"退出成功,退出用户:{CommonMethods.currentAdmin?.LoginName},权限:{CommonMethods.currentAdmin?.LoginLevel}");
|
||||||
LogHelper.Instance.WriteLog($"用户:" + CommonMethods.currentAdmin?.LoginName + "-退出");
|
LoggerHelp.WriteLog($"用户:" + CommonMethods.currentAdmin?.LoginName + "-退出");
|
||||||
CommonMethods.LoginOut = true;
|
CommonMethods.LoginOut = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,12 +221,12 @@ namespace LargeSquareOne
|
|||||||
{
|
{
|
||||||
if (ex.Message.Contains("重复键"))
|
if (ex.Message.Contains("重复键"))
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteEX(ex);
|
LoggerHelp.WriteEX(ex);
|
||||||
new FrmMsgBoxOutWithAck(3, "添加失败:已存在改型号,重复新增!", "添加型号").Show();
|
new FrmMsgBoxOutWithAck(3, "添加失败:已存在改型号,重复新增!", "添加型号").Show();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteEX(ex);
|
LoggerHelp.WriteEX(ex);
|
||||||
new FrmMsgBoxOutWithAck(3, $"添加失败:{ex.Message}", "添加型号").Show();
|
new FrmMsgBoxOutWithAck(3, $"添加失败:{ex.Message}", "添加型号").Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -402,12 +402,12 @@ namespace LargeSquareOne
|
|||||||
{
|
{
|
||||||
if (ex.Message.Contains("重复键"))
|
if (ex.Message.Contains("重复键"))
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteEX(ex);
|
LoggerHelp.WriteEX(ex);
|
||||||
new FrmMsgBoxOutWithAck(3, "添加失败:已存在该挑战件条码,重复新增!", "添加添加挑战件条码").Show();
|
new FrmMsgBoxOutWithAck(3, "添加失败:已存在该挑战件条码,重复新增!", "添加添加挑战件条码").Show();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogHelper.Instance.WriteEX(ex);
|
LoggerHelp.WriteEX(ex);
|
||||||
new FrmMsgBoxOutWithAck(3, $"添加失败:{ex.Message}", "添加添加挑战件条码").Show();
|
new FrmMsgBoxOutWithAck(3, $"添加失败:{ex.Message}", "添加添加挑战件条码").Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -93,10 +93,6 @@
|
|||||||
<Reference Include="K4os.Hash.xxHash, Version=1.0.8.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
|
<Reference Include="K4os.Hash.xxHash, Version=1.0.8.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\K4os.Hash.xxHash.1.0.8\lib\net462\K4os.Hash.xxHash.dll</HintPath>
|
<HintPath>..\packages\K4os.Hash.xxHash.1.0.8\lib\net462\K4os.Hash.xxHash.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="log4net, Version=3.0.0.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
|
||||||
<SpecificVersion>False</SpecificVersion>
|
|
||||||
<HintPath>bin\Debug\log4net.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="MathNet.Numerics, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="MathNet.Numerics, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\MathNet.Numerics.5.0.0\lib\net461\MathNet.Numerics.dll</HintPath>
|
<HintPath>..\packages\MathNet.Numerics.5.0.0\lib\net461\MathNet.Numerics.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -115,6 +111,12 @@
|
|||||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="NLog, Version=6.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\NLog.6.0.2\lib\net46\NLog.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="NLog.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\NLog.Windows.Forms.6.0.2\lib\net35\NLog.Windows.Forms.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="PLCCommunication, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
|
<Reference Include="PLCCommunication, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
|
||||||
<Reference Include="PresentationCore" />
|
<Reference Include="PresentationCore" />
|
||||||
<Reference Include="PresentationFramework" />
|
<Reference Include="PresentationFramework" />
|
||||||
@@ -417,6 +419,9 @@
|
|||||||
<None Include="Config\Device.ini" />
|
<None Include="Config\Device.ini" />
|
||||||
<None Include="Config\Group.xlsx" />
|
<None Include="Config\Group.xlsx" />
|
||||||
<None Include="Config\Variable.xlsx" />
|
<None Include="Config\Variable.xlsx" />
|
||||||
|
<Content Include="NLog.config">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
@@ -455,6 +460,7 @@
|
|||||||
<None Include="Resources\数据查询.png" />
|
<None Include="Resources\数据查询.png" />
|
||||||
<None Include="Resources\资源 6.png" />
|
<None Include="Resources\资源 6.png" />
|
||||||
<None Include="Resources\订单查询.png" />
|
<None Include="Resources\订单查询.png" />
|
||||||
|
<Content Include="TextFile1.txt" />
|
||||||
<Content Include="电池.ico" />
|
<Content Include="电池.ico" />
|
||||||
<None Include="Resources\25_密码.png" />
|
<None Include="Resources\25_密码.png" />
|
||||||
<None Include="Resources\Exit1.png" />
|
<None Include="Resources\Exit1.png" />
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<nlog
|
||||||
|
xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
|
||||||
|
autoReload="true"
|
||||||
|
throwExceptions="false"
|
||||||
|
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
|
||||||
|
<variable name="variable1" value="${newline}date: ${date}${newline}level: ${level}${newline}logger: ${logger}${newline}machinename: ${machinename}
|
||||||
|
${newline}clientip:${local-ip}${newline}message: ${message} ${newline}exception:${exception}
|
||||||
|
${newline}appdomain: ${appdomain}${newline}assembly-version: ${assembly-version}${newline}basedir: ${basedir}
|
||||||
|
${newline}callsite: ${callsite}${newline}callsite-linenumber: ${callsite-linenumber}${newline}counter: ${counter}${newline}nlogdir: ${nlogdir}
|
||||||
|
${newline}processid: ${processid}${newline}processname: ${processname}
|
||||||
|
${newline}traceid: ${aspnet-traceidentifier}
|
||||||
|
${newline}specialfolder: ${specialfolder}
|
||||||
|
${newline}stacktrace: ${stacktrace}${newline}-----------------------------------------------------------" />
|
||||||
|
<variable name="variable2" value="日志时间:${longdate}${newline}日志来源:${callsite}${newline}日志级别:${uppercase:${level}}${newline}消息内容:${message}${newline}异常信息:${exception}${newline}stacktrace: ${stacktrace}${newline}==============================================================${newline}" />
|
||||||
|
<variable name="variable3" value="${longdate}消息内容:${message}${newline}==============================================================${newline}" />
|
||||||
|
<variable name="variable_info" value="<HR COLOR=blue>${newline}日志时间:${longdate} <BR>${newline}日志级别:${level} <BR>${newline}日 志 类:log_info <BR>${newline}${message} <BR>${newline} <HR Size=1>" />
|
||||||
|
<variable name="variable_error" value="<HR COLOR=blue>${newline}日志时间:${longdate} <BR>${newline}日志级别:${level} <BR>${newline}日 志 类:log_error <BR>${newline}${message} <BR>${newline} <HR Size=1>" />
|
||||||
|
<variable name="variable_mqtt" value="<HR COLOR=blue>${newline}日志时间:${longdate} <BR>${newline}日志级别:${level} <BR>${newline}日 志 类:log_mqtt <BR>${newline}${message} <BR>${newline} <HR Size=1>" />
|
||||||
|
<variable name="variable_Infos" value="${longdate}消息内容:${message}${newline}==============================================================${newline}" />
|
||||||
|
<variable name="variable_MEStIME" value="${longdate}消息内容:${message}${newline}==============================================================${newline}" />
|
||||||
|
<variable name="variable_sql" value="${longdate}消息内容:${message}${newline}==============================================================${newline}" />
|
||||||
|
<variable name="variable_SysErrorLog" value="${longdate}消息内容:${message}${newline}==============================================================${newline}" />
|
||||||
|
<variable name="variable_SysErrorLogcn" value="${longdate}消息内容:${message}${newline}==============================================================${newline}" />
|
||||||
|
<!--
|
||||||
|
See https://github.com/nlog/nlog/wiki/Configuration-file
|
||||||
|
for information on customizing logging rules and outputs.
|
||||||
|
-->
|
||||||
|
<targets>
|
||||||
|
<!--
|
||||||
|
Write events to a file with the date in the filename. -->
|
||||||
|
<!--<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
|
||||||
|
layout="${longdate} ${uppercase:${level}} ${message}" />-->
|
||||||
|
<target name="log_file" xsi:type="AsyncWrapper" queueLimit="5000" overflowAction="Discard">
|
||||||
|
<target xsi:type="File" fileName="${basedir}/logs/${shortdate}/${shortdate}.${level}.log"
|
||||||
|
layout="${variable2}" archiveAboveSize="2097152" archiveEvery="Day" />
|
||||||
|
</target>
|
||||||
|
<!--<target name="log_file" xsi:type="File" fileName="${basedir}/logs/${shortdate}.log" layout="${variable1}" />-->
|
||||||
|
<target name="log_info" xsi:type="File" fileName="${basedir}/Log/${shortdate}/LogInfo.${level}.html" layout="${variable_info}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="log_error" xsi:type="File" fileName="${basedir}/Log/${shortdate}/LogError.${level}.html" layout="${variable_error}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="log_mqtt" xsi:type="File" fileName="${basedir}/Log/${shortdate}/LogMqtt.${level}.html" layout="${variable_mqtt}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="logs_Infos" xsi:type="File" fileName="${basedir}/Logs/Info/${shortdate}/${level}.log" layout="${variable_Infos}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="logs_MEStIME" xsi:type="File" fileName="${basedir}/Logs/MESTime/${shortdate}/${level}.log" layout="${variable_MEStIME}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="logs_Sql" xsi:type="File" fileName="${basedir}/Logs/SQL执行/${shortdate}/${level}.log" layout="${variable_sql}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="logs_SysErrorLog" xsi:type="File" fileName="${basedir}/Logs/SysErrorLog/${shortdate}/${level}.log" layout="${variable_SysErrorLog}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="logs_SysErrorLogcn" xsi:type="File" fileName="${basedir}/Logs/系统报错/${shortdate}/${level}.log" layout="${variable_SysErrorLogcn}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="log_ReadPlcInt" xsi:type="File" fileName="${basedir}/hslLogs/${shortdate}/ReadPlcInt.${level}.log" layout="${Heartvariable}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
</targets>
|
||||||
|
<rules>
|
||||||
|
<logger name="loginfo" minlevel="Info" writeTo="log_info" final="true"/>
|
||||||
|
<logger name="logerror" minlevel="Info" writeTo="log_error" final="true"/>
|
||||||
|
<logger name="logmqtt" minlevel="Info" writeTo="log_mqtt" final="true"/>
|
||||||
|
<logger name="logsInfo" minlevel="Info" writeTo="logs_Infos" final="true"/>
|
||||||
|
<logger name="logsMEStIME" minlevel="Info" writeTo="logs_MEStIME" final="true"/>
|
||||||
|
<logger name="logsSql" minlevel="Info" writeTo="logs_Sql" final="true"/>
|
||||||
|
<logger name="logsSysErrorLog" minlevel="Info" writeTo="logs_SysErrorLog" final="true"/>
|
||||||
|
<logger name="logsSysErrorLogcn" minlevel="Info" writeTo="logs_SysErrorLogcn" final="true"/>
|
||||||
|
<logger name="*" minlevel="Info" writeTo="log_info" final="true"/>
|
||||||
|
</rules>
|
||||||
|
</nlog>
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
using JinYuan.Helper;
|
using JinYuan.Helper;
|
||||||
using JinYuan.Models;
|
using JinYuan.Models;
|
||||||
using JinYuan.VirtualDataLibrary;
|
using JinYuan.VirtualDataLibrary;
|
||||||
|
using NLog;
|
||||||
|
using NLog.Config;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
@@ -36,6 +38,7 @@ namespace LargeSquareOne
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
|
LoggerHelp.WriteInfo("Application 启动");
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
string strname = Process.GetCurrentProcess().ProcessName;
|
string strname = Process.GetCurrentProcess().ProcessName;
|
||||||
@@ -83,7 +86,6 @@ namespace LargeSquareOne
|
|||||||
|
|
||||||
public static void ReadConfig()
|
public static void ReadConfig()
|
||||||
{
|
{
|
||||||
LogHelper.Instance.InitLog(Application.StartupPath + "\\Logs\\");
|
|
||||||
IniConfigHelper.CreateIniFile(Application.StartupPath + "\\Config\\", "Configure.ini");
|
IniConfigHelper.CreateIniFile(Application.StartupPath + "\\Config\\", "Configure.ini");
|
||||||
string connString = ConfigurationManager.ConnectionStrings["connString"].ToString();
|
string connString = ConfigurationManager.ConnectionStrings["connString"].ToString();
|
||||||
string connString2 = ConfigurationManager.ConnectionStrings["connString2"].ToString();
|
string connString2 = ConfigurationManager.ConnectionStrings["connString2"].ToString();
|
||||||
@@ -91,7 +93,7 @@ namespace LargeSquareOne
|
|||||||
var connDbType = (SqlSugar.DbType)Enum.Parse(typeof(SqlSugar.DbType), strDBType);
|
var connDbType = (SqlSugar.DbType)Enum.Parse(typeof(SqlSugar.DbType), strDBType);
|
||||||
CommonMethods.db.SetConnectionStr(connString, connDbType);
|
CommonMethods.db.SetConnectionStr(connString, connDbType);
|
||||||
CommonMethods.dbServer.SetConnectionStr(connString2, connDbType);
|
CommonMethods.dbServer.SetConnectionStr(connString2, connDbType);
|
||||||
CommonMethods.sysConfig.SwipeCardMode=Convert.ToBoolean(IniConfigHelper.ReadIniData("配置信息", "开启刷卡模式", "false"));
|
CommonMethods.sysConfig.SwipeCardMode = Convert.ToBoolean(IniConfigHelper.ReadIniData("配置信息", "开启刷卡模式", "false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -107,7 +109,7 @@ namespace LargeSquareOne
|
|||||||
{
|
{
|
||||||
Exception ex = (Exception)e.ExceptionObject;
|
Exception ex = (Exception)e.ExceptionObject;
|
||||||
|
|
||||||
LogHelper.Instance.WriteEX(ex);
|
LoggerHelp.WriteEX(ex);
|
||||||
MessageBox.Show($"程序出现大异常,请联系 【金源自动化软件设计部】。\r\n异常信息: {ex.Message}\r\n异常堆栈:{ex.StackTrace}",
|
MessageBox.Show($"程序出现大异常,请联系 【金源自动化软件设计部】。\r\n异常信息: {ex.Message}\r\n异常堆栈:{ex.StackTrace}",
|
||||||
"致命错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
"致命错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<nlog
|
||||||
|
xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
|
||||||
|
autoReload="true"
|
||||||
|
throwExceptions="false"
|
||||||
|
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
|
||||||
|
<variable name="variable1" value="${newline}date: ${date}${newline}level: ${level}${newline}logger: ${logger}${newline}machinename: ${machinename}
|
||||||
|
${newline}clientip:${local-ip}${newline}message: ${message} ${newline}exception:${exception}
|
||||||
|
${newline}appdomain: ${appdomain}${newline}assembly-version: ${assembly-version}${newline}basedir: ${basedir}
|
||||||
|
${newline}callsite: ${callsite}${newline}callsite-linenumber: ${callsite-linenumber}${newline}counter: ${counter}${newline}nlogdir: ${nlogdir}
|
||||||
|
${newline}processid: ${processid}${newline}processname: ${processname}
|
||||||
|
${newline}traceid: ${aspnet-traceidentifier}
|
||||||
|
${newline}specialfolder: ${specialfolder}
|
||||||
|
${newline}stacktrace: ${stacktrace}${newline}-----------------------------------------------------------" />
|
||||||
|
<variable name="variable2" value="日志时间:${longdate}${newline}日志来源:${callsite}${newline}日志级别:${uppercase:${level}}${newline}消息内容:${message}${newline}异常信息:${exception}${newline}stacktrace: ${stacktrace}${newline}==============================================================${newline}" />
|
||||||
|
<variable name="variable3" value="${longdate}消息内容:${message}${newline}==============================================================${newline}" />
|
||||||
|
<variable name="variable_info" value="<HR COLOR=blue>${newline}日志时间:${longdate} <BR>${newline}日志级别:${level} <BR>${newline}日 志 类:log_info <BR>${newline}${message} <BR>${newline} <HR Size=1>" />
|
||||||
|
<variable name="variable_error" value="<HR COLOR=blue>${newline}日志时间:${longdate} <BR>${newline}日志级别:${level} <BR>${newline}日 志 类:log_error <BR>${newline}${message} <BR>${newline} <HR Size=1>" />
|
||||||
|
<variable name="variable_mqtt" value="<HR COLOR=blue>${newline}日志时间:${longdate} <BR>${newline}日志级别:${level} <BR>${newline}日 志 类:log_mqtt <BR>${newline}${message} <BR>${newline} <HR Size=1>" />
|
||||||
|
<variable name="variable_Infos" value="${longdate}消息内容:${message}${newline}==============================================================${newline}" />
|
||||||
|
<variable name="variable_MEStIME" value="${longdate}消息内容:${message}${newline}==============================================================${newline}" />
|
||||||
|
<variable name="variable_sql" value="${longdate}消息内容:${message}${newline}==============================================================${newline}" />
|
||||||
|
<variable name="variable_SysErrorLog" value="${longdate}消息内容:${message}${newline}==============================================================${newline}" />
|
||||||
|
<variable name="variable_SysErrorLogcn" value="${longdate}消息内容:${message}${newline}==============================================================${newline}" />
|
||||||
|
<!--
|
||||||
|
See https://github.com/nlog/nlog/wiki/Configuration-file
|
||||||
|
for information on customizing logging rules and outputs.
|
||||||
|
-->
|
||||||
|
<targets>
|
||||||
|
<!--
|
||||||
|
Write events to a file with the date in the filename. -->
|
||||||
|
<!--<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
|
||||||
|
layout="${longdate} ${uppercase:${level}} ${message}" />-->
|
||||||
|
<target name="log_file" xsi:type="AsyncWrapper" queueLimit="5000" overflowAction="Discard">
|
||||||
|
<target xsi:type="File" fileName="${basedir}/logs/${shortdate}/${shortdate}.${level}.log"
|
||||||
|
layout="${variable2}" archiveAboveSize="2097152" archiveEvery="Day" />
|
||||||
|
</target>
|
||||||
|
<!--<target name="log_file" xsi:type="File" fileName="${basedir}/logs/${shortdate}.log" layout="${variable1}" />-->
|
||||||
|
<target name="log_info" xsi:type="File" fileName="${basedir}/Log/${shortdate}/LogInfo.${level}.log" layout="${variable_info}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="log_error" xsi:type="File" fileName="${basedir}/Log/${shortdate}/LogError.${level}.log" layout="${variable_error}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="log_mqtt" xsi:type="File" fileName="${basedir}/Log/${shortdate}/LogMqtt.${level}.log" layout="${variable_mqtt}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="logs_Infos" xsi:type="File" fileName="${basedir}/Logs/Info/${shortdate}/${level}.log" layout="${variable_Infos}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="logs_MEStIME" xsi:type="File" fileName="${basedir}/Logs/MESTime/${shortdate}/${level}.log" layout="${variable_MEStIME}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="logs_Sql" xsi:type="File" fileName="${basedir}/Logs/SQL执行/${shortdate}/${level}.log" layout="${variable_sql}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="logs_SysErrorLog" xsi:type="File" fileName="${basedir}/Logs/SysErrorLog/${shortdate}/${level}.log" layout="${variable_SysErrorLog}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="logs_SysErrorLogcn" xsi:type="File" fileName="${basedir}/Logs/系统报错/${shortdate}/${level}.log" layout="${variable_SysErrorLogcn}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
<target name="log_ReadPlcInt" xsi:type="File" fileName="${basedir}/hslLogs/${shortdate}/ReadPlcInt.${level}.log" layout="${Heartvariable}" archiveAboveSize="2097152" archiveEvery="Day"/>
|
||||||
|
</targets>
|
||||||
|
<rules>
|
||||||
|
<logger name="loginfo" minlevel="Info" writeTo="log_info" final="true"/>
|
||||||
|
<logger name="logerror" minlevel="Info" writeTo="log_error" final="true"/>
|
||||||
|
<logger name="logmqtt" minlevel="Info" writeTo="log_mqtt" final="true"/>
|
||||||
|
<logger name="logsInfo" minlevel="Info" writeTo="logs_Infos" final="true"/>
|
||||||
|
<logger name="logsMEStIME" minlevel="Info" writeTo="logs_MEStIME" final="true"/>
|
||||||
|
<logger name="logsSql" minlevel="Info" writeTo="logs_Sql" final="true"/>
|
||||||
|
<logger name="logsSysErrorLog" minlevel="Info" writeTo="logs_SysErrorLog" final="true"/>
|
||||||
|
<logger name="logsSysErrorLogcn" minlevel="Info" writeTo="logs_SysErrorLogcn" final="true"/>
|
||||||
|
<logger name="*" minlevel="Info" writeTo="log_info" final="true"/>
|
||||||
|
</rules>
|
||||||
|
</nlog>
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<configuration>
|
|
||||||
<configSections>
|
|
||||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
|
|
||||||
</configSections>
|
|
||||||
<log4net>
|
|
||||||
错误日志类
|
|
||||||
<logger name="logerror">
|
|
||||||
<level value="ALL" />
|
|
||||||
<appender-ref ref="ErrorAppender" />
|
|
||||||
</logger>
|
|
||||||
信息日志类
|
|
||||||
<logger name="loginfo">
|
|
||||||
<level value="ALL" />
|
|
||||||
<appender-ref ref="InfoAppender" />
|
|
||||||
</logger>
|
|
||||||
信息日志类
|
|
||||||
<logger name="logmqtt">
|
|
||||||
<level value="ALL" />
|
|
||||||
<appender-ref ref="MqttAppender" />
|
|
||||||
</logger>
|
|
||||||
错误日志附加介质
|
|
||||||
<appender name="ErrorAppender" type="log4net.Appender.RollingFileAppender">
|
|
||||||
<param name="File" value="Log\\LogError\\" />
|
|
||||||
<param name="AppendToFile" value="true" />
|
|
||||||
<param name="MaxSizeRollBackups" value="30" />
|
|
||||||
<param name="MaxFileSize" value="10240" />
|
|
||||||
<param name="StaticLogFileName" value="false" />
|
|
||||||
<param name="DatePattern" value="yyyyMMddHH".htm"" />
|
|
||||||
<param name="RollingStyle" value="Date" />
|
|
||||||
布局
|
|
||||||
<layout type="log4net.Layout.PatternLayout">
|
|
||||||
<param name="ConversionPattern" value="<HR COLOR=red>%n异常时间:%d [%t] <BR>%n异常级别:%-5p <BR>%n异 常 类:%c [%x] <BR>%n%m <BR>%n <HR Size=1>" />
|
|
||||||
</layout>
|
|
||||||
</appender>
|
|
||||||
信息日志附加介质
|
|
||||||
<appender name="InfoAppender" type="log4net.Appender.RollingFileAppender">
|
|
||||||
<param name="File" value="Log\\LogInfo\\" />
|
|
||||||
<param name="AppendToFile" value="true" />
|
|
||||||
<param name="MaxFileSize" value="10240" />
|
|
||||||
<param name="MaxSizeRollBackups" value="30" />
|
|
||||||
<param name="StaticLogFileName" value="false" />
|
|
||||||
<param name="DatePattern" value="yyyyMMddhh".htm"" />
|
|
||||||
<param name="RollingStyle" value="Date" />
|
|
||||||
信息日志布局
|
|
||||||
<layout type="log4net.Layout.PatternLayout">
|
|
||||||
<param name="ConversionPattern" value="<HR COLOR=blue>%n日志时间:%d [%t] <BR>%n日志级别:%-5p <BR>%n日 志 类:%c [%x] <BR>%n%m <BR>%n <HR Size=1>" />
|
|
||||||
</layout>
|
|
||||||
</appender>
|
|
||||||
信息日志附加介质
|
|
||||||
<appender name="MqttAppender" type="log4net.Appender.RollingFileAppender">
|
|
||||||
<param name="File" value="Log\\LogMqtt\\" />
|
|
||||||
<param name="AppendToFile" value="true" />
|
|
||||||
<param name="MaxFileSize" value="10240" />
|
|
||||||
<param name="MaxSizeRollBackups" value="30" />
|
|
||||||
<param name="StaticLogFileName" value="false" />
|
|
||||||
<param name="DatePattern" value="yyyyMMddHH".htm"" />
|
|
||||||
<param name="RollingStyle" value="Date" />
|
|
||||||
信息日志布局
|
|
||||||
<layout type="log4net.Layout.PatternLayout">
|
|
||||||
<param name="ConversionPattern" value="<HR COLOR=blue>%n日志时间:%d [%t] <BR>%n日志级别:%-5p <BR>%n日 志 类:%c [%x] <BR>%n%m <BR>%n <HR Size=1>" />
|
|
||||||
</layout>
|
|
||||||
</appender>
|
|
||||||
</log4net>
|
|
||||||
</configuration>
|
|
||||||
Binary file not shown.
@@ -12,6 +12,8 @@
|
|||||||
<package id="MiniExcel" version="1.31.2" targetFramework="net472" />
|
<package id="MiniExcel" version="1.31.2" targetFramework="net472" />
|
||||||
<package id="MySql.Data" version="8.1.0" targetFramework="net472" />
|
<package id="MySql.Data" version="8.1.0" targetFramework="net472" />
|
||||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
||||||
|
<package id="NLog" version="6.0.2" targetFramework="net472" />
|
||||||
|
<package id="NLog.Windows.Forms" version="6.0.2" targetFramework="net472" />
|
||||||
<package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net472" />
|
<package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net472" />
|
||||||
<package id="SeeSharpTools.JY.GUI" version="1.4.4.533" targetFramework="net472" />
|
<package id="SeeSharpTools.JY.GUI" version="1.4.4.533" targetFramework="net472" />
|
||||||
<package id="SqlSugar" version="5.1.4.94" targetFramework="net472" />
|
<package id="SqlSugar" version="5.1.4.94" targetFramework="net472" />
|
||||||
|
|||||||
Reference in New Issue
Block a user