From 087bfb0d37901c3264444909a06b28b20078c216 Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周五, 23 8月 2024 06:01:02 +0800 Subject: [PATCH] 监控帮助类,测试用,后期要去掉 --- DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare.config | 34 +++++++++++++++++ DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/Enums.cs | 5 ++ DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/MonitorHelper.cs | 46 +++++++++++++++++++++++ DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare - 复制用.config | 20 +++++----- DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_01.cs | 3 + DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj | 1 6 files changed, 99 insertions(+), 10 deletions(-) diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_01.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_01.cs index 5bc848b..26c0ea6 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_01.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_01.cs @@ -171,6 +171,9 @@ } } + //鐩戞帶娴嬭瘯鏁版嵁锛屾ā鎷燂紝娴嬭瘯 + MonitorHelper.MonitorTestForOP3501(_dataCaptureConfig, value, colConfig, wplog); + //鐗规畩澶勭悊OP50 銆怑ditby shaocx,2024-08-16銆� string sideValue = GetSideForOP50(plcService, wplog); wplog.MonitoringPoint += sideValue; diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/MonitorHelper.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/MonitorHelper.cs new file mode 100644 index 0000000..d469505 --- /dev/null +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/MonitorHelper.cs @@ -0,0 +1,46 @@ +锘� +using iWare_SCADA_Model; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace iWare_SCADA_BusinessLogical.Utils +{ + /// <summary> + /// 鐩戞帶甯姪绫�,娴嬭瘯鐢紝鍚庢湡瑕佸幓鎺� + /// </summary> + public class MonitorHelper + { + /// <summary> + /// 鐩戞帶OP3501,娴嬭瘯鐢紝鍚庢湡瑕佸幓鎺� + /// </summary> + /// <param name="value"></param> + /// <returns></returns> + public static void MonitorTestForOP3501(DataCaptureConfig _dataCaptureConfig, object value, List<DataCaptureColumnConfig> colConfig, WorkPieceLog wplog) + { + try + { + if (_dataCaptureConfig.DataCapturePointCode == "OP3501") + { + //璁板綍涓� 瑙﹀彂鐨勭偣浣嶅拰鎵惧埌鐨勪簩缁寸爜鍊� + var str = ""; + str = $"OP3501 瑙﹀彂鐨勭偣浣� DbNumber:{_dataCaptureConfig.DbNumber},Offset:{_dataCaptureConfig.Offset},鍊兼槸{value.ToString()}"; + + var col = colConfig.First(o => o.DataCapturePointCode == _dataCaptureConfig.DataCapturePointCode && o.DataCapturePointCname == "浜岀淮鐮�"); + + str += $",鑾峰彇浜岀淮鐮佸�� DbNumber:{col.DbNumber},Offset:{col.Offset},鍊兼槸{wplog.WorkPieceID.ToString()}"; + str += $",鏁翠綋瀵硅薄 wplog鏄瘂JsonConvert.SerializeObject(wplog)}"; + + Log4NetHelper.WriteInfoLog(LogType.MonitorTest, str); + } + } + catch (Exception ex) + { + Log4NetHelper.WriteErrorLog(LogType.MonitorTest, "MonitorTestForOP3501寮傚父", ex); + } + } + } +} diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj index f524d2e..02cec37 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj @@ -156,6 +156,7 @@ <DesignTime>True</DesignTime> <DependentUpon>Resources.resx</DependentUpon> </Compile> + <Compile Include="Utils\MonitorHelper.cs" /> <Compile Include="Utils\SystemHelper.cs" /> <Compile Include="Utils\ComboBoxHelper.cs" /> <Compile Include="Utils\ConfigHelper.cs" /> diff --git "a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare - \345\244\215\345\210\266\347\224\250.config" "b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare - \345\244\215\345\210\266\347\224\250.config" index cfc6b45..59f5e59 100644 --- "a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare - \345\244\215\345\210\266\347\224\250.config" +++ "b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare - \345\244\215\345\210\266\347\224\250.config" @@ -5,9 +5,9 @@ <appSettings> </appSettings> <log4net> - <!-- 娓呮礂鏈洪噰闆嗘暟鎹嚎绋嬨�愪俊鎭�戞棩蹇�--> - <appender name="OP7009_Info" type="log4net.Appender.RollingFileAppender"> - <file value="D:\\Log\\SCADALog\\OP7009_Info\\" /> + <!-- 鐩戞帶娴嬭瘯鏁版嵁绾跨▼銆愪俊鎭�戞棩蹇�--> + <appender name="MonitorTest_Info" type="log4net.Appender.RollingFileAppender"> + <file value="D:\\Log\\SCADALog\\MonitorTest_Info\\" /> <appendToFile value="true" /> <rollingStyle value="Date" /> <staticLogFileName value="false" /> @@ -17,13 +17,13 @@ <param name="ConversionPattern" value="%n娑堟伅鏃堕棿锛�%d [%t] %n娑堟伅绾у埆锛�%-5p %n娑� 鎭� 绫伙細%c [%x] %n%m %n "/> </layout> <filter type="log4net.Filter.LoggerMatchFilter"> - <loggerToMatch value="OP7009_Info" /> + <loggerToMatch value="MonitorTest_Info" /> </filter> <filter type="log4net.Filter.DenyAllFilter" /> </appender> - <!--娓呮礂鏈洪噰闆嗘暟鎹嚎绋嬨�愰敊璇�戞棩蹇�--> - <appender name="OP7009_Error" type="log4net.Appender.RollingFileAppender"> - <file value="D:\\Log\\SCADALog\\OP7009_Error\\" /> + <!--鐩戞帶娴嬭瘯鏁版嵁绾跨▼銆愰敊璇�戞棩蹇�--> + <appender name="MonitorTest_Error" type="log4net.Appender.RollingFileAppender"> + <file value="D:\\Log\\SCADALog\\MonitorTest_Error\\" /> <appendToFile value="true" /> <rollingStyle value="Date" /> <staticLogFileName value="false" /> @@ -33,14 +33,14 @@ <param name="ConversionPattern" value="%n寮傚父鏃堕棿锛�%d [%t] %n寮傚父绾у埆锛�%-5p %n寮� 甯� 绫伙細%c [%x] %n%m %n "/> </layout> <filter type="log4net.Filter.LoggerMatchFilter"> - <loggerToMatch value="OP7009_Error" /> + <loggerToMatch value="MonitorTest_Error" /> </filter> <filter type="log4net.Filter.DenyAllFilter" /> </appender> <root> <level value="ALL"/> - <appender-ref ref="OP7009_Info"/> - <appender-ref ref="OP7009_Error"/> + <appender-ref ref="MonitorTest_Info"/> + <appender-ref ref="MonitorTest_Error"/> </root> </log4net> </configuration> \ No newline at end of file diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare.config b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare.config index 13ff65a..a357a8b 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare.config +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare.config @@ -5,6 +5,38 @@ <appSettings> </appSettings> <log4net> + <!-- 鐩戞帶娴嬭瘯鏁版嵁绾跨▼銆愪俊鎭�戞棩蹇�--> + <appender name="MonitorTest_Info" type="log4net.Appender.RollingFileAppender"> + <file value="D:\\Log\\SCADALog\\MonitorTest_Info\\" /> + <appendToFile value="true" /> + <rollingStyle value="Date" /> + <staticLogFileName value="false" /> + <datePattern value="yyyy-MM-dd.LOG" /> + <layout type="log4net.Layout.PatternLayout"> + <!--杈撳嚭鏍煎紡--> + <param name="ConversionPattern" value="%n娑堟伅鏃堕棿锛�%d [%t] %n娑堟伅绾у埆锛�%-5p %n娑� 鎭� 绫伙細%c [%x] %n%m %n "/> + </layout> + <filter type="log4net.Filter.LoggerMatchFilter"> + <loggerToMatch value="MonitorTest_Info" /> + </filter> + <filter type="log4net.Filter.DenyAllFilter" /> + </appender> + <!--鐩戞帶娴嬭瘯鏁版嵁绾跨▼銆愰敊璇�戞棩蹇�--> + <appender name="MonitorTest_Error" type="log4net.Appender.RollingFileAppender"> + <file value="D:\\Log\\SCADALog\\MonitorTest_Error\\" /> + <appendToFile value="true" /> + <rollingStyle value="Date" /> + <staticLogFileName value="false" /> + <datePattern value="yyyy-MM-dd.LOG" /> + <layout type="log4net.Layout.PatternLayout"> + <!--杈撳嚭鏍煎紡--> + <param name="ConversionPattern" value="%n寮傚父鏃堕棿锛�%d [%t] %n寮傚父绾у埆锛�%-5p %n寮� 甯� 绫伙細%c [%x] %n%m %n "/> + </layout> + <filter type="log4net.Filter.LoggerMatchFilter"> + <loggerToMatch value="MonitorTest_Error" /> + </filter> + <filter type="log4net.Filter.DenyAllFilter" /> + </appender> <!-- 娓呮礂鏈洪噰闆嗘暟鎹嚎绋嬨�愪俊鎭�戞棩蹇�--> <appender name="OP7009_Info" type="log4net.Appender.RollingFileAppender"> <file value="D:\\Log\\SCADALog\\OP7009_Info\\" /> @@ -557,6 +589,8 @@ </appender> <root> <level value="ALL"/> + <appender-ref ref="MonitorTest_Info"/> + <appender-ref ref="MonitorTest_Error"/> <appender-ref ref="OP7009_Info"/> <appender-ref ref="OP7009_Error"/> <appender-ref ref="DeleteData_Info"/> diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/Enums.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/Enums.cs index 35b5c92..f1c23ba 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/Enums.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/Enums.cs @@ -222,6 +222,11 @@ /// </summary> OP7009 = 503, + /// <summary> + /// 鐩戞帶娴嬭瘯鏁版嵁 + /// </summary> + MonitorTest = 504, + } -- Gitblit v1.9.3