Ejemplo n.º 1
0
        public void CreateTask(TaskMaster task)
        {
            #region 处理代码
            string prefix = string.Empty;
            if (task.Type == CodeMaster.TaskType.Plan)
            {
                prefix = ISIConstants.CODE_PREFIX_PLAN;
            }
            if (task.Type == CodeMaster.TaskType.Issue)
            {
                prefix = ISIConstants.CODE_PREFIX_ISSUE;
            }
            if (task.Type == CodeMaster.TaskType.Improve)
            {
                prefix = ISIConstants.CODE_PREFIX_IMPROVE;
            }
            if (task.Type == CodeMaster.TaskType.Change)
            {
                prefix = ISIConstants.CODE_PREFIX_CHANGE;
            }
            if (task.Type == CodeMaster.TaskType.Privacy)
            {
                prefix = ISIConstants.CODE_PREFIX_PRIVACY;
            }
            if (task.Type == CodeMaster.TaskType.Response)
            {
                prefix = ISIConstants.CODE_PREFIX_RESPONSE;
            }
            if (task.Type == CodeMaster.TaskType.Project)
            {
                prefix = ISIConstants.CODE_PREFIX_PROJECT;
            }
            if (task.Type == CodeMaster.TaskType.Issue)
            {
                prefix = ISIConstants.CODE_PREFIX_PROJECT_ISSUE;
            }
            if (task.Type == CodeMaster.TaskType.Audit)
            {
                prefix = ISIConstants.CODE_PREFIX_AUDIT;
            }
            if (task.Type == CodeMaster.TaskType.Change)
            {
                prefix = ISIConstants.CODE_PREFIX_ENGINEERING_CHANGE;
            }
            if (string.IsNullOrEmpty(prefix))
            {
                prefix = ISIConstants.CODE_PREFIX_ISI;
            }

            task.Code = numberControlMgr.GetTaskNo(prefix);
            #endregion

            task.Status = CodeMaster.TaskStatus.Create;

            genericMgr.Create(task);

        }
Ejemplo n.º 2
0
        public ActionResult New(TaskMaster task)
        {
            if (ModelState.IsValid)
            {

                TaskSubType taskSubType = genericMgr.FindById<TaskSubType>(task.TaskSubType);
                task.Type = taskSubType.Type;

                taskMgr.CreateTask(task);
                SaveSuccessMessage(Resources.ISI.TaskMaster.TaskMaster_Added);
                return RedirectToAction("Edit/" + task.Code);

            }

            return View(task);
        }
Ejemplo n.º 3
0
        private IList<UserSub> SubmitUserSub(TaskMaster task, User user)
        {
            IList<UserSub> userSubList = null;

            if (task.Status == CodeMaster.TaskStatus.Submit && !string.IsNullOrEmpty(ISIHelper.EditUser(task.AssignUserId.ToString())))
            {
                userSubList = GenerateUserSub(task, task.AssignUserId.ToString(), false, user);
            }
            else if (task.Status == CodeMaster.TaskStatus.Assign)
            {
                if (!string.IsNullOrEmpty(ISIHelper.EditUser(task.StartedUser)))
                {
                    userSubList = GenerateUserSub(task, task.StartedUser, false, user);
                }
                else if (!string.IsNullOrEmpty(ISIHelper.EditUser(task.StartUserId.ToString())))
                {
                    userSubList = GenerateUserSub(task, task.StartUserId.ToString(), false, user);
                }
            }
            return userSubList;
        }
Ejemplo n.º 4
0
        private void Remind(TaskMaster task, string level, double minutes, IList<UserSub> userSubList, User operationUser)
        {
            if (userSubList == null || userSubList.Count == 0) return;

            StringBuilder toEmail = new StringBuilder();
            StringBuilder toMobliePhone = new StringBuilder();

            foreach (UserSub userSub in userSubList)
            {
                if (userSub.IsEmail)
                {
                    if (toEmail.Length != 0)
                    {
                        toEmail.Append(";");
                    }
                    toEmail.Append(userSub.Email);
                }
                if (userSub.IsSMS)
                {
                    if (toMobliePhone.Length != 0)
                    {
                        toMobliePhone.Append(";");
                    }
                    toMobliePhone.Append(userSub.MobilePhone);
                }
            }

            string emailBody = string.Empty;
            string smsBody = string.Empty;

            #region 获取内容

            if (toEmail.Length > 0)
            {
                emailBody = this.GetEmailBody(task, level, minutes, operationUser);
            }

            if (toMobliePhone.Length > 0)
            {
                smsBody = this.GetSMSBody(task, level, minutes, operationUser);
            }

            #endregion

            string userMail = string.Empty;
            MailPriority mailPriority;

            #region email标题 回复人 优先级

            string subject = this.GetSubject(operationUser.Code, operationUser.Name, task.Code, task.Type, task.Priority, task.Subject, level, task.Status);

            if (operationUser != null && !string.IsNullOrEmpty(operationUser.Email) && ISIHelper.IsValidEmail(operationUser.Email))
            {
                userMail = operationUser.Name + "," + operationUser.Email;
            }
            else if (level == ISIConstants.ISI_LEVEL_BASE && !string.IsNullOrEmpty(task.Email) && ISIHelper.IsValidEmail(task.Email))
            {
                if (!string.IsNullOrEmpty(task.UserName))
                {
                    userMail = task.UserName + "," + task.Email;
                }
                else
                {
                    userMail = task.Email;
                }
            }

            if (task.Priority == CodeMaster.TaskPriority.Urgent)
            {
                mailPriority = MailPriority.High;
            }
            else
            {
                mailPriority = MailPriority.Normal;
            }

            #endregion

            bool isEmailException = false;
            bool isSMSException = false;

            #region 邮件与短信发送

            if (!string.IsNullOrEmpty(emailBody) && !string.IsNullOrEmpty(toEmail.ToString()))
            {
                //todo
                emailMgr.SendEmail(subject, emailBody, toEmail.ToString(), string.Empty, mailPriority);
                
                // isEmailException = this.SendEmail(task.Code, subject, emailBody, toEmail.ToString(), userMail, mailPriority, operationUser);
                //isEmailException = this.SendEmail(task.Code, subject, emailBody, "*****@*****.**", userMail, mailPriority, operationUser);
            }
            if (!string.IsNullOrEmpty(smsBody) && !string.IsNullOrEmpty(toMobliePhone.ToString()))
            {
                isSMSException = this.SendSMS(task.Code, toMobliePhone.ToString(), smsBody, operationUser);
            }
            #endregion

            #region 记录上报TaskDetail
            CreateTaskDetail(task, level, userSubList, isEmailException, isSMSException, operationUser);
            #endregion
        }
Ejemplo n.º 5
0
 public void UpdateTaskStatus(TaskStatus taskStatus, TaskMaster task)
 {
     task.Flag = taskStatus.Flag;
     task.Color = taskStatus.Color;
     task.LastModifyDate = taskStatus.LastModifyDate;
     task.LastModifyUserId = taskStatus.LastModifyUserId;
     task.LastModifyUserName = taskStatus.LastModifyUserName;
     this.UpdateTask(task);
 }
Ejemplo n.º 6
0
        protected void RemindStatus(TaskMaster task, TaskStatus taskStatus)
        {
            #region 获取用户列表
            StringBuilder users = new StringBuilder();
            if (taskStatus.IsRemindCreateUser)
            {
                users.Append(task.CreateUserId.ToString());
                if (!string.IsNullOrEmpty(task.SubmitUserId.ToString()))
                {
                    users.Append(ISIConstants.ISI_USER_SEPRATOR);
                    users.Append(task.SubmitUserId.ToString());
                }
            }
            if (taskStatus.IsRemindAssignUser)
            {
                if (!string.IsNullOrEmpty(task.AssignUserId.ToString()))
                {
                    if (users.Length != 0)
                    {
                        users.Append(ISIConstants.ISI_USER_SEPRATOR);
                    }
                    users.Append(task.AssignUserId.ToString());
                }
                else if (task.AssignUserId != null)
                {
                    if (users.Length != 0)
                    {
                        users.Append(ISIConstants.ISI_USER_SEPRATOR);
                    }
                    users.Append(task.AssignUserId.ToString());
                }
            }
            if (taskStatus.IsRemindStartUser && task.StartedUser != null)
            {
                if (users.Length != 0)
                {
                    users.Append(ISIConstants.ISI_USER_SEPRATOR);
                }
                users.Append(task.StartedUser);
            }
            if (taskStatus.IsRemindCommentUser)
            {
                //所有评论人
                //   var commentList = commentDetailMgrE.GetComment(task.Code);
                var commentList = new List<CommentDetail>();
                if (commentList != null && commentList.Count > 0)
                {
                    string commentUsers = string.Join(";", commentList.Select(t => t.CreateUser).Distinct().ToArray<string>());
                    if (users.Length != 0)
                    {
                        users.Append(ISIConstants.ISI_USER_SEPRATOR);
                    }
                    users.Append(commentUsers);

                    task.CommentDetail = commentList[0];
                }
            }
            #endregion

            User operationUser = new User();
            operationUser.Id = taskStatus.LastModifyUserId;
            operationUser.FirstName = taskStatus.LastModifyUserName;
            IList<UserSub> userSubList = this.GenerateUserSub(task, users.ToString(), false, operationUser);

            task.TaskStatus = taskStatus;
            this.Remind(task, ISIConstants.ISI_LEVEL_STATUS, 0, userSubList, operationUser);
        }
Ejemplo n.º 7
0
        private void HandleAssign(TaskMaster task, DateTime now, User user)
        {
            task.SubmitDate = now;
            task.SubmitUserId = user.Id;
            task.SubmitUserName = user.Name.Trim();

            task.Status = CodeMaster.TaskStatus.Submit;

            if (string.IsNullOrEmpty(task.AssignStartUser))
            {
                #region 排班
                //IList<SchedulingView> schedulingViewList = schedulingMgrE.GetScheduling2(now.Date, now.Date, task.TaskSubType.Code, string.Empty);
                //if (schedulingViewList != null && schedulingViewList.Count > 0)
                //{
                //    SchedulingView schedulingView = schedulingViewList.Where(s => s.StartTime <= now && now <= s.EndTime).FirstOrDefault();
                //    if (schedulingView != null)
                //    {
                //        if (schedulingView.Id.HasValue)
                //        {
                //            //排班表有执行人
                //            task.Scheduling = schedulingView.Id;
                //            task.SchedulingStartUser = schedulingView.StartUser;
                //            task.SchedulingShift = schedulingView.ShiftCode;
                //            task.SchedulingShiftTime = schedulingView.StartTime.ToString("yyyy-MM-dd HH:mm") + " " + schedulingView.EndTime.ToString("yyyy-MM-dd HH:mm");
                //        }
                //        else
                //        {
                //            task.Scheduling = null;

                //            task.AssignStartUser = schedulingView.StartUser;
                //            if (string.IsNullOrEmpty(task.AssignStartUser) && schedulingView.IsAutoAssign)
                //            {
                //                task.AssignStartUser = ISIConstants.ISI_LEVEL_SEPRATOR + user.Code + ISIConstants.ISI_LEVEL_SEPRATOR;
                //            }
                //            task.SchedulingShift = schedulingView.ShiftCode;
                //            task.SchedulingShiftTime = schedulingView.StartTime.ToString("yyyy-MM-dd HH:mm") + " " + schedulingView.EndTime.ToString("yyyy-MM-dd HH:mm");
                //        }
                //    }
                //    else
                //    {
                //        ClearScheduling(task);
                //    }
                //}
                //else
                //{
                //    ClearScheduling(task);
                //}

                #endregion

                if (!string.IsNullOrEmpty(task.SchedulingStartUser) || !string.IsNullOrEmpty(task.AssignStartUser))
                {
                    //userCodes = !string.IsNullOrEmpty(task.SchedulingStartUser) ? task.SchedulingStartUser : task.AssignStartUser;
                    //this.wfDetailMgrE.CreateWFDetail(task.Code, task.Status, ISIConstants.CODE_MASTER_ISI_STATUS_VALUE_ASSIGN, now, user);
                    task.Status = CodeMaster.TaskStatus.Assign;
                    task.AssignDate = now;
                    task.AssignUserId = user.Id;
                    task.AssignUserName = user.Name.Trim();

                    if (!task.IsAutoAssign)
                    {
                        task.PlanStartDate = now;
                        task.PlanCompleteDate = this.GetPlanCompleteDate(task.TaskSubType, task.PlanStartDate.Value);
                    }
                }
            }
        }
Ejemplo n.º 8
0
 private void Remind(TaskMaster task, IList<UserSub> userSubList, User operationUser)
 {
     this.Remind(task, ISIConstants.ISI_LEVEL_BASE, 0, userSubList, operationUser);
 }
Ejemplo n.º 9
0
        private void PutStatusText(TaskMaster task, StringBuilder content, string separator)
        {
            if (task.TaskStatus != null)
            {
                content.Append(separator);
                content.Append("<U>进展</U>:");

                if (!string.IsNullOrEmpty(task.TaskStatus.Description))
                {
                    content.Append(task.TaskStatus.Description.Replace(ISIConstants.TEXT_SEPRATOR, separator).Replace(ISIConstants.TEXT_SEPRATOR2, "<br/>"));
                    content.Append(separator);
                    content.Append("标志: <span style='background-color:" + task.TaskStatus.Color + "'>" + task.TaskStatus.Flag + "</span>");
                    content.Append(separator);
                    content.Append("开始时间: " + task.TaskStatus.StartDate.ToString("yyyy-MM-dd"));
                    content.Append(separator);
                    content.Append("结束时间: " + task.TaskStatus.EndDate.ToString("yyyy-MM-dd"));
                }
                content.Append(separator);
                content.Append(separator);
                content.Append(task.TaskStatus.LastModifyUserName);
                content.Append(separator);
                content.Append(task.TaskStatus.LastModifyDate.ToString("yyyy-MM-dd HH:mm"));
                content.Append(separator);
                content.Append(separator);
                content.Append(separator);
            }
        }
Ejemplo n.º 10
0
        protected string GetSMSBody(TaskMaster task, string level, double minutes, User operationUser)
        {
            StringBuilder content = new StringBuilder();
            string separator = ISIConstants.SMS_SEPRATOR;
            try
            {
                content.Append("ISI  ");
                var companyName = systemMgr.GetEntityPreferenceValue(Entity.SYS.EntityPreference.CodeEnum.CompanyName);
                ISIHelper.AppendTestText(companyName, content, separator);
                if (!string.IsNullOrEmpty(task.HelpContent))
                {
                    content.Append("请协助求助处理");
                    content.Append(separator);
                }

                #region 拼邮件,后续再加
                //content.Append(this.GetDesc(task.Type, operationUser.Code));
                //content.Append(task.Code);
                //if (task.Priority == ISIConstants.CODE_MASTER_ISI_PRIORITY_URGENT)
                //{
                //    content.Append("[" + codeMasterMgrE.GetCachedCodeMaster(ISIConstants.CODE_MASTER_ISI_PRIORITY, task.Priority).Description + "]");
                //}

                //if (!string.IsNullOrEmpty(task.Subject))
                //{
                //    content.Append(separator);
                //    content.Append("标题:" + task.Subject);
                //}

                //content.Append(separator);
                //content.Append("类型: " + (task.TaskSubType != null ? task.TaskSubType.Description : task.TaskSubTypeDesc) + "|" + this.codeMasterMgrE.LoadCodeMaster(ISIConstants.CODE_MASTER_ISI_STATUS, task.Status).Description);

                //DateTime date = DateTime.Now;

                //if (level == ISIConstants.ISI_LEVEL_BASE)//提醒
                //{

                //    content.Append("|提醒");
                //}
                //else if (level == ISIConstants.ISI_LEVEL_HELP)
                //{

                //    content.Append("|求助");
                //}
                //else if (level == ISIConstants.ISI_LEVEL_COMMENT)
                //{

                //    content.Append("|评论");
                //}
                //else if (level == ISIConstants.ISI_LEVEL_STARTPERCENT)
                //{

                //    content.Append("|执行进度");
                //}
                //else if (level == ISIConstants.ISI_LEVEL_OPEN)
                //{

                //    content.Append("|开始");
                //}
                //else if (level == ISIConstants.ISI_LEVEL_COMPLETE)
                //{

                //    content.Append("|逾期完成");
                //}
                //else//上报
                //{
                //    content.Append("|上报");
                //    //content.Append(level + "级");

                //    //分派提醒
                //    if (task.Status == ISIConstants.CODE_MASTER_ISI_STATUS_VALUE_SUBMIT && task.SubmitDate.HasValue)
                //    {
                //        string diff = ISIHelper.GetDiff(task.SubmitDate.Value.AddMinutes(minutes));
                //        if (!string.IsNullOrEmpty(diff))
                //        {
                //            content.Append(separator);
                //            content.Append("分派超时:" + diff);
                //        }
                //        date = task.SubmitDate.Value;
                //    }
                //    //开始提醒
                //    if ((task.Status == ISIConstants.CODE_MASTER_ISI_STATUS_VALUE_ASSIGN && task.AssignDate.HasValue))
                //    {
                //        string diff = ISIHelper.GetDiff(task.AssignDate.Value.AddMinutes(minutes));
                //        if (!string.IsNullOrEmpty(diff))
                //        {
                //            content.Append(separator);
                //            content.Append("确认超时:" + diff);
                //        }
                //        date = task.AssignDate.Value;
                //    }
                //    //关闭提醒
                //    else if ((task.Status == ISIConstants.CODE_MASTER_ISI_STATUS_VALUE_INPROCESS
                //                || task.Status == ISIConstants.CODE_MASTER_ISI_STATUS_VALUE_COMPLETE) && task.StartDate.HasValue)
                //    {
                //        string diff = ISIHelper.GetDiff(task.StartDate.Value.AddMinutes(minutes));
                //        if (!string.IsNullOrEmpty(diff))
                //        {
                //            content.Append(separator);
                //            content.Append("关闭超时:" + diff);
                //        }
                //        if (task.Status == ISIConstants.CODE_MASTER_ISI_STATUS_VALUE_INPROCESS)
                //        {
                //            date = task.StartDate.Value;
                //        }
                //        else if (task.Status == ISIConstants.CODE_MASTER_ISI_STATUS_VALUE_COMPLETE)
                //        {
                //            date = task.CompleteDate.Value;
                //        }
                //    }
                //}
                //if (!string.IsNullOrEmpty(task.BackYards))
                //{
                //    content.Append(separator);
                //    content.Append("追溯码:" + task.BackYards);
                //}
                //content.Append(separator);
                //content.Append("时间:" + date.ToString("yyyy-MM-dd HH:mm") + separator);
                ////content.Append("类型:" + task.TaskSubType.Description + separator);
                //if (task.FailureMode != null || !string.IsNullOrEmpty(task.FailureModeCode))
                //{
                //    content.Append("失效模式:" + (task.FailureMode != null ? task.FailureMode.Code : task.FailureModeCode) + separator);
                //}
                //content.Append("地点:" + task.TaskAddress + separator);
                //if (task.PlanStartDate.HasValue)
                //{
                //    content.Append("预计开始时间:" + task.PlanStartDate.Value.ToString("yyyy-MM-dd HH:mm") + separator);
                //}
                //if (task.PlanCompleteDate.HasValue)
                //{
                //    content.Append("预计完成时间:" + task.PlanCompleteDate.Value.ToString("yyyy-MM-dd HH:mm") + separator);
                //}
                //if (task.Status == ISIConstants.CODE_MASTER_ISI_STATUS_VALUE_COMPLETE)
                //{
                //    content.Append("已经完成!");
                //    return content.ToString();
                //}
                //if (level == ISIConstants.ISI_LEVEL_COMMENT)
                //{
                //    if (task.CommentDetail != null && !string.IsNullOrEmpty(task.CommentDetail.Comment))
                //    {
                //        content.Append(ISIHelper.GetStrLength(task.CommentDetail.Comment, 20));
                //        content.Append(separator);
                //        content.Append(task.CommentDetail.CreateUserNm);
                //        content.Append(separator);
                //        content.Append(task.CommentDetail.CreateDate.ToString("yyyy-MM-dd HH:mm"));

                //    }
                //}
                //else
                //{
                //    if (!string.IsNullOrEmpty(task.Description1))
                //    {
                //        content.Append(ISIHelper.GetStrLength(task.Description1, 20));
                //        content.Append(separator);
                //    }
                //    if (!string.IsNullOrEmpty(task.UserName)
                //        || (!string.IsNullOrEmpty(task.MobilePhone) && ISIHelper.IsValidMobilePhone(task.MobilePhone)))
                //    {
                //        content.Append("[");

                //        if (!string.IsNullOrEmpty(task.UserName))
                //        {
                //            content.Append(task.UserName);
                //        }
                //        if (!string.IsNullOrEmpty(task.MobilePhone) && ISIHelper.IsValidMobilePhone(task.MobilePhone))
                //        {
                //            if (!string.IsNullOrEmpty(task.UserName))
                //            {
                //                content.Append(", ");
                //            }
                //            content.Append(task.MobilePhone);
                //        }
                //        content.Append("]");
                //    }

                //    if (task.Status == ISIConstants.CODE_MASTER_ISI_STATUS_VALUE_COMPLETE)
                //    {
                //        content.Append(separator);
                //        content.Append("关闭回复 " + ISIHelper.GetSerialNo(task.Code) + "+空格+Y");
                //    }
                //}
                #endregion

            }
            catch (Exception e)
            {
                // log.Error(e.Message, e);
            }
            return content.ToString();
        }
Ejemplo n.º 11
0
        private void PutCommentText(TaskMaster task, StringBuilder content, string separator)
        {
            if (task.CommentDetail != null)
            {
                content.Append(separator);
                content.Append("<U>评论</U>:");

                if (!string.IsNullOrEmpty(task.CommentDetail.Comment))
                {
                    content.Append(task.CommentDetail.Comment.Replace(ISIConstants.TEXT_SEPRATOR, separator).Replace(ISIConstants.TEXT_SEPRATOR2, "<br/>"));
                }
                content.Append(separator);
                content.Append(separator);
                content.Append(task.CommentDetail.CreateUserNm);
                content.Append(separator);
                content.Append(task.CommentDetail.CreateDate.ToString("yyyy-MM-dd HH:mm"));
                content.Append(separator);
                content.Append(separator);
                content.Append(separator);
            }
        }
Ejemplo n.º 12
0
        public void SubmitTask(TaskMaster task, User user)
        {
            try
            {
                if (task.Status != CodeMaster.TaskStatus.Create)
                {
                    throw new BusinessException(Resources.ISI.TaskMaster.TaskMaster_Errors_StatusErrorWhenSubmit, task.Status.ToString());
                }

                DateTime dateTimeNow = DateTime.Now;

                HandleAssign(task, dateTimeNow, user);

                task.LastModifyDate = dateTimeNow;
                task.LastModifyUserId = user.Id;
                task.LastModifyUserName = user.Name.Trim();
                this.UpdateTask(task);

                if (task.Status == CodeMaster.TaskStatus.Assign && task.IsAutoStart)
                {
                    this.ConfirmTask(task.Code, user);
                }
                else if ((!task.IsNoSend
                                && !ISIHelper.Contains(task.AssignUserId.ToString(), user.Id.ToString())//分派人
                                && !ISIHelper.Contains(task.AssignUpUser, user.Code)
                    //&& !user.Permissions.Contains(ISIConstants.CODE_MASTER_ISI_TASK_VALUE_ISIADMIN)
                    ))
                {

                    IList<UserSub> userSubList = SubmitUserSub(task, user);
                    #region 处理发送用户
                    if (userSubList != null && userSubList.Count > 0)
                    {
                        Remind(task, userSubList, user);
                    }
                    #endregion

                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 13
0
 public void UpdateTask(TaskMaster task)
 {
     genericMgr.Update(task);
 }
Ejemplo n.º 14
0
 private IList<UserSub> GenerateUserSub(TaskMaster task, User user)
 {
     return this.GenerateUserSub(task, string.Empty, true, user);
 }
Ejemplo n.º 15
0
        public void ConfirmTask(TaskMaster task, User user)
        {
            //检查状态
            if (task.Status != CodeMaster.TaskStatus.Assign)
            {
                throw new BusinessException(Resources.ISI.TaskMaster.TaskMaster_Errors_StatusErrorWhenConfirm, task.Status.ToString());
            }

            DateTime nowDate = DateTime.Now;

            task.Flag = ISIConstants.CODE_MASTER_ISI_FLAG_DI2;

            task.Status = CodeMaster.TaskStatus.InProcess;
            task.StartDate = nowDate;
            task.StartUserId = user.Id;
            task.StartUserName = user.Name.Trim();
            task.LastModifyDate = nowDate;
            task.LastModifyUserId = user.Id;
            task.LastModifyUserName = user.Name.Trim();
            this.UpdateTask(task);

            if (task.IsAutoComplete)
            {
                this.CompleteTask(task, user);
            }
        }
Ejemplo n.º 16
0
 private IList<UserSub> GenerateUserSub(TaskMaster task, string userCodes, bool isUserSub, User user)
 {
     return GenerateUserSub(task.Type, task.TaskSubType, task.Code, userCodes, isUserSub, user);
 }
Ejemplo n.º 17
0
        public void CompleteTask(TaskMaster task, User user)
        {
            //检查状态
            if (task.Status != CodeMaster.TaskStatus.InProcess)
            {
                throw new BusinessException(Resources.ISI.TaskMaster.TaskMaster_Errors_StatusErrorWhenComplete, task.Status.ToString());
            }

            DateTime nowDate = DateTime.Now;

            task.Flag = ISIConstants.CODE_MASTER_ISI_FLAG_DI4;
            task.Status = CodeMaster.TaskStatus.Complete;
            task.CompleteDate = nowDate;
            task.CompleteUserId = user.Id;
            task.CompleteUserName = user.Name.Trim();
            task.LastModifyDate = nowDate;
            task.LastModifyUserId = user.Id;
            task.LastModifyUserName = user.Name.Trim();
            this.UpdateTask(task);

            if (task.IsAutoClose)
            {
                this.CloseTask(task.Code, user);
            }
            else if (!task.IsCompleteNoRemind)
            {
                //提醒关闭
                IList<UserSub> userSubList = this.GenerateUserSub(task, task.CreateUserId.ToString() + ISIConstants.ISI_USER_SEPRATOR + task.SubmitUserId.ToString() + ISIConstants.ISI_USER_SEPRATOR + task.AssignUserId.ToString(), false, user);
                Remind(task, userSubList, user);
            }
        }
Ejemplo n.º 18
0
 private void Remind(TaskMaster task, IList<UserSub> userSubList, string helpContent, User operationUser)
 {
     task.HelpContent = helpContent;
     this.Remind(task, ISIConstants.ISI_LEVEL_HELP, 0, userSubList, operationUser);
 }
Ejemplo n.º 19
0
        public void CreateTaskDetail(TaskMaster task, string level, IList<UserSub> userSubList, bool isEmailException, bool isSMSException, User user)
        {
            DateTime now = DateTime.Now;
            foreach (UserSub userSub in userSubList)
            {
                TaskDetail taskDetail = new TaskDetail();
                taskDetail.TaskCode = task.Code;
                taskDetail.Status = task.Status;
                taskDetail.IsEmail = userSub.IsEmail;
                taskDetail.IsSMS = userSub.IsSMS;
                taskDetail.BackYards = task.BackYards;
                taskDetail.TaskSubType = task.TaskSubType;
                taskDetail.Description1 = task.Description1;
                taskDetail.Description2 = task.Description2;
                taskDetail.UserName = task.UserName;
                taskDetail.ExpectedResults = task.ExpectedResults;
                taskDetail.Flag = task.Flag;
                taskDetail.Color = task.Color;
                //  taskDetail.FailureMode = task.FailureMode != null ? task.FailureMode.Code : task.FailureModeCode;
                taskDetail.PlanCompleteDate = task.PlanCompleteDate;
                taskDetail.PlanStartDate = task.PlanStartDate;
                taskDetail.Subject = task.Subject;
                taskDetail.UserEmail = task.Email;
                taskDetail.UserMobilePhone = task.MobilePhone;
                taskDetail.CreateDate = now;
                taskDetail.CreateUserId = user.Id;
                taskDetail.CreateUserName = user.Name;
                taskDetail.LastModifyDate = now;
                taskDetail.LastModifyUserId = user.Id;
                taskDetail.LastModifyUserName = user.Name;
                taskDetail.Priority = task.Priority;
                if (isEmailException)
                {
                    taskDetail.EmailStatus = ISIConstants.CODE_MASTER_ISI_SEND_STATUS_FAIL;
                }
                else
                {
                    taskDetail.EmailStatus = taskDetail.IsEmail ? ISIConstants.CODE_MASTER_ISI_SEND_STATUS_SUCCESS : ISIConstants.CODE_MASTER_ISI_SEND_STATUS_NOTSEND;
                }

                if (taskDetail.IsEmail)
                {
                    taskDetail.EmailCount += 1;
                }

                if (isSMSException)
                {
                    taskDetail.SMSStatus = ISIConstants.CODE_MASTER_ISI_SEND_STATUS_FAIL;
                }
                else
                {
                    taskDetail.SMSStatus = taskDetail.IsSMS ? ISIConstants.CODE_MASTER_ISI_SEND_STATUS_SUCCESS : ISIConstants.CODE_MASTER_ISI_SEND_STATUS_NOTSEND;
                }

                if (taskDetail.IsSMS)
                {
                    taskDetail.SMSCount += 1;
                }

                taskDetail.Level = level;
                taskDetail.Email = userSub.Email;
                taskDetail.MobilePhone = userSub.MobilePhone;

                taskDetail.Receiver = userSub.Code;

                taskDetail.IsActive = true;
                genericMgr.Create(taskDetail);
            }
        }
Ejemplo n.º 20
0
        protected string GetEmailBody(TaskMaster task, string level, double minutes, User operationUser)
        {

            StringBuilder content = new StringBuilder();
            try
            {
                content.Append("<p style='font-size:15px;'>");
                string separator = ISIConstants.EMAIL_SEPRATOR;
                DateTime now = DateTime.Now;

                var companyName = systemMgr.GetEntityPreferenceValue(Entity.SYS.EntityPreference.CodeEnum.CompanyName);
                ISIHelper.AppendTestText(companyName, content, separator);

                if (level == ISIConstants.ISI_LEVEL_HELP)
                {
                    content.Append(separator);
                    content.Append("<U>求助</U>:" + task.HelpContent);
                    content.Append(separator);
                    content.Append(separator);
                    content.Append(operationUser.Name);
                    content.Append(separator);
                    content.Append(now.ToString("yyyy-MM-dd HH:mm"));
                    content.Append(separator);
                    content.Append(separator);
                }
                if (level == ISIConstants.ISI_LEVEL_STATUS)
                {
                    PutStatusText(task, content, separator);
                    PutCommentText(task, content, separator);
                }
                if (level == ISIConstants.ISI_LEVEL_COMMENT)
                {
                    PutCommentText(task, content, separator);
                    PutStatusText(task, content, separator);
                }
                if (level == ISIConstants.ISI_LEVEL_STARTPERCENT)
                {
                    content.Append(separator);
                    content.Append("按照预计完成时间 " + (task.PlanCompleteDate.HasValue ? task.PlanCompleteDate.Value.ToString("yyyy-MM-dd HH:mm") : string.Empty) + " 已经过去 " + (task.StartPercent.Value * 100).ToString("0.####") + "% 请注意进度。");
                    content.Append(separator);
                    content.Append(separator);
                    content.Append(separator);
                }
                if (level == ISIConstants.ISI_LEVEL_OPEN)
                {
                    content.Append(separator);
                    content.Append("已经到了预计开始时间 " + (task.PlanStartDate.HasValue ? task.PlanStartDate.Value.ToString("yyyy-MM-dd HH:mm") : string.Empty) + ",提醒开始执行!");
                    content.Append(separator);
                    content.Append(separator);
                    content.Append(separator);
                }
                if (level == ISIConstants.ISI_LEVEL_COMPLETE)
                {
                    content.Append(separator);
                    content.Append("已经超过预计完成时间 " + (task.PlanCompleteDate.HasValue ? task.PlanCompleteDate.Value.ToString("yyyy-MM-dd HH:mm") : string.Empty) + "。请注意!");
                    content.Append(separator);
                    content.Append(separator);
                    content.Append(separator);
                }
                if (!string.IsNullOrEmpty(task.Description1))
                {
                    content.Append("<U>描述</U>: " + task.Description1.Replace(ISIConstants.TEXT_SEPRATOR, separator).Replace(ISIConstants.TEXT_SEPRATOR2, "<br/>"));
                }
                content.Append(separator);
                if (!string.IsNullOrEmpty(task.Description2))
                {
                    content.Append("<I>补充描述</I>: " + task.Description2.Replace(ISIConstants.TEXT_SEPRATOR, separator).Replace(ISIConstants.TEXT_SEPRATOR2, "<br/>"));
                }
                content.Append(separator + separator);
                if (!string.IsNullOrEmpty(task.ExpectedResults))
                {
                    content.Append("<U>预期结果/达成结果</U>: ");
                    content.Append(task.ExpectedResults.Replace(ISIConstants.TEXT_SEPRATOR, separator).Replace(ISIConstants.TEXT_SEPRATOR2, "<br/>"));
                    content.Append(separator + separator);
                }
                content.Append("<U>" + this.GetDesc(task.Type, operationUser.Name) + "</U>: ");
                content.Append(task.Code);
                if (task.Priority == CodeMaster.TaskPriority.Urgent)
                {
                    // content.Append("[" + codeMasterMgrE.GetCachedCodeMaster(ISIConstants.CODE_MASTER_ISI_PRIORITY, task.Priority).Description + "]");
                }
                content.Append(separator);
                //  content.Append("<U>状态</U>: " + systemMgr.r( this.codeMasterMgrE.LoadCodeMaster(ISIConstants.CODE_MASTER_ISI_STATUS, task.Status).Description);

                if (!string.IsNullOrEmpty(task.Subject))
                {
                    content.Append(separator);
                    content.Append("<U>标题</U>: " + task.Subject);
                }
                DateTime date = DateTime.Now;

                if (level == ISIConstants.ISI_LEVEL_BASE)//提醒
                {
                    content.Append(separator);
                    if (task.Status == CodeMaster.TaskStatus.Submit)
                    {
                        content.Append("<U>发送类型</U>: 分派提醒");
                    }
                    else if (task.Status == CodeMaster.TaskStatus.Assign)
                    {
                        content.Append("<U>发送类型</U>: 执行提醒");
                    }
                    else
                    {
                        content.Append("<U>发送类型</U>: 提醒");
                    }
                }
                else if (level == ISIConstants.ISI_LEVEL_COMMENT)
                {
                    content.Append(separator);
                    content.Append("<U>发送类型</U>: 评论");
                }
                else if (level == ISIConstants.ISI_LEVEL_STATUS)
                {
                    content.Append(separator);
                    content.Append("<U>发送类型</U>: 进展");
                }
                else if (level == ISIConstants.ISI_LEVEL_HELP)
                {
                    content.Append(separator);
                    content.Append("<U>发送类型</U>: 求助");
                }
                else if (level == ISIConstants.ISI_LEVEL_STARTPERCENT)
                {
                    content.Append(separator);
                    content.Append("<U>发送类型</U>: 执行进度提醒");
                }
                else if (level == ISIConstants.ISI_LEVEL_OPEN)
                {
                    content.Append(separator);
                    content.Append("<U>发送类型</U>: 开始执行提醒");
                }
                else if (level == ISIConstants.ISI_LEVEL_COMPLETE)
                {
                    content.Append(separator);
                    content.Append("<U>发送类型</U>: 逾期完成提醒");
                }
                else//上报
                {
                    content.Append(separator);
                    content.Append("<U>发送类型</U>: 上报" + level + "级");

                    //分派提醒
                    if (task.Status == CodeMaster.TaskStatus.Submit && task.SubmitDate.HasValue)
                    {
                        string diff = ISIHelper.GetDiff(task.SubmitDate.Value.AddMinutes(minutes));
                        if (!string.IsNullOrEmpty(diff))
                        {
                            content.Append(separator);
                            content.Append("<U>分派超时</U>: " + diff);
                        }
                        date = task.SubmitDate.Value;
                    }
                    //开始提醒
                    if ((task.Status == CodeMaster.TaskStatus.Assign && task.AssignDate.HasValue))
                    {
                        string diff = ISIHelper.GetDiff(task.AssignDate.Value.AddMinutes(minutes));
                        if (!string.IsNullOrEmpty(diff))
                        {
                            content.Append(separator);
                            content.Append("<U>确认超时</U>: " + diff);
                        }
                        date = task.AssignDate.Value;
                    }
                    //关闭提醒
                    else if (task.Status == CodeMaster.TaskStatus.Complete && task.CompleteDate.HasValue)
                    {
                        string diff = ISIHelper.GetDiff(task.CompleteDate.Value.AddMinutes(minutes));
                        if (!string.IsNullOrEmpty(diff))
                        {
                            content.Append(separator);
                            content.Append("<U>关闭超时</U>: " + diff);
                        }
                        date = task.CompleteDate.Value;
                    }
                }

                if (!string.IsNullOrEmpty(task.BackYards))
                {
                    content.Append(separator);
                    content.Append("<U>追溯码</U>: " + task.BackYards);
                }
                content.Append(separator);
                content.Append("<U>时间</U>: " + date.ToString("yyyy-MM-dd HH:mm") + separator);

                if (task.Type == CodeMaster.TaskType.Project)
                {
                    content.Append("<U>项目</U>: " + task.TaskSubTypeDesc + separator);
                    content.Append("<U>阶段</U>: " + task.Phase + separator);
                    //content.Append("序号: " + task.Seq + separator);
                }
                else
                {
                    //content.Append("<U>类型</U>: " + (task.TaskSubType != null ? task.TaskSubType.Description : task.TaskSubTypeDesc) + separator);
                    //if (task.FailureMode != null || !string.IsNullOrEmpty(task.FailureModeCode))
                    //{
                    //    content.Append("<U>失效模式</U>: " + (task.FailureMode != null ? task.FailureMode.Code : task.FailureModeCode) + separator);
                    //}
                }

                content.Append("<U>地点</U>: " + task.TaskAddress + separator);

                if (!string.IsNullOrEmpty(task.AssignStartUserName))
                {
                    content.Append("<U>执行人</U>: " + task.AssignStartUserName + separator);
                }
                else
                {
                    //string principals = this.GetUserName(task.AssignStartUserName);
                    //content.Append("<U>执行人</U>: " + principals + separator);
                }

                if (task.PlanStartDate.HasValue)
                {
                    content.Append("<U>预计开始时间</U>: " + task.PlanStartDate.Value.ToString("yyyy-MM-dd HH:mm") + separator);
                }
                if (task.PlanCompleteDate.HasValue)
                {
                    content.Append("<U>预计完成时间</U>: " + task.PlanCompleteDate.Value.ToString("yyyy-MM-dd HH:mm") + separator);
                }

                content.Append(separator + separator);

                if (task.UserName != null && task.UserName.Trim() != string.Empty)
                    content.Append(task.UserName + separator);
                if (task.MobilePhone != null && task.MobilePhone.Trim() != string.Empty && ISIHelper.IsValidMobilePhone(task.MobilePhone))
                    content.Append("Tel: " + task.MobilePhone + separator);
                if (task.Email != null && task.Email.Trim() != string.Empty && ISIHelper.IsValidEmail(task.Email))
                    content.Append("Email: " + task.Email + separator);

                var webAddress = systemMgr.GetEntityPreferenceValue(Entity.SYS.EntityPreference.CodeEnum.WebAddress);

                content.Append(separator);
                content.Append(companyName + separator);
                content.Append("<a href='http://" + webAddress + "'>http://" + webAddress + "</a>");
                content.Append(separator);
                content.Append("</p>");
            }
            catch (Exception e)
            {
                //  log.Error(e.Message, e);
            }
            return content.ToString();
        }
Ejemplo n.º 21
0
        public ActionResult _Edit(TaskMaster task)
        {
            try
            {
                taskMgr.UpdateTask(task);
                SaveSuccessMessage(Resources.ISI.TaskMaster.TaskMaster_Updated);
            }

            catch (BusinessException ex)
            {
                SaveErrorMessage(ex.GetMessages()[0].GetMessageString());
            }
            return RedirectToAction("Edit", new { code = task.Code });
        }