Пример #1
0
 public RemoveWorkerResult Execute(RemoveWorkerArgs args)
 {
     RemoveWorkerResult result;
     try
     {
         this.RemoveProgress = new ArrangeProgress(ArrangeProgress.ProgresType.Remove);
         this.RemoveProgress.CancelEvent += new EventHandler(this.OnCancel);
         this.RemoveProgress.CanCancel = true;
         this.BackWorker = new BackgroundWorker();
         this.BackWorker.DoWork += new DoWorkEventHandler(this.DoWork);
         this.BackWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.RunWorkerCompleted);
         this.BackWorker.ProgressChanged += new ProgressChangedEventHandler(this.ProgressChanged);
         this.BackWorker.WorkerReportsProgress = true;
         this.BackWorker.WorkerSupportsCancellation = true;
         this.BackWorker.RunWorkerAsync(args);
         this.RemoveProgress.ShowDialog();
         if (this.WorkerResult.Error != null)
         {
             throw this.WorkerResult.Error;
         }
         result = (RemoveWorkerResult) this.WorkerResult.Result;
     }
     finally
     {
         this.BackWorker.Dispose();
         this.RemoveProgress.Dispose();
         this.RemoveProgress = null;
     }
     return result;
 }
Пример #2
0
 private bool RemoveRequest(bool bResetid)
 {
     this.ResetRemoveDate();
     DataGridView internalDataGrid = this.Dataview.InternalDataGrid;
     DataSet internalDataSet = this.Dataview.InternalDataSet;
     DataTable table = internalDataSet.Tables["NACCS"];
     ULogClass.LogWrite(string.Format("# Will start deleting the old messages.[Number of messages:{0} Date/time applied for deletion:{1}]", table.Rows.Count, this.RemoveDate));
     Stopwatch stopwatch = new Stopwatch();
     stopwatch.Start();
     this.Dataview.DataViewNoRepaint(true);
     internalDataGrid.RowPrePaint += new DataGridViewRowPrePaintEventHandler(this.OnRowPrePaint);
     internalDataGrid.ClearSelection();
     internalDataGrid.Refresh();
     internalDataGrid.Cursor = Cursors.WaitCursor;
     bool flag = false;
     try
     {
         Naccs.Core.DataView.Arrange.DatasetRemove remove = new Naccs.Core.DataView.Arrange.DatasetRemove();
         RemoveWorkerArgs args = new RemoveWorkerArgs {
             Table = table,
             RemoveDate = this.RemoveDate,
             ResetID = bResetid
         };
         RemoveWorkerResult result = remove.Execute(args);
         flag = !result.IsCancel;
         if (result.IsCancel)
         {
             ULogClass.LogWrite(string.Format("# Deletion of old messages has been stopped.[Number of restored messages:{0} Processing time:{1}]", result.RemoveCount, stopwatch.ElapsedMilliseconds));
             return flag;
         }
         ULogClass.LogWrite(string.Format("# Deletion of old messages has been completed.[Number of deleted messages:{0} Processing time:{1}]", result.RemoveCount, stopwatch.ElapsedMilliseconds));
     }
     finally
     {
         stopwatch.Stop();
         internalDataGrid.RowPrePaint -= new DataGridViewRowPrePaintEventHandler(this.OnRowPrePaint);
         this.Dataview.DataViewNoRepaint(false);
         internalDataSet.AcceptChanges();
         internalDataGrid.Refresh();
         this.Dataview.UpdateCount();
         internalDataGrid.Cursor = Cursors.Default;
     }
     return flag;
 }