Beispiel #1
0
        /// <summary>
        /// Creates a specialized class from a defined interface.
        /// </summary>
        /// <param name="iTask">Version 1.0 interface.</param>
        /// <returns>Specialized action class</returns>
        internal static Action CreateAction(V1Interop.ITask iTask)
        {
            ExecAction tempAction = new ExecAction(iTask);
            Action     a          = ConvertFromPowerShellAction(tempAction);

            return(a ?? tempAction);
        }
Beispiel #2
0
 /// <summary>
 /// Releases all resources used by this class.
 /// </summary>
 public void Dispose()
 {
     if (v2Coll != null)
     {
         Marshal.ReleaseComObject(v2Coll);
     }
     v2Def  = null;
     v1Task = null;
 }
Beispiel #3
0
        internal override void Bind(V1Interop.ITask v1Task)
        {
            object o = null;

            unboundValues.TryGetValue("Path", out o);
            v1Task.SetApplicationName(o == null ? string.Empty : o.ToString());
            o = null;
            unboundValues.TryGetValue("Arguments", out o);
            v1Task.SetParameters(o == null ? string.Empty : o.ToString());
            o = null;
            unboundValues.TryGetValue("WorkingDirectory", out o);
            v1Task.SetWorkingDirectory(o == null ? string.Empty : o.ToString());
        }
Beispiel #4
0
            /// <summary>
            /// Moves to the next task. See MoveNext for more information.
            /// </summary>
            /// <returns>true if next task found, false if no more tasks.</returns>
            public bool MoveNext()
            {
                IntPtr names = IntPtr.Zero;
                bool   valid = false;

                do
                {
                    curItem = null;
                    uint uFetched = 0;
                    try
                    {
                        wienum.Next(1, out names, out uFetched);
                        if (uFetched != 1)
                        {
                            break;
                        }
                        using (V1Interop.CoTaskMemString name = new V1Interop.CoTaskMemString(Marshal.ReadIntPtr(names)))
                            curItem = name.ToString();
                        if (curItem.EndsWith(".job", StringComparison.InvariantCultureIgnoreCase))
                        {
                            curItem = curItem.Remove(curItem.Length - 4);
                        }
                    }
                    catch { }
                    finally { Marshal.FreeCoTaskMem(names); names = IntPtr.Zero; }

                    // If name doesn't match filter, look for next item
                    if (filter != null)
                    {
                        if (!filter.IsMatch(curItem))
                        {
                            continue;
                        }
                    }

                    V1Interop.ITask itask = null;
                    try { itask = this.ICurrent; valid = true; }
                    catch { valid = false; }
                    finally { itask = null; }
                } while (!valid);

                return(curItem != null);
            }
        /// <summary>
        /// Gets the task with the specified path.
        /// </summary>
        /// <param name="taskPath">The task path.</param>
        /// <returns>The task.</returns>
        public Task GetTask(string taskPath)
        {
            Task t = null;

            if (v2TaskService != null)
            {
                V2Interop.IRegisteredTask iTask = GetTask(this.v2TaskService, taskPath);
                if (iTask != null)
                {
                    t = new Task(this, iTask);
                }
            }
            else
            {
                V1Interop.ITask iTask = GetTask(this.v1TaskScheduler, taskPath);
                if (iTask != null)
                {
                    t = new Task(this, iTask);
                }
            }
            return(t);
        }
Beispiel #6
0
        /// <summary>
        /// Gets the task with the specified path.
        /// </summary>
        /// <param name="taskPath">The task path.</param>
        /// <returns>The <see cref="Task"/> instance matching the <paramref name="taskPath"/>, if found. If not found, this method returns <c>null</c>.</returns>
        public Task GetTask([NotNull] string taskPath)
        {
            Task t = null;

            if (v2TaskService != null)
            {
                V2Interop.IRegisteredTask iTask = GetTask(v2TaskService, taskPath);
                if (iTask != null)
                {
                    t = Task.CreateTask(this, iTask);
                }
            }
            else
            {
                taskPath = System.IO.Path.GetFileNameWithoutExtension(taskPath);
                V1Interop.ITask iTask = GetTask(v1TaskScheduler, taskPath);
                if (iTask != null)
                {
                    t = new Task(this, iTask);
                }
            }
            return(t);
        }
Beispiel #7
0
        internal virtual void Bind(V1Interop.ITask iTask)
        {
            if (Id != null)
            {
                iTask.SetDataItem("ActionId", Id);
            }
            IBindAsExecAction bindable = this as IBindAsExecAction;

            if (bindable != null)
            {
                iTask.SetDataItem("ActionType", InternalActionType.ToString());
            }
            object o = null;

            unboundValues.TryGetValue("Path", out o);
            iTask.SetApplicationName(bindable != null ? ExecAction.PowerShellPath : o?.ToString() ?? string.Empty);
            o = null;
            unboundValues.TryGetValue("Arguments", out o);
            iTask.SetParameters(bindable != null ? ExecAction.BuildPowerShellCmd(ActionType.ToString(), GetPowerShellCommand()) : o?.ToString() ?? string.Empty);
            o = null;
            unboundValues.TryGetValue("WorkingDirectory", out o);
            iTask.SetWorkingDirectory(o?.ToString() ?? string.Empty);
        }
Beispiel #8
0
 internal ComHandlerAction([NotNull] V1Interop.ITask task) : base(task)
 {
 }
Beispiel #9
0
 /// <summary>
 /// Releases all resources used by this class.
 /// </summary>
 public void Dispose()
 {
     iTask = null;
 }
Beispiel #10
0
 /// <summary>
 /// Releases all resources used by this class.
 /// </summary>
 public void Dispose()
 {
     if (v2Principal != null)
         Marshal.ReleaseComObject(v2Principal);
     v1Task = null;
 }
Beispiel #11
0
 internal virtual void Bind(V1Interop.ITask iTask)
 {
 }
Beispiel #12
0
 internal Enumerator(V1Interop.ITask task)
 {
     v1Task = task;
 }
 internal TriggerCollection(V1Interop.ITask iTask)
 {
     v1Task = iTask;
 }
Beispiel #14
0
 internal ExecAction(V1Interop.ITask task)
 {
     v1Task = task;
 }
Beispiel #15
0
 /// <summary>
 /// Releases all resources used by this class.
 /// </summary>
 public void Dispose()
 {
     if (v2Task != null)
         Marshal.ReleaseComObject(v2Task);
     v1Task = null;
 }
Beispiel #16
0
 internal TaskDefinition(V1Interop.ITask iTask, string name)
 {
     v1Task = iTask;
     v1Name = name;
 }
Beispiel #17
0
 internal Task(TaskService svc, TaskScheduler.V1Interop.ITask iTask)
 {
     this.TaskService = svc;
     v1Task = iTask;
 }
Beispiel #18
0
 /// <summary>
 /// Releases all resources used by this class.
 /// </summary>
 public void Dispose()
 {
     if (v2Settings != null)
         Marshal.ReleaseComObject(v2Settings);
     v1Task = null;
 }
Beispiel #19
0
 internal IdleSettings(TaskScheduler.V1Interop.ITask iTask)
 {
     v1Task = iTask;
 }
Beispiel #20
0
 internal Action([NotNull] V1Interop.ITask iTask)
 {
     v1Task = iTask;
 }
Beispiel #21
0
 /// <summary>
 /// Releases all resources used by this class.
 /// </summary>
 public void Dispose()
 {
     regInfo = null;
     triggers = null;
     settings = null;
     principal = null;
     actions = null;
     if (v2Def != null) Marshal.ReleaseComObject(v2Def);
     v1Task = null;
 }
Beispiel #22
0
 internal ExecAction([NotNull] V1Interop.ITask task) : base(task)
 {
 }
Beispiel #23
0
 internal ActionCollection(V1Interop.ITask task)
 {
     v1Task = task;
 }
Beispiel #24
0
 /// <summary>
 /// Releases all resources used by this class.
 /// </summary>
 public void Dispose()
 {
     v1Task = null;
     v2Def  = null;
     v2Coll = null;
 }
 internal ActionCollection([NotNull] V1Interop.ITask task)
 {
     v1Task               = task;
     v1Actions            = GetV1Actions();
     PowerShellConversion = Action.TryParse(v1Task.GetDataItem(nameof(PowerShellConversion)), psConvert | PowerShellActionPlatformOption.Version2);
 }
Beispiel #26
0
 internal TriggerCollection([NotNull] V1Interop.ITask iTask)
 {
     v1Task = iTask;
 }
Beispiel #27
0
 internal ShowMessageAction([NotNull] V1Interop.ITask task) : base(task)
 {
 }
Beispiel #28
0
 internal V1TriggerEnumerator(V1Interop.ITask task)
 {
     iTask = task;
 }
Beispiel #29
0
 /// <summary>
 /// Releases all resources used by this class.
 /// </summary>
 public void Dispose()
 {
     v1Task = null;
     v2Enum = null;
 }
Beispiel #30
0
 internal ExecAction(V1Interop.ITask task)
 {
     v1Task = task;
 }
Beispiel #31
0
 internal TaskPrincipal(TaskScheduler.V1Interop.ITask iTask)
 {
     v1Task = iTask;
 }