This commit is contained in:
@@ -304,9 +304,9 @@ namespace AyaNova.Api.Controllers
|
|||||||
await Task.Delay(nFailedAuthDelay);//fishing protection
|
await Task.Delay(nFailedAuthDelay);//fishing protection
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
var FilePath = FileUtil.GetFullPathForTemporaryFile(fileName);
|
var FilePath = FileUtil.GetFullPathForTemporaryFile(fileName);
|
||||||
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(DownloadUser.Id, 0, AyaType.NoType, AyaEvent.UtilityFileDownload, fileName), ct);
|
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(DownloadUser.Id, 0, AyaType.NoType, AyaEvent.UtilityFileDownload, fileName), ct);
|
||||||
return PhysicalFile(FilePath, "application/pdf");
|
return PhysicalFile(FilePath, "application/pdf");
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -502,7 +502,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
|
|
||||||
var aylogo = $"{{small:'{API_URL}logo/small',medium:'{API_URL}logo/medium',large:'{API_URL}logo/large'}}";
|
var aylogo = $"{{small:'{API_URL}logo/small',medium:'{API_URL}logo/medium',large:'{API_URL}logo/large'}}";
|
||||||
var reportData = "{ person: { firstname: ' First', lastname: '[NAME]' },aylogo:[AYLOGO], mdtest:'| CODE | MEANING |\\n| ----- | ------------------------------ |\\n| E1000 | Could not connect to the database specified in the [connection string](ops-config-db.md). |\\n| E1050 | XXXXXXXX |\\n| E1012 | Missing resource folder. AyaNova was started from the wrong location or was not installed properly. |\\n' }";
|
var reportData = "{ person: { firstname: 'Thatcher', lastname: '[NAME]' },aylogo:[AYLOGO], mdtest:'| CODE | MEANING |\\n| ----- | ------------------------------ |\\n| E1000 | Could not connect to the database specified in the [connection string](ops-config-db.md). |\\n| E1050 | XXXXXXXX |\\n| E1012 | Missing resource folder. AyaNova was started from the wrong location or was not installed properly. |\\n' }";
|
||||||
reportData = reportData.Replace("[AYLOGO]", aylogo);
|
reportData = reportData.Replace("[AYLOGO]", aylogo);
|
||||||
reportData = reportData.Replace("[NAME]", nameItem.Name);
|
reportData = reportData.Replace("[NAME]", nameItem.Name);
|
||||||
|
|
||||||
@@ -535,8 +535,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
//test add helpers
|
//test add helpers
|
||||||
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-report.js") });
|
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-report.js") });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//execute to add to handlebars
|
//execute to add to handlebars
|
||||||
await page.EvaluateExpressionAsync("ayRegisterHelpers();");
|
await page.EvaluateExpressionAsync("ayRegisterHelpers();");
|
||||||
|
|
||||||
@@ -550,13 +548,16 @@ namespace AyaNova.Api.Controllers
|
|||||||
//add style (after page or it won't work)
|
//add style (after page or it won't work)
|
||||||
await page.AddStyleTagAsync(new AddTagOptions { Content = reportCSS });
|
await page.AddStyleTagAsync(new AddTagOptions { Content = reportCSS });
|
||||||
|
|
||||||
//useful for debugging purposes only
|
string outputFileName = StringUtil.ReplaceLastOccurrence(FileUtil.NewRandomFileName, ".", "") + ".pdf";
|
||||||
//var pagecontent = await page.GetContentAsync();
|
string outputFullPath = System.IO.Path.Combine(FileUtil.TemporaryFilesFolder, outputFileName);
|
||||||
|
|
||||||
//render to pdf and return
|
//render to pdf and return
|
||||||
var pdfBuffer = await page.PdfDataAsync();
|
await page.PdfAsync(outputFullPath);
|
||||||
|
log.LogDebug($"returning results now:");
|
||||||
|
|
||||||
log.LogInformation($"returning results now:");
|
log.LogInformation($"returning results now:");
|
||||||
return new FileContentResult(pdfBuffer, "application/pdf");
|
return Ok(ApiOkResponse.Response(outputFileName));
|
||||||
|
// return new FileContentResult(pdfBuffer, "application/pdf");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user