/// <summary> /// Handle the success event. /// </summary> /// <param name="sender">The DataImporter.</param> /// <param name="eventArgs">The event arguments.</param> private void OnSuccess(object sender, DataImporter.ImportEventArgs eventArgs) { this.Dispatcher.BeginInvoke( DispatcherPriority.Normal, new Action(delegate() { this.timer.Stop(); this.TimeLeft = TimeSpan.Zero; if (eventArgs.FailedCount == 0) { BindingOperations.ClearBinding(this, WindowImport.HeaderProperty); this.Header = String.Format(Properties.Resources.ImportEndedSuccessHeader, eventArgs.SucceededCount); this.Message = String.Format(Properties.Resources.ImportEndedSuccessMessage, Path.GetFileName(this.ImportFile)); this.cancelBtn.Content = Properties.Resources.Close; this.succeeded = true; this.Activate(); } else { WindowImportReport report = new WindowImportReport(); report.ImportEventArgs = eventArgs; report.FailureFile = this.failureFile; report.SchemaVersion = this.SchemaVersion; report.Owner = this; report.ShowDialog(); this.Close(); } })); }
/// <summary> /// Handle the failed event. /// </summary> /// <param name="sender">The DataImporter.</param> /// <param name="eventArgs">The event arguments.</param> private void OnFailed(object sender, DataImporter.ImportEventArgs eventArgs) { this.Dispatcher.BeginInvoke( DispatcherPriority.Normal, new Action(delegate() { Boolean threadAborted = eventArgs.Exception is ThreadAbortException || eventArgs.Exception.InnerException is ThreadAbortException; this.timer.Stop(); if (!(threadAborted && !this.loaded)) { WindowImportReport report = new WindowImportReport(); if (eventArgs.FailedCount != 0) { report.FailureFile = this.failureFile; } else { report.FailureFile = null; } report.ImportEventArgs = eventArgs; report.SchemaVersion = this.SchemaVersion; report.Owner = this; report.ShowDialog(); this.Close(); } })); }