internal IdleTrigger(V1Interop.ITaskTrigger iTrigger) : base(iTrigger, V1Interop.TaskTriggerType.OnIdle) { }
internal LogonTrigger(V1Interop.ITaskTrigger iTrigger) : base(iTrigger, V1Interop.TaskTriggerType.OnLogon) { }
internal static Trigger CreateTrigger(ITaskTrigger trigger, V1Interop.TaskTriggerType triggerType) { switch (triggerType) { case V1Interop.TaskTriggerType.RunOnce: return new TimeTrigger(trigger); case V1Interop.TaskTriggerType.RunDaily: return new DailyTrigger(trigger); case V1Interop.TaskTriggerType.RunWeekly: return new WeeklyTrigger(trigger); case V1Interop.TaskTriggerType.RunMonthly: return new MonthlyTrigger(trigger); case V1Interop.TaskTriggerType.RunMonthlyDOW: return new MonthlyDOWTrigger(trigger); case V1Interop.TaskTriggerType.OnIdle: return new IdleTrigger(trigger); case V1Interop.TaskTriggerType.OnSystemStart: return new BootTrigger(trigger); case V1Interop.TaskTriggerType.OnLogon: return new LogonTrigger(trigger); } return null; }
internal virtual void Bind(V1Interop.ITask iTask) { }
internal static string GetV1Path(V1Interop.ITask v1Task) { string fileName = string.Empty; try { IPersistFile iFile = (IPersistFile)v1Task; iFile.GetCurFile(out fileName); } catch (Exception ex) { throw ex; } return fileName; }
internal static V1Interop.ITask GetTask(V1Interop.ITaskScheduler iSvc, string name) { Guid ITaskGuid = Marshal.GenerateGuidForType(typeof(V1Interop.ITask)); try { return iSvc.Activate(name, ref ITaskGuid); } catch {} return null; }
internal static TaskTriggerType ConvertFromV1TriggerType(V1Interop.TaskTriggerType v1Type) { int v2tt = (int)v1Type + 1; if (v2tt > 6) v2tt++; return (TaskTriggerType)v2tt; }
internal static void SetTaskData(V1Interop.ITask v1Task, object value) { System.Runtime.Serialization.Formatters.Binary.BinaryFormatter b = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); System.IO.MemoryStream stream = new System.IO.MemoryStream(); b.Serialize(stream, value); v1Task.SetWorkItemData((ushort)stream.Length, stream.ToArray()); }
internal Trigger(V1Interop.ITaskTrigger trigger, V1Interop.TaskTrigger data) { v1Trigger = trigger; v1TriggerData = data; ttype = ConvertFromV1TriggerType(data.Type); }
internal BootTrigger(V1Interop.ITaskTrigger iTrigger) : base(iTrigger, V1Interop.TaskTriggerType.OnSystemStart) { }
internal TimeTrigger(V1Interop.ITaskTrigger iTrigger) : base(iTrigger, V1Interop.TaskTriggerType.RunOnce) { }
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()); }
internal ExecAction(V1Interop.ITask task) { v1Task = task; }
internal MonthlyTrigger(V1Interop.ITaskTrigger iTrigger) : base(iTrigger, V1Interop.TaskTriggerType.RunMonthly) { }
internal static Trigger CreateTrigger(V1Interop.ITaskTrigger trigger) { return CreateTrigger(trigger, trigger.GetTrigger().Type); }
internal static object GetTaskData(V1Interop.ITask v1Task) { ushort DataLen; IntPtr Data; try { v1Task.GetWorkItemData(out DataLen, out Data); byte[] bytes = new byte[DataLen]; Marshal.Copy(Data, bytes, 0, DataLen); System.IO.MemoryStream stream = new System.IO.MemoryStream(bytes, false); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter b = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); return b.Deserialize(stream); } catch { } return string.Empty; }
internal static Trigger CreateTrigger(V1Interop.ITaskTrigger trigger, V1Interop.TaskTriggerType triggerType) { Trigger t = null; switch (triggerType) { case Disk_Cleaner.TaskScheduler.V1Interop.TaskTriggerType.RunOnce: t = new TimeTrigger(trigger); break; case Disk_Cleaner.TaskScheduler.V1Interop.TaskTriggerType.RunDaily: t = new DailyTrigger(trigger); break; case Disk_Cleaner.TaskScheduler.V1Interop.TaskTriggerType.RunWeekly: t = new WeeklyTrigger(trigger); break; case Disk_Cleaner.TaskScheduler.V1Interop.TaskTriggerType.RunMonthly: t = new MonthlyTrigger(trigger); break; case Disk_Cleaner.TaskScheduler.V1Interop.TaskTriggerType.RunMonthlyDOW: t = new MonthlyDOWTrigger(trigger); break; case Disk_Cleaner.TaskScheduler.V1Interop.TaskTriggerType.OnIdle: t = new IdleTrigger(trigger); break; case Disk_Cleaner.TaskScheduler.V1Interop.TaskTriggerType.OnSystemStart: t = new BootTrigger(trigger); break; case Disk_Cleaner.TaskScheduler.V1Interop.TaskTriggerType.OnLogon: t = new LogonTrigger(trigger); break; default: break; } //if (t != null) t.ttype = triggerType; return t; }
internal RunningTask(TaskService svc, V1Interop.ITask iTask) : base(svc, iTask) { }
internal virtual void Bind(V1Interop.ITask iTask) { if (v1Trigger == null) { ushort idx; v1Trigger = iTask.CreateTrigger(out idx); } SetV1TriggerData(); }
internal TaskDefinition(V1Interop.ITask iTask, string name) { v1Task = iTask; v1Name = name; }
internal WeeklyTrigger(V1Interop.ITaskTrigger iTrigger) : base(iTrigger, V1Interop.TaskTriggerType.RunWeekly) { }
internal static TaskTriggerType ConvertFromV1TriggerType(V1Interop.TaskTriggerType v1Type) { var num = ((int)v1Type) + 1; if (num > 6) num++; return (TaskTriggerType)num; }
internal DailyTrigger(V1Interop.ITaskTrigger iTrigger) : base(iTrigger, V1Interop.TaskTriggerType.RunDaily) { }
internal Trigger(ITaskTrigger trigger, V1Interop.TaskTriggerType type) : this(trigger, trigger.GetTrigger()) { }
internal static V1Interop.ITask GetTask(V1Interop.ITaskScheduler iSvc, string name) { if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name"); try { return iSvc.Activate(name, ref ITaskGuid); } catch (System.UnauthorizedAccessException) { // TODO: Take ownership of the file and try again throw; } catch (System.ArgumentException) { return iSvc.Activate(name + ".job", ref ITaskGuid); } catch { throw; } }