Beispiel #1
0
 /// <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) {
     Enabled = sourceTrigger.Enabled;
     EndBoundary = sourceTrigger.EndBoundary;
     try {
         ExecutionTimeLimit = sourceTrigger.ExecutionTimeLimit;
     } catch {
     }
     Repetition.Duration = sourceTrigger.Repetition.Duration;
     Repetition.Interval = sourceTrigger.Repetition.Interval;
     Repetition.StopAtDurationEnd = sourceTrigger.Repetition.StopAtDurationEnd;
     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>
        ///     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) {
            var 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);
        }
Beispiel #3
0
 /// <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() == GetType()) {
         DaysOfWeek = ((WeeklyTrigger)sourceTrigger).DaysOfWeek;
         WeeksInterval = ((WeeklyTrigger)sourceTrigger).WeeksInterval;
     }
 }
Beispiel #4
0
 /// <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() == GetType()) {
         StateChange = ((SessionStateChangeTrigger)sourceTrigger).StateChange;
     }
 }
Beispiel #5
0
 internal RepetitionPattern(Trigger parent) {
     pTrigger = parent;
     if (pTrigger.v2Trigger != null) {
         v2Pattern = pTrigger.v2Trigger.Repetition;
     }
 }
Beispiel #6
0
 /// <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() == GetType()) {
         DaysOfMonth = ((MonthlyTrigger)sourceTrigger).DaysOfMonth;
         MonthsOfYear = ((MonthlyTrigger)sourceTrigger).MonthsOfYear;
         try {
             RunOnLastDayOfMonth = ((MonthlyTrigger)sourceTrigger).RunOnLastDayOfMonth;
         } catch {
         }
     }
 }
Beispiel #7
0
 /// <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() == GetType()) {
         Subscription = ((EventTrigger)sourceTrigger).Subscription;
         ((EventTrigger)sourceTrigger).ValueQueries.CopyTo(ValueQueries);
     }
 }