/// <summary> /// Constructor with dependency injection /// </summary> public ExportController(ILoggerFactory loggerFactory, IExportJob exportJob, ITransferProxyFactory transferProxyFactory, IJobRunner jobRunner) { log = loggerFactory.CreateLogger <ExportController>(); this.exportJob = exportJob; this.transferProxyFactory = transferProxyFactory; this.jobRunner = jobRunner; }
private void ExportOptionDialogOnExportOptionSelected(object sender, ExportOptionSelectedEventArgs e) { try { var exportType = e.ExportOption.ExportType; var mapType = e.ExportOption.MapType; IExportJob exist = null; #if DEBUG foreach (var exportJob in RootMap.ExportJobs) { var exportOption = new ExportOption(exportJob.ExportProperties, exportJob.Type, exportJob.MapType); if (exportOption.Equals(e.ExportOption)) { exist = exportJob; break; } } //exist = RootMap.ExportJobs.FirstOrDefault(q => new ExportOption(q.ExportProperties, q.Type, q.MapType).Equals(e.ExportOption)); #else exist = RootMap.ExportJobs.FirstOrDefault(q => new ExportOption(q.ExportProperties, q.Type, q.MapType).Equals(e.ExportOption) && q.IsCurrent); #endif if (exist != null) { switch (exist.Status) { case ExportStatus.Completed: SuperMessageBoxService.ShowInformation("Export Exists", "An existing export that matches is up-to-date and ready for download already"); break; case ExportStatus.Error: SuperMessageBoxService.ShowInformation("Export Exists", "An existing export that matches did not complete successfully, delete the failed export and try again"); break; case ExportStatus.Processing: case ExportStatus.Scheduled: SuperMessageBoxService.ShowInformation("Export Exists", string.Format("An existing export that matches is already {0}, please wait until it has completed", exist.Status.ToString().ToLower())); break; default: break; } IsBusy = false; } else { ExportServiceManager.CreateExportJobCompleted.RegisterEvent(RootMap.Id, OnCreateExportJobCompleted); ExportServiceManager.CreateExportJobAsync(RootMap.ParentId, RootMap.Id, e.ExportOption.Value, mapType, exportType); DebugLogger.Instance.LogMsg("Submitted export job details, Domain: {0}, RootMap: {1}, MapType: {2}, ExportType: {3}", RootMap.ParentId, RootMap.Id, mapType, exportType); } } catch (Exception ex) { DebugLogger.Instance.LogMsg("An error occurred processing the Export Options dialog. {0}.", ex.ToString()); SuperMessageBoxService.ShowError("Error Occurred", "You cannot export the map at the moment, please try again later."); } }