Example #1
0
        public bool isLastGeneratorState(int planningAppStateId)
        {
            if (this.CurrentPlanningStatus.Name != StatusList.AppInProgress)
            {
                return(false); //Only interested in live applications when adding generators
            }
            var r = OrderedPlanningAppStates.GetEnumerator();

            while (r.MoveNext())
            {
                PlanningAppState prev = r.Current;
                if (r.Current.Id == planningAppStateId)
                {
                    if (r.MoveNext())
                    {
                        if (r.Current.GeneratorOrder > prev.GeneratorOrder &&
                            !prev.Completed()) //Cannot add generator if completed last gen state
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #2
0
 //Private Functions
 public void SetCurrent(PlanningAppState planningAppState)
 {
     foreach (var state  in OrderedPlanningAppStates)
     {
         state.CurrentState = false;
     }
     OrderedPlanningAppStates[OrderedPlanningAppStates.IndexOf(planningAppState)].CurrentState = true;
 }
Example #3
0
 public PlanningAppState SeekPrev(PlanningAppState planningAppState) //Get previous state based on specified State
 {
     if (!Completed() && !isFirstState(planningAppState))
     {
         return(OrderedPlanningAppStates[OrderedPlanningAppStates.IndexOf(planningAppState) - 1]);
     }
     else
     {
         return(null);
     }
 }
Example #4
0
 public PlanningAppState SeekPrev()  //Get previous state based on CurrentState
 {
     if (!Completed() && !isFirstState(Current()))
     {
         return(OrderedPlanningAppStates[OrderedPlanningAppStates.IndexOf(Current()) - 1]);
     }
     else
     {
         return(null);
     }
 }
Example #5
0
 public PlanningAppState SeekNext()
 {
     if (!Completed() && !isLastState(Current()))
     {
         return(OrderedPlanningAppStates[OrderedPlanningAppStates.IndexOf(Current()) + 1]);
     }
     else
     {
         return(null);
     }
 }
Example #6
0
        public PlanningAppState Next(PlanningAppState planningAppState)
        {
            PlanningAppState nextState = new PlanningAppState();

            if (!isLastState(planningAppState))
            {
                nextState = OrderedPlanningAppStates[OrderedPlanningAppStates.IndexOf(planningAppState) + 1];
                planningAppState.CurrentState = false;
                nextState.CurrentState        = true;
                return(nextState);
            }
            else
            {
                return(null);
            }
        }
Example #7
0
 private PlanningAppState FirstState(PlanningAppState planningAppState)
 {
     return(OrderedPlanningAppStates.Count() > 0 ? OrderedPlanningAppStates[0] : null);
 }
Example #8
0
 private PlanningAppState SeekLastState()
 {
     return(OrderedPlanningAppStates.Count() > 0 ? OrderedPlanningAppStates[OrderedPlanningAppStates.Count() - 1] : null);
 }
Example #9
0
 public PlanningAppState FirstState()
 {
     return(OrderedPlanningAppStates.FirstOrDefault());
 }
Example #10
0
 public bool isFirstState(PlanningAppState planningAppState)
 {
     return(OrderedPlanningAppStates.IndexOf(planningAppState) == 0);
 }
Example #11
0
 public bool isLastState(PlanningAppState planningAppState)
 {
     return(OrderedPlanningAppStates.Count() == (OrderedPlanningAppStates.IndexOf(planningAppState) + 1));
 }
Example #12
0
 public PlanningAppState Current()
 {
     return(OrderedPlanningAppStates.Where(s => s.CurrentState == true).SingleOrDefault());
 }
Example #13
0
 public bool Completed()
 {
     return(OrderedPlanningAppStates.Where(p => p.CurrentState == true).Count() == 0);
 }