public IWorkflowBuilder Attach(ISchedulable schedulable) { StageAction stageAction; if (schedulable is IActivity) { stageAction = StageAction.NewScheduleActivity((IActivity)schedulable); } else if (schedulable is IWorkflow) { stageAction = StageAction.NewStartChildWorkflow((IWorkflow)schedulable); } else { throw new NotSupportedException(string.Format( "Type [{0}] is not a supported schedulable action", schedulable.GetType())); } var stage = new Stage(stages.Count, stageAction); stages.Add(stage); return(this); }
private static bool TryGetTimeSpan(ISchedulable device, JobActions action, out TimeSpan timeSpanUtc) { switch (action) { case JobActions.Close: case JobActions.Off: timeSpanUtc = device.OffTime.LocalToUtc(); break; case JobActions.Open: case JobActions.On: timeSpanUtc = device.OnTime.LocalToUtc(); break; default: Logger.Error( $"Time could not be set for device: {device.Description} - {device.GetType().Name} - action: {action}"); timeSpanUtc = new TimeSpan(0); return(false); } return(true); }
public IWorkflowBuilder Attach(ISchedulable schedulable) { StageAction stageAction; if (schedulable is IActivity) { stageAction = StageAction.NewScheduleActivity((IActivity)schedulable); } else if (schedulable is IWorkflow) { stageAction = StageAction.NewStartChildWorkflow((IWorkflow)schedulable); } else { throw new NotSupportedException(string.Format( "Type [{0}] is not a supported schedulable action", schedulable.GetType())); } var stage = new Stage(stages.Count, stageAction); stages.Add(stage); return this; }
private static bool TryGetJobType(ISchedulable device, JobActions action, out Type jobType) { jobType = null; if (device is IShuttable) { switch (action) { case JobActions.Open: jobType = typeof(ShuttableOpenJob); break; case JobActions.Close: jobType = typeof(ShuttableCloseJob); break; default: Logger.Error($"TryGetJobType method - Action {action} not implemented for device {device.Description} - {device.GetType().Name}"); return(false); } } else if (device is ISwitchable) { switch (action) { case JobActions.On: jobType = typeof(SwitchableOnJob); break; case JobActions.Off: jobType = typeof(SwitchableOffJob); break; default: Logger.Error($"TryGetJobType method - Action {action} not implemented for device {device.Description} - {device.GetType().Name}"); return(false); } } else { Logger.Error($"TryGetJobType method could not resolve the JobType for {device.Description} - {device.GetType().Name}"); return(false); } return(true); }
private static IEnumerable <JobActions> ValidJobActionsForDevice(ISchedulable device) { var retval = new List <JobActions>(); if (device is IShuttable) { retval.Add(JobActions.Open); retval.Add(JobActions.Close); } else if (device is ISwitchable) { retval.Add(JobActions.On); retval.Add(JobActions.Off); } else { Logger.Error($"ValidJobActionsForDevice method could not resolve the JobActions for {device.Description} - {device.GetType().Name}"); } return(retval); }