Esempio n. 1
0
 internal static void Trace <T>(TraceType traceType, T obj)
 {
     if (obj != null && DDIHelper.HasTraceEnabled(traceType))
     {
         DDIHelper.Trace(traceType, EcpTraceHelper.GetTraceString(obj));
     }
 }
Esempio n. 2
0
        internal void ExecuteCmdlet(IEnumerable pipelineInput, RunResult runResult, out PowerShellResults <PSObject> result, bool isGetListAsync = false)
        {
            DDIHelper.Trace(TraceType.InfoTrace, "Executing :" + base.GetType().Name);
            DDIHelper.Trace(TraceType.InfoTrace, "Task: {0}", new object[]
            {
                this.Command
            });
            DDIHelper.Trace(TraceType.InfoTrace, "Pipeline: {0}", new object[]
            {
                pipelineInput
            });
            WebServiceParameters parameters = null;

            if (this.AllowExceuteThruHttpGetRequest)
            {
                parameters = CmdletActivity.allowExceuteThruHttpGetRequestParameters;
            }
            result = this.Command.Invoke <PSObject>(DataSourceService.UserRunspaces, pipelineInput, parameters, this, isGetListAsync);
            if (this.DisableLogging)
            {
                result.CmdletLogInfo = null;
            }
            this.StatusReport    = result;
            runResult.ErrorOccur = !this.StatusReport.Succeeded;
        }
Esempio n. 3
0
        public sealed override bool IsRunnable(DataRow input, DataTable dataTable, DataObjectStore store)
        {
            if (AsyncServiceManager.IsCurrentWorkCancelled())
            {
                return(false);
            }
            List <Parameter> parametersToInvoke = this.GetParametersToInvoke(input, dataTable, store);
            bool             flag = this.IsToExecuteCmdlet(input, dataTable, store, parametersToInvoke);

            if (!flag)
            {
                return(false);
            }
            List <string> parameters = (from x in parametersToInvoke
                                        select x.Name).ToList <string>();
            string cmdletRbacString = this.GetCmdletRbacString(store, parameters);
            bool   flag2            = base.RbacChecker.IsInRole(cmdletRbacString);

            DDIHelper.Trace("Checking RBAC: {0} : {1}", new object[]
            {
                cmdletRbacString,
                flag2
            });
            if (!flag2)
            {
                throw new CmdletAccessDeniedException(Strings.AccessDeniedMessage);
            }
            return(true);
        }
        protected override PowerShellResults <JsonDictionary <object> > ExecuteCore(Workflow workflow)
        {
            PowerShellResults <JsonDictionary <object> > powerShellResults = new PowerShellResults <JsonDictionary <object> >();
            PowerShellResults powerShellResults2 = workflow.Run(base.Input, base.Table, base.DataObjectStore, base.ProfileBuilder.Class, delegate(string result, bool fillAllColumns)
            {
            });

            powerShellResults.MergeErrors(powerShellResults2);
            powerShellResults.MergeProgressData <JsonDictionary <object> >(powerShellResults2 as PowerShellResults <JsonDictionary <object> >);
            if (powerShellResults.ErrorRecords.Length == 0)
            {
                using (EcpPerformanceData.DDITypeConversion.StartRequestTimer())
                {
                    Dictionary <string, object>     dictionary = null;
                    List <JsonDictionary <object> > list       = new List <JsonDictionary <object> >();
                    IList <string> outputList = base.GetOutputVariables(base.OutputVariableWorkflow);
                    DataColumn[]   columns    = (from DataColumn c in base.Table.Columns
                                                 where outputList == null || outputList.Contains(c.ColumnName, StringComparer.OrdinalIgnoreCase)
                                                 select c).ToArray <DataColumn>();
                    foreach (object obj in base.Table.DefaultView)
                    {
                        DataRowView dataRowView = (DataRowView)obj;
                        base.ExtractDataRow(dataRowView.Row, columns, out dictionary);
                        list.Add(dictionary);
                    }
                    this.AddSortDataToResult(powerShellResults, list, outputList);
                    if (this.sortOptions != null && outputList.Contains(this.sortOptions.PropertyName))
                    {
                        Func <JsonDictionary <object>[], JsonDictionary <object>[]> ddisortFunction = this.sortOptions.GetDDISortFunction();
                        powerShellResults.Output = ddisortFunction(list.ToArray());
                    }
                    else
                    {
                        powerShellResults.Output = list.ToArray();
                    }
                    GetListWorkflow getListWorkflow = workflow as GetListWorkflow;
                    if (getListWorkflow != null)
                    {
                        int resultSizeInt = getListWorkflow.GetResultSizeInt32(base.Input, base.Table);
                        if (resultSizeInt > 0 && resultSizeInt < list.Count)
                        {
                            powerShellResults.Output = powerShellResults.Output.Take(resultSizeInt).ToArray <JsonDictionary <object> >();
                            if (!powerShellResults.Warnings.Contains(Strings.WarningMoreResultsAvailable))
                            {
                                powerShellResults.Warnings = powerShellResults.Warnings.Concat(new string[]
                                {
                                    Strings.WarningMoreResultsAvailable
                                }).ToArray <string>();
                            }
                        }
                    }
                }
            }
            DDIHelper.Trace(TraceType.InfoTrace, "Result: ");
            DDIHelper.Trace <PowerShellResults <JsonDictionary <object> > >(TraceType.InfoTrace, powerShellResults);
            return(powerShellResults);
        }
 public override void CalculateProgressImpl(ProgressReportEventArgs e)
 {
     DDIHelper.Trace("In CalculateProgress: " + e.Percent);
     base.ProgressRecord.Percent = e.Percent;
     base.ProgressRecord.Status  = e.Status;
     if (e.Errors != null)
     {
         base.ProgressRecord.Errors = ((base.ProgressRecord.Errors == null) ? e.Errors.ToArray <ErrorRecord>() : base.ProgressRecord.Errors.Concat(e.Errors.ToArray <ErrorRecord>() ?? new ErrorRecord[0]).ToArray <ErrorRecord>());
     }
 }
Esempio n. 6
0
        public virtual void InputValue(string columnName, object value)
        {
            Variable variable = base.Table.Columns[columnName].ExtendedProperties["Variable"] as Variable;

            if (variable != null && variable.InputConverter != null && variable.InputConverter.CanConvert(value))
            {
                value = variable.InputConverter.Convert(value);
            }
            DDIHelper.Trace("      Initial value: " + EcpTraceExtensions.FormatParameterValue(value) + ", Column: " + columnName);
            base.Input[columnName] = value;
        }
Esempio n. 7
0
        private static void SetDate(DataRow row, List <string> modifiedColumns, string propertyName, string dateString)
        {
            ExDateTime?utcExDateTime = DiscoveryHoldPropertiesHelper.GetUtcExDateTime(dateString);

            if (utcExDateTime != null)
            {
                row[propertyName] = utcExDateTime.Value.ToUtc();
                modifiedColumns.Add(propertyName);
                return;
            }
            DDIHelper.Trace(string.Format("{0} was not set because an expected date {1} resulted in null.", propertyName, dateString));
        }
Esempio n. 8
0
 internal void DoPreRun(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind)
 {
     if (null != codeBehind && !string.IsNullOrEmpty(this.PreAction))
     {
         DDIHelper.Trace("PreAction: " + this.PreAction);
         codeBehind.GetMethod(this.PreAction).Invoke(null, new object[]
         {
             input,
             dataTable,
             store
         });
     }
     this.DoPreRunCore(input, dataTable, store, codeBehind);
 }
Esempio n. 9
0
 internal static void Trace(TraceType traceType, string formatString, params object[] args)
 {
     if (formatString != null && DDIHelper.HasTraceEnabled(traceType))
     {
         List <string> list = new List <string>();
         if (args != null)
         {
             foreach (object obj in args)
             {
                 list.Add((obj == null) ? string.Empty : EcpTraceHelper.GetTraceString(obj));
             }
         }
         DDIHelper.Trace(traceType, string.Format(formatString, list.ToArray()));
     }
 }
Esempio n. 10
0
        public static void MigrationReportPostAction(DataRow inputrow, DataTable dataTable, DataObjectStore store)
        {
            if (dataTable.Rows.Count == 0)
            {
                return;
            }
            DataRow dataRow = dataTable.Rows[0];

            dataRow["ShowError"]         = false;
            dataRow["ProblemsMigrating"] = true;
            try
            {
                string    text                = dataRow["Report"].ToStringWithNull();
                XDocument xdocument           = XDocument.Parse(text);
                IEnumerable <XElement> source = from y in xdocument.Descendants("Step")
                                                select y;
                DateTime dateTime  = Convert.ToDateTime(source.First <XElement>().Attribute("StartTime").Value.ToString());
                DateTime dateTime2 = Convert.ToDateTime(source.Last <XElement>().Attribute("EndTime").Value.ToString());
                dataRow["StartedOn"]   = dateTime.ToString("g");
                dataRow["CompletedOn"] = dateTime2.ToString("g");
                IEnumerable <XElement> source2 = from x in xdocument.Descendants("Step")
                                                 where Convert.ToInt32(x.Attribute("ToState").Value) >= 100
                                                 select x;
                IEnumerable <FFOMigrationStatusService.MigrationStep> enumerable = from e in source2.Elements("Prop")
                                                                                   where e.Attribute("PropID").Value == "10003"
                                                                                   select new FFOMigrationStatusService.MigrationStep(e.Parent.Attribute("StepName").Value, e.Parent.Attribute("ToState").Value, e.Attribute("Value").Value);
                if (enumerable.Count <FFOMigrationStatusService.MigrationStep>() >= 1)
                {
                    FFOMigrationStatusService.PopulateStepErrors(enumerable, dataRow, "SpamQuarantineMigrationStep", "SpamQuarantineGroupData", "SpamQuarantineGroupVisible");
                    FFOMigrationStatusService.PopulateStepErrors(enumerable, dataRow, "AntispamMigrationStep", "AntispamGroupData", "AntispamGroupVisible");
                    FFOMigrationStatusService.PopulateStepErrors(enumerable, dataRow, "AntimalwareMigrationStep", "AntimalwareGroupData", "AntimalwareGroupVisible");
                    FFOMigrationStatusService.PopulateStepErrors(enumerable, dataRow, "PolicyMigrationStep", "PolicyRulesGroupData", "PolicyRulesGroupVisible");
                    FFOMigrationStatusService.PopulateStepErrors(enumerable, dataRow, "ConnectorMigrationStep", "ConnectorGroupData", "ConnectorGroupVisible");
                }
                else
                {
                    dataRow["ProblemsMigrating"] = false;
                }
            }
            catch (Exception exception)
            {
                dataRow["ShowError"] = true;
                DDIHelper.Trace("Error processing Migration Report: {0}", new object[]
                {
                    exception.GetTraceFormatter()
                });
            }
        }
Esempio n. 11
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);
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
 private static object TryStrongTypeConversion(object obj)
 {
     if (!DDIHelper.IsSkippingStrongTypeConversion(obj))
     {
         Type type  = obj.GetType();
         Type type2 = null;
         if (DDIHelper.StrongTypeToStringList.Contains(type))
         {
             obj = obj.ToString();
         }
         else if (type == typeof(MultiValuedProperty <string>))
         {
             obj = ((MultiValuedProperty <string>)obj).ToArray();
         }
         else if (!DDIHelper.strongType2DataContractMapping.TryGetValue(type, out type2))
         {
             foreach (KeyValuePair <Type, Type> keyValuePair in DDIHelper.strongType2DataContractMapping)
             {
                 if (keyValuePair.Key.IsAssignableFrom(type))
                 {
                     type2 = keyValuePair.Value;
                     break;
                 }
             }
         }
         if (type2 == null && (type.IsEnum || typeof(Uri).IsAssignableFrom(type)))
         {
             obj = obj.ToString();
         }
         else if (type2 != null && type2 != null)
         {
             DDIHelper.Trace("Object: {0} of Type '{1}' is converted to '{2}'.", new object[]
             {
                 obj,
                 type,
                 type2
             });
             obj = Activator.CreateInstance(type2, new object[]
             {
                 obj
             });
         }
     }
     return(obj);
 }
Esempio n. 14
0
        private bool IsWorkflowDefined(string workflowName)
        {
            DDIHelper.Trace("IsWorkflowDefined: Schema:{0} WorkflowName:{1}", new object[]
            {
                this.schema,
                workflowName
            });
            bool flag = (from c in ServiceManager.GetInstance().GetService(this.schemaFilesInstallPath, this.schema).Workflows
                         where c.Name.Equals(workflowName, StringComparison.InvariantCultureIgnoreCase)
                         select c).Count <Workflow>() > 0;

            DDIHelper.Trace("IsWorkflowDefined({0}) returning {1}", new object[]
            {
                workflowName,
                flag
            });
            return(flag);
        }
Esempio n. 15
0
 internal void DoPostRun(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind)
 {
     if (null != codeBehind && !string.IsNullOrEmpty(this.PostAction))
     {
         DDIHelper.Trace("PostAction: " + this.PostAction);
         MethodInfo method = codeBehind.GetMethod(this.PostAction, new Type[]
         {
             typeof(DataRow),
             typeof(DataTable),
             typeof(DataObjectStore)
         });
         if (method != null)
         {
             method.Invoke(null, new object[]
             {
                 input,
                 dataTable,
                 store
             });
         }
         else
         {
             method = codeBehind.GetMethod(this.PostAction, new Type[]
             {
                 typeof(DataRow),
                 typeof(DataTable),
                 typeof(DataObjectStore),
                 typeof(PowerShellResults[])
             });
             if (!(method != null))
             {
                 throw new NotImplementedException("The specified method " + this.PostAction + " should implement one of the two signatures: (DataRow, DataTable, DataObjectStore) or (DataRow, DataTable, DataObjectStore, PowerShellResults[]) .");
             }
             method.Invoke(null, new object[]
             {
                 input,
                 dataTable,
                 store,
                 this.GetStatusReport(input, dataTable, store)
             });
         }
     }
     this.DoPostRunCore(input, dataTable, store, codeBehind);
 }
Esempio n. 16
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);
        }
Esempio n. 17
0
        protected virtual bool CheckPermission(DataObjectStore store, List <string> parameters, Variable variable)
        {
            string name = this.DataObjectName;

            if (variable != null)
            {
                name = (variable.RbacDataObjectName ?? this.DataObjectName);
            }
            string     cmdletRbacString = this.GetCmdletRbacString(store, parameters);
            ADRawEntry adrawEntry       = store.IsDataObjectDummy(name) ? null : (store.GetDataObject(name) as ADRawEntry);
            bool       flag             = base.RbacChecker.IsInRole(cmdletRbacString, adrawEntry);

            DDIHelper.Trace("Checking {0} on object {1}: {2}", new object[]
            {
                cmdletRbacString,
                (adrawEntry != null) ? adrawEntry.ToString() : string.Empty,
                flag
            });
            return(flag);
        }
Esempio n. 18
0
 protected override void DoPreRunCore(DataRow input, DataTable dataTable, DataObjectStore store, Type codeBehind)
 {
     if (!this.SingletonObject)
     {
         DDIHelper.Trace("Map identity parameter : {0} - {1}", new object[]
         {
             base.IdentityName,
             base.IdentityVariable
         });
         Parameter item = new Parameter
         {
             Name      = base.IdentityName,
             Reference = base.IdentityVariable,
             Type      = ParameterType.Mandatory
         };
         if (!base.Parameters.Contains(item))
         {
             base.Parameters.Add(item);
         }
     }
     base.DoPreRunCore(input, dataTable, store, codeBehind);
 }
Esempio n. 19
0
        public Service GetService(string schemaFilesInstallPath, string schemaName)
        {
            string text = schemaName.ToLowerInvariant();

            if (!this.dic.ContainsKey(text))
            {
                lock (ServiceManager.synchronizationObject)
                {
                    if (!this.dic.ContainsKey(text))
                    {
                        string[] files = Directory.GetFiles(schemaFilesInstallPath);
                        files.Perform(delegate(string c)
                        {
                            this.dic[Path.GetFileNameWithoutExtension(c).ToLowerInvariant()] = null;
                        });
                        if (!this.dic.ContainsKey(text))
                        {
                            DDIHelper.Trace("Requested workflow {0} not defined", new object[]
                            {
                                text
                            });
                            throw new SchemaNotExistException(text);
                        }
                    }
                }
            }
            if (this.dic[text] != null)
            {
                return(this.dic[text].Clone() as Service);
            }
            lock (ServiceManager.synchronizationObject)
            {
                if (this.dic[text] == null)
                {
                    this.dic[text] = ServiceManager.BuildService(schemaFilesInstallPath, text);
                }
            }
            return(this.dic[text].Clone() as Service);
        }
        public static string GetMatchedUserFilter(object disp, object legDN)
        {
            string text  = disp as string;
            string text2 = legDN as string;
            string text3 = null;

            if (text2 != null && text2.Length != 0)
            {
                int num = text2.ToUpperInvariant().LastIndexOf("/CN=");
                if (num != -1)
                {
                    text3 = text2.Substring(num + "/CN=".Length);
                }
            }
            string text4 = (text == null || text.Length == 0) ? null : string.Format("DisplayName -eq '{0}' -or SamAccountName -eq '{0}'", text.Replace("'", "''"));
            string text5 = (text3 == null || text3.Length == 0) ? null : string.Format("DisplayName -eq '{0}' -or SamAccountName -eq '{0}'", text3.Replace("'", "''"));

            if (text4 == null && text5 == null)
            {
                DDIHelper.Trace("Invalid argument: disp or legDN can not be both null");
                throw new ArgumentOutOfRangeException("argument disp or legDN can not be both null");
            }
            string str;

            if (text4 == null)
            {
                str = text5;
            }
            else if (text5 == null)
            {
                str = text4;
            }
            else
            {
                str = text4 + " -or " + text5;
            }
            return("(" + str + ") -and (RecipientTypeDetails -eq 'User' -or RecipientTypeDetails -eq 'DisabledUser')");
        }
Esempio n. 21
0
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            object result = null;

            if (!string.IsNullOrEmpty(this.target))
            {
                string[] array = this.target.Split(new char[]
                {
                    '.'
                });
                if (array.Length == 2)
                {
                    string typeName = "Microsoft.Exchange.Management.DDIService." + array[0];
                    string name     = array[1];
                    Type   type     = Type.GetType(typeName, false);
                    if (type != null)
                    {
                        FieldInfo field = type.GetField(name, BindingFlags.Static | BindingFlags.Public);
                        result = field.GetValue(null);
                    }
                    DDIHelper.Trace("InvokeExtension invoked: {0}.", new object[]
                    {
                        this.target
                    });
                }
                else
                {
                    DDIHelper.Trace("InvokeExtension parse failed: {0}. The invoke target should be in 'Type.Method' format. Default namespace is {1} Update InvokeExtension if want to use type inother namespace.", new object[]
                    {
                        this.target,
                        "Microsoft.Exchange.Management.DDIService."
                    });
                }
            }
            return(result);
        }
Esempio n. 22
0
        internal static string GetCreatedByUserDisplayName(string rawName)
        {
            string result = string.Empty;

            if (!string.IsNullOrEmpty(rawName))
            {
                result = rawName;
                int num = rawName.IndexOf("\\");
                if (num > -1 && num < rawName.Length - 1)
                {
                    result = rawName.Substring(num + 1);
                }
                else
                {
                    try
                    {
                        SecurityIdentifier           sid = new SecurityIdentifier(rawName);
                        SecurityPrincipalIdParameter securityPrincipalIdParameter = new SecurityPrincipalIdParameter(sid);
                        IEnumerable <SecurityPrincipalIdParameter> sidPrincipalId = new SecurityPrincipalIdParameter[]
                        {
                            securityPrincipalIdParameter
                        }.AsEnumerable <SecurityPrincipalIdParameter>();
                        List <AcePermissionRecipientRow> list = RecipientObjectResolver.Instance.ResolveSecurityPrincipalId(sidPrincipalId).ToList <AcePermissionRecipientRow>();
                        if (list.Count > 0)
                        {
                            result = list[0].DisplayName;
                        }
                    }
                    catch (ArgumentException ex)
                    {
                        DDIHelper.Trace("Created by value is not a valid SID: " + ex.Message);
                    }
                }
            }
            return(result);
        }
Esempio n. 23
0
        public static string GetCountryDisplayName(string locale)
        {
            if (string.IsNullOrEmpty(locale))
            {
                return(string.Empty);
            }
            string result;

            try
            {
                LanguageList languageList = new LanguageList();
                result = RtlUtil.ConvertToDecodedBidiString(languageList.GetDisplayValue(locale), RtlUtil.IsRtl);
            }
            catch (Exception exception)
            {
                DDIHelper.Trace("Failed to locate locale {0}, Error: {1}", new object[]
                {
                    locale,
                    exception.GetTraceFormatter()
                });
                result = locale;
            }
            return(result);
        }
Esempio n. 24
0
 private void Table_ColumnChanged(object sender, DataColumnChangeEventArgs e)
 {
     DDIHelper.Trace("      New value: " + EcpTraceExtensions.FormatParameterValue(base.Row[e.Column]) + ", Variable: " + e.Column.ColumnName);
 }
Esempio n. 25
0
 internal static void Trace(string formatString, params object[] args)
 {
     DDIHelper.Trace(TraceType.DebugTrace, formatString, args);
 }
Esempio n. 26
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);
        }
Esempio n. 27
0
 internal static void Trace <T>(T obj)
 {
     DDIHelper.Trace <T>(TraceType.DebugTrace, obj);
 }
Esempio n. 28
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);
        }
Esempio n. 29
0
 internal static void Trace(string msg)
 {
     DDIHelper.Trace(TraceType.DebugTrace, msg);
 }
Esempio n. 30
0
 public AutomatedDataHandlerBase(string schemaFilesInstallPath, string schema) : this(AutomatedDataHandlerBase.BuildProfile(schemaFilesInstallPath, schema))
 {
     DDIHelper.Trace("Schema: " + schema);
     this.Table.TableName = schema;
 }