/// <summary> /// 修改工作任务状态 /// </summary> /// <param name="workTaskStatus"></param> protected override void UpdateWorkTaskStatus(WorkTaskStatus workTaskStatus) { var oldWorkTaskStatus = WorkTaskStatus; base.UpdateWorkTaskStatus(workTaskStatus); if (DataReports == null || DataReports.Count == 0) { return; } if (oldWorkTaskStatus == WorkTaskStatus.Waiting && workTaskStatus == WorkTaskStatus.Executing) { if (DataReportType == DataReportType.Parallel) { foreach (var item in DataReports) { item.Start(); } } else { var item = DataReports.FirstOrDefault(); item.Start(); } } }
/// <summary> /// 更新工作任务执行状态 /// </summary> /// <param name="workTaskStatus"></param> protected virtual void UpdateWorkTaskStatus(WorkTaskStatus workTaskStatus) { var oldWorkTaskStatus = WorkTaskStatus; WorkTaskStatus = workTaskStatus; if (OnWorkTaskStatusChange != null && oldWorkTaskStatus != WorkTaskStatus) { OnWorkTaskStatusChange.Invoke(this); } }
/// <summary> /// 更新工作任务状态 /// </summary> /// <param name="workTaskStatus"></param> protected override void UpdateWorkTaskStatus(WorkTaskStatus workTaskStatus) { if (workTaskStatus == WorkTaskStatus.Executing && (_workTasks == null || _workTasks.Count == 0)) { throw new Exception("项目流程不包含工作流程,不能开启"); } var oldWorkTaskStatus = WorkTaskStatus; base.UpdateWorkTaskStatus(workTaskStatus); if (oldWorkTaskStatus == WorkTaskStatus.Waiting && workTaskStatus == WorkTaskStatus.Executing) { var firstWorkTask = _workTasks.FirstOrDefault(); firstWorkTask.Start(); } }
/// <summary> /// 执行工作任务工作任务 /// </summary> /// <param name="taskId"></param> /// <param name="nextStatus"></param> /// <param name="currentUser"></param> /// <param name="comment">备注信息</param> /// <returns></returns> public bool Do(int taskId, WorkTaskStatus nextStatus, UserModel currentUser, string comment = null) { using (var dbContext = new MissionskyOAEntities()) { var entity = dbContext.WorkTasks.FirstOrDefault(it => it.Id == taskId); if (entity == null) { Log.Error(string.Format("任务无效, 任务ID: {0}", taskId)); throw new InvalidOperationException("任务无效"); } entity.Status = (int)nextStatus; //状态流转 #region 添加操作日志 switch (nextStatus) { case WorkTaskStatus.Started: AddHistory(dbContext, currentUser.Id, taskId, nextStatus, string.Format("{0}开始执行工作任务,备注: {1}。", currentUser.EnglishName, comment)); //记录日志 break; case WorkTaskStatus.Completed: AddHistory(dbContext, currentUser.Id, taskId, nextStatus, string.Format("{0}完成了工作任务,备注: {1}。", currentUser.EnglishName, comment)); //记录日志 break; case WorkTaskStatus.Closed: AddHistory(dbContext, currentUser.Id, taskId, nextStatus, string.Format("{0}关闭了工作任务,备注: {1}。", currentUser.EnglishName, comment)); //记录日志 break; default: Log.Error("无效的工作任务操作。"); throw new InvalidOperationException("无效的工作任务操作。"); } #endregion //添加推送消息 AddNotification(dbContext, entity.ToModel(), currentUser); dbContext.SaveChanges(); return(true); } }
/// <summary> /// 任务状态更新 /// </summary> /// <param name="taskid"></param> /// <param name="workTaskStatus"></param> public void UpdateWorkTaskState(string taskid, WorkTaskStatus workTaskStatus) { if (taskid == null) { return; } var taskInfo = GetWorkTask(taskid); if (taskInfo == null) { return; } taskInfo.TaskStatus = (int)workTaskStatus; taskInfo.CompleteTime = DateTime.Now; if (workTaskStatus == WorkTaskStatus.Normal) { WorkrecordUpdate(taskInfo.AssignUsers, taskInfo.TodotaskID); } QueryDb.Update(taskInfo); }
public static Task LogAsync(Serilog.ILogger logger, string message, WorkTaskStatus status, string targetId) { logger.Information("{Message}", message); return(Task.CompletedTask); }
public static void Log(string message, WorkTaskStatus status, string deploymentTargetId) { }
public static string ToStatusColor(this WorkTaskStatus value) { return(value.Status.ToLowerInvariant()); }
/// <summary> /// 添加操作记录 /// </summary> /// <param name="dbContext"></param> /// <param name="userId"></param> /// <param name="taskId"></param> /// <param name="status"></param> /// <param name="auditMsg"></param> public void AddHistory(MissionskyOAEntities dbContext, int userId, int taskId, WorkTaskStatus status, string auditMsg) { var history = new WorkTaskHistoryModel() { TaskId = taskId, Operator = userId, Status = status, Audit = auditMsg, CreatedTime = DateTime.Now }; _workTaskHistoryService.AddHistory(dbContext, history); }
public void RetrieveEnumDescription_EnumValuePassed_ReturnsEnumDescription( WorkTaskStatus enumValue, string enumValueDescription) { Assert.AreEqual(DescriptionHelper.RetrieveEnumDescription(enumValue), enumValueDescription); }
public WorkTaskWithStatus(Identity workTaskId, WorkTaskStatus status) { WorkTaskId = workTaskId; Status = status; }