/// <summary> /// 添加操作记录 /// </summary> /// <param name="model"></param> public bool AddHistory(WorkTaskHistoryModel model) { using (var dbContext = new MissionskyOAEntities()) { AddHistory(dbContext, model); dbContext.SaveChanges(); return(true); } }
/// <summary> /// 添加操作记录 /// </summary> /// <param name="dbContext"></param> /// <param name="model"></param> public bool AddHistory(MissionskyOAEntities dbContext, WorkTaskHistoryModel model) { if (model == null) { Log.Error("无效的操作历史记录。"); throw new InvalidOperationException("无效的操作历史记录。 "); } dbContext.WorkTaskHistories.Add(model.ToEntity()); return(true); }
/// <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 static WorkTaskHistory ToEntity(this WorkTaskHistoryModel model) { if (model == null) { Log.Error("参数无效。"); throw new InvalidOperationException("参数无效。"); } var enity = new WorkTaskHistory() { Id = model.Id, TaskId = model.TaskId, Operator = model.Operator, Status = (int)model.Status, Audit = model.Audit, CreatedTime = model.CreatedTime }; return(enity); }
public static WorkTaskHistoryModel ToModel(this WorkTaskHistory entity) { if (entity == null) { Log.Error("参数无效。"); throw new InvalidOperationException("参数无效。"); } var model = new WorkTaskHistoryModel() { Id = entity.Id, TaskId = entity.TaskId, Operator = entity.Operator, OperatorName = entity.OperatorName ?? string.Empty, Status = (WorkTaskStatus)entity.Status, Audit = entity.Audit, CreatedTime = entity.CreatedTime }; return(model); }