예제 #1
0
        private async Task <MessageReport> SendMessage(WM_Task task, List <string> users)
        {
            var result = new MessageReport(false, "error");

            try
            {
                //Lấy Players
                var players = await _OS_PlayerService.GetPlayerIdsByUserIds(users);

                //Gửi
                var model = new OneSignalrMessage()
                {
                    Id          = "",
                    Title       = string.Format("Công việc: {0}", task.Title),
                    Description = string.Format("Công việc mới được giao cho bạn"),
                    UserIds     = "",
                    PlayerIds   = players.Select(n => n.PlayerId).ToArray(),
                    View        = "TaskPage"
                };

                result = await _OS_PlayerService.SendMessage(model);
            }
            catch (System.Exception ex)
            {
                result = new MessageReport(false, ex.Message);
            }

            return(result);
        }
예제 #2
0
        private async Task <MessageReport> SendMessageProject(PM_Project project, PM_Component component)
        {
            var result = new MessageReport(false, "error");

            try
            {
                //Lấy danh sách người dùng liên quan tới component + người tạo dự án
                var users = await GetUserInvolved(component.Id);

                users.Add(project.UserCreatedId);

                //Lấy Players
                var players = await _OS_PlayerService.GetPlayerIdsByUserIds(users);

                //Gửi
                var model = new OneSignalrMessage()
                {
                    Id          = "",
                    Title       = string.Format("Dự án: {0}", project.Title),
                    Description = string.Format("Nhắc nhở hoàn thành Component: {0}", component.Code),
                    UserIds     = "",
                    PlayerIds   = players.Select(n => n.PlayerId).ToArray(),
                    View        = "HomePage"
                };

                result = await _OS_PlayerService.SendMessage(model);
            }
            catch (System.Exception ex)
            {
                result = new MessageReport(false, ex.Message);
            }

            return(result);
        }
예제 #3
0
        public async Task <IActionResult> MessageSubmit(OneSignalrMessage model)
        {
            var result = new MessageReport(false, "Có lỗi xảy ra");

            try
            {
                //Lấy danh sách cần gửi
                if (string.IsNullOrWhiteSpace(model.UserIds))
                {
                    result = new MessageReport(false, "Chưa có người để gửi");
                    return(Json(result));
                }

                //
                var k       = model.UserIds.Split(',', StringSplitOptions.RemoveEmptyEntries).ToList();
                var players = await _OS_PlayerService.GetPlayerIdsByUserIds(k);

                model.PlayerIds = players.Where(n => n.PlayerId != null).Select(n => n.PlayerId).ToArray();
                model.View      = "ProjectPage";

                //
                result = await _OS_PlayerService.SendMessage(model);
            }
            catch (Exception ex)
            {
                result = new MessageReport(false, ex.Message);
            }

            return(Json(result));
        }