public static WorkFlowStateViewModel FromEntity(WorkFlowState entity) { return(new WorkFlowStateViewModel { WorkFlowStateId = entity.WorkFlowStateId, WorkFlowId = entity.WorkFlowId, StateCode = entity.StateCode, Status = entity.Status }); }
private static WorkFlowState GetNewWorkFlow() { var workflow = new WorkFlowState(storage); workflow.Steps.Add(new Step() { Name = "Procurement Review", StartCondition = StartCondition.Any, StartTrigger = StartTrigger.StartAfterPrevious, SuccessCondition = SuccessCondition.All, Actions = new List <WorkFlow.Model.Action>() { new WaitReadLineStep() { Name = "Procurement Approval" } } }); workflow.Steps.Add(new Step() { Name = "Financial Review", StartCondition = StartCondition.Any, StartTrigger = StartTrigger.StartAfterPrevious, SuccessCondition = SuccessCondition.All, Actions = new List <WorkFlow.Model.Action>() { new WaitReadLineStep() { Name = "Financial Delegation Approval" } } }); workflow.Steps.Add(new Step() { Name = "Procurment Release", StartCondition = StartCondition.Success, StartTrigger = StartTrigger.StartAfterPrevious, SuccessCondition = SuccessCondition.All, Actions = new List <WorkFlow.Model.Action>() { new WaitReadLineStep() { Name = "Procurement Approval" } } }); return(workflow); }
public void Save(WorkFlowState state) { InitStore(); using (var trn = store.BeginTransaction(RetriableOperation.Update)) { var isExistingWorkflow = false; var storedState = (StoredWorkFlowState)state; if (!isExistingWorkflow) { trn.Insert(storedState); } else { trn.Update(storedState); } trn.Commit(); } }
public void NotifyEventFromInternal(long workFlowID, string eventName, object eventData) { string stateName = string.Empty; try { DTO.WorkFlow workFlow = WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(workFlowID); WorkFlowTypeDocumentType workFlowTypeDocumentType = WorkFlowQueryProvider.WorkFlowTypeDocumentTypeQuery.GetByWorkFlowTypeID_DocumentTypeID(workFlow.WorkFlowType.WorkFlowTypeID, workFlow.Document.DocumentType.DocumentTypeID); string serviceName = workFlowTypeDocumentType.ServiceName; stateName = workFlow.CurrentState.Name; object finder = ContextRegistry.GetContext().GetObject(serviceName); //Call method On{EventName}{StateName} ex. OnSubmitDraft , OnApproveWaitAR .. MethodInfo methodInfo = finder.GetType().GetMethod(string.Format("On{0}{1}", eventName, stateName)); if (methodInfo != null) { string signal = (string)methodInfo.Invoke(finder, new object[] { workFlowID, eventData }); //Call method OnExit{StateName} methodInfo = finder.GetType().GetMethod(string.Format("On{0}{1}", "Exit", stateName)); if (methodInfo != null) { methodInfo.Invoke(finder, new object[] { workFlowID }); } //Get NextState in Transition WorkFlowState nextState = WorkFlowQueryProvider.WorkFlowStateTransitionQuery.GetNextState(workFlow.CurrentState.WorkFlowStateID, signal); if (nextState != null) { if (workFlow.CurrentState.Ordinal > nextState.Ordinal) { this.ResetActiveResponse(workFlowID, nextState.Ordinal); } this.UpdateState(workFlowID, nextState); this.ReCalculateWorkFlowPermission(workFlowID); //Call method OnEnter{NextStateName} methodInfo = finder.GetType().GetMethod(string.Format("On{0}{1}", "Enter", nextState.Name)); if (methodInfo != null) { methodInfo.Invoke(finder, new object[] { workFlowID }); } } } else { Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); errors.AddError("WorkFlow.Error", new Spring.Validation.ErrorMessage("WorkFlow_Error_Invalid_Document_State")); //สถานะของเอกสารไม่ถูกต้อง เอกสารนี้อาจกำลังถูกปรับปรุงโดยผู้ใช้งานท่านอื่น throw new ServiceValidationException(errors); } } catch (ServiceValidationException ex) { throw ex; } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException.GetType().Equals(typeof(ServiceValidationException))) { throw ex; } else { if (logger != null) { logger.Error(string.Format("WorkflowID: {0}, EventName: {1}, StateName: {2}", workFlowID, eventName, stateName)); logger.Error(string.Format("WorkFlowService.NotifyEventFromInternal(workflowID) : {0}", workFlowID, ex.StackTrace)); } Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); errors.AddError("WorkFlow.Error", new Spring.Validation.ErrorMessage("WorkFlow_Error_Problem_Occurred")); //ระบบมีปัญหาในการประมวลผล กรุณาลองอีกครั้งหนึ่ง throw new ServiceValidationException(errors); } } }
public void Save(WorkFlowState state) { cache.Add(state.Id, state, DateTimeOffset.MaxValue); }