Beispiel #1
0
        private void ReportDataTable(int rowCount, int expectedRowCount, DataTable dataTable, RefreshRequestEventArgs e, bool resolved, TimeSpan elapsed)
        {
            ResultsLoaderProfile resultsLoaderProfile = e.Argument as ResultsLoaderProfile;

            this.FillColumnsBasedOnLambdaExpression(dataTable, resultsLoaderProfile);
            ColumnValueCalculator.CalculateAll(dataTable);
            DataTable dataTable2 = this.MoveRows(dataTable, null, false);

            if (resultsLoaderProfile != null && resolved && resultsLoaderProfile.IsResolving)
            {
                foreach (object obj in resultsLoaderProfile.PipelineObjects)
                {
                    if (this.FindRowByIdentity(dataTable2, obj) != null)
                    {
                        resultsLoaderProfile.ResolvedObjects.Add(obj);
                    }
                }
            }
            ExTraceGlobals.ProgramFlowTracer.TraceFunction((long)this.GetHashCode(), "-->DataTableLoader.ReportDataTable: report batch: {0}. progressReportTable.Rows.Count:{1}, this.BatchSize:{2}, rowCount:{3}, expectedRowCount:{4}. ElapsedTime:{5}", new object[]
            {
                this,
                dataTable2.Rows.Count,
                this.BatchSize,
                rowCount,
                expectedRowCount,
                elapsed
            });
            if (!e.ReportedProgress)
            {
                ExTraceGlobals.ProgramFlowTracer.TracePerformance <DataTableLoader, string, string>(0L, "Time:{1}. {2} First batch data arrived in worker thread. {0}", this, ExDateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff"), (this != null) ? this.Table.TableName : string.Empty);
            }
            e.ReportProgress(rowCount, expectedRowCount, this.ProgressText, dataTable2);
            ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader>((long)this.GetHashCode(), "<--DataTableLoader.ReportDataTable: report batch: {0}", this);
        }
Beispiel #2
0
 protected virtual bool TryToGetPartialRefreshArgument(object[] ids, out object partialRefreshArgument)
 {
     partialRefreshArgument = null;
     if (ids != null)
     {
         if (this.ResultsLoaderProfile != null)
         {
             ResultsLoaderProfile resultsLoaderProfile = null;
             if (1 != ids.Length || this.ResultsLoaderProfile.InputTable.Columns.Contains("Identity"))
             {
                 resultsLoaderProfile = (this.ResultsLoaderProfile.Clone() as ResultsLoaderProfile);
                 resultsLoaderProfile.TryInputValue("IsFullRefresh", false);
                 if (1 == ids.Length)
                 {
                     resultsLoaderProfile.InputValue("Identity", ids[0]);
                 }
                 else if (this.ResultsLoaderProfile.InputTable.Columns.Contains("IdentityList"))
                 {
                     resultsLoaderProfile.InputValue("IdentityList", ids);
                 }
                 else
                 {
                     resultsLoaderProfile.PipelineObjects = ids;
                 }
             }
             partialRefreshArgument = resultsLoaderProfile;
         }
         else
         {
             partialRefreshArgument = ids;
         }
     }
     return(null != partialRefreshArgument);
 }
Beispiel #3
0
        protected override void DoPostRefreshAction(RefreshRequestEventArgs refreshRequest)
        {
            ResultsLoaderProfile resultsLoaderProfile = refreshRequest.Argument as ResultsLoaderProfile;

            if (resultsLoaderProfile != null && resultsLoaderProfile.PostRefreshAction != null)
            {
                resultsLoaderProfile.PostRefreshAction.DoPostRefreshAction(this, refreshRequest);
            }
        }
Beispiel #4
0
 private void FillPrimaryKeysBasedOnLambdaExpression(DataRow dataRow, ResultsLoaderProfile profile)
 {
     ConvertTypeCalculator.Convert(dataRow);
     if (profile == null)
     {
         return;
     }
     foreach (DataColumn dataColumn in dataRow.Table.PrimaryKey)
     {
         IList <KeyValuePair <string, object> > list = this.GetExpressionCalculator().CalculateSpecifiedColumn(dataColumn.ColumnName, dataRow, profile.InputTable.Rows[0]);
         foreach (KeyValuePair <string, object> keyValuePair in list)
         {
             dataRow[keyValuePair.Key] = keyValuePair.Value;
         }
     }
 }
Beispiel #5
0
 private void FillColumnsBasedOnLambdaExpression(DataTable dataTable, ResultsLoaderProfile profile)
 {
     if (profile == null)
     {
         return;
     }
     foreach (object obj in dataTable.Rows)
     {
         DataRow dataRow = (DataRow)obj;
         IList <KeyValuePair <string, object> > list = this.GetExpressionCalculator().CalculateAll(dataRow, profile.InputTable.Rows[0]);
         foreach (KeyValuePair <string, object> keyValuePair in list)
         {
             dataRow[keyValuePair.Key] = keyValuePair.Value;
         }
     }
 }
Beispiel #6
0
 protected virtual void RemoveExistingRows(RefreshProgressChangedEventArgs e)
 {
     if (e.IsFirstProgressReport)
     {
         ResultsLoaderProfile resultsLoaderProfile = e.RequestArgument as ResultsLoaderProfile;
         if (resultsLoaderProfile != null && resultsLoaderProfile.LoadableFromProfilePredicate != null)
         {
             for (int i = this.Table.Rows.Count - 1; i >= 0; i--)
             {
                 DataRow row = this.Table.Rows[i];
                 if (resultsLoaderProfile.IsLoadable(row))
                 {
                     this.Table.Rows.Remove(row);
                 }
             }
             return;
         }
         if (e.IsFullRefresh)
         {
             ExTraceGlobals.ProgramFlowTracer.TraceDebug <DataTableLoader>((long)this.GetHashCode(), "DataTableLoader.OnProgressChanged: clearing table as this is the first progress report of this refresh. {0}", this);
             this.Table.Clear();
             return;
         }
         PartialRefreshRequestEventArgs partialRefreshRequestEventArgs = e.Request as PartialRefreshRequestEventArgs;
         if (partialRefreshRequestEventArgs != null)
         {
             DataTable dataTable = (DataTable)e.UserState;
             foreach (object identity in partialRefreshRequestEventArgs.Identities)
             {
                 if (this.FindRowByIdentity(dataTable, identity) == null)
                 {
                     DataRow dataRow = this.FindRowByIdentity(this.Table, identity);
                     if (dataRow != null)
                     {
                         this.Table.Rows.Remove(dataRow);
                     }
                 }
             }
         }
     }
 }
Beispiel #7
0
        private void Cancel(RefreshRequestEventArgs e)
        {
            ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader>((long)this.GetHashCode(), "-->DataTableLoader.Cancel: {0}", this);
            IDbCommand dbCommand = e.Argument as IDbCommand;

            if (dbCommand != null)
            {
                ExTraceGlobals.ProgramFlowTracer.TraceDebug <DataTableLoader, IDbCommand>((long)this.GetHashCode(), "DataTableLoader.Cancel: {0} cancelling IDbCommand: {1}", this, dbCommand);
                dbCommand.Cancel();
            }
            ResultsLoaderProfile resultsLoaderProfile = e.Argument as ResultsLoaderProfile;

            if (resultsLoaderProfile != null)
            {
                foreach (AbstractDataTableFiller abstractDataTableFiller in resultsLoaderProfile.TableFillers)
                {
                    abstractDataTableFiller.Cancel();
                }
            }
            this.OnCancelFill(e);
            ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader>((long)this.GetHashCode(), "<--DataTableLoader.Cancel: {0}", this);
        }
        private ResultsLoaderProfile CloneInternal(bool shareInputTable)
        {
            ResultsLoaderProfile resultsLoaderProfile = new ResultsLoaderProfile(new UIPresentationProfile(this.DisplayedColumnCollection), shareInputTable ? this.inputTable : this.inputTable.Copy(), this.dataTable);

            resultsLoaderProfile.Name                         = this.Name;
            resultsLoaderProfile.DisplayName                  = this.DisplayName;
            resultsLoaderProfile.HideIcon                     = this.HideIcon;
            resultsLoaderProfile.ImageProperty                = this.ImageProperty;
            resultsLoaderProfile.SearchText                   = this.searchText;
            resultsLoaderProfile.PipelineObjects              = this.PipelineObjects;
            resultsLoaderProfile.ScopeSupportingLevel         = this.ScopeSupportingLevel;
            resultsLoaderProfile.Scope                        = this.Scope;
            resultsLoaderProfile.UseTreeViewForm              = this.UseTreeViewForm;
            resultsLoaderProfile.IsResolving                  = this.IsResolving;
            resultsLoaderProfile.ResolveProperty              = this.ResolveProperty;
            resultsLoaderProfile.WholeObjectProperty          = this.WholeObjectProperty;
            resultsLoaderProfile.NameProperty                 = this.NameProperty;
            resultsLoaderProfile.LoadableFromProfilePredicate = this.LoadableFromProfilePredicate;
            resultsLoaderProfile.PostRefreshAction            = this.PostRefreshAction;
            resultsLoaderProfile.SerializationLevel           = this.SerializationLevel;
            resultsLoaderProfile.MultiSelect                  = this.MultiSelect;
            resultsLoaderProfile.FillType                     = this.FillType;
            foreach (AbstractDataTableFiller abstractDataTableFiller in this.TableFillers)
            {
                resultsLoaderProfile.AddTableFiller(abstractDataTableFiller.Clone() as AbstractDataTableFiller, this.GetRunnableLambdaExpression(abstractDataTableFiller));
            }
            resultsLoaderProfile.BatchSize       = this.BatchSize;
            resultsLoaderProfile.CommandsProfile = new ResultCommandsProfile();
            resultsLoaderProfile.CommandsProfile.ResultPaneCommands.AddRange(this.CommandsProfile.ResultPaneCommands);
            resultsLoaderProfile.CommandsProfile.CustomSelectionCommands.AddRange(this.CommandsProfile.CustomSelectionCommands);
            resultsLoaderProfile.CommandsProfile.DeleteSelectionCommands.AddRange(this.CommandsProfile.DeleteSelectionCommands);
            resultsLoaderProfile.CommandsProfile.ShowSelectionPropertiesCommands.AddRange(this.CommandsProfile.ShowSelectionPropertiesCommands);
            resultsLoaderProfile.AutoGenerateColumns   = this.AutoGenerateColumns;
            resultsLoaderProfile.DataColumnsCalculator = this.DataColumnsCalculator;
            resultsLoaderProfile.DistinguishIdentity   = this.DistinguishIdentity;
            return(resultsLoaderProfile);
        }
Beispiel #9
0
        private void Fill(RefreshRequestEventArgs e)
        {
            ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader>((long)this.GetHashCode(), "-->DataTableLoader.Fill: {0}", this);
            ResultsLoaderProfile profile = e.Argument as ResultsLoaderProfile;

            if (profile != null)
            {
                DataTable dataTable = e.Result as DataTable;
                dataTable.RowChanged += delegate(object sender, DataRowChangeEventArgs eventArgs)
                {
                    if (eventArgs.Action == DataRowAction.Add)
                    {
                        this.FillPrimaryKeysBasedOnLambdaExpression(eventArgs.Row, profile);
                    }
                };
                DataTable dataTable2 = dataTable.Clone();
                dataTable2.RowChanged += delegate(object sender, DataRowChangeEventArgs eventArgs)
                {
                    if (eventArgs.Action == DataRowAction.Add)
                    {
                        this.FillPrimaryKeysBasedOnLambdaExpression(eventArgs.Row, profile);
                    }
                };
                if (!this.EnforeViewEntireForest && !profile.HasPermission())
                {
                    goto IL_26F;
                }
                using (DataAdapterExecutionContext dataAdapterExecutionContext = this.executionContextFactory.CreateExecutionContext())
                {
                    dataAdapterExecutionContext.Open(base.UIService, this.WorkUnits, this.EnforeViewEntireForest, profile);
                    foreach (AbstractDataTableFiller filler in profile.TableFillers)
                    {
                        if (profile.IsRunnable(filler))
                        {
                            if (e.CancellationPending)
                            {
                                break;
                            }
                            profile.BuildCommand(filler);
                            if (profile.FillType == 1 || this.IsPreFillForResolving(filler))
                            {
                                dataAdapterExecutionContext.Execute(filler, dataTable2, profile);
                                this.MergeChanges(dataTable2, dataTable);
                                dataTable2.Clear();
                            }
                            else
                            {
                                dataAdapterExecutionContext.Execute(filler, dataTable, profile);
                            }
                        }
                    }
                    goto IL_26F;
                }
            }
            MonadCommand monadCommand = e.Argument as MonadCommand;

            if (monadCommand != null)
            {
                this.AttachCommandToMonitorWarnings(monadCommand);
                using (MonadConnection monadConnection = new MonadConnection(PSConnectionInfoSingleton.GetInstance().GetConnectionStringForScript(), new CommandInteractionHandler(), ADServerSettingsSingleton.GetInstance().CreateRunspaceServerSettingsObject(), PSConnectionInfoSingleton.GetInstance().GetMonadConnectionInfo(ExchangeRunspaceConfigurationSettings.SerializationLevel.Full)))
                {
                    monadConnection.Open();
                    monadCommand.Connection = monadConnection;
                    using (MonadDataAdapter monadDataAdapter = new MonadDataAdapter(monadCommand))
                    {
                        DataTable dataTable3 = (DataTable)e.Result;
                        if (dataTable3.Columns.Count != 0)
                        {
                            monadDataAdapter.MissingSchemaAction  = MissingSchemaAction.Ignore;
                            monadDataAdapter.EnforceDataSetSchema = true;
                        }
                        ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader, MonadCommand>((long)this.GetHashCode(), "-->DataTableLoader.Fill: calling dataAdapter.Fill: {0}. Command:{1}", this, monadCommand);
                        monadDataAdapter.Fill(dataTable3);
                        ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader, MonadCommand>((long)this.GetHashCode(), "<--DataTableLoader.Fill: calling dataAdaptr.Fill: {0}. Command:{1}", this, monadCommand);
                    }
                }
                this.DetachCommandFromMonitorWarnings(monadCommand);
            }
IL_26F:
            this.OnFillTable(e);
            ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader>((long)this.GetHashCode(), "<--DataTableLoader.Fill: {0}", this);
        }
Beispiel #10
0
        protected override void OnDoRefreshWork(RefreshRequestEventArgs e)
        {
            Stopwatch sw = Stopwatch.StartNew();

            ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader>((long)this.GetHashCode(), "-->DataTableLoader.OnDoRefreshWork: {0}", this);
            this.expressionCalculator = null;
            DataTable dataTable = (e as DataTableLoader.IDataTableLoaderRefreshRequest).DataTable.Clone();

            e.Result = dataTable;
            dataTable.RowChanging += delegate(object param0, DataRowChangeEventArgs param1)
            {
                if (e.CancellationPending)
                {
                    e.Cancel = true;
                    this.Cancel(e);
                    e.Result = dataTable;
                }
            };
            int rowCount                 = 0;
            int expectedRowCount         = Math.Max(this.lastRowCount, this.BatchSize);
            ResultsLoaderProfile profile = e.Argument as ResultsLoaderProfile;

            if (profile != null)
            {
                foreach (AbstractDataTableFiller abstractDataTableFiller in profile.TableFillers)
                {
                    abstractDataTableFiller.FillCompleted += delegate(object sender, FillCompletedEventArgs args)
                    {
                        AbstractDataTableFiller filler = sender as AbstractDataTableFiller;
                        if (this.IsPreFillForResolving(filler) || profile.FillType == null)
                        {
                            expectedRowCount = Math.Max(expectedRowCount, rowCount + this.BatchSize + 1);
                            bool flag = !this.IsPreFillForResolving(filler) && profile.FillType == 0;
                            this.ReportDataTable(rowCount, expectedRowCount, args.DataTable, e, flag, sw.Elapsed);
                            if (profile.IsResolving && profile.PipelineObjects != null && flag)
                            {
                                foreach (object obj in profile.PipelineObjects)
                                {
                                    if (this.FindRowByIdentity(args.DataTable, obj) != null)
                                    {
                                        profile.ResolvedObjects.Add(obj);
                                    }
                                }
                                IEnumerable <object> source = from id in profile.PipelineObjects
                                                              where !profile.ResolvedObjects.Contains(id)
                                                              select id;
                                profile.PipelineObjects = source.ToArray <object>();
                                profile.ResolvedObjects.Clear();
                            }
                        }
                    };
                }
            }
            dataTable.RowChanged += delegate(object sender, DataRowChangeEventArgs rowChangedEvent)
            {
                if (rowChangedEvent.Action == DataRowAction.Add)
                {
                    rowCount++;
                    ExTraceGlobals.DataFlowTracer.Information <DataTableLoader, int, TimeSpan>((long)this.GetHashCode(), "DataTableLoader.OnDoRefreshWork: {0}, rowCount:{1}. ElapsedTime:{2}", this, rowCount, sw.Elapsed);
                    ConvertTypeCalculator.Convert(rowChangedEvent.Row);
                    if (dataTable.Rows.Count >= this.BatchSize && (profile == null || profile.FillType == null))
                    {
                        expectedRowCount = Math.Max(expectedRowCount, rowCount + this.BatchSize + 1);
                        this.ReportDataTable(rowCount, expectedRowCount, dataTable, e, true, sw.Elapsed);
                    }
                }
            };
            try
            {
                ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader, TimeSpan>((long)this.GetHashCode(), "-->DataTableLoader.OnDoRefreshWork: Fill: {0}. ElapsedTime:{1}", this, sw.Elapsed);
                this.Fill(e);
            }
            catch (MonadDataAdapterInvocationException ex)
            {
                if (!(ex.InnerException is ManagementObjectNotFoundException) && !(ex.InnerException is MapiObjectNotFoundException))
                {
                    throw;
                }
            }
            finally
            {
                ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader, TimeSpan>((long)this.GetHashCode(), "<--DataTableLoader.OnDoRefreshWork: Fill: {0}. ElapsedTime:{1}", this, sw.Elapsed);
                e.Result = dataTable;
                ExTraceGlobals.ProgramFlowTracer.TraceFunction((long)this.GetHashCode(), "-->DataTableLoader.OnDoRefreshWork: report last batch: {0}. dataTable.Rows.Count:{1}, this.BatchSize:{2}, rowCount:{3}, expectedRowCount:{4}", new object[]
                {
                    this,
                    dataTable.Rows.Count,
                    this.BatchSize,
                    rowCount,
                    rowCount + 1
                });
                this.FillColumnsBasedOnLambdaExpression(dataTable, e.Argument as ResultsLoaderProfile);
                ColumnValueCalculator.CalculateAll(dataTable);
                if (!e.ReportedProgress)
                {
                    ExTraceGlobals.ProgramFlowTracer.TracePerformance <DataTableLoader, string, string>(0L, "Time:{1}. {2} First batch data arrived in worker thread. {0}", this, ExDateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff"), (this != null) ? this.Table.TableName : string.Empty);
                }
                e.ReportProgress(rowCount, rowCount + 1, this.ProgressText, this.MoveRows(dataTable, null, false));
                ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader>((long)this.GetHashCode(), "<--DataTableLoader.OnDoRefreshWork: report last batch: {0}", this);
            }
            base.OnDoRefreshWork(e);
            e.Result = dataTable;
            ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader, TimeSpan>((long)this.GetHashCode(), "<--DataTableLoader.OnDoRefreshWork: {0}. Total ElapsedTime:{1}", this, sw.Elapsed);
        }
Beispiel #11
0
 public DataTableLoader(ResultsLoaderProfile profile)
 {
     this.expectedResultSize   = this.DefaultExpectedResultSize;
     this.ResultsLoaderProfile = profile;
 }