/// <summary> /// Copies the properties from another <see cref="Trigger"/> the current instance. This will not copy any properties associated with any derived triggers except those supporting the <see cref="ITriggerDelay"/> interface. /// </summary> /// <param name="sourceTrigger">The source <see cref="Trigger"/>.</param> public override void CopyProperties(Trigger sourceTrigger) { base.CopyProperties(sourceTrigger); if (sourceTrigger.GetType() == this.GetType()) { this.DaysOfWeek = ((MonthlyDOWTrigger)sourceTrigger).DaysOfWeek; this.MonthsOfYear = ((MonthlyDOWTrigger)sourceTrigger).MonthsOfYear; try { this.RunOnLastWeekOfMonth = ((MonthlyDOWTrigger)sourceTrigger).RunOnLastWeekOfMonth; } catch { } this.WeeksOfMonth = ((MonthlyDOWTrigger)sourceTrigger).WeeksOfMonth; } }
/// <summary> /// Creates a new task, registers the taks, and returns the instance. /// </summary> /// <param name="path">The task name. If this value is NULL, the task will be registered in the root task folder and the task name will be a GUID value that is created by the Task Scheduler service. A task name cannot begin or end with a space character. The '.' character cannot be used to specify the current task folder and the '..' characters cannot be used to specify the parent task folder in the path.</param> /// <param name="trigger">The <see cref="Trigger"/> to determine when to run the task.</param> /// <param name="action">The <see cref="Action"/> to determine what happens when the task is triggered.</param> /// <param name="UserId">The user credentials used to register the task.</param> /// <param name="Password">The password for the userId used to register the task.</param> /// <param name="LogonType">A <see cref="TaskLogonType"/> value that defines what logon technique is used to run the registered task.</param> /// <returns> /// A <see cref="Task"/> instance of the registered task. /// </returns> public Task AddTask(string path, Trigger trigger, Action action, string UserId = null, string Password = null, TaskLogonType LogonType = TaskLogonType.InteractiveToken) { TaskDefinition td = NewTask(); // Create a trigger that will fire the task at a specific date and time td.Triggers.Add(trigger); // Create an action that will launch Notepad whenever the trigger fires td.Actions.Add(action); // Register the task in the root folder return RootFolder.RegisterTaskDefinition(path, td, TaskCreation.CreateOrUpdate, UserId, Password, LogonType); }
/// <summary> /// Copies the properties from another <see cref="Trigger"/> the current instance. This will not copy any properties associated with any derived triggers except those supporting the <see cref="ITriggerDelay"/> interface. /// </summary> /// <param name="sourceTrigger">The source <see cref="Trigger"/>.</param> public override void CopyProperties(Trigger sourceTrigger) { base.CopyProperties(sourceTrigger); if (sourceTrigger.GetType() == this.GetType()) { this.Subscription = ((EventTrigger)sourceTrigger).Subscription; ((EventTrigger)sourceTrigger).ValueQueries.CopyTo(this.ValueQueries); } }
/// <summary> /// Copies the properties from another <see cref="Trigger"/> the current instance. This will not copy any properties associated with any derived triggers except those supporting the <see cref="ITriggerDelay"/> interface. /// </summary> /// <param name="sourceTrigger">The source <see cref="Trigger"/>.</param> public override void CopyProperties(Trigger sourceTrigger) { base.CopyProperties(sourceTrigger); if (sourceTrigger.GetType() == this.GetType()) { this.DaysInterval = ((DailyTrigger)sourceTrigger).DaysInterval; } }
/// <summary> /// Copies the properties from another <see cref="Trigger"/> the current instance. This will not copy any properties associated with any derived triggers except those supporting the <see cref="ITriggerDelay"/> interface. /// </summary> /// <param name="sourceTrigger">The source <see cref="Trigger"/>.</param> public virtual void CopyProperties(Trigger sourceTrigger) { this.Enabled = sourceTrigger.Enabled; this.EndBoundary = sourceTrigger.EndBoundary; try { this.ExecutionTimeLimit = sourceTrigger.ExecutionTimeLimit; } catch { } this.Repetition.Duration = sourceTrigger.Repetition.Duration; this.Repetition.Interval = sourceTrigger.Repetition.Interval; this.Repetition.StopAtDurationEnd = sourceTrigger.Repetition.StopAtDurationEnd; this.StartBoundary = sourceTrigger.StartBoundary; if (sourceTrigger is ITriggerDelay && this is ITriggerDelay) try { ((ITriggerDelay)this).Delay = ((ITriggerDelay)sourceTrigger).Delay; } catch { } if (sourceTrigger is ITriggerUserId && this is ITriggerUserId) try { ((ITriggerUserId)this).UserId = ((ITriggerUserId)sourceTrigger).UserId; } catch { } }
/// <summary> /// Copies the properties from another <see cref="Trigger"/> the current instance. This will not copy any properties associated with any derived triggers except those supporting the <see cref="ITriggerDelay"/> interface. /// </summary> /// <param name="sourceTrigger">The source <see cref="Trigger"/>.</param> public override void CopyProperties(Trigger sourceTrigger) { base.CopyProperties(sourceTrigger); if (sourceTrigger.GetType() == this.GetType()) this.StateChange = ((SessionStateChangeTrigger)sourceTrigger).StateChange; }
internal RepetitionPattern(Trigger parent) { pTrigger = parent; if (pTrigger.v2Trigger != null) v2Pattern = pTrigger.v2Trigger.Repetition; }