/// <summary> /// Create report with showing SaveFileDialog /// </summary> /// <param name="format">type of creating report</param> public void CreateReport(DefaultDialogs.TargetFileType format) { try { DefaultDialogs dialogs = new DefaultDialogs(); if (dialogs.SaveFileDialog(format) == true) { IReportCreator creator = GetIReportCreatorFromReportFormat(format); creator.CreateReport(dialogs.FilePath, properties.ToList()); } } catch (NullReferenceException e) { DefaultDialogs.ShowMessage("Не удалось создать отчет, возможно не достаточно свободной памяти\n" + "Системное описание ошибки" + e.Message, "Ошибка"); } catch (IOException e) { DefaultDialogs.ShowMessage(e.Message, "Ошибка"); } catch (Exception e) { DefaultDialogs.ShowMessage("Не опознанная ошибка!\n" + "Системное описание ошибки" + e.Message, "Ошибка"); } }
/// <summary> /// Create report with battery information /// </summary> /// <param name="creator">object, which can create report (implement required interface)</param> private void CreateNewReport(IReportCreator creator) { try { if (CommandParams.Length > 1) { MainWindowViewModel vm = new MainWindowViewModel(); creator.CreateReport(CommandParams[1], vm.properties.ToList()); TryPrintErrorToParrentConsole(null, "\t *** Отчет успешно создан! *** \n", false); } else { throw new ArgumentException("Ошибка! Путь для файла не передан"); } } catch (ArgumentException e) { TryPrintErrorToParrentConsole(e, e.Message, false); } catch (IOException e) { TryPrintErrorToParrentConsole(e, e.Message, false); } catch (Exception e) { TryPrintErrorToParrentConsole(e, "Ошибка, не удалось создать отчет", true); } }