Exemplo n.º 1
0
 public RevertWorkerResult Execute(RevertWorkerArgs args)
 {
     RevertWorkerResult result;
     try
     {
         this.RevertProgress = new ArrangeProgress(ArrangeProgress.ProgresType.Revert);
         this.RevertProgress.CancelEvent += new EventHandler(this.OnCancel);
         this.RevertProgress.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.RevertProgress.ShowDialog();
         if (this.WorkerResult.Error != null)
         {
             throw this.WorkerResult.Error;
         }
         result = (RevertWorkerResult) this.WorkerResult.Result;
     }
     finally
     {
         this.BackWorker.Dispose();
         this.RevertProgress.Dispose();
         this.RevertProgress = null;
     }
     return result;
 }
Exemplo n.º 2
0
 private bool RevertRequest(string root, string[] files)
 {
     ULogClass.LogWrite(string.Format("# Will start restoring the old messages.[Number of messages:{0}]", files.Length));
     DataGridView internalDataGrid = this.Dataview.InternalDataGrid;
     DataSet internalDataSet = this.Dataview.InternalDataSet;
     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.DatasetRevert revert = new Naccs.Core.DataView.Arrange.DatasetRevert();
         RevertWorkerArgs args = new RevertWorkerArgs {
             DataView = this.Dataview,
             PathRoot = root,
             FileNames = files
         };
         RevertWorkerResult result = revert.Execute(args);
         flag = !result.IsCancel;
         if (result.IsCancel)
         {
             ULogClass.LogWrite(string.Format("# Restoration of old messages has been stopped.[Number of restored messages:{0} Processing time:{1}]", result.RevertCount, stopwatch.ElapsedMilliseconds));
         }
         else
         {
             ULogClass.LogWrite(string.Format("# Restoration of old messages has been completed.  [Number of restored messages:{0} Processing time:{1}]", result.RevertCount, stopwatch.ElapsedMilliseconds));
         }
         if (result.SkipFiles.Length > 0)
         {
             StringBuilder builder = new StringBuilder();
             builder.AppendLine(string.Format("# The file exists, so no need to restore the file.[Number of skipped processes:{0}]", result.SkipFiles.Length));
             ULogClass.LogWrite(builder.ToString());
         }
         if (result.FirstError == null)
         {
             return flag;
         }
         StringBuilder builder2 = new StringBuilder();
         builder2.AppendLine(string.Format("# Error occurred while restoring the old messages.\r\n{0}\r\n{1}", result.FirstError.Message, result.FirstError.StackTrace));
         builder2.AppendLine(Resources.ResourceManager.GetString("CORE105") + result.ErrorFiles.Length);
         foreach (string str in result.ErrorFiles)
         {
             builder2.AppendLine(str);
         }
         MessageDialog dialog = new MessageDialog();
         dialog.ShowMessage("E402", "", builder2.ToString());
         dialog.Dispose();
     }
     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;
 }