|
@@ -9,15 +9,11 @@ exports.__esModule = true;
|
|
|
// designerReport('', true);
|
|
|
var ffi = require("ffi");
|
|
|
var os = require("os");
|
|
|
-var cpu = os.arch() === "x64" ? "64" : "86";
|
|
|
-var callback = ffi.Callback('void', ['int', 'string'], function (id, name) {
|
|
|
- console.log("id: ", id);
|
|
|
- console.log("name: ", name);
|
|
|
-});
|
|
|
-var dll = ffi.Library(__dirname + "/dll/GetEasy.Node.Printer." + cpu + ".dll", {
|
|
|
- designerReport: ["void", ["string", "string", "pointer"]],
|
|
|
- reportShowPreview: ["void", ["string", "string"]],
|
|
|
- reportPrinter: ["void", ["string", "string"]]
|
|
|
+var cpu = os.arch() === 'x64' ? '64' : '86';
|
|
|
+var dll = ffi.Library(__dirname + '/dll/GetEasy.Node.Printer.' + cpu + '.dll', {
|
|
|
+ designerReport: ['void', ['string', 'string', 'pointer']],
|
|
|
+ reportShowPreview: ['void', ['string', 'string']],
|
|
|
+ reportPrinter: ['void', ['string', 'string']]
|
|
|
});
|
|
|
var ReportApi = /** @class */ (function () {
|
|
|
function ReportApi() {
|
|
@@ -30,7 +26,23 @@ var ReportApi = /** @class */ (function () {
|
|
|
* @memberof ReportApi
|
|
|
*/
|
|
|
ReportApi.designerReport = function (template, tempData, saveCallback) {
|
|
|
- var callbackPointer = ffi.Callback('bool', ['string'], saveCallback);
|
|
|
+ var callbackPointer = ffi.Callback('void', ['string', 'pointer'], function (data, func) {
|
|
|
+ var nativeCallback = ffi.ForeignFunction(func, 'void', ['bool']);
|
|
|
+ try {
|
|
|
+ saveCallback(data, function (result) {
|
|
|
+ if (result) {
|
|
|
+ nativeCallback(true);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ nativeCallback(false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ console.error(e);
|
|
|
+ nativeCallback(false);
|
|
|
+ }
|
|
|
+ });
|
|
|
dll.designerReport(template, tempData, callbackPointer);
|
|
|
};
|
|
|
/**
|