This commit is contained in:
@@ -353,16 +353,11 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Missing required FormFieldData value: FileData"));
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Missing required FormFieldData value: FileData"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//fileData in JSON stringify format which contains the actual last modified dates etc
|
//fileData in JSON stringify format
|
||||||
//"[{\"name\":\"Client.csv\",\"lastModified\":1582822079618},{\"name\":\"wmi4fu06nrs41.jpg\",\"lastModified\":1586900220990}]"
|
|
||||||
FileData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<UploadFileData>>(uploadFormData.FormFieldData["FileData"].ToString());
|
FileData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<UploadFileData>>(uploadFormData.FormFieldData["FileData"].ToString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// long UserId = UserIdFromContext.Id(HttpContext.Items);
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
TranslationBiz biz = TranslationBiz.GetBiz(ct, HttpContext);
|
ReportBiz biz = ReportBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
|
|
||||||
//We have our files now can parse and insert into db
|
//We have our files now can parse and insert into db
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using AyaNova.Api.ControllerHelpers;
|
|||||||
using AyaNova.Models;
|
using AyaNova.Models;
|
||||||
using EnumsNET;
|
using EnumsNET;
|
||||||
using PuppeteerSharp;
|
using PuppeteerSharp;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace AyaNova.Biz
|
namespace AyaNova.Biz
|
||||||
{
|
{
|
||||||
@@ -86,6 +87,44 @@ namespace AyaNova.Biz
|
|||||||
return newObject;
|
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
|
//GET
|
||||||
//
|
//
|
||||||
@@ -326,7 +365,7 @@ namespace AyaNova.Biz
|
|||||||
await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
|
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:");
|
log.LogDebug($"Launching headless Chrome now:");
|
||||||
using (var browser = await Puppeteer.LaunchAsync(lo))
|
using (var browser = await Puppeteer.LaunchAsync(lo))
|
||||||
using (var page = await browser.NewPageAsync())
|
using (var page = await browser.NewPageAsync())
|
||||||
@@ -359,12 +398,12 @@ namespace AyaNova.Biz
|
|||||||
var clientMeta = "{}";
|
var clientMeta = "{}";
|
||||||
if (reportParam.ClientMeta != null)
|
if (reportParam.ClientMeta != null)
|
||||||
clientMeta = reportParam.ClientMeta.ToString();
|
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
|
//this is how you view the contents of the page
|
||||||
#if (DEBUG)
|
#if (DEBUG)
|
||||||
var pagecontent = await page.GetContentAsync();
|
var pagecontent = await page.GetContentAsync();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
//compile and run handlebars template
|
//compile and run handlebars template
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ using AyaNova.Util;
|
|||||||
using AyaNova.Api.ControllerHelpers;
|
using AyaNova.Api.ControllerHelpers;
|
||||||
using AyaNova.Models;
|
using AyaNova.Models;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Serialization;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace AyaNova.Biz
|
namespace AyaNova.Biz
|
||||||
|
|||||||
Reference in New Issue
Block a user