This commit is contained in:
@@ -9,6 +9,7 @@ using AyaNova.Api.ControllerHelpers;
|
||||
using AyaNova.Models;
|
||||
using EnumsNET;
|
||||
using PuppeteerSharp;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace AyaNova.Biz
|
||||
{
|
||||
@@ -86,6 +87,44 @@ namespace AyaNova.Biz
|
||||
return newObject;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//IMPORT
|
||||
//
|
||||
internal async Task<bool> ImportAsync(JObject o)
|
||||
{
|
||||
|
||||
Report newObject = new Report();
|
||||
var proposedName = (string)o["Name"];
|
||||
string newUniqueName = proposedName;
|
||||
bool NotUnique = true;
|
||||
long l = 1;
|
||||
do
|
||||
{
|
||||
NotUnique = await ct.Report.AnyAsync(z => z.Name == newUniqueName);
|
||||
if (NotUnique)
|
||||
newUniqueName = Util.StringUtil.UniqueNameBuilder(proposedName, l++, 255);
|
||||
|
||||
} while (NotUnique);
|
||||
|
||||
newObject.Name = newUniqueName;
|
||||
newObject.Active = (bool)o["Active"];
|
||||
newObject.JsHelpers = (string)o["JsHelpers"];
|
||||
newObject.JsPrerender = (string)o["JsPrerender"];
|
||||
newObject.Notes = (string)o["Notes"];
|
||||
newObject.ObjectType = (AyaType)(int)o["ObjectType"];
|
||||
newObject.RenderType = (ReportRenderType)(int)o["RenderType"];
|
||||
newObject.Roles = (AuthorizationRoles)(int)o["Roles"];
|
||||
newObject.Style = (string)o["Style"];
|
||||
newObject.Template = (string)o["Template"];
|
||||
await ValidateAsync(newObject, null);
|
||||
if (HasErrors) return false;
|
||||
await ct.Report.AddAsync(newObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//GET
|
||||
//
|
||||
@@ -326,7 +365,7 @@ namespace AyaNova.Biz
|
||||
await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
|
||||
}
|
||||
|
||||
//https://stackoverflow.com/questions/53367966/puppeteer-sharp-still-appear-many-chromium-instance-in-process-task-manager-when
|
||||
//https://stackoverflow.com/questions/53367966/puppeteer-sharp-still-appear-many-chromium-instance-in-process-task-manager-when
|
||||
log.LogDebug($"Launching headless Chrome now:");
|
||||
using (var browser = await Puppeteer.LaunchAsync(lo))
|
||||
using (var page = await browser.NewPageAsync())
|
||||
@@ -359,12 +398,12 @@ namespace AyaNova.Biz
|
||||
var clientMeta = "{}";
|
||||
if (reportParam.ClientMeta != null)
|
||||
clientMeta = reportParam.ClientMeta.ToString();
|
||||
// await page.AddScriptTagAsync(new AddTagOptions() { Content = $"var ayClientMetaData = {clientMeta}" });
|
||||
// await page.AddScriptTagAsync(new AddTagOptions() { Content = $"var ayClientMetaData = {clientMeta}" });
|
||||
|
||||
//this is how you view the contents of the page
|
||||
#if (DEBUG)
|
||||
var pagecontent = await page.GetContentAsync();
|
||||
|
||||
|
||||
#endif
|
||||
//compile and run handlebars template
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@ using AyaNova.Util;
|
||||
using AyaNova.Api.ControllerHelpers;
|
||||
using AyaNova.Models;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace AyaNova.Biz
|
||||
|
||||
Reference in New Issue
Block a user