public ServiceResponse RejectStep(DataInitProcessExe data, int currentUserID) { ServiceResponse res = new ServiceResponse(); if (data == null) { res.OnError("Data empty"); return(res); } var stepExe = _stepExeRepository.GetSingleByCondition(x => x.NextAssigneeId == null && x.CurrentAssigneeId == currentUserID && x.ProcessStepId == data.ProcessStepId && x.ProcessExecutionId == data.ProcessExeId); if (stepExe == null) { res.OnError("Some error happen"); return(res); } stepExe.IsReject = true; stepExe.RejectReason = data.RejectReason; _stepExeRepository.Update(stepExe); var processExe = _processExeRepository.GetSingleById(data.ProcessExeId); if (processExe != null) { processExe.Status = 3; _processExeRepository.Update(processExe); } this.Save(); res.OnSuccess(processExe); return(res); }
public ServiceResponse RejectStep(DataInitProcessExe data) { ServiceResponse result = new ServiceResponse(); try { var currentUserID = GetCurrentUser.GetUserID(User.Claims.ToList()); result = _processExeService.RejectStep(data, currentUserID); } catch (Exception ex) { result.OnExeption(ex); } return(result); }
public ServiceResponse NextStep(DataInitProcessExe data, int currentUserID) { DateTime now = DateTime.Now; ServiceResponse res = new ServiceResponse(); if (data == null) { res.OnError("Data truyền lên rỗng"); return(res); } var stepExe = _stepExeRepository.GetSingleByCondition(x => x.NextAssigneeId == null && x.CurrentAssigneeId == currentUserID && x.ProcessStepId == data.ProcessStepId); if (stepExe == null) { res.OnError("Không có dữ liệu"); return(res); } stepExe.StepExecutionData = data.StepExecutionData; var nextStepExe = new StepExecution(); nextStepExe.CurrentAssigneeId = data.AssigneeId; nextStepExe.CreatedDate = now; var process = _processRepository.GetSingleById(data.ProcessSettingId); var processExe = _processExeRepository.GetSingleById(data.ProcessExeId); var nextStep = GetNextStep(data.ProcessStepId, process.ProcessId); if (nextStep != null) { if (data.AssigneeId == 0 || data.AssigneeId == null) { res.OnError("Lỗi người thực hiện"); return(res); } processExe.CurrentStepId = nextStep.ProcessStepId; stepExe.NextAssigneeId = data.AssigneeId; stepExe.CurrentAssigneeId = currentUserID; stepExe.CompletedDate = now; nextStepExe.ProcessStepId = nextStep.ProcessStepId; nextStepExe.ProcessExecutionId = data.ProcessExeId; nextStepExe.CurrentAssigneeId = data.AssigneeId; _stepExeRepository.Add(nextStepExe); _stepExeRepository.AddOrUpdate(stepExe); _processExeRepository.Update(processExe); } else { processExe.CurrentStepId = null; stepExe.NextAssigneeId = null; stepExe.CompletedDate = now; processExe.CompletedDate = now; processExe.Status = 2; _processExeRepository.Update(processExe); } this.Save(); res.OnSuccess(processExe); return(res); }
public ServiceResponse InitProcessExe(DataInitProcessExe data, int currentUserID) { DateTime now = DateTime.Now; ServiceResponse res = new ServiceResponse(); if (data == null) { res.OnError("Data empty"); return(res); } var process = _processRepository.GetSingleById(data.ProcessSettingId); var stepExe = new StepExecution(); stepExe.StepExecutionData = data.StepExecutionData; stepExe.NextAssigneeId = data.AssigneeId; stepExe.CurrentAssigneeId = currentUserID; stepExe.CreatedDate = now; stepExe.CompletedDate = now; stepExe.ProcessStepId = data.ProcessStepId; var nextStepExe = new StepExecution(); nextStepExe.CurrentAssigneeId = data.AssigneeId; nextStepExe.CreatedDate = now; var processExe = new ProcessExecution(); processExe.ProcessExecutionName = process.ProcessName; processExe.ProcessSettingId = process.ProcessId; processExe.CurrentStepId = data.ProcessStepId; processExe.OwnerId = currentUserID; processExe.Status = 1; processExe.CreatedDate = now; processExe.StepExecutions = new List <StepExecution>() { stepExe }; var nextStep = GetNextStep(data.ProcessStepId, process.ProcessId); if (nextStep != null) { processExe.CurrentStepId = nextStep.ProcessStepId; nextStepExe.ProcessStepId = nextStep.ProcessStepId; processExe.StepExecutions.Add(nextStepExe); } else { processExe.CurrentStepId = -999; } _processExeRepository.Add(processExe); this.Save(); res.OnSuccess(processExe); return(res); }