Beispiel #1
0
        public bool CanEnterGroup(Guid userId, bool isPlatformAdmin = false)
        {
            // Platform admins can always enter all groups
            if (isPlatformAdmin)
            {
                return(true);
            }

            // Open groups can be entered by everyone
            if (GroupType == GroupType.Open)
            {
                return(true);
            }

            // Hidden and private groups by admins and users of that group and platform admins
            if (GroupType == GroupType.Hidden || GroupType == GroupType.Private)
            {
                if (AdminIds != null && AdminIds.Contains(userId))
                {
                    return(true);
                }
                if (UserIds != null && UserIds.Contains(userId))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
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);
         }
     }
 }
Beispiel #3
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);
                }
            }
        }
Beispiel #4
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);
             }
         }
     }
 }
Beispiel #5
0
        public bool IsAdmin(Guid userId, bool isPlatformAdmin = false)
        {
            // Platform admins can always enter all groups
            if (isPlatformAdmin)
            {
                return(true);
            }

            if (AdminIds != null && AdminIds.Contains(userId))
            {
                return(true);
            }



            return(false);
        }
Beispiel #6
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);
        }
Beispiel #7
0
        /// <summary>
        /// Ответ бота на сообщение пользователя
        /// </summary>
        /// <param name="message">Сообщение пользователя</param>
        private void MessageResponse(Message message)
        {
            var command = message.Text.ToLower();
            var userId  = message.FromId.Value;

            if (!AllUserSessions.ContainsKey(userId))
            {
                AllUserSessions.Add(userId, new UserSession(userId, this));
            }
            if ((command == "таблица" || command == "принять" || command == "отклонить") &&
                !AdminIds.Contains(userId))
            {
                command = "unknown";
            }
            if (!CommandsPhrases.Commands.ContainsKey(command))
            {
                command = "unknown";
            }
            CommandsPhrases.CommandsActions[CommandsPhrases.Commands[command]].Invoke(this, message);
        }