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);
        }
Beispiel #2
0
        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);
        }
Beispiel #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];
            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);
        }
        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);
        }
        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());
        }