Inheritance: Dev2Trigger, IDailyTrigger
コード例 #1
0
        public ITrigger SanitiseTrigger(ITrigger resource)
        {
            ITrigger trigger           = new Dev2Trigger(this, resource.Instance);
            Trigger  serialisedTrigger = resource.Instance;

            switch (resource.Instance.TriggerType)
            {
            case TaskTriggerType.Boot:
                trigger = new Dev2BootTrigger(this, new BootTrigger());
                ExtractDelay(resource.Instance as ITriggerDelay, trigger.Instance as ITriggerDelay);
                break;

            case TaskTriggerType.Custom:
                trigger = new Dev2Trigger(this, new DailyTrigger());

                break;

            case TaskTriggerType.Daily:
// ReSharper disable PossibleNullReferenceException
                trigger = new Dev2DailyTrigger(this,
                                               new DailyTrigger((serialisedTrigger as DailyTrigger).DaysInterval));
// ReSharper restore PossibleNullReferenceException

                break;

            case TaskTriggerType.Event:
                var evt = resource.Instance as EventTrigger;
                if (evt != null)
                {
                    int?   eventId;
                    string source;
                    string log;
                    evt.GetBasic(out log, out source, out eventId);

                    trigger = new Dev2EventTrigger(this, new EventTrigger(log, source, eventId));
                }


                break;

            case TaskTriggerType.Idle:
                trigger = new Dev2IdleTrigger(this, new IdleTrigger());

                break;

            case TaskTriggerType.Logon:
                var logonTrigger = resource.Instance as LogonTrigger;
                if (logonTrigger != null)
                {
                    trigger = new Dev2LogonTrigger(this, new LogonTrigger {
                        UserId = logonTrigger.UserId
                    });
                }

                break;

            case TaskTriggerType.Monthly:
                var a = (serialisedTrigger as MonthlyTrigger);
// ReSharper disable PossibleNullReferenceException
                trigger = new Dev2MonthlyTrigger(this, new MonthlyTrigger(a.DaysOfMonth.First(), a.MonthsOfYear));
// ReSharper restore PossibleNullReferenceException

                break;

            case TaskTriggerType.MonthlyDOW:
                var b = (serialisedTrigger as MonthlyDOWTrigger);
                trigger = new Dev2MonthlyDowTrigger(this,
// ReSharper disable PossibleNullReferenceException
                                                    new MonthlyDOWTrigger(b.DaysOfWeek, b.MonthsOfYear,
                                                                          b.WeeksOfMonth));
// ReSharper restore PossibleNullReferenceException

                break;

            case TaskTriggerType.Registration:

                trigger = new Dev2RegistrationTrigger(this, new RegistrationTrigger());

                break;

            case TaskTriggerType.SessionStateChange:

                var sessionStateChangeTrigger = resource.Instance as SessionStateChangeTrigger;
                if (sessionStateChangeTrigger != null)
                {
                    trigger = new Dev2Trigger(this,
                                              new SessionStateChangeTrigger
                    {
                        UserId      = sessionStateChangeTrigger.UserId,
                        StateChange = sessionStateChangeTrigger.StateChange
                    });
                }
                break;

            case TaskTriggerType.Time:
                var y = (serialisedTrigger as TimeTrigger);
// ReSharper disable PossibleNullReferenceException
                trigger = new Dev2TimeTrigger(this, new TimeTrigger(y.StartBoundary));
// ReSharper restore PossibleNullReferenceException

                break;

            case TaskTriggerType.Weekly:
                var z = (serialisedTrigger as WeeklyTrigger);
// ReSharper disable PossibleNullReferenceException
                trigger = new Dev2WeeklyTrigger(this, new WeeklyTrigger(z.DaysOfWeek, z.WeeksInterval));
// ReSharper restore PossibleNullReferenceException

                break;

            default:
                trigger = null;
                break;
            }
            if (trigger != null)
            {
                trigger.Enabled                      = resource.Enabled;
                trigger.EndBoundary                  = resource.EndBoundary;
                trigger.StartBoundary                = resource.StartBoundary;
                trigger.Repetition.Duration          = resource.Repetition.Duration;
                trigger.Repetition.Interval          = resource.Repetition.Interval;
                trigger.Repetition.StopAtDurationEnd = resource.Repetition.StopAtDurationEnd;

                ExtractDelay(resource.Instance as ITriggerDelay, trigger.Instance as ITriggerDelay);
            }
            return(trigger);
        }
コード例 #2
0
ファイル: SchedulerViewModel.cs プロジェクト: ndubul/Chillas
 public void CreateNewTask()
 {
     if(CurrentEnvironment != null)
     {
         Dev2Logger.Log.Info(String.Format("Delete Schedule Environment: {0} ",CurrentEnvironment.Name));
     }
     var dev2DailyTrigger = new Dev2DailyTrigger(new TaskServiceConvertorFactory(), new DailyTrigger());
     var scheduleTrigger = _schedulerFactory.CreateTrigger(TaskState.Ready, dev2DailyTrigger);
     ScheduledResource scheduledResource = new ScheduledResource(NewTaskName + _newTaskCounter, SchedulerStatus.Enabled, scheduleTrigger.Trigger.Instance.StartBoundary, scheduleTrigger, string.Empty) { IsDirty = true };
     scheduledResource.OldName = scheduledResource.Name;
     ScheduledResourceModel.ScheduledResources.Add(scheduledResource);
     _newTaskCounter++;
     NotifyOfPropertyChange(() => TaskList);
     SelectedTask = ScheduledResourceModel.ScheduledResources.Last();
     WorkflowName = string.Empty;
     SelectedTask.IsNew = true;
 }
コード例 #3
0
        public ITrigger SanitiseTrigger(ITrigger resource)
        {
            ITrigger trigger = new Dev2Trigger(this, resource.Instance);
            Trigger serialisedTrigger = resource.Instance;
            switch (resource.Instance.TriggerType)
            {
                case TaskTriggerType.Boot:
                    trigger = new Dev2BootTrigger(this, new BootTrigger());
                    ExtractDelay(resource.Instance as ITriggerDelay, trigger.Instance as ITriggerDelay);
                    break;
                case TaskTriggerType.Custom:
                    trigger = new Dev2Trigger(this, new DailyTrigger());

                    break;
                case TaskTriggerType.Daily:
            // ReSharper disable PossibleNullReferenceException
                    trigger = new Dev2DailyTrigger(this,
                        new DailyTrigger((serialisedTrigger as DailyTrigger).DaysInterval));
            // ReSharper restore PossibleNullReferenceException

                    break;
                case TaskTriggerType.Event:
                    var evt = resource.Instance as EventTrigger;
                    if (evt != null)
                    {
                        int? eventId;
                        string source;
                        string log;
                        evt.GetBasic(out log, out source, out eventId);

                        trigger = new Dev2EventTrigger(this, new EventTrigger(log, source, eventId));
                    }

                    break;
                case TaskTriggerType.Idle:
                    trigger = new Dev2IdleTrigger(this, new IdleTrigger());

                    break;
                case TaskTriggerType.Logon:
                    var logonTrigger = resource.Instance as LogonTrigger;
                    if (logonTrigger != null)
                        trigger = new Dev2LogonTrigger(this, new LogonTrigger {UserId = logonTrigger.UserId});

                    break;
                case TaskTriggerType.Monthly:
                    var a = (serialisedTrigger as MonthlyTrigger);
            // ReSharper disable PossibleNullReferenceException
                    trigger = new Dev2MonthlyTrigger(this, new MonthlyTrigger(a.DaysOfMonth.First(), a.MonthsOfYear));
            // ReSharper restore PossibleNullReferenceException

                    break;
                case TaskTriggerType.MonthlyDOW:
                    var b = (serialisedTrigger as MonthlyDOWTrigger);
                    trigger = new Dev2MonthlyDowTrigger(this,
            // ReSharper disable PossibleNullReferenceException
                        new MonthlyDOWTrigger(b.DaysOfWeek, b.MonthsOfYear,
                            b.WeeksOfMonth));
            // ReSharper restore PossibleNullReferenceException

                    break;
                case TaskTriggerType.Registration:

                    trigger = new Dev2RegistrationTrigger(this, new RegistrationTrigger());

                    break;
                case TaskTriggerType.SessionStateChange:

                    var sessionStateChangeTrigger = resource.Instance as SessionStateChangeTrigger;
                    if (sessionStateChangeTrigger != null)
                        trigger = new Dev2Trigger(this,
                            new SessionStateChangeTrigger
                            {
                                UserId = sessionStateChangeTrigger.UserId,
                                StateChange = sessionStateChangeTrigger.StateChange
                            });
                    break;
                case TaskTriggerType.Time:
                    var y = (serialisedTrigger as TimeTrigger);
            // ReSharper disable PossibleNullReferenceException
                    trigger = new Dev2TimeTrigger(this, new TimeTrigger(y.StartBoundary));
            // ReSharper restore PossibleNullReferenceException

                    break;
                case TaskTriggerType.Weekly:
                    var z = (serialisedTrigger as WeeklyTrigger);
            // ReSharper disable PossibleNullReferenceException
                    trigger = new Dev2WeeklyTrigger(this, new WeeklyTrigger(z.DaysOfWeek, z.WeeksInterval));
            // ReSharper restore PossibleNullReferenceException

                    break;
                default:
                    trigger = null;
                    break;
            }
            if (trigger != null)
            {
                trigger.Enabled = resource.Enabled;
                trigger.EndBoundary = resource.EndBoundary;
                trigger.StartBoundary = resource.StartBoundary;
                trigger.Repetition.Duration = resource.Repetition.Duration;
                trigger.Repetition.Interval = resource.Repetition.Interval;
                trigger.Repetition.StopAtDurationEnd = resource.Repetition.StopAtDurationEnd;

                ExtractDelay(resource.Instance as ITriggerDelay, trigger.Instance as ITriggerDelay);
            }
            return trigger;
        }