From 227e6ec2cc43e303b0dbd690db2585bd1515f954 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 23 Dec 2021 22:17:19 +0000 Subject: [PATCH] --- .../ops-config-report-rendering-timeout.md | 6 +- server/AyaNova/biz/QuoteBiz.cs | 136 ++++++++++++++---- server/AyaNova/util/ServerBootConfig.cs | 2 +- 3 files changed, 110 insertions(+), 34 deletions(-) diff --git a/docs/8.0/ayanova/docs/ops-config-report-rendering-timeout.md b/docs/8.0/ayanova/docs/ops-config-report-rendering-timeout.md index 801a4dc6..7ce0da20 100644 --- a/docs/8.0/ayanova/docs/ops-config-report-rendering-timeout.md +++ b/docs/8.0/ayanova/docs/ops-config-report-rendering-timeout.md @@ -30,9 +30,9 @@ The value is specified in **minutes**. If no override is specified AyaNova will use the following default value: -`3` +`5` -This means AyaNova will wait for a prior report to complete for no longer than 3 minutes before it will stop and return an error. +This means AyaNova will wait for a prior report to complete for no longer than 5 minutes before it will stop and return an error. ## MINIMUM / MAXIMUM @@ -46,7 +46,7 @@ AyaNova expects this value to be provided by a config.json property, environment `AYANOVA_REPORT_RENDERING_TIMEOUT` The value specified should be a string specifying the timeout in **minutes**, for example: -`30000` +`10` Example config.json entry diff --git a/server/AyaNova/biz/QuoteBiz.cs b/server/AyaNova/biz/QuoteBiz.cs index d804d68a..d1377530 100644 --- a/server/AyaNova/biz/QuoteBiz.cs +++ b/server/AyaNova/biz/QuoteBiz.cs @@ -61,6 +61,9 @@ namespace AyaNova.Biz } + //request cache for viz fields + private VizCache vc = new VizCache(); + private ObjectCache oc = new ObjectCache(); /* ██████╗ ██╗ ██╗ ██████╗ ████████╗███████╗ @@ -859,38 +862,111 @@ namespace AyaNova.Biz //Alert notes //Customer notes first then others below - var custInfo = await ct.Customer.AsNoTracking().Where(x => x.Id == o.CustomerId).Select(x => new { x.AlertNotes, x.TechNotes, x.Name, x.Phone1, x.Phone2, x.Phone3, x.Phone4, x.Phone5, x.EmailAddress }).FirstOrDefaultAsync(); - if (!string.IsNullOrWhiteSpace(custInfo.AlertNotes)) { - o.AlertViz = $"{await Translate("Customer")} - {await Translate("AlertNotes")}\n{custInfo.AlertNotes}\n\n"; - } - - if (!string.IsNullOrWhiteSpace(custInfo.TechNotes)) - { - o.CustomerTechNotesViz = $"{await Translate("CustomerTechNotes")}\n{custInfo.TechNotes}\n\n"; - } - - o.CustomerViz = custInfo.Name; - o.CustomerPhone1Viz = custInfo.Phone1; - o.CustomerPhone2Viz = custInfo.Phone2; - o.CustomerPhone3Viz = custInfo.Phone3; - o.CustomerPhone4Viz = custInfo.Phone4; - o.CustomerPhone5Viz = custInfo.Phone5; - o.CustomerEmailAddressViz = custInfo.EmailAddress; - - if (o.ProjectId != null) - o.ProjectViz = await ct.Project.AsNoTracking().Where(x => x.Id == o.ProjectId).Select(x => x.Name).FirstOrDefaultAsync(); - - if (o.PreparedById != null) - o.PreparedByViz = await ct.User.AsNoTracking().Where(x => x.Id == o.PreparedById).Select(x => x.Name).FirstOrDefaultAsync(); - - if (o.ContractId != null) - { - var contractVizFields = await ct.Contract.AsNoTracking().Where(x => x.Id == o.ContractId).Select(x => new { Name = x.Name, AlertNotes = x.AlertNotes }).FirstOrDefaultAsync(); - o.ContractViz = contractVizFields.Name; - if (!string.IsNullOrWhiteSpace(contractVizFields.AlertNotes)) + if (vc.Get("wocustname", o.CustomerId) == null)//will always be present so no need to check other values { - o.AlertViz += $"{await Translate("Contract")}\n{contractVizFields.AlertNotes}\n\n"; + var custInfo = await ct.Customer.AsNoTracking().Where(x => x.Id == o.CustomerId).Select(x => new { x.AlertNotes, x.TechNotes, x.Name, x.Phone1, x.Phone2, x.Phone3, x.Phone4, x.Phone5, x.EmailAddress }).FirstOrDefaultAsync(); + vc.Add(custInfo.Name, "wocustname", o.CustomerId); + if (!string.IsNullOrWhiteSpace(custInfo.AlertNotes)) + { + vc.Add($"{await Translate("Customer")} - {await Translate("AlertNotes")}\n{custInfo.AlertNotes}\n\n", "woalert", o.CustomerId); + } + else + { + vc.Add(string.Empty, "woalert", o.CustomerId); + } + + if (!string.IsNullOrWhiteSpace(custInfo.TechNotes)) + { + vc.Add($"{await Translate("CustomerTechNotes")}\n{custInfo.TechNotes}\n\n", "custtechnotes", o.CustomerId); + } + + vc.Add(custInfo.Phone1, "custphone1", o.CustomerId); + vc.Add(custInfo.Phone2, "custphone2", o.CustomerId); + vc.Add(custInfo.Phone3, "custphone3", o.CustomerId); + vc.Add(custInfo.Phone4, "custphone4", o.CustomerId); + vc.Add(custInfo.Phone5, "custphone5", o.CustomerId); + vc.Add(custInfo.EmailAddress, "custemail", o.CustomerId); + } + o.CustomerViz = vc.Get("wocustname", o.CustomerId); + o.AlertViz = vc.Get("woalert", o.CustomerId); + o.CustomerTechNotesViz = vc.Get("custtechnotes", o.CustomerId); + o.CustomerPhone1Viz = vc.Get("custphone1", o.CustomerId); + o.CustomerPhone2Viz = vc.Get("custphone2", o.CustomerId); + o.CustomerPhone3Viz = vc.Get("custphone3", o.CustomerId); + o.CustomerPhone4Viz = vc.Get("custphone4", o.CustomerId); + o.CustomerPhone5Viz = vc.Get("custphone5", o.CustomerId); + o.CustomerEmailAddressViz = vc.Get("custemail", o.CustomerId); + + } + // var custInfo = await ct.Customer.AsNoTracking().Where(x => x.Id == o.CustomerId).Select(x => new { x.AlertNotes, x.TechNotes, x.Name, x.Phone1, x.Phone2, x.Phone3, x.Phone4, x.Phone5, x.EmailAddress }).FirstOrDefaultAsync(); + // if (!string.IsNullOrWhiteSpace(custInfo.AlertNotes)) + // { + // o.AlertViz = $"{await Translate("Customer")} - {await Translate("AlertNotes")}\n{custInfo.AlertNotes}\n\n"; + // } + + // if (!string.IsNullOrWhiteSpace(custInfo.TechNotes)) + // { + // o.CustomerTechNotesViz = $"{await Translate("CustomerTechNotes")}\n{custInfo.TechNotes}\n\n"; + // } + + // o.CustomerViz = custInfo.Name; + // o.CustomerPhone1Viz = custInfo.Phone1; + // o.CustomerPhone2Viz = custInfo.Phone2; + // o.CustomerPhone3Viz = custInfo.Phone3; + // o.CustomerPhone4Viz = custInfo.Phone4; + // o.CustomerPhone5Viz = custInfo.Phone5; + // o.CustomerEmailAddressViz = custInfo.EmailAddress; + + // if (o.ProjectId != null) + // o.ProjectViz = await ct.Project.AsNoTracking().Where(x => x.Id == o.ProjectId).Select(x => x.Name).FirstOrDefaultAsync(); + if (o.ProjectId != null) + { + string value = vc.Get("projname", o.ProjectId); + if (value == null) + { + value = await ct.Project.AsNoTracking().Where(x => x.Id == o.ProjectId).Select(x => x.Name).FirstOrDefaultAsync(); + vc.Add(value, "projname", o.ProjectId); + } + o.ProjectViz = value; + } + + // if (o.PreparedById != null) + // o.PreparedByViz = await ct.User.AsNoTracking().Where(x => x.Id == o.PreparedById).Select(x => x.Name).FirstOrDefaultAsync(); + + if (o.PreparedById != null) + { + if (!vc.Has("user", o.PreparedById)) + { + vc.Add(await ct.User.AsNoTracking().Where(x => x.Id == o.PreparedById).Select(x => x.Name).FirstOrDefaultAsync(), "user", o.PreparedById); + } + o.PreparedByViz = vc.Get("user", o.PreparedById); + } + + // if (o.ContractId != null) + // { + // var contractVizFields = await ct.Contract.AsNoTracking().Where(x => x.Id == o.ContractId).Select(x => new { Name = x.Name, AlertNotes = x.AlertNotes }).FirstOrDefaultAsync(); + // o.ContractViz = contractVizFields.Name; + // if (!string.IsNullOrWhiteSpace(contractVizFields.AlertNotes)) + // { + // o.AlertViz += $"{await Translate("Contract")}\n{contractVizFields.AlertNotes}\n\n"; + // } + // } + // else + // o.ContractViz = "-"; + if (o.ContractId != null) + { + if (vc.Get("ctrctname", o.ContractId) == null) + { + var contractVizFields = await ct.Contract.AsNoTracking().Where(x => x.Id == o.ContractId).Select(x => new { Name = x.Name, AlertNotes = x.AlertNotes }).FirstOrDefaultAsync(); + vc.Add(contractVizFields.Name, "ctrctname", o.ContractId); + vc.Add(contractVizFields.AlertNotes, "ctrctalrt", o.ContractId); + } + o.ContractViz = vc.Get("ctrctname", o.ContractId);//contractVizFields.Name; + var alrtNotes = vc.Get("ctrctalrt", o.ContractId); + if (!string.IsNullOrWhiteSpace(alrtNotes)) + { + o.AlertViz += $"{await Translate("Contract")}\n{alrtNotes}\n\n"; } } else diff --git a/server/AyaNova/util/ServerBootConfig.cs b/server/AyaNova/util/ServerBootConfig.cs index fa83e0b4..c11d8f84 100644 --- a/server/AyaNova/util/ServerBootConfig.cs +++ b/server/AyaNova/util/ServerBootConfig.cs @@ -181,7 +181,7 @@ namespace AyaNova.Util //PROCESS CONTROL int? nTemp = config.GetValue("AYANOVA_REPORT_RENDERING_TIMEOUT"); - AYANOVA_REPORT_RENDERING_TIMEOUT = (null == nTemp) ? 3 : (int)nTemp;//default is 3 minutes + AYANOVA_REPORT_RENDERING_TIMEOUT = (null == nTemp) ? 5 : (int)nTemp;//default is 3 minutes if (AYANOVA_REPORT_RENDERING_TIMEOUT < 1) AYANOVA_REPORT_RENDERING_TIMEOUT = 1; //one minute minimum timeout if (AYANOVA_REPORT_RENDERING_TIMEOUT > 15) AYANOVA_REPORT_RENDERING_TIMEOUT = 15; //15 minutes maximum timeout