Quellcode durchsuchen

增加websocket数据监控

xuwei vor 3 Jahren
Ursprung
Commit
94b6e953d8

+ 3 - 0
DK.Service/PMModuleLogic/PMModuleLogic.csproj

@@ -83,6 +83,9 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\..\DLL\Curtain.Core.dll</HintPath>
     </Reference>
+    <Reference Include="Fleck">
+      <HintPath>..\..\DLL\Fleck.dll</HintPath>
+    </Reference>
     <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\..\DLL\Newtonsoft.Json.dll</HintPath>

+ 33 - 0
DK.Service/PMModuleLogic/PMModuleLogicDAL.cs

@@ -27,6 +27,8 @@ using System.Data;
 using System.IO;
 using System.Net;
 using System.Text;
+using Fleck;
+using System.Linq;
 
 namespace Dongke.IBOSS.PRD.Service.PMModuleLogic
 {
@@ -37,6 +39,29 @@ namespace Dongke.IBOSS.PRD.Service.PMModuleLogic
     {
         #region 生产管理
 
+        #region xuwei add 2022-09-07 增加数据监控变量
+        public static List<IWebSocketConnection> webSocketConection;
+        public static WebSocketServer webSocketServer;
+        public static int WebSocketSend(string data)
+        {
+            try
+            {
+                if (webSocketServer == null)
+                {
+                    webSocketConection = new List<IWebSocketConnection>();
+                    webSocketServer = new WebSocketServer("ws://127.0.0.1:8000");
+                    webSocketServer.Start(socket => { socket.OnOpen = () => webSocketConection.Add(socket); socket.OnClose = () => webSocketConection.Remove(socket); });
+                }
+                webSocketConection.ToList().ForEach(s => s.Send(data));
+                return 1;
+            }
+            catch
+            {
+                return -1;
+            }
+        }
+        #endregion
+
         #region 计件
 
         /// <summary>
@@ -51,6 +76,14 @@ namespace Dongke.IBOSS.PRD.Service.PMModuleLogic
         /// </remarks>
         public static DataTable AddWorkPiece(int procedureID, DataTable barcodeTable, SUserInfo sUserInfo, out ProcedureEntity procedureInfo)
         {
+            #region xuwei add 2022-09-07 增加数据监控
+            JObject pieceData = new JObject();
+            pieceData.Add(new JProperty("procedureID", procedureID));
+            pieceData.Add(new JProperty("barcodeTable", barcodeTable));
+            pieceData.Add(new JProperty("sUserInfo", sUserInfo));
+            WebSocketSend(pieceData.ToString());
+            #endregion
+
             procedureInfo = null;
             if (barcodeTable == null || barcodeTable.Rows.Count == 0)
             {

BIN
DLL/Fleck.dll