public async Task <bool> AddOrUpdateWorkFlowForm(WorkFlowFormViewModel viewModel) { try { var userName = _httpContextAccessor.HttpContext?.User?.GetUserName(); viewModel.FormViewModel.WorkFlowId = viewModel.WorkFlowId; foreach (var control in viewModel.FormControlViewModels) { control.WorkFlowId = viewModel.WorkFlowId; } var workflow = await _workflowRepository.GetAsync(viewModel.WorkFlowId); workflow.UpdatedTime = DateTime.Now; workflow.UpdatedUser = userName; await _formRepository.RemoveAsync(f => f.WorkFlowId == viewModel.WorkFlowId); await _formRepository.AddAsync(_mapper.Map <WorkFlowForm>(viewModel.FormViewModel)); await _formControlRepository.RemoveAsync(f => f.WorkFlowId == viewModel.WorkFlowId); await _formControlRepository.AddAsync(_mapper.Map <List <WorkFlowFormControl> >(viewModel.FormControlViewModels)); await _unitOfWork.SaveAsync(); return(true); } catch (Exception e) { _logger.LogError(e.StackTrace); return(false); } }
public override void WorkFlowFormSave <TClass, TVM>(WorkFlowFormViewModel workFlowFormViewModel) { base.WorkFlowFormSave <TClass, TVM>(workFlowFormViewModel); WorkFlowTrace torSatinAlmaIslem = Mapper.Map <WorkFlowFormViewModel, WorkFlowTrace>(workFlowFormViewModel); AddOrUpdate(torSatinAlmaIslem); }
public bool FullFormValidate(WorkFlowFormViewModel formData, ModelStateDictionary modelState) { bool resultStandartForm = StandartFormValidate(formData, modelState); bool resultCustomForm = CustomFormValidate(formData, modelState); return(resultCustomForm && resultStandartForm); }
public ActionResult SaveAsDraft(WorkFlowFormViewModel formData) { if (ModelState.IsValid) { if (formData.ProcessFormViewCompleted && formData.GetType() != typeof(WorkFlowFormViewModel)) { _workFlowProcessService.CustomFormSave(formData); } else { WorkFlowTrace torSatinAlmaIslem = Mapper.Map <WorkFlowFormViewModel, WorkFlowTrace>(formData); _workFlowProcessService.AddOrUpdate(torSatinAlmaIslem); } UserProcessViewModel kullaniciIslemVM = _workFlowProcessService.GetUserProcessVM(formData.Id); var workFlowBase = _workFlowProcessService.WorkFlowBaseInfo(kullaniciIslemVM); _workFlowProcessService.SetWorkFlowTraceForm(formData, workFlowBase); return(View(formData.ProcessTaskSpecialFormTemplateView, formData).WithMessage(this, string.Format("{0} saved successfully.", formData.ProcessName), MessageType.Success)); } else { UserProcessViewModel kullaniciIslemVM = _workFlowProcessService.GetUserProcessVM(formData.Id); var workFlowBase = _workFlowProcessService.WorkFlowBaseInfo(kullaniciIslemVM); _workFlowProcessService.SetWorkFlowTraceForm(formData, workFlowBase); return(View(formData.ProcessTaskSpecialFormTemplateView, formData).WithMessage(this, string.Format("Validation error!"), MessageType.Danger)); } }
public ActionResult Index(int workFlowTraceId) { UserProcessViewModel userProcessVM = _workFlowProcessService.GetUserProcessVM(workFlowTraceId); if (_workFlowProcessService.WorkFlowPermissionCheck(userProcessVM) == false) { return(RedirectToAction("Index", new { controller = "Home" }).WithMessage(this, "Access denied!", MessageType.Danger)); } WorkFlowTrace workFlowTrace = _workFlowProcessService.WorkFlowTraceDetail(workFlowTraceId); WorkFlowFormViewModel workFlowTraceForm = Mapper.Map <WorkFlowTrace, WorkFlowFormViewModel>(workFlowTrace); int ownerId = workFlowTraceForm.OwnerId; ActionResult viewResult = null; WorkFlowFormViewModel workFlowForm = null; var workFlowBase = _workFlowProcessService.WorkFlowBaseInfo(userProcessVM); _workFlowProcessService.SetWorkFlowTraceForm(workFlowTraceForm, workFlowBase); workFlowForm = _workFlowProcessService.WorkFlowFormLoad(workFlowTraceForm); viewResult = View(workFlowForm.ProcessTaskSpecialFormTemplateView, workFlowForm); return(viewResult); }
public ActionResult ReturnTo(WorkFlowFormViewModel formData) { if (formData.Description == null) { string errorMessage = "Please enter your cancellation reason."; ModelState.AddModelError("ProcessForm.Description", errorMessage); UserProcessViewModel kullaniciIslemVM = _workFlowProcessService.GetUserProcessVM(formData.Id); var workFlowBase = _workFlowProcessService.WorkFlowBaseInfo(kullaniciIslemVM); _workFlowProcessService.SetWorkFlowTraceForm(formData, workFlowBase); return(View(formData.ProcessTaskSpecialFormTemplateView, formData).WithMessage(this, "Error occured!", MessageType.Warning)); } WorkFlowTrace islem = Mapper.Map <WorkFlowFormViewModel, WorkFlowTrace>(formData); _workFlowProcessService.AddOrUpdate(islem); var workFlowTraceId = formData.Id; _workFlowProcessService.CancelWorkFlowTrace(workFlowTraceId, formData.TargetProcessId); var surecKontrolSonuc = _workFlowProcessService.SetNextProcessForWorkFlow(workFlowTraceId); return(RedirectToAction("Index", surecKontrolSonuc).WithMessage(this, "Previous step started.", MessageType.Success)); }
public WorkFlowFormViewModel Load(WorkFlowFormViewModel workFlowFormViewModel) { var healthInformationFormList = _unitOfWork.Repository <BusinessProcess>().GetList(x => x.OwnerId == workFlowFormViewModel.OwnerId).ToList(); if (healthInformationFormList.Count() == 0) { var physicalExamination = new BusinessProcess() { Name = "Physical Examination", OwnerId = workFlowFormViewModel.OwnerId }; var psychotechniqueResult = new BusinessProcess() { Name = "Psychotechnique Result", OwnerId = workFlowFormViewModel.OwnerId }; _unitOfWork.Repository <BusinessProcess>().Add(physicalExamination); _unitOfWork.Repository <BusinessProcess>().Add(psychotechniqueResult); _unitOfWork.Complete(); healthInformationFormList.Add(physicalExamination); healthInformationFormList.Add(psychotechniqueResult); } SubBusinessProcessViewModel healthInformationForm = new SubBusinessProcessViewModel { SubBusinessProcessList = healthInformationFormList }; Mapper.Map(workFlowFormViewModel, healthInformationForm); return(healthInformationForm); }
public void CustomFormSave(WorkFlowFormViewModel formData) { IWorkFlowForm form = GetWorkFlowForm(formData.ProcessFormViewViewName); if (form != null) { form.Save(formData); } }
public async Task <IActionResult> AddOrUpdate(WorkFlowFormViewModel viewModel) { var isSuccess = await _workFlowFormService.AddOrUpdateWorkFlowForm(viewModel); if (!isSuccess) { return(this.BadRequestResult("保存失败!")); } return(Ok()); }
public bool CustomFormValidate(WorkFlowFormViewModel formData, ModelStateDictionary modelState) { IWorkFlowForm form = GetWorkFlowForm(formData.ProcessFormViewViewName); if (form != null) { return(form.Validate(formData, modelState)); } return(true); }
public WorkFlowFormViewModel WorkFlowFormLoad(WorkFlowFormViewModel workFlowFormViewModel) { WorkFlowFormViewModel workFlowForm = workFlowFormViewModel; if (workFlowFormViewModel.ProcessFormViewViewName != null && workFlowFormViewModel.ProcessFormViewCompleted) { IWorkFlowForm form = GetWorkFlowForm(workFlowFormViewModel.ProcessFormViewViewName); if (form != null) { workFlowForm = form.Load(workFlowFormViewModel); } } return(workFlowForm); }
public void SetWorkFlowTraceForm(WorkFlowFormViewModel workFlowFormVM, WorkFlowDTO workFlowBase) { workFlowFormVM.ProgressProcessList = workFlowBase.ProgressProcessList; workFlowFormVM.TargetProcessListForCancel = workFlowBase.TargetProcessListForCancel; workFlowFormVM.AuthorizedProcessList = workFlowBase.AuthorizedProcessList; if (workFlowFormVM.IsCondition) { workFlowFormVM.ListOfOptions = _workFlowDataService .GetWorkFlowProcessList(workFlowFormVM.ProcessTaskId) .Where(x => x.ConditionId == workFlowFormVM.ProcessId) .ToList(); } }
public ActionResult SaveAndSend(WorkFlowFormViewModel formData) { if (ModelState.IsValid) { bool fullFormValidate = _workFlowProcessService.FullFormValidate(formData, ModelState); if (!fullFormValidate) { UserProcessViewModel userProcessVM = _workFlowProcessService.GetUserProcessVM(formData.Id); var workFlowBase = _workFlowProcessService.WorkFlowBaseInfo(userProcessVM); _workFlowProcessService.SetWorkFlowTraceForm(formData, workFlowBase); return(View(formData.ProcessTaskSpecialFormTemplateView, formData).WithMessage(this, "Validation error!", MessageType.Warning)); } WorkFlowTrace workFlowTrace = Mapper.Map <WorkFlowFormViewModel, WorkFlowTrace>(formData); if (formData.ProcessFormViewCompleted) { if (formData.GetType() != typeof(WorkFlowFormViewModel)) { _workFlowProcessService.CustomFormSave(formData); } else { _workFlowProcessService.AddOrUpdate(workFlowTrace); } } else { _workFlowProcessService.AddOrUpdate(workFlowTrace); } _workFlowProcessService.GoToWorkFlowNextProcess(workFlowTrace.OwnerId); var targetProcess = _workFlowProcessService.SetNextProcessForWorkFlow(workFlowTrace.Id); return(RedirectToAction("Index", targetProcess).WithMessage(this, "Saved Successfully.", MessageType.Success)); } else { UserProcessViewModel userProcessVM = _workFlowProcessService.GetUserProcessVM(formData.Id); var workFlowBase = _workFlowProcessService.WorkFlowBaseInfo(userProcessVM); _workFlowProcessService.SetWorkFlowTraceForm(formData, workFlowBase); return(View(formData.ProcessTaskSpecialFormTemplateView, formData).WithMessage(this, string.Format("Validation error!"), MessageType.Danger)); } }
public WorkFlowFormViewModel Load(WorkFlowFormViewModel workFlowFormViewModel) { TestForm testForm = _unitOfWork.Repository <TestForm>().Get(x => x.OwnerId == workFlowFormViewModel.OwnerId); if (testForm == null) { testForm = new TestForm(); testForm.OwnerId = workFlowFormViewModel.OwnerId; _unitOfWork.Repository <TestForm>().Add(testForm); _unitOfWork.Complete(); } TestWorkFlowFormViewModel testFormViewModel = Mapper.Map <TestForm, TestWorkFlowFormViewModel>(testForm); Mapper.Map(workFlowFormViewModel, testFormViewModel); return(testFormViewModel); }
public virtual void WorkFlowFormSave <TClass, TVM>(WorkFlowFormViewModel workFlowFormViewModel) where TClass : class where TVM : WorkFlowFormViewModel { TClass form = _unitOfWork.Repository <TClass>().Get(workFlowFormViewModel.OwnerId); if (form != null) { Mapper.Map((TVM)workFlowFormViewModel, form); _unitOfWork.Repository <TClass>().Update(form); } else { form = (TClass)Activator.CreateInstance(typeof(TClass)); Mapper.Map((TVM)workFlowFormViewModel, form); _unitOfWork.Repository <TClass>().Add(form); } _unitOfWork.Complete(); }
public void Save(WorkFlowFormViewModel formData) { _testWorkFlowProcessService.WorkFlowFormSave <TestForm, TestWorkFlowFormViewModel>(formData); }
public void FormSave(WorkFlowFormViewModel formData) { base.CustomFormSave(formData); }
public bool FormValidate(WorkFlowFormViewModel formData, ModelStateDictionary modelState) { return(base.CustomFormValidate(formData, modelState)); }
public async Task <IActionResult> AddOrUpdateWorkFlowForm([FromBody] WorkFlowFormViewModel model) { await _workFlowFormService.AddOrUpdateWorkFlowFormAsync(model.DefineId, model.FormContent, model.FormElements); return(Ok()); }
public bool StandartFormValidate(WorkFlowFormViewModel formData, ModelStateDictionary modelState) { return(ValidationHelper.Validate(formData, new WorkFlowFormViewModelValidator(_unitOfWork), modelState)); }
public bool FormValidate(WorkFlowFormViewModel formData, ModelStateDictionary modelState) { throw new System.NotImplementedException(); }
public void FormSave(WorkFlowFormViewModel formData) { throw new System.NotImplementedException(); }
public bool Validate(WorkFlowFormViewModel formData, ModelStateDictionary modelState) { return(true); }
public void Save(WorkFlowFormViewModel formData) { }