This commit is contained in:
2021-12-22 22:43:38 +00:00
parent a89d64ccfb
commit 7fe8ba9a3d
2 changed files with 12 additions and 9 deletions

View File

@@ -6181,8 +6181,8 @@ namespace AyaNova.Biz
private async Task UnitPopulateVizFields(WorkOrderItemUnit o, bool populateForReporting) private async Task UnitPopulateVizFields(WorkOrderItemUnit o, bool populateForReporting)
{ {
//see if it's in the cache already, populate the cache fully if not //see if it's in the cache already, populate the cache fully if not
bool UnitHasModel=false; bool UnitHasModel = false;
if (vc.Get("unitserial", o.UnitId) == null) if (!vc.Has("unitserial", o.UnitId))
{ {
//cache it //cache it
var unitInfo = await ct.Unit.AsNoTracking() var unitInfo = await ct.Unit.AsNoTracking()
@@ -6201,12 +6201,12 @@ namespace AyaNova.Biz
if (unitInfo.UnitModelId != null) if (unitInfo.UnitModelId != null)
{ {
UnitHasModel=true; UnitHasModel = true;
//units model name cached? (if it is then the rest will be cached as well) //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?? //nope, model name cached??
if (vc.Get("unitmodelname", unitInfo.UnitModelId) == null) if (!vc.Has("unitmodelname", unitInfo.UnitModelId))
{ {
//nope, so cache it all //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(); 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.UnitViz = vc.Get("unitserial", o.UnitId);
o.UnitDescriptionViz = vc.Get("unitdesc", o.UnitId); o.UnitDescriptionViz = vc.Get("unitdesc", o.UnitId);
o.UnitMeteredViz = vc.GetAsBool("unitmetered", 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) if (populateForReporting)
{ {
o.AddressViz = vc.Get("unitaddr", o.UnitId); o.AddressViz = vc.Get("unitaddr", o.UnitId);

View File

@@ -16,7 +16,7 @@ namespace AyaNova.Util
{ {
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_vizCache[$"{key}{id}"] = value; _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) internal string Get(string key, long? id = 0)
{ {
@@ -28,11 +28,16 @@ namespace AyaNova.Util
} }
else else
{ {
System.Diagnostics.Debug.WriteLine($"vizGet cache miss {key}{id}"); //System.Diagnostics.Debug.WriteLine($"vizGet cache miss {key}{id}");
return null; return null;
} }
} }
internal bool Has(string key, long? id = 0)
{
return _vizCache.ContainsKey($"{key}{id}");
}
internal bool GetAsBool(string key, long? id = 0) internal bool GetAsBool(string key, long? id = 0)
{ {
var s = Get(key, id); var s = Get(key, id);