Пример #1
0
        public override IList <Parameter> GetEffectiveParameters(DataRow input, DataTable dataTable, DataObjectStore store)
        {
            IList <Parameter> list = base.GetEffectiveParameters(input, dataTable, store);

            list = (list ?? new List <Parameter>());
            ShouldContinueContext shouldContinueContext = base.EacHttpContext.ShouldContinueContext;

            if (shouldContinueContext == null && dataTable.Columns.Contains("ShouldContinue") && dataTable.Rows.Count > 0)
            {
                bool?flag = dataTable.Rows[0]["ShouldContinue"] as bool?;
                if (flag.IsTrue())
                {
                    shouldContinueContext = (dataTable.Rows[0]["LastErrorContext"] as ShouldContinueContext);
                    base.EacHttpContext.ShouldContinueContext = shouldContinueContext;
                }
            }
            if (shouldContinueContext != null && shouldContinueContext.CmdletsPrompted.Contains(this.GetCommandText(store)))
            {
                if (this.ShouldContinueOperation == ShouldContinueOperation.AddParam)
                {
                    list.Add(new Parameter
                    {
                        Name = this.ShouldContinueParam,
                        Type = ParameterType.Switch
                    });
                }
                else if (this.ShouldContinueOperation == ShouldContinueOperation.RemoveParam)
                {
                    list.Remove(new Parameter
                    {
                        Name = this.ShouldContinueParam,
                        Type = ParameterType.Switch
                    });
                }
            }
            return(list);
        }
Пример #2
0
        protected override PowerShellResults <JsonDictionary <object> > ExecuteCore(Workflow workflow)
        {
            DataRow row = base.Table.NewRow();

            base.Table.Rows.Add(row);
            base.Row.ItemArray = base.Input.ItemArray;
            PowerShellResults <JsonDictionary <object> > powerShellResults = new PowerShellResults <JsonDictionary <object> >();

            powerShellResults.MergeErrors(workflow.Run(base.Input, base.Table, base.DataObjectStore, base.ProfileBuilder.Class, new Workflow.UpdateTableDelegate(this.UpdateTable)));
            if (powerShellResults.ErrorRecords.Length == 0)
            {
                if (workflow.AsyncRunning && AsyncServiceManager.IsCurrentWorkCancelled())
                {
                    goto IL_451;
                }
                using (EcpPerformanceData.DDITypeConversion.StartRequestTimer())
                {
                    IList <string>          outputVariables = base.GetOutputVariables(base.OutputVariableWorkflow);
                    Func <DataColumn, bool> predicate;
                    if (this.IsGetObjectForNew)
                    {
                        predicate = ((DataColumn c) => outputVariables.Contains(c.ColumnName, StringComparer.OrdinalIgnoreCase) && this.Row[c.ColumnName] != DBNull.Value);
                    }
                    else
                    {
                        predicate = ((DataColumn c) => outputVariables.Contains(c.ColumnName, StringComparer.OrdinalIgnoreCase) || (Variable.MandatoryVariablesForGetObject.Contains(c.ColumnName) && this.ExecutingWorkflow is GetObjectWorkflow));
                    }
                    IEnumerable <DataColumn>    columns = (outputVariables == null) ? base.Table.Columns.Cast <DataColumn>() : base.Table.Columns.Cast <DataColumn>().Where(predicate);
                    Dictionary <string, object> dictionary;
                    base.ExtractDataRow(base.Table.Rows[0], columns, out dictionary);
                    if (base.ExecutingWorkflow is GetObjectWorkflow)
                    {
                        foreach (string name in this.GetOutputRelatedDataObjects(columns))
                        {
                            IVersionable versionable = base.DataObjectStore.GetDataObject(name) as IVersionable;
                            if (versionable != null && versionable.ExchangeVersion != null)
                            {
                                bool flag = versionable.ExchangeVersion.IsOlderThan(base.DataObjectStore.GetDataObjectDeclaration(name).MinSupportedVersion);
                                if (versionable.IsReadOnly || flag)
                                {
                                    base.Table.Rows[0]["IsReadOnly"] = true;
                                    if (dictionary.ContainsKey("IsReadOnly"))
                                    {
                                        dictionary["IsReadOnly"] = true;
                                    }
                                    string text = flag ? Strings.ObjectTooOld : Strings.VersionMismatchWarning(versionable.ExchangeVersion.ExchangeBuild);
                                    powerShellResults.Warnings = ((powerShellResults.Warnings == null) ? new string[]
                                    {
                                        text
                                    } : powerShellResults.Warnings.Concat(new string[]
                                    {
                                        text
                                    }).ToArray <string>());
                                    break;
                                }
                            }
                        }
                    }
                    Dictionary <string, ValidatorInfo[]> dictionary2;
                    IList <string> source;
                    IList <string> source2;
                    workflow.LoadMetaData(base.Input, base.Table, base.DataObjectStore, outputVariables, out dictionary2, out source, out source2, base.ProfileBuilder);
                    powerShellResults.Validators         = dictionary2;
                    powerShellResults.ReadOnlyProperties = source.ToArray <string>();
                    powerShellResults.NoAccessProperties = source2.ToArray <string>();
                    powerShellResults.Output             = new JsonDictionary <object>[]
                    {
                        dictionary
                    };
                    goto IL_451;
                }
            }
            ShouldContinueException ex = powerShellResults.ErrorRecords[0].Exception as ShouldContinueException;

            if (ex != null)
            {
                ShouldContinueContext shouldContinueContext = (HttpContext.Current.Items["ShouldContinueContext"] as ShouldContinueContext) ?? new ShouldContinueContext();
                if (!shouldContinueContext.CmdletsPrompted.Contains(ex.Details.CurrentCmdlet))
                {
                    shouldContinueContext.CmdletsPrompted.Add(ex.Details.CurrentCmdlet);
                }
                powerShellResults.ErrorRecords[0].Context = shouldContinueContext;
            }
            if (!workflow.OutputOnError.IsNullOrEmpty())
            {
                IEnumerable <DataColumn> columns2 = from DataColumn c in base.Table.Columns
                                                    where workflow.OutputOnError.Contains(c.ColumnName)
                                                    select c;
                Dictionary <string, object> dictionary3;
                base.ExtractDataRow(base.Table.Rows[0], columns2, out dictionary3);
                if (powerShellResults.ErrorRecords[0].Context == null)
                {
                    powerShellResults.ErrorRecords[0].Context = new ErrorRecordContext();
                }
                powerShellResults.ErrorRecords[0].Context.LastOuput = dictionary3;
            }
IL_451:
            DDIHelper.Trace(TraceType.InfoTrace, "Result: ");
            DDIHelper.Trace <PowerShellResults <JsonDictionary <object> > >(TraceType.InfoTrace, powerShellResults);
            return(powerShellResults);
        }