Example #1
0
        public string GoToPreviousState(object user)
        {
            var prevState = flowWorker.GetFlowStateById(StateValueHelper.GetPreviousStateValue(user));

            StateValueHelper.UpdatePreivousStateValue(user, StateValueHelper.GetCurrentStateValue(user));
            StateValueHelper.UpdateCurrentStateValue(user, prevState.Id);
            return(prevState.State);
        }
Example #2
0
        public string GetCurrentState(object user)
        {
            var flow = flowWorker.GetFlowStateById(StateValueHelper.GetCurrentStateValue(user));

            StateValueHelper.UpdateCurrentStateValue(user, flow.Id);
            StateValueHelper.UpdatePreivousStateValue(user, flow.Id);
            return(flow.State);
        }
Example #3
0
 public string GoToNextState(object user, string condition)
 {
     if (condition == null)
     {
         var currentState = flowWorker.GetFlowStateById(StateValueHelper.GetCurrentStateValue(user));
         currentState.Transitions.TryGetValue("default", out string nextStateName);
         var nextState = flowWorker.GetFlowStateByName(nextStateName);
         StateValueHelper.UpdateCurrentStateValue(user, nextState.Id);
         StateValueHelper.UpdatePreivousStateValue(user, currentState.Id);
         return(nextState.State);
     }
     else
     {
         var currentState = flowWorker.GetFlowStateById(StateValueHelper.GetCurrentStateValue(user));
         currentState.Transitions.TryGetValue(condition, out string nextStateName);
         var nextState = flowWorker.GetFlowStateByName(nextStateName);
         StateValueHelper.UpdateCurrentStateValue(user, nextState.Id);
         StateValueHelper.UpdatePreivousStateValue(user, currentState.Id);
         return(nextState.State);
     }
 }