Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        private async Task <MessageReport> SendMessageComplete(WM_Task task, List <string> users, string userCompleteId)
        {
            var result = new MessageReport(false, "error");

            try
            {
                //Lấy người hoàn thiện
                var objUser = await _SY_UserService.GetById(userCompleteId);

                //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 được check hoàn thành bởi {0}", objUser != null ? objUser.Username : ""),
                    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);
        }
Ejemplo n.º 3
0
        private async Task <MessageReport> SendMessageTask(WM_Task task)
        {
            var result = new MessageReport(false, "error");

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

                users.Add(task.UserCreatedId);

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

                //Gửi
                var model = new OneSignalrMessage()
                {
                    Id          = "",
                    Title       = string.Format("Nhắc nhở công việc: {0}", task.Title),
                    Description = "Công việc sắp đến hạn hoàn thành",
                    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);
        }
Ejemplo n.º 4
0
        private async Task RemoveSchedule(WM_Task model)
        {
            var paramPs = new Dictionary <string, string>();

            paramPs.Add("RecordId", model.Id);
            paramPs.Add("RecordType", "task");

            var respond = await ApiHelper.HttpPostFormData("http://localhost:8888/api/wm_task/removeregisterreminder", paramPs, "");
        }
Ejemplo n.º 5
0
        public async Task <MessageReport> Update(WM_Task model)
        {
            var query = new StringBuilder();

            query.AppendLine("{");
            query.AppendLine("'_id': { '$eq': '" + model.Id + "' }");
            query.AppendLine("}");

            return(await _WM_TaskRepository.Update(MongoHelper.ConvertQueryStringToDocument(query.ToString()), model));
        }
Ejemplo n.º 6
0
        public async Task <WM_TaskSubmit> GetCustomByModel(WM_Task model)
        {
            var obj = new WM_TaskSubmit()
            {
                Id          = model.Id,
                DateEnd     = model.DateEnd.ToString("dd/MM/yyyy HH:mm"),
                DateStart   = model.DateStart.ToString("dd/MM/yyyy HH:mm"),
                Description = model.Description,
                Title       = model.Title,
                Status      = model.Status,
                Note        = ""
            };

            var userTasks = from n in _WM_TaskUserRepository.Table
                            where n.TaskId == model.Id
                            select n;

            obj.UserTasks = userTasks.ToList();
            obj.UserIds   = userTasks.Select(n => n.UserId).ToList();

            return(await Task.FromResult(obj));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create(WM_TaskSubmit model, bool SaveAndCountinue = false)
        {
            ViewBag.Select_User = await Select_User("");

            ViewBag.Select_Status = Select_ProjectStatus(model.Status.ToString());
            var users = new string[] { };

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var currentUser = await SessionCookieHelper.CurrentUser(this.HttpContext);

            var obj = new WM_Task()
            {
                DateCreated   = DateTime.Now,
                DateEnd       = Convert.ToDateTime(model.DateEnd),
                DateStart     = Convert.ToDateTime(model.DateStart),
                Description   = model.Description,
                Id            = ObjectId.GenerateNewId().ToString(),
                Title         = model.Title,
                Status        = 0,
                Note          = "",
                UserCreatedId = currentUser != null ? currentUser.UserId : ""
            };

            if (model.UserIds.Any())
            {
                //Lấy danh sách mới
                //users = model.UserIds.Split(',', StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in model.UserIds)
                {
                    var userTask = new WM_TaskUser()
                    {
                        Id            = ObjectId.GenerateNewId().ToString(),
                        TaskId        = obj.Id,
                        UserId        = item,
                        IsCompleted   = false,
                        IsOnScheduled = false,
                        DateCompleted = DateTime.Now,
                        DateCreated   = DateTime.Now
                    };

                    await _WM_TaskService.CreateUserTask(userTask);
                }

                //Thêm người tạo dự án
                users.Append(obj.UserCreatedId);
            }

            //Thực hiện thêm mới
            var result = await _WM_TaskService.Create(obj);

            if (result.isSuccess)
            {
                SendMessage(obj, users.ToList());

                RegisterSchedule(obj);

                //Lưu lại log trên server
                _SY_ReminderSystemService.Create(new Kztek_Model.Models.SY_ReminderSystem()
                {
                    Id           = obj.Id,
                    Type         = "task",
                    isDone       = false,
                    DateReminder = obj.DateEnd.AddMinutes(-15)
                });

                if (SaveAndCountinue)
                {
                    TempData["Success"] = "Thêm mới thành công";
                    return(RedirectToAction("Create"));
                }

                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(obj));
            }
        }
Ejemplo n.º 8
0
 private async Task RemoveSchedule(WM_Task model)
 {
     await _ReminderService.RemoveSchedule(model.Id, "task");
 }
Ejemplo n.º 9
0
 private async Task RegisterSchedule(WM_Task model)
 {
     await _ReminderService.RegisterSchedule(model.Id, "task", model.DateEnd.AddMinutes(-15).ToString("yyyy/MM/dd HH:mm:ss"), string.Format("Nhắc nhở check hoàn thành công việc: {0}", model.Title));
 }
Ejemplo n.º 10
0
 private async Task ReRegisterSchedule(WM_Task model)
 {
     await RemoveSchedule(model);
     await RegisterSchedule(model);
 }
Ejemplo n.º 11
0
 public async Task <MessageReport> Create(WM_Task model)
 {
     return(await _WM_TaskRepository.Add(model));
 }