From dd651f9ce0156fc7db869da04e0c2004a1811c52 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期二, 25 十月 2022 21:00:36 +0800
Subject: [PATCH] 安灯报表开发

---
 VueWebApi/Hubs/ChatHub.cs |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/VueWebApi/Hubs/ChatHub.cs b/VueWebApi/Hubs/ChatHub.cs
index 759cd8e..77ab1dd 100644
--- a/VueWebApi/Hubs/ChatHub.cs
+++ b/VueWebApi/Hubs/ChatHub.cs
@@ -1,5 +1,6 @@
 锘縰sing Dapper;
 using Microsoft.AspNet.SignalR;
+using Microsoft.AspNet.SignalR.Hubs;
 using System;
 using System.Collections.Generic;
 using System.Data;
@@ -10,6 +11,10 @@
 
 namespace VueWebApi.Hubs
 {
+    /// <summary>
+    /// chatHub闆嗙嚎鍣ㄧ被
+    /// </summary>
+    [HubName("chatHub")]
     public class ChatHub : Hub
     {
         /// <summary>
@@ -52,14 +57,25 @@
         /// <param name="json"></param>
         public void SendByGroupList(string username,string wkshpcode, string eqpcode, List<AnDnDate> json)
         {
-            for (int i = 0; i < json.Count; i++)
+            try
             {
-                string cont = wkshpcode + "瀵瑰簲璁惧" + eqpcode + json[i].name.ToString();
-                var departmentIDs = json[i].children.ToList().Select(x => x.username).ToList();//鑾峰彇鎺ㄩ�佷汉鍛�
-                var FindPublicBaseDic = _connections.Where(d => departmentIDs.Contains(d.Key)).Select(x => x.Value).ToList(); //鍖归厤宸茬粡鐧诲綍鐨勬帹閫佷汉鍛樺敮涓�鐮�
-                var FindPublicBaseDicName = _connections.Where(d => FindPublicBaseDic.Contains(d.Value)).Select(x => x.Key).ToList(); //鏍规嵁鍞竴鐮佸尮閰嶅凡缁忕櫥褰曠殑鎺ㄩ�佷汉鍛樺悕绉�
-                Clients.Clients(FindPublicBaseDic).SendMessage("鏉ヨ嚜鐢ㄦ埛:" + username +" 鍐呭锛�" + cont + "鏃堕棿" + DateTime.Now.ToString("yyyy/MM/ddhh:mm:ss") + "鐨勬秷鎭�氱煡锛�");
+                for (int i = 0; i < json.Count; i++)
+                {
+                    string cont = wkshpcode + "瀵瑰簲璁惧" + eqpcode + json[i].name.ToString();
+                    var departmentIDs = json[i].children.ToList().Select(x => x.username).ToList();//鑾峰彇鎺ㄩ�佷汉鍛�
+                    var FindPublicBaseDic = _connections.Where(d => departmentIDs.Contains(d.Key)).Select(x => x.Value).ToList(); //鍖归厤宸茬粡鐧诲綍鐨勬帹閫佷汉鍛樺敮涓�鐮�
+                    LogHelper.WriteLogData("鍦ㄧ嚎浜烘暟锛�"+FindPublicBaseDic.Count.ToString());
+                    var FindPublicBaseDicName = _connections.Where(d => FindPublicBaseDic.Contains(d.Value)).Select(x => x.Key).ToList(); //鏍规嵁鍞竴鐮佸尮閰嶅凡缁忕櫥褰曠殑鎺ㄩ�佷汉鍛樺悕绉�
+                    LogHelper.WriteLogData("鍦ㄧ嚎浜轰汉鍛樺悕绉帮細" + FindPublicBaseDicName.ToString());
+                    Clients.Clients(FindPublicBaseDic).SendMessage("鏉ヨ嚜鐢ㄦ埛:" + username + " 鍐呭锛�" + cont + "鏃堕棿" + DateTime.Now.ToString("yyyy/MM/ddhh:mm:ss") + "鐨勬秷鎭�氱煡锛�");
+                }
             }
+            catch (Exception ex)
+            {
+                LogHelper.WriteLogData("鎶ラ敊:"+ex.Message);
+                throw;
+            }
+           
         }
 
 
@@ -80,6 +96,7 @@
             {
                 //姣忔鐧婚檰id浼氬彂鐢熷彉鍖�
                 _connections[name] = Context.ConnectionId;
+                LogHelper.WriteLogData("鎵ц鍏宠仈:-->" + _connections[name]);
             }
             //鏂扮敤鎴蜂笂绾匡紝鏈嶅姟鍣ㄥ箍鎾鐢ㄦ埛鍚�
             Clients.All.loginUser(userList);

--
Gitblit v1.9.3