public async Task DoExportResourceChartToCsvAsync()
        {
            try
            {
                IsBusy = true;
                string directory = m_ProjectSettingService.PlanDirectory;
                if (m_FileDialogService.ShowSaveDialog(
                        directory,
                        Properties.Resources.Filter_SaveCsvFileType,
                        Properties.Resources.Filter_SaveCsvFileExtension) == DialogResult.OK)
                {
                    string filename = m_FileDialogService.Filename;
                    if (string.IsNullOrWhiteSpace(filename))
                    {
                        DispatchNotification(
                            Properties.Resources.Title_Error,
                            Properties.Resources.Message_EmptyFilename);
                    }
                    else
                    {
                        DataTable dataTable = await BuildResourceChartDataTableAsync();

                        await ChartHelper.ExportDataTableToCsvAsync(dataTable, filename);

                        m_ProjectSettingService.SetDirectory(filename);
                    }
                }
            }
            catch (Exception ex)
            {
                DispatchNotification(
                    Properties.Resources.Title_Error,
                    ex.Message);
            }
            finally
            {
                IsBusy = false;
                RaiseCanExecuteChangedAllCommands();
            }
        }
示例#2
0
 private void ExportGraphML_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string directory = m_ProjectSettingService.PlanDirectory;
         if (m_FileDialogService.ShowSaveDialog(
                 directory,
                 Properties.Resources.Filter_SaveGraphMLFileType,
                 Properties.Resources.Filter_SaveGraphMLFileExtension) == DialogResult.OK)
         {
             {
                 string filename = m_FileDialogService.Filename;
                 if (string.IsNullOrWhiteSpace(filename))
                 {
                     System.Windows.MessageBox.Show(
                         Properties.Resources.Message_EmptyFilename,
                         Properties.Resources.Title_Error,
                         MessageBoxButton.OKCancel,
                         MessageBoxImage.Error);
                 }
                 else
                 {
                     File.WriteAllBytes(
                         filename,
                         ViewModel.ExportArrowGraphToDiagram(
                             ArrowGraphAreaCtrl.ToDiagramArrowGraphDto()));
                     m_ProjectSettingService.SetDirectory(filename);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show(
             ex.Message,
             Properties.Resources.Title_Error,
             MessageBoxButton.OKCancel,
             MessageBoxImage.Error);
     }
 }