/// <summary> /// Starts the import. /// </summary> /// <param name="importType">Type of the import.</param> private void StartImport(ImportType importType) { var physicalSlingshotFile = this.Request.MapPath(fupSlingshotFile.UploadedContentFilePath); long totalMilliseconds = 0; var importTask = new Task(() => { // wait a little so the browser can render and start listening to events System.Threading.Thread.Sleep(1000); _hubContext.Clients.All.showButtons(this.SignalRNotificationKey, false); _hubContext.Clients.All.showLog(); Stopwatch stopwatch = Stopwatch.StartNew(); _importer = new Rock.Slingshot.SlingshotImporter(physicalSlingshotFile, tbForeignSystemKey.Text); _importer.FinancialTransactionChunkSize = 100000; _importer.OnProgress += _importer_OnProgress; if (importType == ImportType.ImportPhotos) { _importer.TEST_UseSampleLocalPhotos = false; _importer.DoImportPhotos(); } else { _importer.DoImport(); } stopwatch.Stop(); if (_importer.Exceptions.Any()) { _importer.Results.Add("ERRORS", string.Join(Environment.NewLine, _importer.Exceptions.Select(a => a.Message).ToArray())); } totalMilliseconds = stopwatch.ElapsedMilliseconds; _hubContext.Clients.All.showButtons(this.SignalRNotificationKey, true); }); importTask.ContinueWith((t) => { if (t.IsFaulted) { foreach (var exception in t.Exception.InnerExceptions) { _importer.Exceptions.Add(exception.GetBaseException()); } _importer_OnProgress(null, "ERROR"); } else { _importer_OnProgress(null, string.Format("{0} Complete: [{1}ms]", importType.ConvertToString(), totalMilliseconds)); } }); importTask.Start(); }
/// <summary> /// Starts the import. /// </summary> /// <param name="importType">Type of the import.</param> private void StartImport(ImportType importType) { var physicalSlingshotFile = this.Request.MapPath(hfMainSlingshotFileName.Value); long totalMilliseconds = 0; Rock.Slingshot.SlingshotImporter _importer = null; var importTask = new Task(() => { // wait a little so the browser can render and start listening to events System.Threading.Thread.Sleep(1000); _hubContext.Clients.All.showButtons(this.SignalRNotificationKey, false); Stopwatch stopwatch = Stopwatch.StartNew(); BulkImporter.ImportUpdateType importUpdateType; if (rbOnlyAddNewRecords.Checked) { importUpdateType = BulkImporter.ImportUpdateType.AddOnly; } else if (rbMostRecentWins.Checked) { importUpdateType = BulkImporter.ImportUpdateType.MostRecentWins; } else { importUpdateType = BulkImporter.ImportUpdateType.AlwaysUpdate; } _importer = new Rock.Slingshot.SlingshotImporter(physicalSlingshotFile, tbForeignSystemKey.Text, importUpdateType, _importer_OnProgress); _importer.FinancialTransactionChunkSize = 100000; if (importType == ImportType.Import || importType == ImportType.All) { _importer.DoImport(); } if (importType == ImportType.Photos || importType == ImportType.All) { _importer.TEST_UseSampleLocalPhotos = false; _importer.DoImportPhotos(); } stopwatch.Stop(); if (_importer.Exceptions.Any()) { _importer.Results.Add("ERRORS", string.Join(Environment.NewLine, _importer.Exceptions.Select(a => a.Message).ToArray())); } totalMilliseconds = stopwatch.ElapsedMilliseconds; _hubContext.Clients.All.showButtons(this.SignalRNotificationKey, true); }); importTask.ContinueWith((t) => { if (t.IsFaulted) { foreach (var exception in t.Exception.InnerExceptions) { LogException(exception); if (_importer.Exceptions != null) { _importer.Exceptions.Add(exception.GetBaseException()); } } _importer_OnProgress(_importer, "ERROR: " + t.Exception.Message); } else { _importer_OnProgress(_importer, string.Format("{0} Complete: [{1}ms]", importType.ConvertToString(), totalMilliseconds)); } }); importTask.Start(); }