Пример #1
0
        protected override bool WriteInternal(IAsyncProgress2 o, object[,] values, ExternalExcelRangeInfo rangeInfo)
        {
            var writeRange = this.GetRange(rangeInfo);

            writeRange.Value2 = values;
            return(true);
        }
        protected virtual object[,] _ReadInternal(IAsyncProgress2 o, ExternalExcelRangeInfo rangeInfo)
        {
            int rows = rangeInfo.EndRow - rangeInfo.StartRow + 1;
            int cols = rangeInfo.EndColumn - rangeInfo.StartColumn + 1;

            int[] lowerBounds = new int[] { 1, 1 };
            int[] lengths     = new int[] { rows, cols };
            object[,] values = (object[, ])Array.CreateInstance(typeof(object), lengths, lowerBounds);

            int totalRows = rows;
            int row       = rangeInfo.StartRow;
            int count     = 1;

            if (o != null)
            {
                o.InitializeProgress(1, totalRows);
            }
            for (int i = values.GetLowerBound(0); i <= values.GetUpperBound(0); i++)
            {
                if (o != null && o.ExecutorService.IsShutdown)
                {
                    break;
                }

                int col = rangeInfo.StartColumn;
                for (int j = values.GetLowerBound(1); j <= values.GetUpperBound(1); j++)
                {
                    values[i, j] = this.Cell(row, col).Value;
                    if (o != null)
                    {
                        Thread.Sleep(1);
                    }
                    col++;
                }

                if (o != null)
                {
                    int proPerc = (int)(((float)(i) / (float)totalRows) * 100.0);
                    o.UpdateStatusProgress((count), "Reading value from excel . . . : " +
                                           (count) + " of " + totalRows.ToString() +
                                           " (" + proPerc + "%)");
                }

                row++;
                count++;
                if (o != null)
                {
                    Thread.Sleep(1);
                }
            }

            return(values);
        }
Пример #3
0
        public decimal ValidateVoidVoucher(string ticketNumber, int userNo, ref int?nResult)
        {
            decimal dAmount = 0;

            try
            {
                // is tis printed ticket
                if (VoucherHelper.IsTISPrintedTicketPrefix(ticketNumber))
                {
                    // if the tis printed ticket available in local db
                    bool isTISTicketAvailable = VoucherHelper.IsTISPrintedTicket(ticketNumber);
                    if (!isTISTicketAvailable)
                    {
                        // wait worst case 10 secs to get the response from TIS
                        int    count   = 10;
                        string message = "Waiting for receiving data from TIS...";
                        WPFExtensions.ShowAsyncDialog(null, message, null, 1, count,
                                                      (o) =>
                        {
                            IAsyncProgress2 o2 = o as IAsyncProgress2;

                            // failure case - hit the tis communication interface and get the ticket
                            try
                            {
                                o2.UpdateStatusProgress(5, message);
                                VoucherHelper.SendTISRedeemTicketQuery(ticketNumber, userNo);
                                o2.UpdateStatusProgress(10, message);
                            }
                            catch (Exception ex)
                            {
                                ExceptionManager.Publish(ex);
                            }
                        });
                    }
                }

                // Success/failure case - ok proceed with voiding
                foreach (var obj in this.ValidateVoidVoucher(ticketNumber, ref nResult))
                {
                    dAmount = Convert.ToDecimal(obj.iAmount) / 100;
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }

            return(dAmount);
        }
        public bool Write(IAsyncProgress2 o, object[,] values, ExternalExcelRangeInfo rangeInfo)
        {
            ModuleProc PROC   = new ModuleProc(this.DYN_MODULE_NAME, "Write");
            bool       result = default(bool);

            try
            {
                result = this.WriteInternal(o, values, rangeInfo);
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return(result);
        }
        public object[,] Read(IAsyncProgress2 o, ExternalExcelRangeInfo rangeInfo)
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Read");

            object[,] result = default(object[, ]);

            try
            {
                result = this.ReadInternal(o, rangeInfo);
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return(result);
        }
        protected virtual bool _WriteInternal(IAsyncProgress2 o, object[,] values, ExternalExcelRangeInfo rangeInfo)
        {
            int totalRows = values.GetUpperBound(0) + 1;
            int row       = rangeInfo.StartRow;
            int count     = 1;

            if (o != null)
            {
                o.InitializeProgress(1, totalRows);
            }
            for (int i = values.GetLowerBound(0); i <= values.GetUpperBound(0); i++)
            {
                if (o != null && o.ExecutorService.IsShutdown)
                {
                    break;
                }

                int col = rangeInfo.StartColumn;
                for (int j = values.GetLowerBound(1); j <= values.GetUpperBound(1); j++)
                {
                    this.Cell(row, col).Value = values[i, j].ToString();
                    if (o != null)
                    {
                        Thread.Sleep(1);
                    }
                    col++;
                }

                if (o != null)
                {
                    int proPerc = (int)(((float)(i) / (float)totalRows) * 100.0);
                    o.UpdateStatusProgress((count), "Writing value to excel  . . . : " +
                                           (count) + " of " + totalRows.ToString() +
                                           " (" + proPerc + "%)");
                }

                row++;
                count++;
                if (o != null)
                {
                    Thread.Sleep(1);
                }
            }

            return(true);
        }
        private void WriteList <T>(object source, Type typeOfT, ref bool result,
                                   IAsyncProgress2 o, bool writeHeaders, Action <ExternalExcelRangeFormatInfo> modifyRange)
        {
            IList items = source as IList;
            IList <PropertyInfo> columns = null;

            // get all the public properties
            columns = (from p in typeOfT.GetProperties(BindingFlags.Instance | BindingFlags.Public)
                       select p).ToList();
            if (columns != null && columns.Count > 0)
            {
                result = this.Write <PropertyInfo, T>(o, items, writeHeaders,
                                                      columns, (c, i) => { return(c.Name); },
                                                      items, (r, i, c, j) =>
                {
                    return(columns[j].GetValue(r, null));
                },
                                                      modifyRange);
            }
        }
 protected override object[,] ReadInternal(IAsyncProgress2 o, ExternalExcelRangeInfo rangeInfo)
 {
     var readRange = this.GetRange(rangeInfo);
     return readRange.Value2 as object[,];
 }
 protected override bool WriteInternal(IAsyncProgress2 o, object[,] values, ExternalExcelRangeInfo rangeInfo)
 {
     var writeRange = this.GetRange(rangeInfo);
     writeRange.Value2 = values;
     return true;
 }
        public bool Write <C, R>(IAsyncProgress2 o, object source,
                                 bool writeHeaders,
                                 IEnumerable columns, GetExcelWriteColumnName <C> getColumnName,
                                 IEnumerable items, GetExcelWriteRowItemValue <C, R> getItemValue,
                                 Action <ExternalExcelRangeFormatInfo> modifyRange)
        {
            ModuleProc PROC   = new ModuleProc(this.DYN_MODULE_NAME, "Write");
            bool       result = default(bool);

            if (source == null || items == null || columns == null)
            {
                return(false);
            }

            try
            {
                int rows = 0;
                int cols = 0;
                o.CrossThreadInvoke(new Action(() =>
                {
                    rows = (writeHeaders ? items.GetCollectionCount <R>() + 1 : items.GetCollectionCount <R>());
                    cols = columns.GetCollectionCount <C>();
                }));

                int rowIndex = 1, rowIndex0 = 0;
                int colIndex = 1, colIndex0 = 0;
                object[,] values = Extensions.CreateArray(rows, cols, 1, 1);

                if (o != null)
                {
                    o.InitializeProgress(1, rows);
                }
                ExternalExcelRangeFormatInfo rangeInfo = new ExternalExcelRangeFormatInfo(1, 1, rows, cols);
                if (modifyRange != null)
                {
                    modifyRange(rangeInfo);
                }

                if (writeHeaders)
                {
                    if (o != null)
                    {
                        o.UpdateStatusProgress(rowIndex, "Preparing row : " + rowIndex.ToString());
                    }
                    colIndex0 = 0;

                    foreach (C col in columns.OfType <C>())
                    {
                        o.CrossThreadInvoke(new Action(() =>
                        {
                            values[rowIndex, colIndex] = getColumnName(col, colIndex0);
                        }));
                        using (ExternalExcelRangeFormatInfo rangeInfo2 = new ExternalExcelRangeFormatInfo(rowIndex, colIndex, rowIndex, colIndex))
                        {
                            rangeInfo2.BackColor           = Color.Blue;
                            rangeInfo2.ForeColor           = Color.White;
                            rangeInfo2.HorizontalAlignment = ExternalExcelCellHAlign.AlignLeft;
                            rangeInfo2.VerticalAlignment   = ExternalExcelCellVAlign.AlignCenter;
                            this.FormatRange(rangeInfo2);
                        }
                        colIndex++;
                        colIndex0++;
                    }

                    using (ExternalExcelRangeFormatInfo rangeInfo2 = new ExternalExcelRangeFormatInfo(rowIndex, 1, rowIndex, cols))
                    {
                        rangeInfo2.AutoFilter = true;
                        this.FormatRange(rangeInfo2);
                    }

                    rowIndex++;
                }

                IEnumerable items2 = null;
                o.CrossThreadInvoke(new Action(() =>
                {
                    items2 = items.OfType <R>();
                }));
                IEnumerator enumerator = items2.GetEnumerator();
                if (enumerator != null)
                {
                    bool hasNext = true;
                    while (hasNext)
                    {
                        o.CrossThreadInvoke(new Action(() =>
                        {
                            hasNext = enumerator.MoveNext();
                        }));
                        if (hasNext && enumerator.Current != null)
                        {
                            R dr = (R)enumerator.Current;
                            if (rowIndex > rows)
                            {
                                break;
                            }
                            colIndex  = 1;
                            colIndex0 = 0;

                            foreach (C col in columns)
                            {
                                o.CrossThreadInvoke(new Action(() =>
                                {
                                    values[rowIndex, colIndex] = getItemValue(dr, rowIndex0, col, colIndex0);
                                }));
                                colIndex++;
                                colIndex0++;
                            }

                            if (o != null)
                            {
                                if (o.ExecutorService != null &&
                                    o.ExecutorService.IsShutdown)
                                {
                                    break;
                                }
                                o.UpdateStatusProgress(rowIndex, "Preparing row : " + rowIndex.ToString());
                            }

                            rowIndex++;
                            rowIndex0++;
                            Thread.Sleep(1);
                        }
                    }
                }

                // excel writing
                result = this.Write(o, values, rangeInfo);

                // excel formatting
                o.UpdateStatus("Formatting...");
                this.FormatRange(rangeInfo);
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return(result);
        }
        public bool Write <T>(ExternalExcelWriteArgs <T> args)
        {
            ModuleProc PROC   = new ModuleProc(this.DYN_MODULE_NAME, "Write");
            bool       result = default(bool);

            try
            {
                IAsyncProgress2 o                   = args.Progress;
                object          source              = args.Source;
                bool            writeHeaders        = args.WriteHeaders;
                bool            writeCheckItemsOnly = args.WriteCheckedItems;
                Action <ExternalExcelRangeFormatInfo> modifyRange = args.FormatInfo;
                Type sourceType = source.GetType();
                bool isList     = false;

                if (args.ExternalWrite != null) // It is caller's responsibility to do the write operation
                {
                    return(args.ExternalWrite(this, args));
                }

                if (source is DataTable) // Data Table
                {
                    DataTable dt = source as DataTable;
                    result = this.Write <DataColumn, DataRow>(o, dt, writeHeaders,
                                                              dt.Columns, (c, i) => { return(c.ColumnName); },
                                                              dt.Rows, (r, i, c, j) => { return(r[c]); },
                                                              modifyRange);
                }
                else if (source is DataGridView) // Windows Forms Data Grid
                {
                    DataGridView dgv = source as DataGridView;
                    result = this.Write <DataGridViewColumn, DataGridViewRow>(o, dgv, writeHeaders,
                                                                              dgv.Columns, (c, i) => { return(c.HeaderText); },
                                                                              dgv.Rows, (r, i, c, j) => { return(r.Cells[c.Index].Value); },
                                                                              modifyRange);
                }
                else if (source is ListView) // List View
                {
                    ListView    lvw   = source as ListView;
                    ICollection items = lvw.Items;
                    if (writeCheckItemsOnly)
                    {
                        o.CrossThreadInvoke(new Action(() =>
                        {
                            if (lvw.MultiSelect &&
                                lvw.SelectedItems != null &&
                                lvw.SelectedItems.Count > 0)
                            {
                                items = lvw.SelectedItems;
                            }
                            else if (lvw.CheckBoxes &&
                                     lvw.CheckedItems != null &&
                                     lvw.CheckedItems.Count > 0)
                            {
                                items = lvw.CheckedItems;
                            }
                        }));
                    }

                    result = this.Write <ColumnHeader, ListViewItem>(o, lvw, writeHeaders,
                                                                     lvw.Columns, (c, i) => { return(c.Text); },
                                                                     items, (r, i, c, j) => { return(r.SubItems[c.Index].Text); },
                                                                     modifyRange);
                }
                else if (source is System.Windows.Controls.ItemsControl) // WPF Items Control
                {
                    System.Windows.Controls.ItemsControl ctlItems = source as System.Windows.Controls.ItemsControl;
                    System.Windows.Controls.DataGrid     dgv      = source as System.Windows.Controls.DataGrid;

                    if (ctlItems.ItemsSource != null &&
                        typeof(IList).IsAssignableFrom(ctlItems.ItemsSource.GetType()))
                    {
                        source     = ctlItems.ItemsSource;
                        sourceType = source.GetType();
                        isList     = true;
                    }
                    else if (dgv != null)
                    {
                        result = this.Write <System.Windows.Controls.DataGridColumn, System.Windows.Controls.DataGridRow>(o, dgv, writeHeaders,
                                                                                                                          dgv.Columns, (c, i) => { return(c.Header); },
                                                                                                                          dgv.Items, (r, i, c, j) => { return(null); },
                                                                                                                          modifyRange);
                    }
                }
                else if (typeof(IList).IsAssignableFrom(sourceType)) // IList (or) IList<T>
                {
                    isList = true;
                }

                // if the item is derived from IList
                if (isList)
                {
                    Type currentType = sourceType;
                    Type typeOfT     = null;
                    while (currentType != typeof(object))
                    {
                        Type[] types = currentType.GetGenericArguments();
                        if (types != null && types.Length > 0)
                        {
                            typeOfT = types[0];
                            break;
                        }
                        currentType = currentType.BaseType;
                    }
                    if (typeOfT == null)
                    {
                        return(false);
                    }

                    if (typeof(IList <T>).IsAssignableFrom(sourceType))
                    {
                        this.WriteList <T>(source, typeOfT, ref result, o, writeHeaders, modifyRange);
                    }
                    else
                    {
                        this.WriteList <object>(source, typeOfT, ref result, o, writeHeaders, modifyRange);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return(result);
        }
 protected abstract bool WriteInternal(IAsyncProgress2 o, object[,] values, ExternalExcelRangeInfo rangeInfo);
Пример #13
0
        public void DataBind(IAsyncProgress2 o)
        {
            ModuleProc PROC = new ModuleProc("", "DataBind");

            _asyncActive = o;

            try
            {
                _pageIndex = 0;
                _pageTotal = 0;
                _totalRows = 0;

                o.CrossThreadInvoke(() =>
                {
                    dgvRows.ClearSelection();
                    dgvRows.Rows.Clear();
                    cboPageNos.Items.Clear();

                    cboPageNos.Enabled       = false;
                    cboPageNos.SelectedIndex = -1;
                    tblButtons.Visible       = false;
                    this.EnableDisablePageButtons();
                });
                this.HasMessages = false;

                if (this.GridDataSource != null &&
                    this.GridDataSource.Count > 0)
                {
                    o.CrossThreadInvoke(() =>
                    {
                        tblButtons.Visible = true;
                    });

                    this.HasMessages = true;
                    _totalRows       = this.GridDataSource.Count;
                    _pageTotal       = (_totalRows / this.RowsPerPage) +
                                       (((_totalRows % this.RowsPerPage) > 0) ? 1 : 0);

                    for (int i = 1; i <= _pageTotal; i++)
                    {
                        o.CrossThreadInvoke(() =>
                        {
                            cboPageNos.Items.Add(i);
                        });
                        Thread.Sleep(1);
                    }
                    o.CrossThreadInvoke(() =>
                    {
                        cboPageNos.Enabled = true;
                    });

                    o.CrossThreadInvoke(() =>
                    {
                        if (cboPageNos.Items.Count > 0)
                        {
                            cboPageNos.SelectedIndex = 0;
                        }
                        else
                        {
                            cboPageNos.SelectedIndex = -1;
                        }
                    });
                }
                else
                {
                    o.CrossThreadInvoke(() =>
                    {
                        cboPageNos.Items.Clear();
                        lblPageInfo.Text         = string.Empty;
                        cboPageNos.SelectedIndex = -1;
                    });
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
        }
        private void DataBind(int pageIndex)
        {
            ModuleProc PROC = new ModuleProc("", "Method");
            GridViewAfterDataBoundEventArgs args = new GridViewAfterDataBoundEventArgs();

            lock (_lockGrid)
            {
                try
                {
                    dgvRows.ClearSelection();
                    dgvRows.Rows.Clear();

                    _pageIndex = pageIndex;
                    int start = (_pageIndex - 1) * this.RowsPerPage;
                    int end = (_pageIndex * this.RowsPerPage) - 1;
                    if (end > (_totalRows - 1)) end = _totalRows - 1;
                    int records = (end - start + 1);
                    int availRecords = Math.Min(records, this.RowsPerPage);
                    args.Start = start + 1;
                    args.End = start + availRecords;
                    args.Total = _totalRows;
                    lblPageInfo.Text = string.Format("{0:D} - {1:D} ({2:D})", args.Start, args.End, args.Total);

                    object[] query = this.GridDataSource
                                                    .AsQueryable()
                                                    .OfType<Object>()
                                                    .Skip(start)
                                                    .Take(availRecords).ToArray();
                    if (this.ManualDataBinding &&
                        query != null &&
                        query.Length > 0)
                    {
                        if (_asyncActive != null)
                        {
                            try
                            {
                                _asyncActive.InitializeProgress(1, query.Length);
                            }
                            catch { }
                        }

                        int i = 1;
                        foreach (var item in query)
                        {
                            if (_asyncActive != null)
                            {
                                try
                                {
                                    if (_asyncActive.ExecutorService != null &&
                                        _asyncActive.ExecutorService.IsShutdown) break;
                                }
                                catch { }
                            }

                            int rowIndex = dgvRows.Rows.Add();
                            DataGridViewRow row = dgvRows.Rows[rowIndex];
                            row.Tag = item;

                            if (_asyncActive != null)
                            {
                                try
                                {
                                    _asyncActive.UpdateStatusProgress(i, string.Empty);
                                }
                                catch { }
                            }

                            ManualRowBindEventArgs e = new ManualRowBindEventArgs()
                            {
                                Row = row,
                                RowNumber = (start + rowIndex + 1),
                                GridRowNumber = (rowIndex + 1),
                                DataObject = item
                            };
                            this.OnManualRowBind(e);
                            e = null;
                            i++;
                        }
                    }
                    else
                    {
                        dgvRows.DataSource = query;
                    }
                }
                catch (Exception ex)
                {
                    Log.Exception(PROC, ex);                    
                }
            }

            try
            {

                if (dgvRows.Rows.Count > 0)
                    dgvRows.Rows[0].Selected = true;
                this.dgvRows_SelectionChanged(dgvRows, EventArgs.Empty);

                this.OnAfterDataBound(args);
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
            finally
            {
                _asyncActive = null;
            }
        }
 protected abstract object[,] ReadInternal(IAsyncProgress2 o, ExternalExcelRangeInfo rangeInfo);
        protected override object[,] ReadInternal(IAsyncProgress2 o, ExternalExcelRangeInfo rangeInfo)
        {
            var readRange = this.GetRange(rangeInfo);

            return(readRange.Value2 as object[, ]);
        }
 protected override bool WriteInternal(IAsyncProgress2 o, object[,] values, ExternalExcelRangeInfo rangeInfo)
 {
     return this._WriteInternal(o, values, rangeInfo);
 }
 protected override object[,] ReadInternal(IAsyncProgress2 o, ExternalExcelRangeInfo rangeInfo)
 {
     return this._ReadInternal(o, rangeInfo);
 }
 protected override bool WriteInternal(IAsyncProgress2 o, object[,] values, ExternalExcelRangeInfo rangeInfo)
 {
     return(this._WriteInternal(o, values, rangeInfo));
 }
 protected override object[,] ReadInternal(IAsyncProgress2 o, ExternalExcelRangeInfo rangeInfo)
 {
     return(this._ReadInternal(o, rangeInfo));
 }
        public void DataBind(IAsyncProgress2 o)
        {
            ModuleProc PROC = new ModuleProc("", "DataBind");
            _asyncActive = o;

            try
            {
                _pageIndex = 0;
                _pageTotal = 0;
                _totalRows = 0;

                o.CrossThreadInvoke(() =>
                {
                    dgvRows.ClearSelection();
                    dgvRows.Rows.Clear();
                    cboPageNos.Items.Clear();

                    cboPageNos.Enabled = false;
                    cboPageNos.SelectedIndex = -1;
                    tblButtons.Visible = false;
                    this.EnableDisablePageButtons();
                });
                this.HasMessages = false;

                if (this.GridDataSource != null
                    && this.GridDataSource.Count > 0)
                {
                    o.CrossThreadInvoke(() =>
                    {
                        tblButtons.Visible = true;
                    });

                    this.HasMessages = true;
                    _totalRows = this.GridDataSource.Count;
                    _pageTotal = (_totalRows / this.RowsPerPage) +
                        (((_totalRows % this.RowsPerPage) > 0) ? 1 : 0);

                    for (int i = 1; i <= _pageTotal; i++)
                    {
                        o.CrossThreadInvoke(() =>
                        {
                            cboPageNos.Items.Add(i);
                        });
                        Thread.Sleep(1);
                    }
                    o.CrossThreadInvoke(() =>
                    {
                        cboPageNos.Enabled = true;
                    });

                    o.CrossThreadInvoke(() =>
                    {
                        if (cboPageNos.Items.Count > 0)
                            cboPageNos.SelectedIndex = 0;
                        else
                            cboPageNos.SelectedIndex = -1;
                    });
                }
                else
                {
                    o.CrossThreadInvoke(() =>
                    {
                        cboPageNos.Items.Clear();
                        lblPageInfo.Text = string.Empty;
                        cboPageNos.SelectedIndex = -1;
                    });
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
        }
Пример #22
0
        private void DataBind(int pageIndex)
        {
            ModuleProc PROC = new ModuleProc("", "Method");
            GridViewAfterDataBoundEventArgs args = new GridViewAfterDataBoundEventArgs();

            lock (_lockGrid)
            {
                try
                {
                    dgvRows.ClearSelection();
                    dgvRows.Rows.Clear();

                    _pageIndex = pageIndex;
                    int start = (_pageIndex - 1) * this.RowsPerPage;
                    int end   = (_pageIndex * this.RowsPerPage) - 1;
                    if (end > (_totalRows - 1))
                    {
                        end = _totalRows - 1;
                    }
                    int records      = (end - start + 1);
                    int availRecords = Math.Min(records, this.RowsPerPage);
                    args.Start       = start + 1;
                    args.End         = start + availRecords;
                    args.Total       = _totalRows;
                    lblPageInfo.Text = string.Format("{0:D} - {1:D} ({2:D})", args.Start, args.End, args.Total);

                    object[] query = this.GridDataSource
                                     .AsQueryable()
                                     .OfType <Object>()
                                     .Skip(start)
                                     .Take(availRecords).ToArray();
                    if (this.ManualDataBinding &&
                        query != null &&
                        query.Length > 0)
                    {
                        if (_asyncActive != null)
                        {
                            try
                            {
                                _asyncActive.InitializeProgress(1, query.Length);
                            }
                            catch { }
                        }

                        int i = 1;
                        foreach (var item in query)
                        {
                            if (_asyncActive != null)
                            {
                                try
                                {
                                    if (_asyncActive.ExecutorService != null &&
                                        _asyncActive.ExecutorService.IsShutdown)
                                    {
                                        break;
                                    }
                                }
                                catch { }
                            }

                            int             rowIndex = dgvRows.Rows.Add();
                            DataGridViewRow row      = dgvRows.Rows[rowIndex];
                            row.Tag = item;

                            if (_asyncActive != null)
                            {
                                try
                                {
                                    _asyncActive.UpdateStatusProgress(i, string.Empty);
                                }
                                catch { }
                            }

                            ManualRowBindEventArgs e = new ManualRowBindEventArgs()
                            {
                                Row           = row,
                                RowNumber     = (start + rowIndex + 1),
                                GridRowNumber = (rowIndex + 1),
                                DataObject    = item
                            };
                            this.OnManualRowBind(e);
                            e = null;
                            i++;
                        }
                    }
                    else
                    {
                        dgvRows.DataSource = query;
                    }
                }
                catch (Exception ex)
                {
                    Log.Exception(PROC, ex);
                }
            }

            try
            {
                if (dgvRows.Rows.Count > 0)
                {
                    dgvRows.Rows[0].Selected = true;
                }
                this.dgvRows_SelectionChanged(dgvRows, EventArgs.Empty);

                this.OnAfterDataBound(args);
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
            finally
            {
                _asyncActive = null;
            }
        }