コード例 #1
0
        private async Task <Report> RenderAsync(string requestString, CancellationToken ct = default(CancellationToken))
        {
            var reqFile = Path.Combine(_tempPath, $"req{Guid.NewGuid().ToString()}.json");

            File.WriteAllText(reqFile, requestString);

            var outFile  = Path.Combine(_tempPath, $"out{Guid.NewGuid().ToString()}");
            var metaFile = Path.Combine(_tempPath, $"meta{Guid.NewGuid().ToString()}");
            var output   = await _binaryProcess.ExecuteExe($"render --keepAlive --request=\"{reqFile}\" --out=\"{outFile}\" --meta=\"{metaFile}\"").ConfigureAwait(false);

            if (output.IsError)
            {
                throw new JsReportBinaryException("Error rendering report: " + output.Logs, output.Logs, output.Command);
            }

            var metaDictionary = new Dictionary <string, string>();
            var meta           = JObject.Parse(File.ReadAllText(metaFile));

            meta.Properties().ToList().ForEach(p => metaDictionary[p.Name] = meta[p.Name].ToString());

            return(new Report()
            {
                Content = File.OpenRead(outFile),
                Meta = SerializerHelper.ParseReportMeta(metaDictionary)
            });
        }
コード例 #2
0
        public async Task <ILocalWebServerReportingService> StartAsync()
        {
            _serverProcess = (await _binaryProcess.ExecuteExe("start", false)).Process;
            await WaitForStarted();

            _started = true;
            return(this);
        }