internal ActionCollection([NotNull] V2Interop.ITaskDefinition iTaskDef) { v2Def = iTaskDef; v2Coll = iTaskDef.Actions; System.Text.RegularExpressions.Match match; if (iTaskDef.Data != null && (match = System.Text.RegularExpressions.Regex.Match(iTaskDef.Data, psV2IdRegex)).Success) { bool on = bool.Parse(match.Groups["v"].Value); if (on) { psConvert |= PowerShellActionPlatformOption.Version2; } else { psConvert &= ~PowerShellActionPlatformOption.Version2; } } UnconvertUnsupportedActions(); }
private List <Action> GetV1Actions() { List <Action> ret = new List <Action>(); if (v1Task != null && v1Task.GetDataItem("ActionType") != "EMPTY") { var exec = new ExecAction(v1Task); var items = exec.ParsePowerShellItems(); if (items != null) { if (items.Length == 2 && items[0] == "MULTIPLE") { PowerShellConversion |= PowerShellActionPlatformOption.Version1; var mc = System.Text.RegularExpressions.Regex.Matches(items[1], @"<# (?<id>\w+):(?<t>\w+) #>\s*(?<c>[^<#]*)\s*"); foreach (System.Text.RegularExpressions.Match ms in mc) { var a = Action.ActionFromScript(ms.Groups["t"].Value, ms.Groups["c"].Value); if (a != null) { if (ms.Groups["id"].Value != "NO_ID") { a.Id = ms.Groups["id"].Value; } ret.Add(a); } } } else { ret.Add(ExecAction.ConvertFromPowerShellAction(exec)); } } else if (!string.IsNullOrEmpty(exec.Path)) { ret.Add(exec); } } return(ret); }
internal static AvailableActions GetFilteredAvailableActions(AvailableActions availableActions, Version tsVer, bool useUnifiedSchedulingEngine, PowerShellActionPlatformOption psOption) { var ret = availableActions; var isV1 = tsVer < TaskServiceVersion.V1_2; var isAfter7 = tsVer > TaskServiceVersion.V1_3; var isWin7 = tsVer == TaskServiceVersion.V1_3; // ComHandler not supported in V1 if (isV1) { ret &= ~AvailableActions.ComHandler; } // Email and Message actions were made available in Vista (v1.2) and deprecated in Windows 8 (v1.4) // This library can optionally make them available regardless of version // Unified Sch Eng disallows these same actions in Win7 (v1.3) if ((isV1 && !psOption.IsFlagSet(PowerShellActionPlatformOption.Version1)) || (!psOption.IsFlagSet(PowerShellActionPlatformOption.Version2) && ((useUnifiedSchedulingEngine && isWin7) || isAfter7))) { ret &= ~(AvailableActions.SendEmail | AvailableActions.ShowMessage); } if (ret == 0) { throw new InvalidOperationException("No actions are available to display given the current settings."); } return(ret); }
/// <summary>Filtered the supplied available actions based on this version of the Task Scheduler and options that could be set on the <see cref="TaskDefinition"/>.</summary> /// <param name="ts">The <see cref="TaskService"/> instance.</param> /// <param name="availableActions">The available actions.</param> /// <param name="useUnifiedSchedulingEngine">if set to <c>true</c> assume the task will use the Unified Scheduling Engine.</param> /// <param name="psOption">The PowerShell conversion options to assume are in place.</param> /// <returns>The filtered set of available actions.</returns> public static AvailableActions GetFilteredAvailableActions(this TaskService ts, AvailableActions availableActions, bool useUnifiedSchedulingEngine = false, PowerShellActionPlatformOption psOption = PowerShellActionPlatformOption.All) => GetFilteredAvailableActions(availableActions, ts.HighestSupportedVersion, useUnifiedSchedulingEngine, psOption);