From 7fe8ba9a3d22e8a4d1b69ceba1e1685238611431 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 22 Dec 2021 22:43:38 +0000 Subject: [PATCH] --- server/AyaNova/biz/WorkOrderBiz.cs | 12 +++++------- server/AyaNova/util/VizCache.cs | 9 +++++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index 9b56516e..5da986c7 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -6181,8 +6181,8 @@ namespace AyaNova.Biz private async Task UnitPopulateVizFields(WorkOrderItemUnit o, bool populateForReporting) { //see if it's in the cache already, populate the cache fully if not - bool UnitHasModel=false; - if (vc.Get("unitserial", o.UnitId) == null) + bool UnitHasModel = false; + if (!vc.Has("unitserial", o.UnitId)) { //cache it var unitInfo = await ct.Unit.AsNoTracking() @@ -6201,12 +6201,12 @@ namespace AyaNova.Biz if (unitInfo.UnitModelId != null) { - UnitHasModel=true; + UnitHasModel = true; //units model name cached? (if it is then the rest will be cached as well) - if (vc.Get("unitsmodelname", o.UnitId) == null) + if (!vc.Has("unitsmodelname", o.UnitId)) { //nope, model name cached?? - if (vc.Get("unitmodelname", unitInfo.UnitModelId) == null) + if (!vc.Has("unitmodelname", unitInfo.UnitModelId)) { //nope, so cache it all var unitModelInfo = await ct.UnitModel.AsNoTracking().Where(x => x.Id == unitInfo.UnitModelId).Select(x => new { x.Name, x.VendorId }).FirstOrDefaultAsync(); @@ -6245,8 +6245,6 @@ namespace AyaNova.Biz o.UnitViz = vc.Get("unitserial", o.UnitId); o.UnitDescriptionViz = vc.Get("unitdesc", o.UnitId); o.UnitMeteredViz = vc.GetAsBool("unitmetered", o.UnitId); - o.UnitModelNameViz = vc.Get("unitsmodelname", o.UnitId); - o.UnitModelVendorViz = vc.Get("unitsmodelvendorname", o.UnitId); if (populateForReporting) { o.AddressViz = vc.Get("unitaddr", o.UnitId); diff --git a/server/AyaNova/util/VizCache.cs b/server/AyaNova/util/VizCache.cs index 69ebac54..76bdd957 100644 --- a/server/AyaNova/util/VizCache.cs +++ b/server/AyaNova/util/VizCache.cs @@ -16,7 +16,7 @@ namespace AyaNova.Util { if (value == null) value = string.Empty; _vizCache[$"{key}{id}"] = value; - System.Diagnostics.Debug.WriteLine($"ADD {key}{id} - {value}"); + // System.Diagnostics.Debug.WriteLine($"ADD {key}{id} - {value}"); } internal string Get(string key, long? id = 0) { @@ -28,11 +28,16 @@ namespace AyaNova.Util } else { - System.Diagnostics.Debug.WriteLine($"vizGet cache miss {key}{id}"); + //System.Diagnostics.Debug.WriteLine($"vizGet cache miss {key}{id}"); return null; } } + internal bool Has(string key, long? id = 0) + { + return _vizCache.ContainsKey($"{key}{id}"); + } + internal bool GetAsBool(string key, long? id = 0) { var s = Get(key, id);