コード例 #1
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());
        }
コード例 #2
0
        private void SaveV1Actions()
        {
            if (v1Task == null)
            {
                throw new ArgumentNullException(nameof(v1Task));
            }
            if (v1Actions.Count == 0)
            {
                v1Task.SetApplicationName(string.Empty);
                v1Task.SetParameters(string.Empty);
                v1Task.SetWorkingDirectory(string.Empty);
                v1Task.SetDataItem("ActionId", null);
                v1Task.SetDataItem("ActionType", "EMPTY");
            }
            else if (v1Actions.Count == 1)
            {
                if (!SupportV1Conversion && v1Actions[0].ActionType != TaskActionType.Execute)
                {
                    throw new NotV1SupportedException($"Only a single {nameof(ExecAction)} is supported unless the {nameof(PowerShellConversion)} property includes the {nameof(PowerShellActionPlatformOption.Version1)} value.");
                }
                v1Task.SetDataItem("ActionType", null);
                v1Actions[0].Bind(v1Task);
            }
            else
            {
                if (!SupportV1Conversion)
                {
                    throw new NotV1SupportedException($"Only a single {nameof(ExecAction)} is supported unless the {nameof(PowerShellConversion)} property includes the {nameof(PowerShellActionPlatformOption.Version1)} value.");
                }
                // Build list of internal PowerShell scripts
                var sb = new System.Text.StringBuilder();
                foreach (var item in v1Actions)
                {
                    sb.Append($"<# {item.Id ?? "NO_ID"}:{item.ActionType} #> {item.GetPowerShellCommand()} ");
                }

                // Build and save PS ExecAction
                var ea = ExecAction.CreatePowerShellAction("MULTIPLE", sb.ToString());
                ea.Bind(v1Task);
                v1Task.SetDataItem("ActionId", null);
                v1Task.SetDataItem("ActionType", "MULTIPLE");
            }
        }
コード例 #3
0
ファイル: Action.cs プロジェクト: stuff2600/TaskScheduler
        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);
        }