|
@@ -20,6 +20,7 @@ using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
|
using System.Linq;
|
|
|
+using System.Reflection.Metadata;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
@@ -217,58 +218,46 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
var model = GetReportPLCInfo(id);
|
|
|
var document = new InvoiceDocument(model);
|
|
|
//pdf名称为轴编号+时间
|
|
|
- string strDt = "报表" + string.Format("{0:yyyyMMddHHmm}", DateTime.Now)+ ".pdf"; ;
|
|
|
- string pathToPDF = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "PDF", strDt);
|
|
|
-
|
|
|
+
|
|
|
//输出文件
|
|
|
+ using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog()
|
|
|
+ {
|
|
|
+ //设置文件类型
|
|
|
+ //书写规则例如:txt files(*.txt)|*.txt
|
|
|
+ Filter = "pdf文件|*.pdf",
|
|
|
+ //设置默认文件名(可以不设置)
|
|
|
+ FileName = "报表" + string.Format("{0:yyyyMMddHHmm}", DateTime.Now),
|
|
|
+
|
|
|
+ //获取或设置一个值,该值指示如果用户省略扩展名,文件对话框是否自动在文件名中添加扩展名。(可以不设置)
|
|
|
+ AddExtension = true,
|
|
|
+
|
|
|
+ //保存对话框是否记忆上次打开的目录
|
|
|
+ RestoreDirectory = true
|
|
|
+ })
|
|
|
+ {
|
|
|
+
|
|
|
|
|
|
- document.GeneratePdf(pathToPDF);
|
|
|
- MessageBox.Show("生成PDF报告成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
+ //点了保存按钮进入
|
|
|
+ if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
|
+ {
|
|
|
+ //获得文件路径
|
|
|
+ string localFilePath = saveFileDialog.FileName.ToString();
|
|
|
+ document.GeneratePdf(localFilePath);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
_logger.LogError(ex.ToString());
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog()
|
|
|
- //{
|
|
|
- // //设置文件类型
|
|
|
- // //书写规则例如:txt files(*.txt)|*.txt
|
|
|
- // Filter = "pdf文|*.pdf",
|
|
|
- // //设置默认文件名(可以不设置)
|
|
|
- // FileName = "报表" + string.Format("{0:yyyyMMddHHmm}", DateTime.Now),
|
|
|
-
|
|
|
- // //获取或设置一个值,该值指示如果用户省略扩展名,文件对话框是否自动在文件名中添加扩展名。(可以不设置)
|
|
|
- // AddExtension = true,
|
|
|
-
|
|
|
- // //保存对话框是否记忆上次打开的目录
|
|
|
- // RestoreDirectory = true
|
|
|
- //})
|
|
|
- //{
|
|
|
-
|
|
|
|
|
|
- // //点了保存按钮进入
|
|
|
- // if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
|
- // {
|
|
|
- // try
|
|
|
- // {
|
|
|
- // //获得文件路径
|
|
|
- // string localFilePath = saveFileDialog.FileName.ToString();
|
|
|
|
|
|
|
|
|
- // document.GeneratePdf(localFilePath);
|
|
|
- // }
|
|
|
- // catch (Exception ex)
|
|
|
- // {
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
- //}
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|