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); }
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); } } }
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); } } }
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); } } } }
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); }
/// <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); }
/// <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); }