Example #1
0
 private static void SaveFile(string defaultFilePath, Report report)
 {
     SaveFileDialog saveDialog = new SaveFileDialog();
     saveDialog.InitialDirectory = System.IO.Path.GetDirectoryName(defaultFilePath);
     saveDialog.Filter = "Файлы Excel|*.xlsx";
     if (saveDialog.ShowDialog() == true)
     {
         try
         {
             report.Save(saveDialog.FileName);
         }
         catch (System.IO.IOException ex)
         {
             ErrorSave(defaultFilePath, report, ex);
             throw;
         }
     }
 }
Example #2
0
 private async void btnExecute_Click(object sender, RoutedEventArgs e)
 {
     EnableButton(false);
     Report report = new Report(fileName);
     report.Start += MainWindow_ReportStart;
     report.Complete += Save;
     try
     {
         await Task.Run(() => report.Create());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка чтения файла", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Example #3
0
 private static void ErrorSave(string defaultFilePath, Report report, System.IO.IOException ex)
 {
     string message = string.Format("{0}\nСохранить отчет в другом файле?", ex.Message);
     MessageBoxResult res = MessageBox.Show(message, "Ошибка сохранения отчета",
     MessageBoxButton.OKCancel, MessageBoxImage.Error);
     if (res == MessageBoxResult.OK)
     {
         SaveFile(defaultFilePath, report);
     }
 }
Example #4
0
 public static void Main(string[] argv)
 {
     string fileName = argv[0];
     Report report = new Report(fileName);
     report.Create();
 }