public async Task Export(ProgressDialogController progress) { if (!Exists) { return; } await Task.Run(() => { // export bacpac var bacpacName = $"{DateTime.Now:yyyyMMdd_HHmm}.bacpac"; _dacService.ProgressChanged += (sender, args) => progress.SetMessage($"{args.Status} : {args.Message}"); _dacService.ExportBacpac(bacpacName, _databaseName); // save file var filePath = Path.Combine(Directory.GetCurrentDirectory(), bacpacName); var result = new SaveFileDialogService().Show( bacpacName , fileName => { if (!File.Exists(fileName)) { File.Move(filePath, fileName); } } , () => File.Delete(filePath) ); progress.SetMessage(result ? "Success" : "Fail"); }); await progress.CloseAsync(); }
public bool SaveOnPDF(BitmapFrame img, ProgressDialogController ctrl) { try { int c = 0; ctrl.SetTitle("Converting to PDF"); ctrl.SetMessage($"{c}/1 Wait a moment..."); var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(img)); using (FileStream stream = new FileStream($@"{_containerNname}.png", FileMode.Create)) encoder.Save(stream); ConvertImageToPDF(); if (File.Exists($"{_containerNname}.png")) { File.Delete($"{_containerNname}.png"); } c++; ctrl.SetMessage($"{c}/1 Wait a moment..."); return(true); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public async Task <BlogResponse <BlogMLBlog> > GetAllBlogPostsAsync(ProgressDialogController progressController) { var response = new BlogResponse <BlogMLBlog>(); try { _password = Settings.Instance.GWBPassword.DecryptString().ToInsecureString(); var blogs = _proxy.getUsersBlogs(_blogId, _userName, _password); await Task.Run(() => { foreach (BlogInfo blog in blogs) { BlogMLBlog xblog = new BlogMLBlog { Title = blog.blogName, RootUrl = blog.url }; progressController.SetMessage("Getting categories"); var categories = GetCategories(blog); var blogMlCategories = categories as IList <BlogMLCategory> ?? categories.ToList(); xblog.Categories.AddRange(blogMlCategories); progressController.SetMessage("Getting posts"); var posts = GetPosts(blog, blogMlCategories); xblog.Posts.AddRange(posts); response.Data = xblog; } }); } catch (Exception exception) { response.Exception = exception; } return(response); }
public async void DeleteCamera(string id, string videoStreamArn, string dataStreamName, string eventSourceUUID, string streamProcessorName, CameraView cv) { ProgressDialogController controller = await this.ShowProgressAsync("Please wait...", ""); controller.SetIndeterminate(); controller.SetCancelable(false); controller.SetMessage("Deleting event source mapping"); await Task.Run(() => Models.Lambda.DeleteEventSourceMapping(eventSourceUUID)); controller.SetMessage("Deleting data stream"); await Task.Run(() => Models.DataStream.DeleteDataStream(dataStreamName)); controller.SetMessage("Deleting video stream"); await Task.Run(() => Models.VideoStream.DeleteVideoStream(videoStreamArn)); controller.SetMessage("Deleting stream processor"); await Task.Run(() => Models.StreamProcessorManager.DeleteStreamProcessor(streamProcessorName)); controller.SetMessage("Deleting database record"); await Task.Run(() => Models.Dynamodb.DeleteItem(id, Models.MyAWSConfigs.CamerasDBTableName)); await controller.CloseAsync(); cv.LoadCamerasData().ConfigureAwait(false); notifyIcon.Visible = true; notifyIcon.ShowBalloonTip(1000, "Deleted", "Camera deleted Successfully", System.Windows.Forms.ToolTipIcon.Info); }
private async void wipeQuests_Click(object sender, RoutedEventArgs e) { MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented; await Dispatcher.InvokeAsync(new Action(async() => { MainDialogController = await this.ShowProgressAsync("Wiping Quests", "Please Wait..."); MainDialogController.SetIndeterminate(); try { var state = await TalosQuests.Instance.WipeQuests(); await Task.Run(() => { Dispatcher.Invoke(DispatcherPriority.Normal, new Action(async() => { if (state) { MainDialogController.SetMessage("Quests Wiped."); await TalosQuests.Instance.FetchInfo(); } })); }); await MainDialogController.CloseAsync(); } catch (TalosQuestsException exc) { MainDialogController.SetMessage("Error: \n" + exc.Message); MainDialogController.SetCancelable(true); MainDialogController.Canceled += (o, args) => MainDialogController.CloseAsync(); } })); }
private async void XLogin_OnClick(object sender, RoutedEventArgs e) { this.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented; AuthDialogController = await this.ShowProgressAsync("Login", "Please Wait..."); AuthDialogController.SetIndeterminate(); var state = await TalosQuests.Instance.Login(xUsername.Text, xPassword.Password); if (state) { AuthDialogController.SetMessage("Welcome.\nLoading Data..."); await TalosQuests.Instance.FetchInfo(); await AuthDialogController.CloseAsync(); MainWindow l = new MainWindow(); l.Show(); Close(); } else { await Task.Run(() => { Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { AuthDialogController.SetMessage( "Either your Credentials are incorrect either your have no access."); })); Thread.Sleep(3000); }); await AuthDialogController.CloseAsync(); } }
// upload private async void BtUploadArchive_OnClick(object sender, RoutedEventArgs e) { if (!await ModPlusAPI.Web.Connection.HasAllConnectionAsync(1)) { await this.ShowMessageAsync(ModPlusAPI.Language.GetItem(LangItem, "msg23"), string.Empty); return; } if (File.Exists(_currentFileToUpload)) { ProgressDialogController controller = null; try { var settings = new MetroDialogSettings { AnimateShow = true, AnimateHide = true, DialogTitleFontSize = 20 }; controller = await this.ShowProgressAsync(ModPlusAPI.Language.GetItem(LangItem, "msg24"), string.Empty, false, settings); controller.Minimum = 0; controller.Maximum = 2; using (var client = ModPlusAPI.Web.ApiClient.CreateClient()) { controller.SetMessage(ModPlusAPI.Language.GetItem(LangItem, "msg25")); controller.SetProgress(1); await client.UploadUserFile(new[] { "DwgForBaseFromUsers" }, _currentFileToUpload, false, true); controller.SetMessage(ModPlusAPI.Language.GetItem(LangItem, "msg26")); controller.SetProgress(2); var emailSettings = await client.GetEmailSettings(); await SendEmailNotification(emailSettings); } await controller.CloseAsync(); await this.ShowMessageAsync( string.Empty, ModPlusAPI.Language.GetItem(LangItem, "msg27") + ": " + _currentFileToUpload + " " + ModPlusAPI.Language.GetItem(LangItem, "msg28") + Environment.NewLine + ModPlusAPI.Language.GetItem(LangItem, "msg29")); } catch (Exception exception) { if (controller != null) { await controller.CloseAsync(); } ExceptionBox.Show(exception); } } else { MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "msg22")); } }
protected override async void ReadLASFileAction() { ProgressDialogController progressDialogController = await _dialogCoordinator.ShowProgressAsync(this, "Please wait...", "Finding headings..."); progressDialogController.Maximum = 100; await Task.Run(() => { List <StageModel> stageModels = new List <StageModel>(); int numberOfRows = Sections[SelectedDataSectionIndex].Content.Count(); progressDialogController.SetMessage("Beginning to read data..."); progressDialogController.SetProgress(0); progressDialogController.Maximum = numberOfRows; for (int currentRow = 0; currentRow < numberOfRows; currentRow++) { string[] splitLine = Sections[SelectedDataSectionIndex].Content[currentRow].SplitOnWhitespace(); bool shouldUse = true; if (LASFilterModels.Any()) { foreach (LASFilterModel lasFilterModel in LASFilterModels) { shouldUse = splitLine[lasFilterModel.HeadingIndex].Contains(lasFilterModel.FilterText); if (shouldUse == false) { break; } } } if (shouldUse) { double x = double.Parse(splitLine[SelectedXHeadingIndex]); double y = double.Parse(splitLine[SelectedYHeadingIndex]); double z = double.Parse(splitLine[SelectedZHeadingIndex]); stageModels.Add(new StageModel { StageNumber = int.Parse(splitLine[SelectedStageHeadingIndex]), Position = new Point3D(x, y, z) }); } progressDialogController.SetMessage($"Reading row {currentRow} of {numberOfRows}..."); progressDialogController.SetProgress(currentRow); } MessengerInstance.Send((stageModels, _wellID), MessageTokenStrings.AddStagesToManager); }); await progressDialogController.CloseAsync(); }
protected override async void ReadExcelFileAction() { ProgressDialogController progressDialogController = await _dialogCoordinator.ShowProgressAsync(this, "Please wait...", "Finding headings..."); progressDialogController.Maximum = 100; await Task.Run(() => { IEnumerable <ExcelRangeBase> dataColumn = _excelUsedRange.Single(cell => cell.Address == DataColumnHeading); IEnumerable <ExcelRangeBase> stageColumn = _excelUsedRange.Single(cell => cell.Address == StageColumnHeading); IEnumerable <ExcelRangeBase> timestampColumn = _excelUsedRange.Single(cell => cell.Address == TimestampColumnHeading); progressDialogController.SetMessage("Headings found..."); progressDialogController.SetProgress(100); List <DataValueModel> values = new List <DataValueModel>(); int numberOfRows = _excelWorksheet.Dimension.Rows; progressDialogController.SetMessage("Beginning to read Worksheet..."); progressDialogController.SetProgress(0); progressDialogController.Maximum = numberOfRows; for (int currentRow = dataColumn.First().Start.Row; currentRow < numberOfRows; currentRow++) { object dataCellValue = _excelWorksheet.Cells[currentRow, dataColumn.First().Start.Column].Value; object stageCellValue = _excelWorksheet.Cells[currentRow, stageColumn.First().Start.Column].Value; object timestampCellValue = _excelWorksheet.Cells[currentRow, timestampColumn.First().Start.Column].Value; if (dataCellValue.IsNumeric() && stageCellValue != null && timestampCellValue != null && FilterRow(currentRow)) { values.Add(new DataValueModel { Stage = int.Parse(Regex.Match(_excelWorksheet.Cells[currentRow, stageColumn.First().Start.Column].Value.ToString(), @"\d+", RegexOptions.RightToLeft).Value), Value = double.Parse(_excelWorksheet.Cells[currentRow, dataColumn.First().Start.Column].Value.ToString()), Timestamp = DateTime.Parse(_excelWorksheet.Cells[currentRow, timestampColumn.First().Start.Column].Value.ToString().Replace("\"", ""), CultureInfo.InvariantCulture) }); } progressDialogController.SetMessage($"Reading row {currentRow} of {numberOfRows}..."); progressDialogController.SetProgress(currentRow); } DataSetModel dataSetModel = new DataSetModel { DataName = DataName, DataUnitOfMeasurement = DataUnitOfMeasurement, Values = values }; MessengerInstance.Send((dataSetModel, _wellID), MessageTokenStrings.AddDataToManager); }); await progressDialogController.CloseAsync(); }
// Retrieve all usable MP4 files in a directory private void OpenWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { // Update the progress message and set to indeterminate _progressDlg.SetMessage("Scanning Directory for compatible files.\r\nExtracting GPS Coordinates and Speed Data."); _progressDlg.SetIndeterminate(); // Organise into journies gpsWorker.RunWorkerAsync(); gpsWorker2.RunWorkerAsync(); }
/// <summary> /// Saves the favorites to text asynchronous. /// </summary> /// <param name="dbName">Name of the database.</param> /// <param name="progressResult">The progress result.</param> /// <param name="system">The system.</param> /// <returns></returns> /// <exception cref="Exception">Failed saving database</exception> private async Task SaveFavoritesAsync(ProgressDialogController progressResult, string system) { progressResult.SetMessage("Saving Favorites"); if (!await _hyperspinManager.SaveFavorites(system)) { ; } progressResult.SetMessage(system + " favorites saved."); }
/// <summary> /// Saves the XML asynchronous. /// </summary> /// <param name="dbName">Name of the database.</param> /// <param name="progressResult">The progress result.</param> /// <param name="system">The system.</param> /// <returns></returns> /// <exception cref="Exception">Failed saving database</exception> private async Task SaveXmlAsync(string dbName, ProgressDialogController progressResult, string system) { progressResult.SetMessage("Saving Database"); if (!await _hyperspinManager.SaveCurrentGamesListToXmlAsync(system, dbName)) { throw new Exception("Failed saving database"); } progressResult.SetMessage(dbName + " Database saved."); }
/// <summary> /// Saves the genre XMLS. /// </summary> /// <param name="progressResult">The progress result.</param> /// <param name="system">The system.</param> /// <returns></returns> /// <exception cref="Exception">Failed saving genre databases</exception> private async Task SaveGenreXmls(ProgressDialogController progressResult, string system) { progressResult.SetMessage("Saving genres.."); if (!await _hyperspinManager.SaveCurrentGamesListToGenreXmlsAsync(system)) { throw new Exception("Failed saving genre databases"); } progressResult.SetMessage("Genre databases saved.."); }
private List <BulkExportModel> GetTimers(ProgressDialogController dialogController, List <JiraTimer> timers) { var timersToShow = new List <BulkExportModel>(); var issuesRetrieved = new List <Issue>(); var timersToGet = timers.Where(x => !x.TempTimer && !x.IsRunning).ToList(); for (var i = 0; i < timersToGet.Count; i++) { var timerToShow = timersToGet[i]; var requireRefresh = !timerToShow.LastJiraTimeCheck.HasValue || timerToShow.LastJiraTimeCheck < DateTime.UtcNow.AddMinutes(-15); var model = new BulkExportModel(timerToShow, modelHelpers.Gallifrey.Settings.ExportSettings); var jiraIssue = issuesRetrieved.FirstOrDefault(x => x.key == timerToShow.JiraReference); if (i == 0) { dialogController.SetMessage($"Downloading Jira Work Logs For {timerToShow.JiraReference} To Ensure Accurate Export"); } else { dialogController.SetMessage($"Downloading Jira Work Logs For {timerToShow.JiraReference} To Ensure Accurate Export\nDone {i} Of {timersToGet.Count}"); } if (jiraIssue == null) { try { jiraIssue = modelHelpers.Gallifrey.JiraConnection.GetJiraIssue(timerToShow.JiraReference, requireRefresh); issuesRetrieved.Add(jiraIssue); } catch (Exception) { throw new BulkExportException($"Unable To Locate Jira {timerToShow.JiraReference}!\nCannot Export Time\nPlease Verify/Correct Jira Reference"); } } if (requireRefresh) { modelHelpers.Gallifrey.JiraTimerCollection.RefreshFromJira(timerToShow.UniqueId, jiraIssue, modelHelpers.Gallifrey.JiraConnection.CurrentUser); timerToShow = modelHelpers.Gallifrey.JiraTimerCollection.GetTimer(timerToShow.UniqueId); } if (!timerToShow.FullyExported) { model.UpdateTimer(timerToShow, jiraIssue); timersToShow.Add(model); } } return(timersToShow); }
public async Task ShowDefaultProgressAsync(string title, string message) { if (_defaultProgressDialogController == null) { _defaultProgressDialogController = await _dialogCoordinator.ShowProgressAsync(_dialogHost.DataContext, title, message); _defaultProgressDialogController.SetIndeterminate(); } else { _defaultProgressDialogController.SetTitle(title); _defaultProgressDialogController.SetMessage(message); } }
private IResult WriteProjectFile(string projectLocation, string projectFileName, ProjectModel projectModel, ProgressDialogController controller) { controller.SetMessage("Writing project file..."); try { _fileService.WriteAllText(Path.Combine(projectLocation, projectFileName), JsonConvert.SerializeObject(projectModel, Formatting.Indented)); controller.SetMessage("Writing project file... Done!"); return(new SuccessResult("Project file written to disk.")); } catch (Exception ex) { return(new FailureResult("Failed to create the project file.", ex)); } }
public ImageFile Scan(ProgressDialogController ctrl, bool colorSetting = true) { try { var image = new ImageFile(); var dialog = new CommonDialog(); ctrl.SetTitle("STARTING SCANNER"); ctrl.SetMessage("This can take a few seconds..."); var x = dialog.ShowSelectDevice(WiaDeviceType.ScannerDeviceType, false, false); var item = x.Items[1]; // HorizontalResolution item.Properties["6147"].set_Value(75); // VerticalResolution item.Properties["6148"].set_Value(75); // CurrentInten, 1 - Color, 4 - Black & White if (colorSetting) { item.Properties["6146"].set_Value(1); } else { item.Properties["6146"].set_Value(4); } image = dialog.ShowTransfer(item, "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}", true); if (image != null) { ctrl.SetTitle("SCANNING FINISHED!"); ctrl.SetMessage($"File Scanned Successfully..."); } return(image); } catch (COMException ex) { if (ex.ErrorCode == -2145320939) { throw new ScannerNotFoundException(); } else { throw new ScannerException(ex.Message, ex); } } }
public MainWindow() { InitializeComponent(); Loaded += async(sender, e) => { ProgressDialogController progressDialog = await ShowProgressDialog("Loading...", "Loading tasks...").ConfigureAwait(false); await Config.LoadConfig(); Dispatcher.Invoke(() => ProgramTitle.Content = Config.WindowTitle ?? "..."); Dispatcher.Invoke(() => { if (!Config.EnablePunishmentTasks) { PunishmentTasksGrid.IsEnabled = false; PunishmentTasksGrid.Visibility = Visibility.Collapsed; } }); progressDialog.SetProgress(0.8); await Task.Delay(100).ConfigureAwait(false); progressDialog.SetMessage("Loading Task Buttons..."); Dispatcher.Invoke(InitTaskButtons); await Task.Delay(130).ConfigureAwait(false); Dispatcher.Invoke(() => RemainingTasksLabel.Content = $"{GetAvailableTasksCount()}/{GetTotalTasksCount()}"); progressDialog.SetProgress(1); await progressDialog.CloseAsync().ConfigureAwait(false); }; }
public static void SetDefaultProgressMessage(string message) { if (ProgressDialogController != null) { ProgressDialogController.SetMessage(message); } }
private async void GeneratorProgressUpdate(object sender, ProgressEventArgs e) { if (e.IsFinished) { DumpTimigs(generator.Timing); ErrorsCount = generator.ErrorsCount; generator.Dispose(); excelStream.Dispose(); templateStream.Dispose(); await controller.CloseAsync(); if (Completed != null) { Completed(this, EventArgs.Empty); } } else { if (controller.IsCanceled) { generator.CancellationRequested = true; } controller.SetProgress(e.Progress); controller.SetMessage(e.StepName); } }
private async Task ProgressFailed(ProgressDialogController controller, String reason) { controller.SetMessage("Failure to login: " + reason); await Task.Delay(1500); await controller.CloseAsync(); }
private void Callback(string arg) { if (pdc != null) { pdc.SetMessage(arg); } }
private async Task RunOrderScripts(List <Order> orders, ProgressDialogController progressDialog) { List <UserScript> scripts; using (var dbContext = _contextFactory.Get()) { scripts = dbContext.UserScripts.Where(x => x.Type == UserScriptType.OrderScript).ToList(); } for (int i = 0; i < scripts.Count; i++) { progressDialog.SetProgress((double)i / scripts.Count); progressDialog.SetMessage("Running script: " + scripts[i].Name); try { await ScriptRunner.RunOrderScript(scripts[i], orders);//todo: this will run subsequent scripts with orders set to a trade... orders = orders.Where(y => y.Trade == null).ToList(); } catch (Exception ex) { _logger.Error(ex, "User script {0} generated an exception: ", scripts[i].Name); await DialogService.ShowMessageAsync(this, "Error", $"User script {scripts[i].Name} generated an exception. See log for more details."); } } }
public void ImportSystemConfigFromDisk(ProgressDialogController controller, GSystem sys) { _ConfigBaseSettings = ConfigBaseSettings.GetConfig(2000000000 + sys.systemId); if (_ConfigBaseSettings == null) { // invalid config id return; } string configPath = _Paths.mednafenExe + @"\" + sys.systemCode + ".cfg"; var specCfg = LoadConfigFromDisk(configPath); if (specCfg.Count == 0) { return; } // data was returned - begin import if (controller != null) { controller.SetMessage("Importing " + sys.systemCode + ".cfg"); } ParseConfigIncoming(specCfg, 2000000000 + sys.systemId); // set to enabled //_ConfigBaseSettings.isEnabled = true; //ConfigBaseSettings.SetConfig(_ConfigBaseSettings); }
private async Task RunTradeScripts(ProgressDialogController progressDialog) { List <UserScript> scripts; using (var dbContext = _contextFactory.Get()) { scripts = dbContext.UserScripts.Where(x => x.Type == UserScriptType.TradeScript).ToList(); } for (int i = 0; i < scripts.Count; i++) { progressDialog.SetProgress((double)i / scripts.Count); progressDialog.SetMessage("Running script: " + scripts[i].Name); try { await ScriptRunner.RunTradeScript(scripts[i]).ConfigureAwait(false); } catch (Exception ex) { _logger.Error(ex, "User script {0} generated an exception: ", scripts[i].Name); await DialogService.ShowMessageAsync(this, "Error", $"User script {scripts[i].Name} generated an exception. See log for more details."); } } }
/* * public void ImportConfigsFromDisk(ProgressDialogController controller) * { * if (controller != null) * controller.SetMessage("Importing Mednafen Configs from disk\nPlease wait....."); * * _ConfigBaseSettings = ConfigBaseSettings.GetConfig(2000000000); * * // get a list of current systems * List<GSystem> systems = GSystem.GetSystems(); * * // first import base config * ImportBaseConfigFromDisk(null); * * // now iterate through each system and search/import system specific config files * foreach (GSystem sys in systems) * { * ImportSystemConfigFromDisk(null, sys); * } * } */ public void ImportBaseConfigFromDisk(ProgressDialogController controller) { string cfgPath = _Paths.mednafenExe + @"\mednafen-09x.cfg"; var config = LoadConfigFromDisk(cfgPath); if (config.Count > 0) { // data was returned - begin import if (controller != null) { controller.SetMessage("Importing mednafen-09x.cfg"); } ParseConfigIncoming(config, 0); // now save to the database /* * if (controller != null) * controller.SetMessage("Saving base settings to database"); * * ConfigBaseSettings.SetConfig(_ConfigBaseSettings); * ConfigNetplaySettings.SetNetplay(_ConfigNetplaySettings); * ConfigServerSettings.SaveToDatabase(_ConfigServerSettings); */ } }
private async void ConnectionManager_PluginUploadStarted(object sender, EventArgs e) { ProgressDialogController progressDialog = null; EventHandler <PluginUploadProgressChangedEventArgs> handler = null; var alreadyFinished = false; handler = (s, args) => { progressDialog?.SetProgress(args.Progress); progressDialog?.SetMessage( $"{FormatBytesConverter.BytesToString(args.BytesSent)} {Application.Current.Resources["Of"]} {FormatBytesConverter.BytesToString(args.TotalBytes)}"); if (Math.Abs(args.Progress - 1) < .1) { ((MainViewModel)DataContext).ConnectionManager.PluginUploadProgressChanged -= handler; progressDialog?.CloseAsync(); alreadyFinished = true; } }; ((MainViewModel)DataContext).ConnectionManager.PluginUploadProgressChanged += handler; progressDialog = await this.ShowProgressAsync((string)Application.Current.Resources["UploadingPlugin"], ""); if (alreadyFinished) { await progressDialog.CloseAsync(); } }
private async Task RemoveFilterEntriesAsync(Regex regex, ProgressDialogController controller) { var removeMessage = "Removing entry..."; await Task.Run(() => { var toRemove = DisplayedSongs .Where(x => !regex.IsMatch(x.Name)) .ToList(); controller.Minimum = 0; controller.Maximum = toRemove.Count; for (int i = 0; i < toRemove.Count; i++) { var currentItemNumber = i + 1; Application.Current.Dispatcher.Invoke(() => { DisplayedSongs.Remove(toRemove[i]); }); controller.SetProgress(currentItemNumber); controller.SetMessage(String.Format("{0} ({1}/{2})", removeMessage, currentItemNumber, toRemove.Count)); } }); }
private void DoExport(ProgressDialogController dialogController, List <BulkExportModel> timersToExport) { for (var i = 0; i < timersToExport.Count; i++) { var exportModel = timersToExport[i]; dialogController.SetMessage(i == 0 ? $"Exporting Timer {exportModel.JiraRef} For {exportModel.ExportDate.Date:ddd, dd MMM}" : $"Exporting Timer {exportModel.JiraRef} For {exportModel.ExportDate.Date:ddd, dd MMM}\nDone {i} Of {timersToExport.Count}"); try { var jiraRef = exportModel.JiraRef; var date = exportModel.ExportDate; var toExport = exportModel.ToExport; var strategy = exportModel.WorkLogStrategy; var comment = exportModel.Comment; var remaining = exportModel.Remaining; var standardComment = exportModel.StandardComment; modelHelpers.Gallifrey.JiraConnection.LogTime(jiraRef, date, toExport, strategy, standardComment, comment, remaining); modelHelpers.Gallifrey.JiraTimerCollection.AddJiraExportedTime(exportModel.Timer.UniqueId, exportModel.ToExportHours ?? 0, exportModel.ToExportMinutes ?? 0); } catch (WorkLogException ex) { if (ex.InnerException != null) { throw new BulkExportException($"Error Logging Work To {exportModel.JiraRef}\n\nError Message From Jira: { ex.InnerException.Message }"); } throw new BulkExportException($"Error Logging Work To {exportModel.JiraRef}"); } catch (CommentException) { throw new BulkExportException($"The Comment Was Not Added To Jira {exportModel.JiraRef}"); } } }
public async Task RestartService() { ProgressDialogController progress = null; try { progress = await this.dialogCoordinator.ShowProgressAsync(this, "Restarting service", "Waiting for the service to stop", false); progress.SetIndeterminate(); await this.windowsServiceProvider.StopServiceAsync(); progress.SetMessage("Wating for the service to start"); await this.windowsServiceProvider.StartServiceAsync(); } catch (Exception ex) { logger.LogError(EventIDs.UIGenericError, ex, "Could not restart service"); } finally { if (progress?.IsOpen ?? false) { await progress.CloseAsync(); } } }