コード例 #1
0
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            RunResult runResult = new RunResult();
            PowerShellResults <PSObject> powerShellResults;

            base.ExecuteCmdlet(null, runResult, out powerShellResults, false);
            if (!runResult.ErrorOccur && powerShellResults.Succeeded && !string.IsNullOrEmpty(base.DataObjectName))
            {
                runResult.DataObjectes.Add(base.DataObjectName);
                store.UpdateDataObject(base.DataObjectName, null);
                if (store.GetDataObjectType(base.DataObjectName) == typeof(object))
                {
                    if (powerShellResults.Output != null)
                    {
                        store.UpdateDataObject(base.DataObjectName, (from c in powerShellResults.Output
                                                                     select c.BaseObject).ToList <object>());
                    }
                }
                else if (powerShellResults.HasValue && powerShellResults.Value != null)
                {
                    store.UpdateDataObject(base.DataObjectName, powerShellResults.Value.BaseObject);
                }
                updateTableDelegate(base.DataObjectName, this.FillAllColumns);
            }
            return(runResult);
        }
コード例 #2
0
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            DDIHelper.Trace(TraceType.InfoTrace, "Executing :" + base.GetType().Name);
            DDIHelper.Trace <IPSCommandWrapper>(TraceType.InfoTrace, base.Command);
            RunResult runResult = new RunResult();
            PowerShellResults <PSObject> powerShellResults;

            if (!DDIHelper.ForGetListProgress)
            {
                base.ExecuteCmdlet(null, runResult, out powerShellResults, store.AsyncType == ListAsyncType.GetListAsync || store.AsyncType == ListAsyncType.GetListPreLoad);
            }
            else if (store.AsyncType == ListAsyncType.GetListEndLoad)
            {
                powerShellResults = AsyncServiceManager.GetPreLoadResult(DDIHelper.ProgressIdForGetListAsync);
            }
            else
            {
                string progressIdForGetListAsync = DDIHelper.ProgressIdForGetListAsync;
                powerShellResults = AsyncServiceManager.GetCurrentResult(progressIdForGetListAsync);
            }
            base.StatusReport    = powerShellResults;
            runResult.ErrorOccur = !base.StatusReport.Succeeded;
            if (!runResult.ErrorOccur)
            {
                if (powerShellResults.Output != null && powerShellResults.Output.Length > 0)
                {
                    Type      type         = null;
                    Hashtable propertyHash = new Hashtable();
                    Hashtable hashtable    = new Hashtable();
                    dataTable.BeginLoadData();
                    foreach (PSObject psobject in powerShellResults.Output)
                    {
                        if (type == null)
                        {
                            type = psobject.BaseObject.GetType();
                            type.GetProperties().Perform(delegate(PropertyInfo c)
                            {
                                propertyHash[c.Name] = c;
                            });
                        }
                        DataRow dataRow = dataTable.NewRow();
                        dataTable.Rows.Add(dataRow);
                        dataRow.BeginEdit();
                        foreach (object obj in dataTable.Columns)
                        {
                            DataColumn dataColumn = (DataColumn)obj;
                            Variable   variable   = dataColumn.ExtendedProperties["Variable"] as Variable;
                            if (variable != null)
                            {
                                if (variable.PersistWholeObject)
                                {
                                    dataRow[dataColumn.ColumnName] = psobject.BaseObject;
                                }
                                else if (!hashtable.ContainsKey(dataColumn.ColumnName))
                                {
                                    PropertyInfo propertyInfo = propertyHash[variable.MappingProperty] as PropertyInfo;
                                    if (propertyInfo != null)
                                    {
                                        dataRow[dataColumn.ColumnName] = propertyInfo.GetValue(psobject.BaseObject, null);
                                    }
                                    else
                                    {
                                        hashtable.Add(dataColumn.ColumnName, null);
                                    }
                                }
                            }
                        }
                        Collection <Set> defaultValues = this.DefaultValues;
                        NewDefaultObject.SetDefaultValues(input, dataRow, dataTable, defaultValues);
                        dataRow.EndEdit();
                    }
                    dataTable.EndLoadData();
                }
            }
            else if (this.isResultSizeAutoApplied)
            {
                Microsoft.Exchange.Management.ControlPanel.ErrorRecord errorRecord = base.StatusReport.ErrorRecords.FirstOrDefault((Microsoft.Exchange.Management.ControlPanel.ErrorRecord x) => x.Exception is ParameterBindingException && (x.Exception as ParameterBindingException).ParameterName == "ResultSize");
                if (errorRecord != null)
                {
                    if (base.StatusReport.ErrorRecords.Length > 1)
                    {
                        base.StatusReport.ErrorRecords = base.StatusReport.ErrorRecords.Except(new Microsoft.Exchange.Management.ControlPanel.ErrorRecord[]
                        {
                            errorRecord
                        }).ToArray <Microsoft.Exchange.Management.ControlPanel.ErrorRecord>();
                    }
                    else
                    {
                        base.StatusReport.ErrorRecords = new Microsoft.Exchange.Management.ControlPanel.ErrorRecord[]
                        {
                            new Microsoft.Exchange.Management.ControlPanel.ErrorRecord(new Exception(Strings.UnsupportedAutoApplyParamMsgText))
                        };
                    }
                    lock (GetListCmdlet.unsupportedCmdletsLock)
                    {
                        string commandText = base.GetCommandText(store);
                        if (!GetListCmdlet.unsupportedCmdlets.Contains(commandText))
                        {
                            GetListCmdlet.unsupportedCmdlets.Add(commandText);
                        }
                    }
                }
            }
            return(runResult);
        }
コード例 #3
0
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            DDIHelper.CheckDataTableForSingleObject(dataTable);
            DataRow dataRow = dataTable.Rows[0];

            if (!(dataRow[base.IdentityVariable] is ADObjectId))
            {
                throw new NotSupportedException("Currently we don't support Back-Link look up based on the UMC type Identity!");
            }
            if (this.EnableFilter)
            {
                base.Command.AddParameter("Filter", string.Format("{0} -{1} '{2}'", this.LinkProperty, this.FilterOperator, DDIHelper.ToQuotationEscapedString(((ADObjectId)dataRow[base.IdentityVariable]).DistinguishedName)));
            }
            RunResult runResult = new RunResult();
            PowerShellResults <PSObject> powerShellResults;

            base.ExecuteCmdlet(null, runResult, out powerShellResults, false);
            if (!runResult.ErrorOccur)
            {
                List <ADObjectId> list = new List <ADObjectId>();
                foreach (PSObject psobject in powerShellResults.Output)
                {
                    if (!this.EnableFilter)
                    {
                        ADObjectId adobjectId = (ADObjectId)psobject.Properties[this.LinkProperty].Value;
                        if (adobjectId != null && adobjectId.Equals(dataRow[base.IdentityVariable]))
                        {
                            list.Add(psobject.Properties["Identity"].Value as ADObjectId);
                        }
                    }
                    else
                    {
                        list.Add(psobject.Properties["Identity"].Value as ADObjectId);
                    }
                }
                dataRow[this.OutputVariable] = list;
            }
            return(runResult);
        }
コード例 #4
0
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            Identity[] array = this.PreparePipelineExecution(input, dataTable);
            if (array == null || this.SingletonObject)
            {
                return(base.Run(input, dataTable, store, codeBehind, updateTableDelegate));
            }
            if (array.Length == 0)
            {
                throw new InvalidOperationException();
            }
            RunResult runResult = new RunResult();
            PowerShellResults <PSObject> powerShellResults;

            base.ExecuteCmdlet(array, runResult, out powerShellResults, false);
            return(runResult);
        }
コード例 #5
0
ファイル: Assign.cs プロジェクト: YHZX2013/exchange_diff
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            RunResult result = new RunResult();
            string    text   = this.Value as string;

            if (DDIHelper.IsLambdaExpression(text))
            {
                dataTable.Rows[0][this.Variable] = ExpressionCalculator.CalculateLambdaExpression(ExpressionCalculator.BuildColumnExpression(text), typeof(object), DDIHelper.GetLambdaExpressionDataRow(dataTable), input);
            }
            else
            {
                dataTable.Rows[0][this.Variable] = this.Value;
            }
            return(result);
        }
コード例 #6
0
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            RunResult result = new RunResult();

            if (null != codeBehind && !string.IsNullOrEmpty(this.LoadDataAction))
            {
                DDIHelper.Trace("LoadDataAction: " + this.LoadDataAction);
                codeBehind.GetMethod(this.LoadDataAction).Invoke(null, new object[]
                {
                    input,
                    dataTable,
                    store
                });
            }
            return(result);
        }
コード例 #7
0
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            RunResult         runResult         = new RunResult();
            IPSCommandWrapper ipscommandWrapper = base.PowershellFactory.CreatePSCommand();
            Activity          activity          = null;

            foreach (Activity activity2 in base.Body)
            {
                ((CmdletActivity)activity2).BuildCommand(input, dataTable, store, codeBehind);
                ipscommandWrapper.AddCommand(((CmdletActivity)activity2).Command.Commands[0]);
                activity = activity2;
            }
            if (activity != null)
            {
                base.CurrentExecutingActivity      = activity;
                ((CmdletActivity)activity).Command = ipscommandWrapper;
                RunResult runResult2 = activity.Run(input, dataTable, store, codeBehind, updateTableDelegate);
                runResult.DataObjectes.AddRange(runResult2.DataObjectes);
                this.statusReport             = this.statusReport.Concat(activity.GetStatusReport(input, dataTable, store)).ToArray <PowerShellResults>();
                base.CurrentExecutingActivity = null;
                if (runResult2.ErrorOccur && base.ErrorBehavior == ErrorBehavior.Stop && activity.ErrorBehavior == ErrorBehavior.Stop)
                {
                    runResult.ErrorOccur = true;
                    return(runResult);
                }
            }
            return(runResult);
        }
コード例 #8
0
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            RunResult runResult = new RunResult();

            foreach (string text in this.GetDataObjectKeys(store))
            {
                object             obj = null;
                IDataObjectCreator dataObjectCreator = store.GetDataObjectCreator(text);
                if (dataObjectCreator != null)
                {
                    obj = dataObjectCreator.Create(dataTable);
                }
                else
                {
                    Type dataObjectType = store.GetDataObjectType(text);
                    if (null != dataObjectType)
                    {
                        obj = dataObjectType.GetConstructor(new Type[0]).Invoke(new object[0]);
                    }
                }
                if (obj != null)
                {
                    store.UpdateDataObject(text, obj, true);
                    updateTableDelegate(text, false);
                }
            }
            runResult.DataObjectes.AddRange(store.GetKeys());
            return(runResult);
        }
コード例 #9
0
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            DataRow   dataRow   = dataTable.Rows[0];
            string    value     = (string)input[this.InputVariable];
            string    text      = (string)input[this.OutputFileNameVariable];
            RunResult runResult = new RunResult();

            try
            {
                runResult.ErrorOccur = true;
                if (!text.EndsWith(WriteFileActivity.textExtension))
                {
                    text += WriteFileActivity.textExtension;
                }
                using (StreamWriter streamWriter = new StreamWriter(File.Open(text, FileMode.CreateNew)))
                {
                    streamWriter.WriteLine(value);
                }
                runResult.ErrorOccur = false;
            }
            catch (UnauthorizedAccessException e)
            {
                this.HandleFileSaveException(e);
            }
            catch (DirectoryNotFoundException e2)
            {
                this.HandleFileSaveException(e2);
            }
            catch (PathTooLongException e3)
            {
                this.HandleFileSaveException(e3);
            }
            catch (SecurityException e4)
            {
                this.HandleFileSaveException(e4);
            }
            catch (IOException e5)
            {
                this.HandleFileSaveException(e5);
            }
            return(runResult);
        }
コード例 #10
0
 public abstract RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate);
コード例 #11
0
        public RunResult RunCore(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            this.ProgressPercent = 0;
            this.DoPreRun(input, dataTable, store, codeBehind);
            RunResult result = this.Run(input, dataTable, store, codeBehind, updateTableDelegate);

            this.DoPostRun(input, dataTable, store, codeBehind);
            this.ProgressPercent = 100;
            return(result);
        }
コード例 #12
0
ファイル: Foreach.cs プロジェクト: YHZX2013/exchange_diff
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            DDIHelper.CheckDataTableForSingleObject(dataTable);
            DataRow              dataRow    = dataTable.Rows[0];
            RunResult            runResult  = new RunResult();
            IList <object>       list       = new List <object>();
            IEnumerable <object> enumerable = DDIHelper.GetVariableValue(store.ModifiedColumns, this.Collection, input, dataTable, store.IsGetListWorkflow) as IEnumerable <object>;

            this.totalItems        = enumerable.Count <object>();
            this.executedItemCount = 0;
            foreach (object obj in enumerable)
            {
                dataRow[this.Item] = obj;
                if (this.Activity.IsRunnable(input, dataTable, store))
                {
                    RunResult runResult2 = this.Activity.RunCore(input, dataTable, store, codeBehind, updateTableDelegate);
                    runResult.DataObjectes.AddRange(runResult2.DataObjectes);
                    this.statusReport = this.statusReport.Concat(this.Activity.GetStatusReport(input, dataTable, store)).ToArray <PowerShellResults>();
                    if (runResult2.ErrorOccur)
                    {
                        list.Add(obj);
                        if (base.ErrorBehavior == ErrorBehavior.Stop && this.Activity.ErrorBehavior == ErrorBehavior.Stop)
                        {
                            runResult.ErrorOccur = true;
                            break;
                        }
                    }
                }
                this.executedItemCount++;
            }
            if (!string.IsNullOrEmpty(this.FailedCollection))
            {
                dataRow[this.FailedCollection] = list;
            }
            return(runResult);
        }
コード例 #13
0
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            DDIHelper.Trace(TraceType.InfoTrace, "Executing :" + base.GetType().Name);
            object[] array  = (object[])input["DeferLoadNames"];
            object[] array2 = (object[])input["DeferLoadIdentities"];
            List <Dictionary <string, object> > list = new List <Dictionary <string, object> >();
            DataRow row = dataTable.NewRow();

            dataTable.Rows.Add(row);
            dataTable.BeginLoadData();
            for (int i = 0; i < array2.Length; i++)
            {
                object value = array2[i];
                object arg   = array[i];
                base.Command = base.PowershellFactory.CreatePSCommand().AddCommand(base.GetCommandText(store));
                base.Command.AddParameter("Identity", string.Format("{0}\\*", arg));
                DDIHelper.Trace <IPSCommandWrapper>(TraceType.InfoTrace, base.Command);
                RunResult runResult = new RunResult();
                PowerShellResults <PSObject> powerShellResults;
                base.ExecuteCmdlet(null, runResult, out powerShellResults, false);
                base.StatusReport    = powerShellResults;
                runResult.ErrorOccur = !base.StatusReport.Succeeded;
                if (!runResult.ErrorOccur && powerShellResults.Output != null && powerShellResults.Output.Length > 0)
                {
                    string     value2 = Strings.StatusUnknown.ToString();
                    bool       flag   = false;
                    int        num    = 0;
                    PSObject[] output = powerShellResults.Output;
                    int        j      = 0;
                    while (j < output.Length)
                    {
                        PSObject psobject = output[j];
                        DatabaseCopyStatusEntry databaseCopyStatusEntry = (DatabaseCopyStatusEntry)psobject.BaseObject;
                        CopyStatus status = databaseCopyStatusEntry.Status;
                        if (status == CopyStatus.Failed || status == CopyStatus.ServiceDown)
                        {
                            goto IL_186;
                        }
                        switch (status)
                        {
                        case CopyStatus.DisconnectedAndHealthy:
                        case CopyStatus.FailedAndSuspended:
                        case CopyStatus.DisconnectedAndResynchronizing:
                        case CopyStatus.Misconfigured:
                            goto IL_186;
                        }
IL_18C:
                        if (databaseCopyStatusEntry.ActiveCopy)
                        {
                            switch (databaseCopyStatusEntry.Status)
                            {
                            case CopyStatus.Mounted:
                            case CopyStatus.Mounting:
                                value2 = Strings.StatusMounted.ToString();
                                flag   = true;
                                break;

                            case CopyStatus.Dismounted:
                            case CopyStatus.Dismounting:
                                value2 = Strings.StatusDismounted.ToString();
                                flag   = false;
                                break;
                            }
                        }
                        Dictionary <string, object> dictionary = new Dictionary <string, object>();
                        list.Add(dictionary);
                        dictionary["Identity"] = value;
                        dictionary["CalcualtedMountStatus"] = value2;
                        dictionary["CalcualtedMounted"]     = flag;
                        dictionary["CalcualtedBadCopies"]   = num;
                        j++;
                        continue;
IL_186:
                        num++;
                        goto IL_18C;
                    }
                }
            }
            dataTable.Clear();
            foreach (Dictionary <string, object> dictionary2 in list)
            {
                DataRow dataRow = dataTable.NewRow();
                dataTable.Rows.Add(dataRow);
                dataRow["Identity"] = dictionary2["Identity"];
                dataRow["CalcualtedMountStatus"] = dictionary2["CalcualtedMountStatus"];
                dataRow["CalcualtedMounted"]     = dictionary2["CalcualtedMounted"];
                dataRow["CalcualtedBadCopies"]   = dictionary2["CalcualtedBadCopies"];
            }
            dataTable.EndLoadData();
            return(new RunResult());
        }
コード例 #14
0
        public PowerShellResults Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            DDIHelper.Trace("Executing workflow: {0} {1}", new object[]
            {
                base.GetType().Name,
                this.Name
            });
            this.Initialize(input, dataTable);
            List <PowerShellResults> list = new List <PowerShellResults>();

            this.activitiesExecutedCount = 0;
            bool forGetListProgress = DDIHelper.ForGetListProgress;

            foreach (Activity activity in this.Activities)
            {
                if (activity.IsRunnable(input, dataTable, store))
                {
                    this.currentExecutingActivity = activity;
                    if (!forGetListProgress && this.AsyncRunning)
                    {
                        foreach (Activity activity2 in activity.Find((Activity x) => x is CmdletActivity))
                        {
                            CmdletActivity cmdletActivity = (CmdletActivity)activity2;
                            cmdletActivity.PSProgressChanged += this.Activity_ProgressChanged;
                        }
                    }
                    RunResult runResult = activity.RunCore(input, dataTable, store, codeBehind, updateTableDelegate);
                    list.AddRange(activity.GetStatusReport(input, dataTable, store));
                    if (runResult.ErrorOccur && activity.ErrorBehavior == ErrorBehavior.Stop)
                    {
                        break;
                    }
                }
                this.activitiesExecutedCount++;
            }
            PowerShellResults powerShellResults = forGetListProgress ? new PowerShellResults <JsonDictionary <object> >() : new PowerShellResults();

            foreach (PowerShellResults powerShellResults2 in list)
            {
                powerShellResults.MergeErrors(powerShellResults2);
                if (forGetListProgress)
                {
                    ((PowerShellResults <JsonDictionary <object> >)powerShellResults).MergeProgressData <PSObject>(powerShellResults2 as PowerShellResults <PSObject>);
                }
            }
            return(powerShellResults);
        }
コード例 #15
0
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            RunResult runResult = new RunResult();
            PowerShellResults <PSObject> powerShellResults;

            this.ExecuteCmdlet(null, runResult, out powerShellResults, false);
            return(runResult);
        }
コード例 #16
0
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            RunResult result = new RunResult();

            if (this.CheckCondition(input, dataTable) && this.Then.IsRunnable(input, dataTable, store))
            {
                this.currentExecutingActivity = this.Then;
                result = this.Then.RunCore(input, dataTable, store, codeBehind, updateTableDelegate);
            }
            else if (this.Else != null && this.Else.IsRunnable(input, dataTable, store))
            {
                this.currentExecutingActivity = this.Else;
                result = this.Else.RunCore(input, dataTable, store, codeBehind, updateTableDelegate);
            }
            this.currentExecutingActivity = null;
            return(result);
        }
コード例 #17
0
ファイル: Sequence.cs プロジェクト: YHZX2013/exchange_diff
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            RunResult runResult = new RunResult();

            this.activitiesExecutedCount = 0;
            foreach (Activity activity in this.Body)
            {
                if (activity.IsRunnable(input, dataTable, store))
                {
                    this.CurrentExecutingActivity = activity;
                    RunResult runResult2 = activity.RunCore(input, dataTable, store, codeBehind, updateTableDelegate);
                    this.statusReport = this.statusReport.Concat(activity.GetStatusReport(input, dataTable, store)).ToArray <PowerShellResults>();
                    runResult.DataObjectes.AddRange(runResult2.DataObjectes);
                    if (runResult2.ErrorOccur && base.ErrorBehavior == ErrorBehavior.Stop && activity.ErrorBehavior == ErrorBehavior.Stop)
                    {
                        runResult.ErrorOccur = true;
                        break;
                    }
                }
                this.activitiesExecutedCount++;
            }
            this.CurrentExecutingActivity = null;
            return(runResult);
        }
コード例 #18
0
        public override RunResult Run(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind, Workflow.UpdateTableDelegate updateTableDelegate)
        {
            RunResult runResult = new RunResult();
            PowerShellResults <PSObject> powerShellResults;

            base.ExecuteCmdlet(null, runResult, out powerShellResults, false);
            if (!runResult.ErrorOccur && powerShellResults.Output != null && null != codeBehind && !string.IsNullOrEmpty(this.RawResultAction) && !string.IsNullOrEmpty(base.DataObjectName))
            {
                store.UpdateDataObject(base.DataObjectName, powerShellResults);
                DDIHelper.Trace("RawResultAction: " + this.RawResultAction);
                codeBehind.GetMethod(this.RawResultAction).Invoke(null, new object[]
                {
                    input,
                    dataTable,
                    store
                });
            }
            return(runResult);
        }