This commit is contained in:
@@ -118,11 +118,30 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Prime the Report Templates
|
||||
/// </summary>
|
||||
public static async Task PrimeReportTemplates()
|
||||
{
|
||||
//Read in each stock translation from a text file and then create them in the DB
|
||||
var ReportFilesPath = Path.Combine(ServerBootConfig.AYANOVA_CONTENT_ROOT_PATH, "resource\\rpt\\stock-report-templates");
|
||||
if (!Directory.Exists(ReportFilesPath))
|
||||
{
|
||||
throw new System.Exception($"E1012: \"resource\\rpt\\stock-report-templates\" folder not found where expected: \"{ReportFilesPath}\", installation damaged?");
|
||||
}
|
||||
|
||||
//iterate all ayrt files and import each one
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
ReportBiz r = ReportBiz.GetBiz(ct);
|
||||
|
||||
|
||||
|
||||
|
||||
System.IO.DirectoryInfo di = new DirectoryInfo(ReportFilesPath);
|
||||
foreach (FileInfo file in di.EnumerateFiles())
|
||||
{
|
||||
await r.ImportAsync(JObject.Parse(await File.ReadAllTextAsync(file.FullName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}//eoc
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"Name":"EXAMPLE API use and meta data","Active":true,"Notes":"","Roles":124927,"ObjectType":2,"Template":"<html>\n\n<body>\n\t<h2>Example: Meta data and API usage</h2>\n\t<p>See help documentation for details</p>\n\t\n\t<div>\n\t\t<h4>ayServerMetaData</h4>\n\t\t{{ ayJSON ayServerMetaData }}\n\t</div>\n\n\t<div>\n\t\t<h4>ayClientMetaData</h4>\n\t\t{{ ayJSON ayClientMetaData }}\n\t</div>\n\n\t<div>\n\t\t<h4>ayReportMetaData</h4>\n\t\t{{ ayJSON ayReportMetaData }}\n\t</div>\n\n\n\t<div>\n\t\t<h4>myData</h4>\n\t\t<h5>(Fetched dynamically from API route <strong>enum-list/list/AyaType</strong>)</h5>\n\t\t{{ ayJSON myData }}\n\t</div>\n\n\t<div>\n\t\t<h4>ayReportData</h4>\n\t\t{{#each ayReportData}}\n\t\t<h2>{{ Name }}</h2>\n\t\t<div>Notes: <span class=\"example\">{{ Notes }}</span></div>\n\t\t{{/each}}\n\t</div>\n</body>\n\n</html>","Style":".example {\n color: blue;\n}","JsPrerender":"async function ayPrepareData(reportData) {\n //this function (if present) is called with the report data \n //before the report is rendered\n //modify data as required here and return it to change the data before the report renders \n\n //Example of using API GET method to fetch data from API server and make it available to the report template\n let route=`${reportData.ayServerMetaData.ayApiUrl}server-info`;\n\n //Put the data into the main report data object so it's available to the template\n reportData.myData={ServerInfo:await ayGetFromAPI(route, reportData.ayClientMetaData.Authorization)};\n\n //Example API POST method to fetch data from api server\n route=`${reportData.ayServerMetaData.ayApiUrl}search`;\n let searchPostData={phrase: \"Fish\"};\n reportData.myData.SearchResults=await ayPostToAPI(route, reportData.ayClientMetaData.Authorization,searchPostData);\n\n return reportData;\n}","JsHelpers":"//Register custom Handlebars helpers here to use in your report script\n//https://handlebarsjs.com/guide/#custom-helpers\nHandlebars.registerHelper('loud', function (aString) {\n return aString.toUpperCase()\n})","RenderType":0}
|
||||
@@ -0,0 +1 @@
|
||||
{"Name":"EXAMPLE Translation helper","Active":true,"Notes":"","Roles":124927,"ObjectType":2,"Template":"<html>\n\n<body>\n\n\t<h2>Example: Translation helper </h2>\n\t<p>See help documentation for details</p>\n\t\n\t<div>\n\t\t<h4>ayReportData</h4>\n\t\t{{#each ayReportData}}\n\t\t<h2>{{ayT 'WidgetName' }}: {{ Name }}</h2>\n\t\t<div>{{ayT 'WidgetNotes' }}: <span class=\"example\">{{ Notes }}</span></div>\n\t\t{{/each}}\n\t</div>\n</body>\n\n</html>","Style":".example {\n color: blue;\n}","JsPrerender":"async function ayPrepareData(reportData){ \n //Fetch translation keys required for report\n //Server will get the translations that match the current logged in user's language \n //Only translation keys pre-fetched here will be available for use with the ayT translation helper\n ayGetTranslations([\n \"Widget\",\n \"WidgetName\",\n \"WidgetSerial\",\n \"WidgetDollarAmount\",\n \"WidgetCount\",\n \"WidgetStartDate\",\n \"WidgetEndDate\",\n \"WidgetNotes\",\n \"WidgetCustom1\",\n \"WidgetCustom2\",\n \"WidgetCustom3\",\n \"WidgetCustom4\",\n \"WidgetCustom5\",\n \"WidgetCustom6\",\n \"WidgetCustom7\",\n \"WidgetCustom8\",\n \"WidgetCustom9\",\n \"WidgetCustom10\",\n \"WidgetCustom11\",\n \"WidgetCustom12\",\n \"WidgetCustom13\",\n \"WidgetCustom14\",\n \"WidgetCustom15\",\n \"WidgetCustom16\",\n ]);\n \n return reportData;\n}","JsHelpers":"//Register custom Handlebars helpers here to use in your report script\n//https://handlebarsjs.com/guide/#custom-helpers\nHandlebars.registerHelper('loud', function (aString) {\n return aString.toUpperCase()\n})","RenderType":0}
|
||||
@@ -0,0 +1 @@
|
||||
{"Name":"EXAMPLE localization helpers","Active":true,"Notes":"","Roles":124927,"ObjectType":2,"Template":"<html>\n\n<body>\n\t<h2>Example: Localization helpers </h2>\n\t<p>See help documentation for details</p>\n\n\t<div>\n\t\t<h3>Client locale settings used</h3>\n\t\tBrowser TimeZone: {{ ayClientMetaData.TimeZoneName }}<br/>\n\t\tBrowser LanguageName: {{ ayClientMetaData.LanguageName }}<br/>\n\t\tHour12: {{ ayClientMetaData.Hour12 }}<br/>\n\t\tCurrencyName: {{ ayClientMetaData.CurrencyName }}<br/>\n\t</div>\n\t<div>\n\t\t{{#each ayReportData}}\n\t\t<h2>{{ayT 'WidgetName' }}: {{ Name }}</h2>\n\t\tStartDate as DateTime: {{ ayDateTime StartDate}} <br/>\n\t\tStartDate as Date : {{ ayDate StartDate}} <br/>\n\t\tStartDate as Time: {{ ayTime StartDate}} <br/>\n\t\tDollarAmount as Currency: {{ ayCurrency DollarAmount}} <br/>\n\t\tDollarAmount as Number: {{ ayDecimal DollarAmount}} <br/>\n\t\t<hr />\n\t\t{{/each}}\n\t</div>\n</body>\n\n</html>","Style":".example {\n color: blue;\n}","JsPrerender":"async function ayPrepareData(reportData){ \n return reportData;\n}","JsHelpers":"//Register custom Handlebars helpers here to use in your report script\n//https://handlebarsjs.com/guide/#custom-helpers\nHandlebars.registerHelper('loud', function (aString) {\n return aString.toUpperCase()\n})","RenderType":0}
|
||||
@@ -725,6 +725,9 @@ $BODY$;
|
||||
await ExecQueryAsync("CREATE TABLE areport (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " +
|
||||
"notes text, roles integer not null, objecttype integer not null, template text, style text, jsprerender text, jshelpers text, rendertype integer not null )");
|
||||
await SetSchemaLevelAsync(++currentSchema);
|
||||
|
||||
//Load the stock REPORT TEMPLATES
|
||||
await AyaNova.Biz.PrimeData.PrimeReportTemplates();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user