Exemplo n.º 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);
        }
Exemplo n.º 2
0
 public static void CalculateAll(DataTable table)
 {
     foreach (object obj in table.Rows)
     {
         DataRow dataRow = (DataRow)obj;
         ColumnValueCalculator.CalculateAll(dataRow);
     }
 }
Exemplo n.º 3
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);
        }