Ejemplo n.º 1
0
        /// <summary>
        /// Starts a new process
        /// </summary>
        /// <param name="processId">Process identifier</param>
        /// <returns>Process navigation result</returns>
        public ProcessDetailsModel StartProcess(int processId)
        {
            var navigationProcess = GetNavigationDataFromStep(FindProcessStartingStep(processId));

            if (validation.Validate(navigationProcess, Authenticated))
            {
                ProcessStack.MoveTo(navigationProcess);
                return(navigationProcess);
            }
            return(navigationProcess);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Remove all child processes and return last main process.
        /// For example, authetication.
        /// </summary>
        /// <returns></returns>
        public ProcessDetailsModel LastMainStep()
        {
            var result = ProcessStack.CurrentProcess;

            while (ProcessStack.IsProcessActive && !ProcessStack.CurrentProcess.IsMainStep)
            {
                ProcessStack.Return();
            }

            if (!ProcessStack.IsProcessActive)
            {
                result.PageURL = "/";
                return(result);
            }

            result = ProcessStack.CurrentProcess;
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Moves to the next step of the current process
        /// </summary>
        /// <returns>Navigation result</returns>
        public ProcessDetailsModel NextStep()
        {
            var currentProcess = ProcessStack.CurrentProcess;

            if (!validation.Validate(currentProcess, Authenticated))
            {
                return(currentProcess);
            }

            var navigationData = GetNavigationDataFromStep(FindNextStep(currentProcess.ProcessId, currentProcess.Step ?? 1));

            if (validation.Validate(navigationData, Authenticated))
            {
                ProcessStack.MoveTo(navigationData);
                return(navigationData);
            }
            return(currentProcess);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Moves to the previous step of the current process
        /// If there's no previous, returns to the previous process
        /// </summary>
        /// <returns>Navigation result</returns>
        public ProcessDetailsModel PreviousStep()
        {
            var result = ProcessStack.CurrentProcess;

            if (!ProcessStack.IsProcessActive)
            {
                result.PageURL = "/";
                return(result);
            }

            var previousStep = GetNavigationDataFromStep(FindPreviousStep(result.ProcessId, result.Step ?? 1));

            if (validation.Validate(previousStep, Authenticated))
            {
                ProcessStack.MoveTo(previousStep);
            }
            else
            {
                if (previousStep.NoProcessOrStep)
                {
                    // no previous step - return to the previous process
                    bool previousProcessExist = ProcessStack.Return();

                    if (previousProcessExist)
                    {
                        var previousProcess = GetNavigationDataFromStep(ProcessStack.CurrentProcess);
                        return(previousProcess);
                    }
                    // no previous process - return to home screen
                    result = new ProcessDetailsModel {
                        PageURL = "/"
                    };
                    return(result);
                }
            }
            return(result);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// The push process.
 /// </summary>
 /// <param name="stack">
 /// The stack.
 /// </param>
 /// <param name="definition">
 /// The definition.
 /// </param>
 private static void PushProcess(ProcessStack stack, DefinitionDescription definition)
 {
     // check if there is a definition on the stack, if there is add it to the list of children, not just push it.
     if (stack.Count == 0)
     {
         stack.Push(definition);
     }
     else
     {
         var lowestParent = FindLowestProcess(stack.Peek());
         if (lowestParent != null)
         {
             lowestParent.ChildProcesses.Push(definition);
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// The pop process.
        /// </summary>
        /// <param name="stack">
        /// The stack.
        /// </param>
        /// <param name="endTime">
        /// The end time.
        /// </param>
        /// <param name="serverEndTime">
        /// The server end time.
        /// </param>
        private static void PopProcess(ProcessStack stack, DateTime endTime, int serverEndTime)
        {
            // Check to see if the definition on top of the stack has children, if so pop from the child, otherwise pop the top of the stack - recursively.
            if (stack.Count == 0)
            {
                return;
            }

            // want to find the definition with no children and pop it from it's parent.
            var parentProcess = FindLowestProcessParent(stack.Peek());
            var processStack = parentProcess.ChildProcesses;
            if (processStack.Count > 0)
            {
                var processDescription = processStack.Pop();
                processDescription.EndTime = endTime;
                if (processDescription.HistoryProcessDescription != null)
                {
                    // set the end time on the process description in the history stack.
                    processDescription.HistoryProcessDescription.EndTime = endTime;
                    processDescription.HistoryProcessDescription.ServerEndMilliseconds = serverEndTime;
                }

                processDescription.HistoryProcessDescription = null;
                Instance.CurrentProcess = parentProcess.HistoryProcessDescription;
            }
            else
            {
                // all the nested children have been removed so remove the top of the stack now.
                var processDescription = stack.Pop();
                processDescription.EndTime = endTime;
                processDescription.ServerEndMilliseconds = serverEndTime;

                if (processDescription.HistoryProcessDescription != null)
                {
                    // set the end time on the process description in the history stack.
                    processDescription.HistoryProcessDescription.EndTime = endTime;
                    processDescription.HistoryProcessDescription.ServerEndMilliseconds = serverEndTime;
                }

                processDescription.HistoryProcessDescription = null;
                Instance.CurrentProcess = null;
            }
        }
        public IGenericProcess GetGenericProcess(ProcessType processType)
        {
            IGenericProcess genericProcess = null;

            switch (processType)
            {
            case ProcessType.Buffer:
                genericProcess = new ProcessBuffer();
                break;

            case ProcessType.CircularBuffer:
                genericProcess = new ProcessCircularBuffer();
                break;

            case ProcessType.Array:
                genericProcess = new ProcessArray();
                break;

            case ProcessType.List:
                genericProcess = new ProcessList();
                break;

            case ProcessType.Queue:
                genericProcess = new ProcessQueue();
                break;

            case ProcessType.Stack:
                genericProcess = new ProcessStack();
                break;

            case ProcessType.HashSet:
                genericProcess = new ProcessHashSet();
                break;

            case ProcessType.LinkedList:
                genericProcess = new ProcessLinkedList();
                break;

            case ProcessType.Dictionary:
                genericProcess = new ProcessDictionary();
                break;

            case ProcessType.Sort:
                genericProcess = new ProcessSort();
                break;

            case ProcessType.ComparingEmployees:
                genericProcess = new ProcessComparingEmployees();
                break;

            case ProcessType.Delegates:
                genericProcess = new ProcessDelegates();
                break;

            case ProcessType.Constraints:
                genericProcess = new ProcessConstraints();
                break;

            case ProcessType.GenericMethods:
                genericProcess = new ProcessGenericMethods();
                break;

            case ProcessType.IocContainer:
                genericProcess = new ProcessIocContainer();
                break;

            case ProcessType.GenericEnum:
                genericProcess = new ProcessGenericEnum();
                break;

            case ProcessType.BaseTypes:
                genericProcess = new ProcessBaseTypes();
                break;

            case ProcessType.GenericStatics:
                genericProcess = new ProcessGenericStatics();
                break;

            default:
                break;
            }
            return(genericProcess);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Remove current process from stack
 /// </summary>
 public void RemoveCurrentProcess()
 {
     ProcessStack.Return();
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Stops all running processes
 /// </summary>
 public void StopAll()
 {
     ProcessStack.Clear();
 }