private void _UpdateItem(IScheduledItem item) { Func <IScheduledItem, IScheduledItemStateObject> newStatedObjectCreator; if (_IsItemAProgram(item)) { newStatedObjectCreator = ScheduledItemService.Instance.CreateProgramStateObject; } else { newStatedObjectCreator = ScheduledItemService.Instance.CreateSequenceStateObject; } IScheduledItemStateObject scheduledItemStateObject = _FindStateObject(item); IScheduledItemStateObject newScheduledItemStateObject = newStatedObjectCreator(item); if (scheduledItemStateObject == null || newScheduledItemStateObject == null) { return; } if (ScheduledItemService.Instance.ScheduledItemQualifiesForExecution(newScheduledItemStateObject)) { _ReplaceItem(scheduledItemStateObject, newScheduledItemStateObject); } else { _RemoveItem(scheduledItemStateObject); _AddItem(newScheduledItemStateObject); } }
private void _RemoveItem(IScheduledItemStateObject item) { if (item != null) { _stateMachine.SetState(item, States.CompletedState); _stateMachine.RemoveStatedObject(item); } }
public void AddProgram(IScheduledItem item) { if (item == null) { throw new ArgumentNullException("item"); } IScheduledItemStateObject scheduledProgram = ScheduledItemService.Instance.CreateProgramStateObject(item); _AddItem(scheduledProgram); }
public void AddSequence(IScheduledItem item) { if (item == null) { throw new ArgumentNullException("item"); } IScheduledItemStateObject scheduledSequence = ScheduledItemService.Instance.CreateSequenceStateObject(item); _AddItem(scheduledSequence); }
public bool Equals(IScheduledItemStateObject other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(other.Id.Equals(Id)); }
public bool Equals(IScheduledItemStateObject other) { if(ReferenceEquals(null, other)) return false; if(ReferenceEquals(this, other)) return true; return other.Id.Equals(Id); }
public bool ScheduledItemQualifiesForExecution(IScheduledItemStateObject item) { return DateTime.Now >= item.Start && DateTime.Now < item.End; }
private void _ReplaceItem(IScheduledItemStateObject oldItem, IScheduledItemStateObject newItem) { _stateMachine.ReplaceStatedObject(oldItem, newItem); }
private void _AddItem(IScheduledItemStateObject item) { _stateMachine.AddStatedObject(item, States.WaitingState); }
public bool ScheduledItemQualifiesForExecution(IScheduledItemStateObject item) { return(DateTime.Now >= item.Start && DateTime.Now < item.End); }
private void _RemoveItem(IScheduledItemStateObject item) { if(item != null) { _stateMachine.SetState(item, States.CompletedState); _stateMachine.RemoveStatedObject(item); } }