Ejemplo n.º 1
0
 /// <summary>
 /// 推送服务器准备发布通知
 /// </summary>
 public static void StartServerRelease(int seconds = 60)
 {
     if (_hubInfo.Count > 0)
     {
         foreach (var item in _hubInfo)
         {
             var client = AllClients.Client(item.connectionId);
             client.startServerRelease(seconds);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 扫码成功后,未登录点击了退出,需要返回重新扫码
        /// </summary>
        /// <param name="uuid"></param>

        public static void backQrCode(string uuid)
        {
            var hubinfo = _hubInfo.FirstOrDefault(f => f.uuid == uuid);

            if (hubinfo.IsNotNull())
            {
                var             client = AllClients.Client(hubinfo.connectionId);
                OperationResult result = new OperationResult(OperationResultType.Success);
                client.backQrCode(result);
            }
        }
Ejemplo n.º 3
0
        public static void sendStatus(string uuid)
        {
            var hubinfo = _hubInfo.FirstOrDefault(f => f.uuid == uuid);

            if (hubinfo.IsNotNull())
            {
                var             client = AllClients.Client(hubinfo.connectionId);
                OperationResult result = new OperationResult(OperationResultType.Success);
                result.Data = uuid;
                client.getStatus(result);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更新页面菜单Badge数值
        /// </summary>
        /// <param name="AdminId"></param>
        /// <param name="ChangeCount"></param>
        /// <param name="BadgeTag"></param>
        public static void UpdateBadgeCount(int AdminId, int ChangeCount, string BadgeTag, bool autoCalc = false)
        {
            var devices = GetCurAdminDeviceIds(AdminId);

            if (devices.Count > 0)
            {
                foreach (var item in devices)
                {
                    var client = AllClients.Client(item.connectionId);
                    client.UpdateBadgeCount(ChangeCount, BadgeTag, autoCalc);
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 所有登录的客户端主动拉取消息数量
 /// </summary>
 public static void SendMessageAll()
 {
     if (_hubInfo.Count > 0)
     {
         MessagerController controllerMessage = new MessagerController(HubEntityContract._messageerContract, HubEntityContract._adminContract);
         foreach (var item in _hubInfo)
         {
             var client  = AllClients.Client(item.connectionId);
             int AdminId = item.AdminId.CastTo <int>();
             var data    = controllerMessage.GetMsgCount(AdminId);
             client.GetMessage(data.Data);
         }
     }
 }
Ejemplo n.º 6
0
 public static void SendMessage(params int[] AdminIds)
 {
     if (AdminIds.IsNotNullThis())
     {
         MessagerController controllerMessage = new MessagerController(HubEntityContract._messageerContract, HubEntityContract._adminContract);
         foreach (var curDevice in GetCurAdminDeviceIds(AdminIds))
         {
             var client  = AllClients.Client(curDevice.connectionId);
             int AdminId = curDevice.AdminId.CastTo <int>();
             var data    = controllerMessage.GetMsgCount(AdminId);
             client.GetMessage(data.Data);
         }
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 通知所以人
        /// </summary>
        /// <returns></returns>
        public async static Task SendNotificationAll()
        {
            if (_hubInfo.Count > 0)
            {
                NotificationViewController controllerNotifciationView = new NotificationViewController(HubEntityContract._notificationContract, HubEntityContract._msgNotificationContract, HubEntityContract._notificationQASystemContract);
                foreach (var item in _hubInfo)
                {
                    var client  = AllClients.Client(item.connectionId);
                    int AdminId = item.AdminId.CastTo <int>();
                    var data    = await controllerNotifciationView.getLastNewNotification(3, AdminId);

                    client.GetNotification(data.Data);
                }
            }
        }
Ejemplo n.º 8
0
        public async static Task SendNotification(params int[] AdminIds)
        {
            if (AdminIds.IsNotNullThis())
            {
                NotificationViewController controllerNotifciationView = new NotificationViewController(HubEntityContract._notificationContract, HubEntityContract._msgNotificationContract, HubEntityContract._notificationQASystemContract);
                foreach (var curDevice in GetCurAdminDeviceIds(AdminIds))
                {
                    var client  = AllClients.Client(curDevice.connectionId);
                    int AdminId = curDevice.AdminId.CastTo <int>();
                    var data    = await controllerNotifciationView.getLastNewNotification(3, AdminId);

                    client.GetNotification(data.Data);
                }
            }
        }
Ejemplo n.º 9
0
 public static void SendPopLoading(bool isClose, string content, params int[] AdminIds)
 {
     if (AdminIds.IsNotNullThis())
     {
         var devices = GetCurAdminDeviceIds(AdminIds);
         if (devices.Count > 0)
         {
             foreach (var item in devices)
             {
                 var client = AllClients.Client(item.connectionId);
                 client.PopLoading(content, isClose);
             }
         }
     }
 }
Ejemplo n.º 10
0
        public static void scanComplete(string uuid, string adminImg)
        {
            var hubinfo = _hubInfo.FirstOrDefault(f => f.uuid == uuid);

            if (hubinfo.IsNotNull())
            {
                var             client = AllClients.Client(hubinfo.connectionId);
                OperationResult result = new OperationResult(OperationResultType.Success);
                result.Data = new
                {
                    //uuid = uuid,
                    adminImg = adminImg
                };
                client.scanComplete(result);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 发送弹窗通知
        /// </summary>
        /// <param name="title"></param>
        /// <param name="content"></param>
        /// <param name="AdminIds"></param>
        /// <returns></returns>
        public static OperationResult SendPopNotification(string title, string content, params int[] AdminIds)
        {
            OperationResult result = new OperationResult(OperationResultType.Error, "被通知人不存在");

            if (AdminIds.IsNotNullThis())
            {
                var devices = GetCurAdminDeviceIds(AdminIds);
                if (devices.Count > 0)
                {
                    foreach (var item in devices)
                    {
                        var client = AllClients.Client(item.connectionId);
                        client.PopNoti(title, content);
                    }
                    result = new OperationResult(OperationResultType.Success);
                }
            }
            return(result);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 退出其它设备的登录
 /// </summary>
 /// <param name="AdminId"></param>
 /// <param name="connectionId"></param>
 /// <returns></returns>
 public static void ExitOtherDevice(string AdminId, string browserId)
 {
     Task.Run(() =>
     {
         if (AdminId.IsNotNullAndEmpty())
         {
             var listOtherDevices = _hubInfo.Where(w => w.AdminId == AdminId && w.browserId != browserId).ToList();//添加browserId原因,同一个浏览器登录多次视为一次
             if (listOtherDevices.Count > 0)
             {
                 OperationResult oResult = new OperationResult(OperationResultType.Success, "账号在其它设备登录,如非本人操作请及时修改密码");
                 foreach (var device in listOtherDevices)
                 {
                     var client = AllClients.Client(device.connectionId);
                     client.exitLogin(oResult);
                 }
             }
         }
     });
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 退出当前用户的登录
        /// </summary>
        /// <param name="AdminId">用户id</param>
        /// <param name="clearAll">是否清除所有登录</param>
        /// <param name="tcid">指定的tcid</param>
        /// <returns></returns>
        public static OperationResult AutoExit(string AdminId, bool clearAll, string tcid)
        {
            OperationResult oResult = new OperationResult(OperationResultType.Error, "取消授权登录失败");

            if (clearAll)
            {
                var curall = GetCurAdminAllLogin(AdminId);
                if (curall.Count > 0)
                {
                    oResult.ResultType = OperationResultType.Success;
                    oResult.Message    = "账号被取消授权登录";
                    foreach (var item in curall)
                    {
                        var client = AllClients.Client(item.connectionId);
                        client.exitLogin(oResult);
                    }
                }
            }
            else
            {
                if (tcid.IsNotNullAndEmpty())
                {
                    var autoExitHub = _hubInfo.FirstOrDefault(f => f.AdminId == AdminId && (f.uuid == tcid || f.uuid.IsNullOrEmpty()));//uuid=""为用户恶意操作,所以强制退出
                    if (autoExitHub.IsNotNull())
                    {
                        var listBrowsers = _hubInfo.Where(w => w.AdminId == AdminId && w.browserId == autoExitHub.browserId).ToList();//uuid在同一个浏览器多次登录后不是唯一的

                        oResult.ResultType = OperationResultType.Success;
                        oResult.Message    = "账号被取消授权登录";
                        foreach (var item in listBrowsers)
                        {
                            var client = AllClients.Client(item.connectionId);
                            client.exitLogin(oResult);
                        }
                    }
                }
            }
            return(oResult);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 发送条码信息
        /// </summary>
        /// <param name="AdminId"></param>
        /// <param name="strbarcode"></param>
        /// <returns></returns>
        public static OperationResult SendBarCodeInfo(int AdminId, params string[] strbarcode)
        {
            var result  = new OperationResult(OperationResultType.Error, "条码信息无效");
            var devices = GetCurAdminDeviceIds(AdminId);

            #region 条码内容校验

            if (strbarcode.IsNotNull())
            {
                strbarcode = strbarcode.Where(w => w.IsNotNullAndEmpty()).ToArray();
                if (!strbarcode.IsNotNullOrEmptyThis())
                {
                    return(result);
                }
            }
            else
            {
                return(result);
            }

            #endregion

            if (devices.Count > 0)
            {
                foreach (var item in devices)
                {
                    var client = AllClients.Client(item.connectionId);
                    client.GetBarCodeInfo(strbarcode);
                }
                result.ResultType = OperationResultType.Success;
                result.Message    = "发送成功";
            }
            else
            {
                result.Message = "未检测到PC端";
            }
            return(result);
        }