Exemplo n.º 1
0
        internal void AbortDeletion()
        {
            this.CurrentProcessStep = WorkflowSteps.Idle;

            this.deletionWorker.Dispose();
            this.deletionWorker = null;

            this.OnAborted?.Invoke(this, new EventArgs());
        }
Exemplo n.º 2
0
        public void StartDeleteProcess()
        {
            this.CurrentProcessStep = WorkflowSteps.DeleteProcessRunning;

            this.deletionWorker = new DeletionWorker {
                Data = this.Data
            };

            this.deletionWorker.ProgressChanged    += this.deletionWorker_ProgressChanged;
            this.deletionWorker.RunWorkerCompleted += this.deletionWorker_RunWorkerCompleted;

            this.deletionWorker.RunWorkerAsync();
        }
Exemplo n.º 3
0
        private void deletionWorker_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e)
        {
            this.CurrentProcessStep = WorkflowSteps.Idle;

            if (e.Error != null)
            {
                this.showErrorMsg(e.Error.Message);

                this.deletionWorker.Dispose();
                this.deletionWorker = null;
            }
            else if (e.Cancelled)
            {
                if (this.deletionWorker.ErrorInfo != null)
                {
                    // A error occurred, process was stopped
                    //
                    // -> Ask user to continue

                    if (this.OnDeleteError != null)
                    {
                        this.OnDeleteError(this, this.deletionWorker.ErrorInfo);
                    }
                    else
                    {
                        throw new Exception("Internal error: event handler is missing.");
                    }
                }
                else
                {
                    // The user cancelled the process
                    this.OnCancelled?.Invoke(this, new EventArgs());
                }
            }
            else
            {
                // TODO: Use separate class here?
                var deletedCount   = this.deletionWorker.DeletedCount;
                var failedCount    = this.deletionWorker.FailedCount;
                var protectedCount = this.deletionWorker.ProtectedCount;

                this.deletionWorker.Dispose();
                this.deletionWorker = null;

                this.OnDeleteProcessFinished?.Invoke(this, new DeleteProcessFinishedEventArgs(deletedCount, failedCount, protectedCount));
            }
        }