|
@@ -39,8 +39,13 @@ namespace GetEasy.Node.Printer
|
|
|
//private static Dictionary<Guid, SaveResultCallback> dicResult = new Dictionary<Guid, SaveResultCallback>();
|
|
|
static NodeReportDesigner()
|
|
|
{
|
|
|
+ //AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
|
|
|
}
|
|
|
-
|
|
|
+ //private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
|
|
|
+ //{
|
|
|
+ // MessageBox.Show(args.Name + "加载失败");
|
|
|
+ // return null;
|
|
|
+ //}
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
|
|
|
public delegate void SaveCallback([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]String template, SaveResultCallback resultCallback);
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
|
|
@@ -172,27 +177,44 @@ namespace GetEasy.Node.Printer
|
|
|
|
|
|
|
|
|
[DllExport(CallingConvention = CallingConvention.Winapi, ExportName = "reportPrinter")]
|
|
|
- public static void ReportPrinter([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]String fileName, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]String jsonData)
|
|
|
+ public static void ReportPrinter([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]String fileName, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]String jsonData, bool isSelectPrinter)
|
|
|
{
|
|
|
- // 加载 Newtonsoft.Json;
|
|
|
- JsonConvert.DeserializeObject("{}");
|
|
|
- Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-CN");
|
|
|
- Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-CN");
|
|
|
- var report = XtraReport.FromFile(fileName);
|
|
|
-
|
|
|
- JsonDataSource dataSource = null;
|
|
|
- if (report.DataSource != null && report.DataSource is JsonDataSource)
|
|
|
- {
|
|
|
- dataSource = report.DataSource as JsonDataSource;
|
|
|
- }
|
|
|
- else
|
|
|
+ var thread = new Thread(() =>
|
|
|
{
|
|
|
- dataSource = new JsonDataSource();
|
|
|
- }
|
|
|
- var jsonDataSource = new CustomJsonSource(jsonData);
|
|
|
- dataSource.JsonSource = jsonDataSource;
|
|
|
- report.DataSource = dataSource;
|
|
|
- report.Print();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-CN");
|
|
|
+ //Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-CN");
|
|
|
+ var report = XtraReport.FromFile(fileName);
|
|
|
+
|
|
|
+ JsonDataSource dataSource = null;
|
|
|
+ if (report.DataSource != null && report.DataSource is JsonDataSource)
|
|
|
+ {
|
|
|
+ dataSource = report.DataSource as JsonDataSource;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dataSource = new JsonDataSource();
|
|
|
+ }
|
|
|
+ var jsonDataSource = new CustomJsonSource(jsonData);
|
|
|
+ dataSource.JsonSource = jsonDataSource;
|
|
|
+ report.DataSource = dataSource;
|
|
|
+ if (isSelectPrinter)
|
|
|
+ {
|
|
|
+ report.PrintDialog();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ report.Print();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ MessageBox.Show(e.InnerException.Message + '\n' + e.InnerException.StackTrace);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ thread.SetApartmentState(ApartmentState.STA);
|
|
|
+ thread.Start();
|
|
|
}
|
|
|
|
|
|
public class SaveObj
|