private void UpdateWorkflowHistory(MasterDataApprovalDetailViewModel data, Enums.ActionType action, string comment = "") { WorkflowHistoryDto workflowDto = new WorkflowHistoryDto(); workflowDto.FORM_ID = data.APPROVAL_ID; workflowDto.ACTION = action; workflowDto.ACTION_DATE = DateTime.Now; workflowDto.FORM_NUMBER = data.FORM_ID; workflowDto.FORM_TYPE_ID = Enums.FormType.MasterDataApproval; if (action == Enums.ActionType.Created) { workflowDto.ROLE = _poaBLL.GetUserRole(data.CREATED_BY); workflowDto.ACTION_BY = data.CREATED_BY; } else { if (action == Enums.ActionType.Reject) { workflowDto.COMMENT = comment; } workflowDto.ROLE = _poaBLL.GetUserRole(data.APPROVED_BY); workflowDto.ACTION_BY = data.APPROVED_BY; } _workflowHistoryBLL.AddHistory(workflowDto); }
private void AddWorkflowHistory(TraCrfDto input, Login currentUserLogin, Enums.ActionType action, int?RemarkId) { var dbData = new WorkflowHistoryDto(); dbData.ACTION_BY = currentUserLogin.USER_ID; dbData.FORM_ID = input.TRA_CRF_ID; dbData.MODUL_ID = Enums.MenuList.TraCrf; dbData.REMARK_ID = RemarkId; dbData.ACTION_DATE = DateTime.Now; dbData.ACTION = action; dbData.REMARK_ID = RemarkId; switch (input.DOCUMENT_STATUS) { case (int)Enums.DocumentStatus.AssignedForUser: SendEmailWorkflow(input, Enums.ActionType.Submit); break; case (int)Enums.DocumentStatus.WaitingHRApproval: if (action == Enums.ActionType.Approve) { SendEmailWorkflow(input, Enums.ActionType.Approve); } else if (action == Enums.ActionType.Submit) { SendEmailWorkflow(input, Enums.ActionType.Approve); } else { SendEmailWorkflow(input, Enums.ActionType.Reject); } break; case (int)Enums.DocumentStatus.WaitingFleetApproval: if (action == Enums.ActionType.Approve) { SendEmailWorkflow(input, Enums.ActionType.Approve); } else if (action == Enums.ActionType.Submit) { SendEmailWorkflow(input, Enums.ActionType.Approve); } else { SendEmailWorkflow(input, Enums.ActionType.Reject); } break; case (int)Enums.DocumentStatus.InProgress: SendEmailWorkflow(input, Enums.ActionType.Approve); break; } _workflowService.Save(dbData); }
private WorkflowHistoryViewModel ToWorkflowHistoryViewModel(WorkflowHistoryDto dto) { return(PropertyMapper <WorkflowHistoryDto, WorkflowHistoryViewModel> .From(dto)); // return new WorkflowHistoryViewModel // { // Id = dto.Id, // Created = dto.Created, // FromState = dto.FromState, // ToState = dto.ToState, // UserName = dto.UserName, // WorkflowId = dto.WorkflowId // }; }
public void Save(WorkflowHistoryDto history) { TRA_WORKFLOW_HISTORY dbData = null; if (history.WORKFLOW_HISTORY_ID > 0) { dbData = _workflowRepository.GetByID(history.WORKFLOW_HISTORY_ID); Mapper.Map <WorkflowHistoryDto, TRA_WORKFLOW_HISTORY>(history, dbData); } else { dbData = Mapper.Map <TRA_WORKFLOW_HISTORY>(history); _workflowRepository.Insert(dbData); } }
private WorkflowHistoryDto CreateWaitingWasteApprovalRecord(GetByFormNumberInput input) { var newRecord = new WorkflowHistoryDto(); newRecord.FORM_NUMBER = input.FormNumber; newRecord.ACTION = Enums.ActionType.WaitingForWasteApproval; string displayUserId = ""; var listUserDisposal = _wasteRoleServices.GetUserWasteApproverByPlant(input.PlantId); displayUserId = String.Join(", ", listUserDisposal.ToArray()); newRecord.ROLE = Enums.UserRole.User; newRecord.UserId = displayUserId; return(newRecord); }
public void UpdateHistoryModifiedForSubmit(WorkflowHistoryDto history) { //var dbData = Mapper.Map<WORKFLOW_HISTORY>(history); var dbData = _repository.Get(c => c.ACTION == Enums.ActionType.Modified && c.FORM_NUMBER == history.FORM_NUMBER, o => o.OrderByDescending(d => d.ACTION_DATE)).FirstOrDefault(); if (dbData == null) { _repository.Insert(Mapper.Map <WORKFLOW_HISTORY>(history)); } else { dbData.ACTION = Enums.ActionType.Submit; dbData.ACTION_DATE = DateTime.Now; _repository.Update(dbData); } }
private WorkflowHistoryDto CreateWaitingDisposalRecord(GetByFormNumberInput input) { var newRecord = new WorkflowHistoryDto(); newRecord.FORM_NUMBER = input.FormNumber; newRecord.ACTION = Enums.ActionType.WaitingForWasteDisposal; string displayUserId = ""; var listUserDisposal = _wasteRoleServices.GetUserDisposalTeamByPlant(input.PlantId); var poaDelegate = _poaDelegationServices.GetListPoaDelegateByDate(listUserDisposal, DateTime.Now); listUserDisposal.AddRange(poaDelegate); displayUserId = String.Join(", ", listUserDisposal.ToArray()); newRecord.ROLE = Enums.UserRole.User; newRecord.UserId = displayUserId; return(newRecord); }
public void AddHistory(WorkflowHistoryDto history) { var dbData = Mapper.Map <WORKFLOW_HISTORY>(history); _repository.Insert(dbData); }
private WorkflowHistoryDto CreateWaitingApprovalRecord(GetByFormNumberInput input) { var newRecord = new WorkflowHistoryDto(); newRecord.FORM_NUMBER = input.FormNumber; if (input.DocumentStatus == Enums.DocumentStatus.WaitingForApproval2) { newRecord.ACTION = Enums.ActionType.WaitingForApproval2; } else { newRecord.ACTION = Enums.ActionType.WaitingForApproval; } string displayUserId = ""; if (input.IsRejected) { displayUserId = input.RejectedBy; newRecord.ROLE = Enums.UserRole.POA; } else { if (input.DocumentStatus == Enums.DocumentStatus.WaitingForApproval || input.DocumentStatus == Enums.DocumentStatus.WaitingForApproval2) { List <POADto> listPoa; if (input.FormType == Enums.FormType.PBCK1) { listPoa = _poaBll.GetPoaByNppbkcIdAndMainPlant(input.NppbkcId).Distinct().ToList(); if (listPoa.Count > 0) { listPoa = listPoa.Where(c => c.POA_ID != input.DocumentCreator).Distinct().ToList(); } displayUserId = listPoa.Aggregate("", (current, poaDto) => current + (poaDto.POA_ID + ",")); } else { var isPoaCreatedUser = _poaBll.GetActivePoaById(input.DocumentCreator); if (isPoaCreatedUser != null) { //created user is poa, let's get poa list in one Nppbkc listPoa = _poaBll.GetPoaActiveByNppbkcId(input.NppbkcId).Distinct().ToList(); if (listPoa.Count > 0) { listPoa = listPoa.Where(c => c.POA_ID != isPoaCreatedUser.POA_ID).Distinct().ToList(); } } else { listPoa = !string.IsNullOrEmpty(input.PlantId) ? _poaBll.GetPoaActiveByPlantId(input.PlantId).Distinct().ToList() : _poaBll.GetPoaActiveByNppbkcId(input.NppbkcId).Distinct().ToList(); } //old code //displayUserId = listPoa.Aggregate("", (current, poaMapDto) => current + (poaMapDto.POA_ID + ",")); } //add delegate poa List <string> listUser = listPoa.Select(c => c.POA_ID).ToList(); var listPoaDelegate = _poaDelegationServices.GetListPoaDelegateByDate(listUser, DateTime.Now); listUser.AddRange(listPoaDelegate); displayUserId = string.Join(",", listUser.Distinct()); //if (displayUserId.Length > 0) // displayUserId = displayUserId.Substring(0, displayUserId.Length - 1); newRecord.ROLE = Enums.UserRole.POA; } else if (input.DocumentStatus == Enums.DocumentStatus.WaitingForApprovalController) { //get action by poa //var poaId = GetPoaByDocumentNumber(input.FormNumber); //displayUserId = _poaBll.GetManagerIdByPoaId(poaId); var controllerList = _userBll.GetControllers(); displayUserId = string.Join(",", controllerList.Select(c => c.USER_ID).Distinct()); newRecord.ROLE = Enums.UserRole.Controller; } } newRecord.UserId = displayUserId; return(newRecord); }