This commit is contained in:
@@ -666,7 +666,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
|
|
||||||
//generate an internal JWT key for reporting purposes used by corejobnotify to send reports as manager account
|
//generate an internal JWT key for reporting purposes used by corejobnotify to send reports as manager account
|
||||||
internal static string GenRpt()
|
internal static string GenRpt(long overrideLanguageId)
|
||||||
{
|
{
|
||||||
byte[] secretKey = System.Text.Encoding.ASCII.GetBytes(ServerBootConfig.AYANOVA_JWT_SECRET);
|
byte[] secretKey = System.Text.Encoding.ASCII.GetBytes(ServerBootConfig.AYANOVA_JWT_SECRET);
|
||||||
var iat = new DateTimeOffset(DateTime.Now.ToUniversalTime(), TimeSpan.Zero);
|
var iat = new DateTimeOffset(DateTime.Now.ToUniversalTime(), TimeSpan.Zero);
|
||||||
@@ -676,7 +676,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
{ "exp", exp.ToUnixTimeSeconds().ToString() },//in payload exp must be in unix epoch time per standard
|
{ "exp", exp.ToUnixTimeSeconds().ToString() },//in payload exp must be in unix epoch time per standard
|
||||||
{ "iss", "ayanova.com" },
|
{ "iss", "ayanova.com" },
|
||||||
{ "id", "1"},
|
{ "id", "1"},
|
||||||
{ "j","1" }
|
{ "rpl",overrideLanguageId.ToString() }
|
||||||
};
|
};
|
||||||
return Jose.JWT.Encode(payload, secretKey, Jose.JwsAlgorithm.HS256);
|
return Jose.JWT.Encode(payload, secretKey, Jose.JwsAlgorithm.HS256);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -492,10 +492,15 @@ namespace AyaNova
|
|||||||
//check if token has j value set
|
//check if token has j value set
|
||||||
if (context.Request.IsLocal())
|
if (context.Request.IsLocal())
|
||||||
{
|
{
|
||||||
if (context.User.Claims.FirstOrDefault(c => c.Type == "j") != null)
|
//if this is a generate report internal token this will be the override language set
|
||||||
|
//and it's existance is enough to indicate it was set internally by this server
|
||||||
|
var rpl=context.User.Claims.FirstOrDefault(c => c.Type == "rpl");
|
||||||
|
if ( rpl!= null)
|
||||||
{
|
{
|
||||||
//it's a local request, the jwt already passed earlier so we issued it and it has the correct claim set so allow it
|
//it's a local request, the jwt already passed earlier so we issued it and it has the correct claim set so allow it
|
||||||
bLocalReportRenderRequest = true;
|
bLocalReportRenderRequest = true;
|
||||||
|
//set override language
|
||||||
|
context.Request.HttpContext.Items["AY_TRANSLATION_ID"]=Convert.ToInt64(rpl.Value);
|
||||||
await next.Invoke();
|
await next.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,8 +343,9 @@ namespace AyaNova.Biz
|
|||||||
//generate a workorder report here get the path and send it with the message
|
//generate a workorder report here get the path and send it with the message
|
||||||
using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext)
|
using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext)
|
||||||
{
|
{
|
||||||
|
long overrideLanguageId=2;
|
||||||
|
|
||||||
ReportBiz biz = ReportBiz.GetBiz(ct);
|
ReportBiz biz = new ReportBiz(ct,1,overrideLanguageId,AuthorizationRoles.BizAdmin);
|
||||||
//example with workorder report
|
//example with workorder report
|
||||||
//{"AType":34,"selectedRowIds":[355],"ReportId":9,"ClientMeta":{"UserName":"AyaNova SuperUser","Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOiIxNjQ2NzgyNTc4IiwiaXNzIjoiYXlhbm92YS5jb20iLCJpZCI6IjEifQ.ad7Acq54JCRGitDWKDJFFnqKkidbdaKaFmj-RA_RG5E","DownloadToken":"NdoU8ca3LG4L39Tj2oi3UReeeM7FLevTgbgopTPhGbA","TimeZoneName":"America/Los_Angeles","LanguageName":"en-US","Hour12":true,"CurrencyName":"USD","DefaultLocale":"en","PDFDate":"3/3/22","PDFTime":"3:38 PM"}}
|
//{"AType":34,"selectedRowIds":[355],"ReportId":9,"ClientMeta":{"UserName":"AyaNova SuperUser","Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOiIxNjQ2NzgyNTc4IiwiaXNzIjoiYXlhbm92YS5jb20iLCJpZCI6IjEifQ.ad7Acq54JCRGitDWKDJFFnqKkidbdaKaFmj-RA_RG5E","DownloadToken":"NdoU8ca3LG4L39Tj2oi3UReeeM7FLevTgbgopTPhGbA","TimeZoneName":"America/Los_Angeles","LanguageName":"en-US","Hour12":true,"CurrencyName":"USD","DefaultLocale":"en","PDFDate":"3/3/22","PDFTime":"3:38 PM"}}
|
||||||
|
|
||||||
@@ -352,7 +353,7 @@ namespace AyaNova.Biz
|
|||||||
reportRequest.AType = AyaType.WorkOrder;
|
reportRequest.AType = AyaType.WorkOrder;
|
||||||
reportRequest.ReportId = 9;
|
reportRequest.ReportId = 9;
|
||||||
reportRequest.SelectedRowIds = new long[] { 1 };
|
reportRequest.SelectedRowIds = new long[] { 1 };
|
||||||
var jwt = Api.Controllers.AuthController.GenRpt();
|
var jwt = Api.Controllers.AuthController.GenRpt(overrideLanguageId);
|
||||||
reportRequest.ClientMeta = JToken.Parse($"{{'UserName':'AyaNova SuperUser','Authorization':'Bearer {jwt}','TimeZoneName':'America/Los_Angeles','LanguageName':'en-US','Hour12':true,'CurrencyName':'USD','DefaultLocale':'en','PDFDate':'3/3/22','PDFTime':'3:38 PM'}}");
|
reportRequest.ClientMeta = JToken.Parse($"{{'UserName':'AyaNova SuperUser','Authorization':'Bearer {jwt}','TimeZoneName':'America/Los_Angeles','LanguageName':'en-US','Hour12':true,'CurrencyName':'USD','DefaultLocale':'en','PDFDate':'3/3/22','PDFTime':'3:38 PM'}}");
|
||||||
//get port number
|
//get port number
|
||||||
var match = System.Text.RegularExpressions.Regex.Match(ServerBootConfig.AYANOVA_USE_URLS, "[0-9]+");
|
var match = System.Text.RegularExpressions.Regex.Match(ServerBootConfig.AYANOVA_USE_URLS, "[0-9]+");
|
||||||
@@ -373,7 +374,6 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
case JobStatus.Completed:
|
case JobStatus.Completed:
|
||||||
{
|
{
|
||||||
//todo: get report path and send it
|
|
||||||
//get job logs and parse file name from it
|
//get job logs and parse file name from it
|
||||||
JobOperationsBiz jobopsbiz = new JobOperationsBiz(ct, 1, AuthorizationRoles.BizAdmin);
|
JobOperationsBiz jobopsbiz = new JobOperationsBiz(ct, 1, AuthorizationRoles.BizAdmin);
|
||||||
List<JobOperationsLogInfoItem> log = await jobopsbiz.GetJobLogListAsync((Guid)jobid);
|
List<JobOperationsLogInfoItem> log = await jobopsbiz.GetJobLogListAsync((Guid)jobid);
|
||||||
|
|||||||
Reference in New Issue
Block a user