注入参数到节点模块时遇到麻烦

上下文


我目前正在开发一个引擎,用Asp.Net Core生成HighMaps脚本。

为了做到这一点,我使用API Microsoft.AspNetCore.NodeServices来执行由HighChart提供的节点模块(请参阅https://github.com/highcharts/node-export-server )。

我已经按照这个链接来实现一个解决schemehttps://davidsekar.com/angular/server-side-rendering-of-highcharts-in-net-core 。

问题


我的代码包含在下面:

节点模块

/** * https://github.com/highcharts/node-export-server */ const exporter = require('highcharts-export-server'); // Set up a pool of PhantomJS workers let config = { maxWorkers: 10, initialWorkers: 5, reaper: true, listenToProcessExits: true }; // exporter.logLevel(4); exporter.initPool(config); // Export settings // var exportSettings = { type: 'png', options: { title: { text: 'My Chart' }, xAxis: { categories: ["Jan", "Feb", "Mar", "Apr", "Mar", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] }, series: [{ type: 'line', data: [1, 3, 2, 4] }, { type: 'line', data: [5, 3, 4, 2] }] } }; module.exports = { generateHighChart: (callback, configurationHighMaps) => { try { //console.log(configurationHighMaps); console.log(exporter); //var exportSettings2 = { type: exportSettings.type, options: exportSettings.chartOptions, scale: 2, sourceWidth: '1170', sourceHeight: '300' }; // Perform an export // Export/Chart settings corresponds to the available CLI arguments. exporter.export(configurationHighMaps, (err, res) => { // try { // The export result is now in res. // If the output is not PDF or SVG, it will be base64 encoded (res.data). // If the output is a PDF or SVG, it will contain a filename (res.filename). // exporter.killPool(); // process.exit(1); Immediate exit will cause error in .Net Core NodeServices //} catch (innerError) { // exporter.log(4, 'Kill throws error : ' + innerError); //} //callback(err, res); callback(err, JSON.stringify(res)); }); } catch (err) { callback(err, null); }; } }; // For testing // exp.generateHighChart(function () { }, exportSettings); 

控制器:

 private async Task<StructureFichier> GenererCarteStatistiqueAsync(ConfigurationHighMaps poConfigurationHighMaps) { JObject loConfigurationHighMaps = JObject.FromObject(poConfigurationHighMaps); string lbytFichier = await mNodeServices.InvokeExportAsync<string>(@"wwwroot\HighMaps\v5\Moteur\MoteurHighMaps.js", "generateHighChart", loConfigurationHighMaps.ToString()); string lsrCheminComplet = Directory.GetCurrentDirectory() + "/modeles/" + "test.png"; //System.IO.File.WriteAllBytes(lsrCheminComplet, lbytFichier); return new StructureFichier(lsrCheminComplet); } 

当我执行方法GenererCarteStatistiqueAsync ,我有这个InvokeExportAsync引发的错误。

调用节点模块失败,出现错误:没有给出input


我提供的参数有什么问题?