This commit is contained in:
2020-09-22 23:46:34 +00:00
parent 912f58d176
commit 28beeaf783

View File

@@ -97,7 +97,10 @@ namespace AyaNova.Biz
internal async Task<bool> ImportAsync(JObject o)
{
Report newObject = new Report();
//Report newObject = new Report();
var newObject = o.ToObject<Report>();
var proposedName = (string)o["Name"];
string newUniqueName = proposedName;
bool NotUnique = true;
@@ -111,15 +114,35 @@ namespace AyaNova.Biz
} 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"];
// This was stupid considering JObject can serialize directly to a report type
//but leaving in for a little while just to be sure it's all good
// 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"];
// //pdf options
// newObject.HeaderTemplate = (string)o["HeaderTemplate"];
// newObject.FooterTemplate = (string)o["FooterTemplate"];
// newObject.MarginOptionsBottom = (string)o["MarginOptionsBottom"];
// newObject.MarginOptionsLeft = (string)o["MarginOptionsLeft"];
// newObject.MarginOptionsRight = (string)o["MarginOptionsRight"];
// newObject.MarginOptionsTop = (string)o["MarginOptionsTop"];
// newObject.PageRanges = (string)o["PageRanges"];
// newObject.PaperFormat = (ReportPaperFormat)(int)o["PaperFormat"];
// newObject.DisplayHeaderFooter = (bool)o["DisplayHeaderFooter"];
// newObject.Landscape = (bool)o["Landscape"];
// newObject.PreferCSSPageSize = (bool)o["PreferCSSPageSize"];
// newObject.PrintBackground = (bool)o["PrintBackground"];
// newObject.Scale = (decimal)o["Scale"];
await ValidateAsync(newObject, null);
if (HasErrors) return false;
await ct.Report.AddAsync(newObject);
@@ -185,7 +208,7 @@ namespace AyaNova.Biz
Report dbObject = await ct.Report.SingleOrDefaultAsync(z => z.Id == id);
ValidateCanDelete(dbObject);
if (HasErrors)
return false;
return false;
ct.Report.Remove(dbObject);
await ct.SaveChangesAsync();
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
@@ -574,22 +597,22 @@ namespace AyaNova.Biz
if (!string.IsNullOrWhiteSpace(report.MarginOptionsBottom))
PdfOptions.MarginOptions.Bottom = report.MarginOptionsBottom;
if (!string.IsNullOrWhiteSpace(report.MarginOptionsLeft))
if (!string.IsNullOrWhiteSpace(report.MarginOptionsLeft))
PdfOptions.MarginOptions.Left = report.MarginOptionsLeft;
if (!string.IsNullOrWhiteSpace(report.MarginOptionsRight))
if (!string.IsNullOrWhiteSpace(report.MarginOptionsRight))
PdfOptions.MarginOptions.Right = report.MarginOptionsRight;
if (!string.IsNullOrWhiteSpace(report.MarginOptionsTop))
if (!string.IsNullOrWhiteSpace(report.MarginOptionsTop))
PdfOptions.MarginOptions.Top = report.MarginOptionsTop;
//holding this back until figure it out
//it's not really a report property, but a print time / render property
//PdfOptions.PageRanges=report.PageRanges;
PdfOptions.PreferCSSPageSize=report.PreferCSSPageSize;
PdfOptions.PrintBackground=report.PrintBackground;
PdfOptions.Scale=report.Scale;
PdfOptions.PreferCSSPageSize = report.PreferCSSPageSize;
PdfOptions.PrintBackground = report.PrintBackground;
PdfOptions.Scale = report.Scale;
//render to pdf and return
log.LogDebug($"Calling render page contents to PDF");