Explorar el Código

修复闪退问题,升级1.1.1

Kevin hace 5 años
padre
commit
01387affbd

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
GetEasy.Node.Printer.Test/Form1.cs


+ 42 - 20
GetEasy.Node.Printer/NodeReportDesigner.cs

@@ -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

BIN
GetEasy.Node.Printer/dll/GetEasy.Node.Printer.64.dll


BIN
GetEasy.Node.Printer/dll/GetEasy.Node.Printer.86.dll


BIN
GetEasy.Node.Printer/dll/GetEasy.Node.Printer.dll


+ 3 - 3
GetEasy.Node.Printer/index.ts

@@ -25,7 +25,7 @@ let callbackPointer: Buffer;
 const dll = ffi.Library(dllPath, {
     designerReport: ['void', ['string', 'string']],
     reportShowPreview: ['void', ['string', 'string']],
-    reportPrinter: ['void', ['string', 'string']],
+    reportPrinter: ['void', ['string', 'string', 'bool']],
     waitSaveOrClose: ['void', ['pointer']]
 });
 type SaveCallback = (saveTemplate: string, callback: (result: boolean) => void) => void;
@@ -79,7 +79,7 @@ export default class ReportApi {
      * @param {string} jsonData 数据
      * @memberof ReportApi
      */
-    static reportPrinter(fileName: string, jsonData: string): void {
-        dll.reportPrinter(fileName, jsonData);
+    static reportPrinter(fileName: string, jsonData: string, isSelectPrinter: boolean): void {
+        dll.reportPrinter(fileName, jsonData, isSelectPrinter);
     }
 }

+ 1 - 1
GetEasy.Node.Printer/package-lock.json

@@ -1,6 +1,6 @@
 {
   "name": "geteasy.node.printer",
-  "version": "1.0.8",
+  "version": "1.1.0",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {

+ 1 - 1
GetEasy.Node.Printer/package.json

@@ -1,6 +1,6 @@
 {
   "name": "geteasy.node.printer",
-  "version": "1.0.9",
+  "version": "1.1.1",
   "description": "",
   "main": "index.js",
   "scripts": {

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio