diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html
index d306ec0..acb057b 100644
--- a/Resources/ChangeLog.html
+++ b/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
WebDoorCreator - Egalware
- Version: 0.9.2308.0108
+ Version: 0.9.2308.0109
Release note:
-
diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt
index 598058e..9d47aac 100644
--- a/Resources/VersNum.txt
+++ b/Resources/VersNum.txt
@@ -1 +1 @@
-0.9.2308.0108
+0.9.2308.0109
diff --git a/Resources/manifest.xml b/Resources/manifest.xml
index 007636e..e7c46c2 100644
--- a/Resources/manifest.xml
+++ b/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 0.9.2308.0108
+ 0.9.2308.0109
http://nexus.steamware.net/repository/SWS/WDC/stable/WDC.UI.zip
http://nexus.steamware.net/repository/SWS/WDC/stable/ChangeLog.html
false
diff --git a/WebDoorCreator.Data/Services/WebDoorCreatorService.cs b/WebDoorCreator.Data/Services/WebDoorCreatorService.cs
index de0347d..7199870 100644
--- a/WebDoorCreator.Data/Services/WebDoorCreatorService.cs
+++ b/WebDoorCreator.Data/Services/WebDoorCreatorService.cs
@@ -1,9 +1,12 @@
using EgwCoreLib.Utils;
+using MailKit.Search;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
+using Microsoft.Reporting.Map.WebForms.BingMaps;
using Newtonsoft.Json;
using NLog;
+using NLog.Fluent;
using StackExchange.Redis;
using System.Diagnostics;
using System.Security.Cryptography;
@@ -80,10 +83,17 @@ namespace WebDoorCreator.Data.Services
public async Task CompanyAddMod(CompanyModel currRec)
{
var dbResult = await dbController.CompanyAddMod(currRec);
- // elimino cache redis...
- RedisValue pattern = new RedisValue($"{Constants.rKeyCompany}");
- bool answ = await ExecFlushRedisPattern(pattern);
- await Task.Delay(1);
+ try
+ {
+ // elimino cache redis...
+ RedisValue pattern = new RedisValue($"{Constants.rKeyCompany}");
+ bool answ = await ExecFlushRedisPattern(pattern);
+ await Task.Delay(1);
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during CompanyAddMod: {exc}{Environment.NewLine}");
+ }
return dbResult;
}
@@ -95,39 +105,45 @@ namespace WebDoorCreator.Data.Services
public async Task
> CompanyGetByKey(int id)
{
string source = "DB";
-
List dbResult = new List();
- // cerco da cache
- string currKey = $"{Constants.rKeyCompany}:{id}";
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string? rawData = await redisDb.StringGetAsync(currKey);
- if (!string.IsNullOrEmpty(rawData))
+ try
{
- source = "REDIS";
- var tempResult = JsonConvert.DeserializeObject>(rawData);
- if (tempResult == null)
+ // cerco da cache
+ string currKey = $"{Constants.rKeyCompany}:{id}";
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ string? rawData = await redisDb.StringGetAsync(currKey);
+ if (!string.IsNullOrEmpty(rawData))
{
- dbResult = new List();
+ source = "REDIS";
+ var tempResult = JsonConvert.DeserializeObject>(rawData);
+ if (tempResult == null)
+ {
+ dbResult = new List();
+ }
+ else
+ {
+ dbResult = tempResult;
+ }
}
else
{
- dbResult = tempResult;
+ dbResult = dbController.CompanyGetByKey(id);
+ rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
+ await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
+ if (dbResult == null)
+ {
+ dbResult = new List();
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"CompanyGetAll | {source} in: {ts.TotalMilliseconds} ms");
}
- else
+ catch (Exception exc)
{
- dbResult = dbController.CompanyGetByKey(id);
- rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
- await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
+ Log.Error($"Exception during CompanyGetByKey: {exc}{Environment.NewLine}");
}
- if (dbResult == null)
- {
- dbResult = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"CompanyGetAll | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
@@ -141,15 +157,21 @@ namespace WebDoorCreator.Data.Services
await Task.Delay(1);
List listActiveCompo = new List();
- //estraggo la lista di componenti che sono attive per il cliente
- IniFile fIni = new IniFile(rootPath);
- string compoDDF = fIni.ReadString("CompoOrder", "CompoDDFOrder", "CONFIG");
- var compoDDFList = compoDDF.Split(",");
- foreach (string compo in compoDDFList)
+ try
{
- listActiveCompo.Add(compo.Trim());
+ //estraggo la lista di componenti che sono attive per il cliente
+ IniFile fIni = new IniFile(rootPath);
+ string compoDDF = fIni.ReadString("CompoOrder", "CompoDDFOrder", "CONFIG");
+ var compoDDFList = compoDDF.Split(",");
+ foreach (string compo in compoDDFList)
+ {
+ listActiveCompo.Add(compo.Trim());
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during CompoGetAllActive: {exc}{Environment.NewLine}");
}
-
return listActiveCompo;
}
@@ -167,378 +189,378 @@ namespace WebDoorCreator.Data.Services
List listValues = new List();
ListValuesTempModel Values = new ListValuesTempModel();
- // usato in fase di test iniziale, da rimuovere
-#if false
- dbController.TestTablesTruncate();
-#endif
+ try
+ {
+ List listActiveCompo = await CompoGetAllActive(Path.Combine(rootPath, @"Default.ini"));
+ List listCompoS = new List();
+ // estraggo tutte le sotto directory della cartella \EgtData\Doors\EgtCompoBase\Compo
+ string[] dirs = Directory.GetDirectories(rootPath, "*", SearchOption.TopDirectoryOnly);
- List listActiveCompo = await CompoGetAllActive(Path.Combine(rootPath, @"Default.ini"));
- List listCompoS = new List();
- // estraggo tutte le sotto directory della cartella \EgtData\Doors\EgtCompoBase\Compo
- string[] dirs = Directory.GetDirectories(rootPath, "*", SearchOption.TopDirectoryOnly);
+ // elenco obj da inserire
+ List ListObjDOT = new List();
- // elenco obj da inserire
- List ListObjDOT = new List();
+ string[] DefaultFile = Directory.GetFiles(rootPath, "Default.ini");
- string[] DefaultFile = Directory.GetFiles(rootPath, "Default.ini");
+ IniFile fIniDef = new IniFile(DefaultFile[0]);
- IniFile fIniDef = new IniFile(DefaultFile[0]);
-
- ListValuesTempModel listValObj = new ListValuesTempModel()
- {
- TableName = "Properties",
- FieldName = "DoorDef",
- Value = "Properties",
- Label = "Properties",
- Ordinal = 1,
- DefaultVal = "Maple, Oak, Pine, Birch, Walnut",
- InputType = ""
- };
- listValues.Add(listValObj);
-
- listValObj = new ListValuesTempModel()
- {
- TableName = "Finishing",
- FieldName = "DoorDef",
- Value = "Finishing",
- Label = "Finishing",
- Ordinal = 1,
- DefaultVal = "Varnishing, Veneer",
- InputType = ""
- };
- listValues.Add(listValObj);
-
- listValObj = new ListValuesTempModel()
- {
- TableName = "All",
- FieldName = "OrderStep",
- Value = "10",
- Label = "Door Draft",
- Ordinal = 10,
- DefaultVal = "#EF6C00",
- InputType = ""
- };
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "All",
- FieldName = "OrderStep",
- Value = "20",
- Label = "Sent to DCA",
- Ordinal = 20,
- DefaultVal = "#FBC02D",
- InputType = ""
- };
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "All",
- FieldName = "OrderStep",
- Value = "30",
- Label = "Approved By Maker",
- Ordinal = 30,
- DefaultVal = "#2962FF",
- InputType = ""
- };
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "All",
- FieldName = "OrderStep",
- Value = "40",
- Label = "Approved By Customer",
- Ordinal = 40,
- DefaultVal = "#673AB7",
- InputType = ""
- };
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "All",
- FieldName = "OrderStep",
- Value = "50",
- Label = "ERP",
- Ordinal = 50,
- DefaultVal = "#00B8D4",
- InputType = ""
- };
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "All",
- FieldName = "OrderStep",
- Value = "60",
- Label = "In Production",
- Ordinal = 60,
- DefaultVal = "#43A047",
- InputType = ""
- };
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "All",
- FieldName = "OrderStep",
- Value = "70",
- Label = "Delivered",
- Ordinal = 70,
- DefaultVal = "#AEEA00",
- InputType = ""
- };
-
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "All",
- FieldName = "DoorDefStep",
- Value = "10",
- Label = "Door",
- Ordinal = 10,
- DefaultVal = "#448AFF",
- InputType = ""
- };
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "All",
- FieldName = "DoorDefStep",
- Value = "20",
- Label = "Hardware",
- Ordinal = 20,
- DefaultVal = "#448AFF",
- InputType = ""
- };
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "All",
- FieldName = "DoorDefStep",
- Value = "30",
- Label = "Report",
- Ordinal = 30,
- DefaultVal = "#448AFF",
- InputType = ""
- };
- listValues.Add(listValObj);
-
- // parto con obj base
- sizeVal = fIniDef.ReadString("Size", "Width", "0.0");
-
- listValObj = new ListValuesTempModel()
- {
- TableName = "Size",
- FieldName = "DoorDef",
- Value = "Width",
- Label = "50001",
- Ordinal = 1,
- DefaultVal = sizeVal,
- InputType = "TextBox",
- isSerializable = true
- };
- listValues.Add(listValObj);
- sizeVal = fIniDef.ReadString("Size", "Height", "0.0");
- listValObj = new ListValuesTempModel()
- {
- TableName = "Size",
- FieldName = "DoorDef",
- Value = "Height",
- Label = "50002",
- Ordinal = 2,
- DefaultVal = sizeVal,
- InputType = "TextBox",
- isSerializable = true
- };
- listValues.Add(listValObj);
- sizeVal = fIniDef.ReadString("Size", "Thickness", "0.0");
- listValObj = new ListValuesTempModel()
- {
- TableName = "Size",
- FieldName = "DoorDef",
- Value = "Thickness",
- Label = "50003",
- Ordinal = 3,
- DefaultVal = sizeVal,
- InputType = "TextBox",
- isSerializable = true
- };
- listValues.Add(listValObj);
- sizeVal = fIniDef.ReadString("Size", "SwingList", "UNDEF");
- listValObj = new ListValuesTempModel()
- {
- TableName = "Swing",
- FieldName = "DoorDef",
- Value = "Swing",
- Label = "50004",
- Ordinal = 1,
- DefaultVal = sizeVal,
- InputType = "TextBox",
- isSerializable = true
- };
- listValues.Add(listValObj);
- //sizeVal = fIniDef.ReadString("Edge", "EdgeTypeList", "UNDEF");
- StringBuilder edgesList = new StringBuilder();
- for (int x = 1; x <= 11; x++)
- {
- var edge = fIniDef.ReadString("Edge", $"EdgeType{x}", "UNDEF");
- if (x != 11)
+ ListValuesTempModel listValObj = new ListValuesTempModel()
{
- edgesList.Append($"{edge.Split("/")[0]},");
- }
- else
+ TableName = "Properties",
+ FieldName = "DoorDef",
+ Value = "Properties",
+ Label = "Properties",
+ Ordinal = 1,
+ DefaultVal = "Maple, Oak, Pine, Birch, Walnut",
+ InputType = ""
+ };
+ listValues.Add(listValObj);
+
+ listValObj = new ListValuesTempModel()
{
- edgesList.Append($"{edge.Split("/")[0]}");
- }
- }
- listValObj = new ListValuesTempModel()
- {
- TableName = "Profiles",
- FieldName = "DoorDef",
- Value = "lockedge",
- Label = "50005",
- Ordinal = 1,
- DefaultVal = "",
- InputType = "",
- isSerializable = true
- };
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "Profiles",
- FieldName = "DoorDef",
- Value = "hingeedge",
- Label = "50006",
- Ordinal = 2,
- DefaultVal = "",
- InputType = "",
- isSerializable = true
- };
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "Profiles",
- FieldName = "DoorDef",
- Value = "top",
- Label = "50007",
- Ordinal = 3,
- DefaultVal = "",
- InputType = "",
- isSerializable = true
- };
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "Profiles",
- FieldName = "DoorDef",
- Value = "bottom",
- Label = "50008",
- Ordinal = 4,
- DefaultVal = "",
- InputType = "",
- isSerializable = true
- };
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "Profiles",
- FieldName = "DoorDef",
- Value = "type",
- Label = "50424",
- Ordinal = 5,
- DefaultVal = edgesList.ToString(),
- InputType = "ComboBox",
- isSerializable = true
- };
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "Profiles",
- FieldName = "DoorDef",
- Value = "machining",
- Label = "90312",
- Ordinal = 6,
- DefaultVal = "ON,OFF",
- InputType = "ComboBox",
- isSerializable = true
- };
- listValues.Add(listValObj);
- listValObj = new ListValuesTempModel()
- {
- TableName = "Profiles",
- FieldName = "DoorDef",
- Value = "overmaterial",
- Label = "90312",
- Ordinal = 7,
- DefaultVal = "0.1",
- InputType = "ComboBox",
- isSerializable = true
- };
- listValues.Add(listValObj);
- int i = 0;
+ TableName = "Finishing",
+ FieldName = "DoorDef",
+ Value = "Finishing",
+ Label = "Finishing",
+ Ordinal = 1,
+ DefaultVal = "Varnishing, Veneer",
+ InputType = ""
+ };
+ listValues.Add(listValObj);
- foreach (string dir in dirs)
- {
- int numPar = 1;
- int numHead = 1;
- // scansione della directory...
- string[] files = Directory.GetFiles(dir, "Config.ini");
- compoName = "";
- //iterazione per cercare tutti numPar file "Config.ini" nelle sotto directory
- foreach (string file in files)
+ listValObj = new ListValuesTempModel()
{
- //leggo tutte le linee del file
- List lines = File.ReadAllLines(file).ToList();
- IniFile fIni = new IniFile(file);
- Guid opCode = Guid.NewGuid();
- //cerco la sezione del file ed estraggo il nome del componente
- compoName = fIni.ReadString("Compo", "Name", "COMPONAME");
- //cerco la sezione del file ed estraggo se numPar template sono attivi per il seguente componente
- var isActive = fIni.ReadString("Template", "IsActive", "1");
- string layerName = fIni.ReadString("Layer", "LayerName", "LAYER");
- // lo slash indica l'alias
- var compoNameSplit = compoName.Split("/");
+ TableName = "All",
+ FieldName = "OrderStep",
+ Value = "10",
+ Label = "Door Draft",
+ Ordinal = 10,
+ DefaultVal = "#EF6C00",
+ InputType = ""
+ };
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "All",
+ FieldName = "OrderStep",
+ Value = "20",
+ Label = "Sent to DCA",
+ Ordinal = 20,
+ DefaultVal = "#FBC02D",
+ InputType = ""
+ };
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "All",
+ FieldName = "OrderStep",
+ Value = "30",
+ Label = "Approved By Maker",
+ Ordinal = 30,
+ DefaultVal = "#2962FF",
+ InputType = ""
+ };
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "All",
+ FieldName = "OrderStep",
+ Value = "40",
+ Label = "Approved By Customer",
+ Ordinal = 40,
+ DefaultVal = "#673AB7",
+ InputType = ""
+ };
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "All",
+ FieldName = "OrderStep",
+ Value = "50",
+ Label = "ERP",
+ Ordinal = 50,
+ DefaultVal = "#00B8D4",
+ InputType = ""
+ };
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "All",
+ FieldName = "OrderStep",
+ Value = "60",
+ Label = "In Production",
+ Ordinal = 60,
+ DefaultVal = "#43A047",
+ InputType = ""
+ };
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "All",
+ FieldName = "OrderStep",
+ Value = "70",
+ Label = "Delivered",
+ Ordinal = 70,
+ DefaultVal = "#AEEA00",
+ InputType = ""
+ };
- var compoAcArray = listActiveCompo.ToArray();
- var x = Array.FindIndex(compoAcArray, row => row == compoNameSplit[0]);
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "All",
+ FieldName = "DoorDefStep",
+ Value = "10",
+ Label = "Door",
+ Ordinal = 10,
+ DefaultVal = "#448AFF",
+ InputType = ""
+ };
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "All",
+ FieldName = "DoorDefStep",
+ Value = "20",
+ Label = "Hardware",
+ Ordinal = 20,
+ DefaultVal = "#448AFF",
+ InputType = ""
+ };
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "All",
+ FieldName = "DoorDefStep",
+ Value = "30",
+ Label = "Report",
+ Ordinal = 30,
+ DefaultVal = "#448AFF",
+ InputType = ""
+ };
+ listValues.Add(listValObj);
- if (listActiveCompo.Contains(compoNameSplit[0].ToString()))
+ // parto con obj base
+ sizeVal = fIniDef.ReadString("Size", "Width", "0.0");
+
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "Size",
+ FieldName = "DoorDef",
+ Value = "Width",
+ Label = "50001",
+ Ordinal = 1,
+ DefaultVal = sizeVal,
+ InputType = "TextBox",
+ isSerializable = true
+ };
+ listValues.Add(listValObj);
+ sizeVal = fIniDef.ReadString("Size", "Height", "0.0");
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "Size",
+ FieldName = "DoorDef",
+ Value = "Height",
+ Label = "50002",
+ Ordinal = 2,
+ DefaultVal = sizeVal,
+ InputType = "TextBox",
+ isSerializable = true
+ };
+ listValues.Add(listValObj);
+ sizeVal = fIniDef.ReadString("Size", "Thickness", "0.0");
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "Size",
+ FieldName = "DoorDef",
+ Value = "Thickness",
+ Label = "50003",
+ Ordinal = 3,
+ DefaultVal = sizeVal,
+ InputType = "TextBox",
+ isSerializable = true
+ };
+ listValues.Add(listValObj);
+ sizeVal = fIniDef.ReadString("Size", "SwingList", "UNDEF");
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "Swing",
+ FieldName = "DoorDef",
+ Value = "Swing",
+ Label = "50004",
+ Ordinal = 1,
+ DefaultVal = sizeVal,
+ InputType = "TextBox",
+ isSerializable = true
+ };
+ listValues.Add(listValObj);
+ //sizeVal = fIniDef.ReadString("Edge", "EdgeTypeList", "UNDEF");
+ StringBuilder edgesList = new StringBuilder();
+ for (int x = 1; x <= 11; x++)
+ {
+ var edge = fIniDef.ReadString("Edge", $"EdgeType{x}", "UNDEF");
+ if (x != 11)
{
- //creo il componente (padre)
- listValObj = new ListValuesTempModel()
- {
- TableName = $"{compoNameSplit[0]}".Trim(),
- FieldName = "Hardware",
- Value = $"{compoNameSplit[0]}",
- Label = $"{compoNameSplit[1]}",
- Ordinal = x,
- DefaultVal = " ",
- InputType = " "
- };
- //HardwareModel compoConfig = new HardwareModel() { compoName = $"{compoNameSplit[0]}", compoAlias = compoNameSplit[1].ToString(), compoLayerName = layerName, compoTemplateIsActive = compoTemplateIsActive };
- //await dbController.CompoAdd(compoConfig);
- //listCompoS.Add(compoConfig);
- listValues.Add(listValObj);
- i++;
- //cerco all'interno del file tutte le sezioni che contengono "[Graphic" così da poter prendere il nome della sezione ES: [Graphic parameters1] = Graphic parameters1
- var lineToSearch = lines.Where(x => x.Contains("[Graphic")).ToList();
- numHead = 1;
- foreach (var match in lineToSearch)
- {
- var listV = await GraphicParamsGetAll(file, match, numHead, numPar, $"{compoNameSplit[0]}");
-
- foreach (var item in listV)
- {
- listValues.Add(item);
- }
-
- numHead++;
- }
- numPar++;
+ edgesList.Append($"{edge.Split("/")[0]},");
+ }
+ else
+ {
+ edgesList.Append($"{edge.Split("/")[0]}");
}
}
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "Profiles",
+ FieldName = "DoorDef",
+ Value = "lockedge",
+ Label = "50005",
+ Ordinal = 1,
+ DefaultVal = "",
+ InputType = "",
+ isSerializable = true
+ };
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "Profiles",
+ FieldName = "DoorDef",
+ Value = "hingeedge",
+ Label = "50006",
+ Ordinal = 2,
+ DefaultVal = "",
+ InputType = "",
+ isSerializable = true
+ };
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "Profiles",
+ FieldName = "DoorDef",
+ Value = "top",
+ Label = "50007",
+ Ordinal = 3,
+ DefaultVal = "",
+ InputType = "",
+ isSerializable = true
+ };
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "Profiles",
+ FieldName = "DoorDef",
+ Value = "bottom",
+ Label = "50008",
+ Ordinal = 4,
+ DefaultVal = "",
+ InputType = "",
+ isSerializable = true
+ };
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "Profiles",
+ FieldName = "DoorDef",
+ Value = "type",
+ Label = "50424",
+ Ordinal = 5,
+ DefaultVal = edgesList.ToString(),
+ InputType = "ComboBox",
+ isSerializable = true
+ };
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "Profiles",
+ FieldName = "DoorDef",
+ Value = "machining",
+ Label = "90312",
+ Ordinal = 6,
+ DefaultVal = "ON,OFF",
+ InputType = "ComboBox",
+ isSerializable = true
+ };
+ listValues.Add(listValObj);
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = "Profiles",
+ FieldName = "DoorDef",
+ Value = "overmaterial",
+ Label = "90312",
+ Ordinal = 7,
+ DefaultVal = "0.1",
+ InputType = "ComboBox",
+ isSerializable = true
+ };
+ listValues.Add(listValObj);
+ int i = 0;
+
+ foreach (string dir in dirs)
+ {
+ int numPar = 1;
+ int numHead = 1;
+ // scansione della directory...
+ string[] files = Directory.GetFiles(dir, "Config.ini");
+ compoName = "";
+ //iterazione per cercare tutti numPar file "Config.ini" nelle sotto directory
+ foreach (string file in files)
+ {
+ //leggo tutte le linee del file
+ List lines = File.ReadAllLines(file).ToList();
+ IniFile fIni = new IniFile(file);
+ Guid opCode = Guid.NewGuid();
+ //cerco la sezione del file ed estraggo il nome del componente
+ compoName = fIni.ReadString("Compo", "Name", "COMPONAME");
+ //cerco la sezione del file ed estraggo se numPar template sono attivi per il seguente componente
+ var isActive = fIni.ReadString("Template", "IsActive", "1");
+ string layerName = fIni.ReadString("Layer", "LayerName", "LAYER");
+ // lo slash indica l'alias
+ var compoNameSplit = compoName.Split("/");
+
+ var compoAcArray = listActiveCompo.ToArray();
+ var x = Array.FindIndex(compoAcArray, row => row == compoNameSplit[0]);
+
+ if (listActiveCompo.Contains(compoNameSplit[0].ToString()))
+ {
+ //creo il componente (padre)
+ listValObj = new ListValuesTempModel()
+ {
+ TableName = $"{compoNameSplit[0]}".Trim(),
+ FieldName = "Hardware",
+ Value = $"{compoNameSplit[0]}",
+ Label = $"{compoNameSplit[1]}",
+ Ordinal = x,
+ DefaultVal = " ",
+ InputType = " "
+ };
+ //HardwareModel compoConfig = new HardwareModel() { compoName = $"{compoNameSplit[0]}", compoAlias = compoNameSplit[1].ToString(), compoLayerName = layerName, compoTemplateIsActive = compoTemplateIsActive };
+ //await dbController.CompoAdd(compoConfig);
+ //listCompoS.Add(compoConfig);
+ listValues.Add(listValObj);
+ i++;
+ //cerco all'interno del file tutte le sezioni che contengono "[Graphic" così da poter prendere il nome della sezione ES: [Graphic parameters1] = Graphic parameters1
+ var lineToSearch = lines.Where(x => x.Contains("[Graphic")).ToList();
+ numHead = 1;
+ foreach (var match in lineToSearch)
+ {
+ var listV = await GraphicParamsGetAll(file, match, numHead, numPar, $"{compoNameSplit[0]}");
+
+ foreach (var item in listV)
+ {
+ listValues.Add(item);
+ }
+
+ numHead++;
+ }
+ numPar++;
+ }
+ }
+ }
+
+ fatto = await dbController.ListValuesAdd(listValues);
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during CompoListSetAll: {exc}{Environment.NewLine}");
}
-
- fatto = await dbController.ListValuesAdd(listValues);
-
- // ripetere con DoorOpType
return fatto;
}
@@ -551,36 +573,43 @@ namespace WebDoorCreator.Data.Services
{
string source = "DB";
List? dbResult = new List();
- string currKey = $"{Constants.rKeyConfig}:Table";
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string? rawData = await redisDb.StringGetAsync(currKey);
- if (!string.IsNullOrEmpty(rawData))
+ try
{
- source = "REDIS";
- var tempResult = JsonConvert.DeserializeObject>(rawData);
- if (tempResult == null)
+ string currKey = $"{Constants.rKeyConfig}:Table";
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ string? rawData = await redisDb.StringGetAsync(currKey);
+ if (!string.IsNullOrEmpty(rawData))
{
- dbResult = new List();
+ source = "REDIS";
+ var tempResult = JsonConvert.DeserializeObject>(rawData);
+ if (tempResult == null)
+ {
+ dbResult = new List();
+ }
+ else
+ {
+ dbResult = tempResult;
+ }
}
else
{
- dbResult = tempResult;
+ dbResult = dbController.ConfigGetAll();
+ rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
+ await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
+ if (dbResult == null)
+ {
+ dbResult = new List();
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"ConfigGetAll | {source} in: {ts.TotalMilliseconds} ms");
}
- else
+ catch (Exception exc)
{
- dbResult = dbController.ConfigGetAll();
- rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
- await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
+ Log.Error($"ConfigGetAll during CompoListSetAll: {exc}{Environment.NewLine}");
}
- if (dbResult == null)
- {
- dbResult = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ConfigGetAll | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
@@ -594,373 +623,390 @@ namespace WebDoorCreator.Data.Services
string source = "DB";
// cerco in cache direttamente la chiave... altrimenti da redis/db
ConfigModel? keyResult = null;
- string currKey = $"{Constants.rKeyConfig}:Dict:{chiave}";
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string? rawData = await redisDb.StringGetAsync(currKey);
- if (!string.IsNullOrEmpty(rawData))
+ try
{
- source = "REDIS";
- var tempResult = JsonConvert.DeserializeObject(rawData);
- if (tempResult == null)
+ string currKey = $"{Constants.rKeyConfig}:Dict:{chiave}";
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ string? rawData = await redisDb.StringGetAsync(currKey);
+ if (!string.IsNullOrEmpty(rawData))
{
- keyResult = new ConfigModel();
+ source = "REDIS";
+ var tempResult = JsonConvert.DeserializeObject(rawData);
+ if (tempResult == null)
+ {
+ keyResult = new ConfigModel();
+ }
+ else
+ {
+ keyResult = tempResult;
+ }
+ keyResult = JsonConvert.DeserializeObject(rawData);
}
else
{
- keyResult = tempResult;
+ var listConfig = await ConfigGetAll();
+ keyResult = listConfig.FirstOrDefault(x => x.chiave == chiave);
+ rawData = JsonConvert.SerializeObject(keyResult, JSSettings);
+ await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
- keyResult = JsonConvert.DeserializeObject(rawData);
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"ConfigGetKey | {chiave} | {source} in: {ts.TotalMilliseconds} ms");
}
- else
+ catch (Exception exc)
{
- var listConfig = await ConfigGetAll();
- keyResult = listConfig.FirstOrDefault(x => x.chiave == chiave);
- rawData = JsonConvert.SerializeObject(keyResult, JSSettings);
- await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
+ Log.Error($"Exception during ConfigGetKey: {exc}{Environment.NewLine}");
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ConfigGetKey | {chiave} | {source} in: {ts.TotalMilliseconds} ms");
return await Task.FromResult(keyResult);
}
public async Task createDoor(int idOrd, string userId, string currMeaUnit)
{
int answ = 0;
-
- // conto le porte x questo ordine e uso x chiamata successiva...
- var door4ord = await DoorGetByOrderId(idOrd);
- int numDoors = door4ord?.Count + 1 ?? 1;
- List listOp = new List();
- DateTime adesso = DateTime.Now;
- // creo una nuova porta...
- DoorModel newDoor = new DoorModel()
+ try
{
- OrderId = idOrd,
- MeasureUnit = currMeaUnit,
- UserIdIns = userId,
- UserIdMod = userId,
- UserIdLock = userId,
- DateIns = adesso,
- DateMod = adesso,
- DateLockExpiry = adesso.AddHours(1),
- DoorDescript = $"ORD {idOrd} | Door {numDoors:00}",
- DoorExtCode = $"ORD {idOrd} | Ext Code --",
- Quantity = 1,
- UnitCost = 0,
- ParentId = 1
- };
- // chiamo metodo x insert...
- var doorId = await DoorInsert(newDoor);
- // aggiungo le lavorazioni standard...
- var doorOpList = await DoorOpGetDefault();
- var listRecordEdge = await ListValuesGetAll("Profiles", "DoorDef");
- var listRecordSizing = await ListValuesGetAll("Size", "DoorDef");
- var listRecordSwing = await ListValuesGetAll("Swing", "DoorDef");
- var listRecordProperties = await ListValuesGetAll("Properties", "DoorDef");
- var listRecordFinishing = await ListValuesGetAll("Finishing", "DoorDef");
- ListValuesModel? profCurrType = null;
- ListValuesModel? profCurrMach = null;
- ListValuesModel? profCurrOverMat = null;
- if (listRecordEdge != null)
- {
- profCurrType = listRecordEdge.Where(x => x.Value == "type").FirstOrDefault();
- profCurrMach = listRecordEdge.Where(x => x.Value == "machining").FirstOrDefault();
- profCurrOverMat = listRecordEdge.Where(x => x.Value == "overmaterial").FirstOrDefault();
- }
- Dictionary>> itemsDictDef = new Dictionary>>();
- Dictionary> itemsDictAct = new Dictionary>();
- Dictionary> paramsDict = new Dictionary>();
- Dictionary actDict = new Dictionary();
- List listDefVal = new List();
- List listDefValCurrMach = new List();
- List listDefValOverMat = new List();
- List defaultParamsList = new List();
-
- #region Gestione Properties
-
- if (listRecordProperties != null)
- {
- foreach (var item in listRecordProperties)
+ // conto le porte x questo ordine e uso x chiamata successiva...
+ var door4ord = await DoorGetByOrderId(idOrd);
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ int numDoors = door4ord?.Count + 1 ?? 1;
+ List listOp = new List();
+ DateTime adesso = DateTime.Now;
+ // creo una nuova porta...
+ DoorModel newDoor = new DoorModel()
{
- foreach (var param in item.DefaultVal.Split(","))
- {
- listDefVal.Add(param.Trim());
- if (!actDict.ContainsKey(item.Value))
- {
- actDict.Add(item.Value, item.DefaultVal.Trim().Split(",")[0]);
- paramsDict.Add(item.Value, listDefVal);
- }
- //itemsDict.Add(itemOld.Value, paramsDict);
- //paramsDict.Clear();
- }
-
- //listDefVal = new List() { itemOld.DefaultVal.Trim() };
+ OrderId = idOrd,
+ MeasureUnit = currMeaUnit,
+ UserIdIns = userId,
+ UserIdMod = userId,
+ UserIdLock = userId,
+ DateIns = adesso,
+ DateMod = adesso,
+ DateLockExpiry = adesso.AddHours(1),
+ DoorDescript = $"ORD {idOrd} | Door {numDoors:00}",
+ DoorExtCode = $"ORD {idOrd} | Ext Code --",
+ Quantity = 1,
+ UnitCost = 0,
+ ParentId = 1
+ };
+ // chiamo metodo x insert...
+ var doorId = await DoorInsert(newDoor);
+ // aggiungo le lavorazioni standard...
+ var doorOpList = await DoorOpGetDefault();
+ var listRecordEdge = await ListValuesGetAll("Profiles", "DoorDef");
+ var listRecordSizing = await ListValuesGetAll("Size", "DoorDef");
+ var listRecordSwing = await ListValuesGetAll("Swing", "DoorDef");
+ var listRecordProperties = await ListValuesGetAll("Properties", "DoorDef");
+ var listRecordFinishing = await ListValuesGetAll("Finishing", "DoorDef");
+ ListValuesModel? profCurrType = null;
+ ListValuesModel? profCurrMach = null;
+ ListValuesModel? profCurrOverMat = null;
+ if (listRecordEdge != null)
+ {
+ profCurrType = listRecordEdge.Where(x => x.Value == "type").FirstOrDefault();
+ profCurrMach = listRecordEdge.Where(x => x.Value == "machining").FirstOrDefault();
+ profCurrOverMat = listRecordEdge.Where(x => x.Value == "overmaterial").FirstOrDefault();
}
- itemsDictDef.Add("Properties", paramsDict);
- itemsDictAct.Add("Properties", actDict);
- //defaultParamsList.Add(listDefVal);
- }
- var jsonDef = JsonConvert.SerializeObject(itemsDictDef);
- var jsonAct = JsonConvert.SerializeObject(itemsDictAct);
+ Dictionary>> itemsDictDef = new Dictionary>>();
+ Dictionary> itemsDictAct = new Dictionary>();
+ Dictionary> paramsDict = new Dictionary>();
+ Dictionary actDict = new Dictionary();
+ List listDefVal = new List();
+ List listDefValCurrMach = new List();
+ List listDefValOverMat = new List();
+ List defaultParamsList = new List();
- DoorOpModel doorOpToAdd = new DoorOpModel()
- {
- DateIns = adesso,
- DateMod = adesso,
- UserIdIns = userId,
- UserIdMod = userId,
- ObjectId = "Properties",
- DoorId = doorId,
- JsoncConfigVal = jsonDef,
- JsoncActVal = jsonAct,
- userConfirm = userId,
- DtConfirm = adesso
- };
- listOp.Add(doorOpToAdd);
+ #region Gestione Properties
- #endregion Gestione Properties
-
- paramsDict.Clear();
- actDict.Clear();
- itemsDictDef.Clear();
- itemsDictAct.Clear();
- listDefVal.Clear();
-
- #region Gestione Finishing
-
- if (listRecordFinishing != null)
- {
- foreach (var item in listRecordFinishing)
+ if (listRecordProperties != null)
{
- foreach (var param in item.DefaultVal.Split(","))
+ foreach (var item in listRecordProperties)
{
- listDefVal.Add(param.Trim());
- if (!actDict.ContainsKey(item.Value))
+ foreach (var param in item.DefaultVal.Split(","))
{
- actDict.Add(item.Value, item.DefaultVal.Trim().Split(",")[0]);
- paramsDict.Add(item.Value, listDefVal);
- }
- //itemsDict.Add(itemOld.Value, paramsDict);
- //paramsDict.Clear();
- }
-
- //listDefVal = new List() { itemOld.DefaultVal.Trim() };
- }
- itemsDictDef.Add("Finishing", paramsDict);
- itemsDictAct.Add("Finishing", actDict);
- //defaultParamsList.Add(listDefVal);
- }
- jsonDef = JsonConvert.SerializeObject(itemsDictDef);
- jsonAct = JsonConvert.SerializeObject(itemsDictAct);
-
- doorOpToAdd = new DoorOpModel()
- {
- DateIns = adesso,
- DateMod = adesso,
- UserIdIns = userId,
- UserIdMod = userId,
- ObjectId = "Finishing",
- DoorId = doorId,
- JsoncConfigVal = jsonDef,
- JsoncActVal = jsonAct,
- userConfirm = userId,
- DtConfirm = adesso
- };
- listOp.Add(doorOpToAdd);
-
- #endregion Gestione Finishing
-
- paramsDict.Clear();
- actDict.Clear();
- itemsDictDef.Clear();
- itemsDictAct.Clear();
- listDefVal.Clear();
-
- #region Gestione sizing
-
- if (listRecordSizing != null)
- {
- foreach (var item in listRecordSizing)
- {
- listDefVal = new List() { item.DefaultVal.Trim() };
- if (!actDict.ContainsKey(item.Value))
- {
- actDict.Add(item.Value, item.DefaultVal.Trim());
- paramsDict.Add(item.Value, listDefVal);
- }
- }
- itemsDictDef.Add("Size", paramsDict);
- itemsDictAct.Add("Size", actDict);
- //defaultParamsList.Add(listDefVal);
- }
- jsonDef = JsonConvert.SerializeObject(itemsDictDef);
- jsonAct = JsonConvert.SerializeObject(itemsDictAct);
-
- doorOpToAdd = new DoorOpModel()
- {
- DateIns = adesso,
- DateMod = adesso,
- UserIdIns = userId,
- UserIdMod = userId,
- ObjectId = "Size",
- DoorId = doorId,
- JsoncConfigVal = jsonDef,
- JsoncActVal = jsonAct,
- userConfirm = userId,
- DtConfirm = adesso
- };
- listOp.Add(doorOpToAdd);
-
- #endregion Gestione sizing
-
- paramsDict.Clear();
- actDict.Clear();
- itemsDictDef.Clear();
- itemsDictAct.Clear();
- listDefVal.Clear();
-
- #region Gestione Swing
-
- if (listRecordSwing != null)
- {
- foreach (var item in listRecordSwing)
- {
- foreach (var param in item.DefaultVal.Split(","))
- {
- listDefVal.Add(param.Trim());
- if (!actDict.ContainsKey(item.Value))
- {
- actDict.Add(item.Value, item.DefaultVal.Trim().Split(",")[0]);
- paramsDict.Add(item.Value, listDefVal);
- }
- //itemsDict.Add(itemOld.Value, paramsDict);
- //paramsDict.Clear();
- }
-
- //listDefVal = new List() { itemOld.DefaultVal.Trim() };
- }
- itemsDictDef.Add("Swing", paramsDict);
- itemsDictAct.Add("Swing", actDict);
- //defaultParamsList.Add(listDefVal);
- }
- jsonDef = JsonConvert.SerializeObject(itemsDictDef);
- jsonAct = JsonConvert.SerializeObject(itemsDictAct);
-
- doorOpToAdd = new DoorOpModel()
- {
- DateIns = adesso,
- DateMod = adesso,
- UserIdIns = userId,
- UserIdMod = userId,
- ObjectId = "Swing",
- DoorId = doorId,
- JsoncConfigVal = jsonDef,
- JsoncActVal = jsonAct,
- userConfirm = userId,
- DtConfirm = adesso
- };
- listOp.Add(doorOpToAdd);
-
- #endregion Gestione Swing
-
- paramsDict.Clear();
- actDict.Clear();
- itemsDictDef.Clear();
- itemsDictAct.Clear();
- listDefVal.Clear();
-
- #region Gestione Profiles
-
- if (listRecordEdge != null)
- {
- listDefVal.Clear();
- if (profCurrType != null)
- {
- foreach (var param in profCurrType.DefaultVal.Split(","))
- {
- listDefVal.Add(param.Trim());
- if (!actDict.ContainsKey(profCurrType.Value))
- {
- actDict.Add(profCurrType.Value, param.Trim());
- paramsDict.Add(profCurrType.Value, listDefVal);
- //listDefVal.Clear();
- }
- //itemsDict.Add(itemOld.Value, paramsDict);
- //paramsDict.Clear();
- }
- if (profCurrMach != null)
- {
- //listDefVal.Clear();
- foreach (var param in profCurrMach.DefaultVal.Split(","))
- {
- listDefValCurrMach.Add(param.Trim());
- if (!actDict.ContainsKey(profCurrMach.Value))
+ listDefVal.Add(param.Trim());
+ if (!actDict.ContainsKey(item.Value))
{
- paramsDict.Add(profCurrMach.Value, listDefValCurrMach);
- actDict.Add(profCurrMach.Value, profCurrMach.DefaultVal.Trim().Split(",")[0]);
+ actDict.Add(item.Value, item.DefaultVal.Trim().Split(",")[0]);
+ paramsDict.Add(item.Value, listDefVal);
+ }
+ //itemsDict.Add(itemOld.Value, paramsDict);
+ //paramsDict.Clear();
+ }
+
+ //listDefVal = new List() { itemOld.DefaultVal.Trim() };
+ }
+ itemsDictDef.Add("Properties", paramsDict);
+ itemsDictAct.Add("Properties", actDict);
+ //defaultParamsList.Add(listDefVal);
+ }
+ var jsonDef = JsonConvert.SerializeObject(itemsDictDef);
+ var jsonAct = JsonConvert.SerializeObject(itemsDictAct);
+
+ DoorOpModel doorOpToAdd = new DoorOpModel()
+ {
+ DateIns = adesso,
+ DateMod = adesso,
+ UserIdIns = userId,
+ UserIdMod = userId,
+ ObjectId = "Properties",
+ DoorId = doorId,
+ JsoncConfigVal = jsonDef,
+ JsoncActVal = jsonAct,
+ userConfirm = userId,
+ DtConfirm = adesso
+ };
+ listOp.Add(doorOpToAdd);
+
+ #endregion Gestione Properties
+
+ paramsDict.Clear();
+ actDict.Clear();
+ itemsDictDef.Clear();
+ itemsDictAct.Clear();
+ listDefVal.Clear();
+
+ #region Gestione Finishing
+
+ if (listRecordFinishing != null)
+ {
+ foreach (var item in listRecordFinishing)
+ {
+ foreach (var param in item.DefaultVal.Split(","))
+ {
+ listDefVal.Add(param.Trim());
+ if (!actDict.ContainsKey(item.Value))
+ {
+ actDict.Add(item.Value, item.DefaultVal.Trim().Split(",")[0]);
+ paramsDict.Add(item.Value, listDefVal);
+ }
+ //itemsDict.Add(itemOld.Value, paramsDict);
+ //paramsDict.Clear();
+ }
+
+ //listDefVal = new List() { itemOld.DefaultVal.Trim() };
+ }
+ itemsDictDef.Add("Finishing", paramsDict);
+ itemsDictAct.Add("Finishing", actDict);
+ //defaultParamsList.Add(listDefVal);
+ }
+ jsonDef = JsonConvert.SerializeObject(itemsDictDef);
+ jsonAct = JsonConvert.SerializeObject(itemsDictAct);
+
+ doorOpToAdd = new DoorOpModel()
+ {
+ DateIns = adesso,
+ DateMod = adesso,
+ UserIdIns = userId,
+ UserIdMod = userId,
+ ObjectId = "Finishing",
+ DoorId = doorId,
+ JsoncConfigVal = jsonDef,
+ JsoncActVal = jsonAct,
+ userConfirm = userId,
+ DtConfirm = adesso
+ };
+ listOp.Add(doorOpToAdd);
+
+ #endregion Gestione Finishing
+
+ paramsDict.Clear();
+ actDict.Clear();
+ itemsDictDef.Clear();
+ itemsDictAct.Clear();
+ listDefVal.Clear();
+
+ #region Gestione sizing
+
+ if (listRecordSizing != null)
+ {
+ foreach (var item in listRecordSizing)
+ {
+ listDefVal = new List() { item.DefaultVal.Trim() };
+ if (!actDict.ContainsKey(item.Value))
+ {
+ actDict.Add(item.Value, item.DefaultVal.Trim());
+ paramsDict.Add(item.Value, listDefVal);
+ }
+ }
+ itemsDictDef.Add("Size", paramsDict);
+ itemsDictAct.Add("Size", actDict);
+ //defaultParamsList.Add(listDefVal);
+ }
+ jsonDef = JsonConvert.SerializeObject(itemsDictDef);
+ jsonAct = JsonConvert.SerializeObject(itemsDictAct);
+
+ doorOpToAdd = new DoorOpModel()
+ {
+ DateIns = adesso,
+ DateMod = adesso,
+ UserIdIns = userId,
+ UserIdMod = userId,
+ ObjectId = "Size",
+ DoorId = doorId,
+ JsoncConfigVal = jsonDef,
+ JsoncActVal = jsonAct,
+ userConfirm = userId,
+ DtConfirm = adesso
+ };
+ listOp.Add(doorOpToAdd);
+
+ #endregion Gestione sizing
+
+ paramsDict.Clear();
+ actDict.Clear();
+ itemsDictDef.Clear();
+ itemsDictAct.Clear();
+ listDefVal.Clear();
+
+ #region Gestione Swing
+
+ if (listRecordSwing != null)
+ {
+ foreach (var item in listRecordSwing)
+ {
+ foreach (var param in item.DefaultVal.Split(","))
+ {
+ listDefVal.Add(param.Trim());
+ if (!actDict.ContainsKey(item.Value))
+ {
+ actDict.Add(item.Value, item.DefaultVal.Trim().Split(",")[0]);
+ paramsDict.Add(item.Value, listDefVal);
+ }
+ //itemsDict.Add(itemOld.Value, paramsDict);
+ //paramsDict.Clear();
+ }
+
+ //listDefVal = new List() { itemOld.DefaultVal.Trim() };
+ }
+ itemsDictDef.Add("Swing", paramsDict);
+ itemsDictAct.Add("Swing", actDict);
+ //defaultParamsList.Add(listDefVal);
+ }
+ jsonDef = JsonConvert.SerializeObject(itemsDictDef);
+ jsonAct = JsonConvert.SerializeObject(itemsDictAct);
+
+ doorOpToAdd = new DoorOpModel()
+ {
+ DateIns = adesso,
+ DateMod = adesso,
+ UserIdIns = userId,
+ UserIdMod = userId,
+ ObjectId = "Swing",
+ DoorId = doorId,
+ JsoncConfigVal = jsonDef,
+ JsoncActVal = jsonAct,
+ userConfirm = userId,
+ DtConfirm = adesso
+ };
+ listOp.Add(doorOpToAdd);
+
+ #endregion Gestione Swing
+
+ paramsDict.Clear();
+ actDict.Clear();
+ itemsDictDef.Clear();
+ itemsDictAct.Clear();
+ listDefVal.Clear();
+
+ #region Gestione Profiles
+
+ if (listRecordEdge != null)
+ {
+ listDefVal.Clear();
+ if (profCurrType != null)
+ {
+ foreach (var param in profCurrType.DefaultVal.Split(","))
+ {
+ listDefVal.Add(param.Trim());
+ if (!actDict.ContainsKey(profCurrType.Value))
+ {
+ actDict.Add(profCurrType.Value, param.Trim());
+ paramsDict.Add(profCurrType.Value, listDefVal);
//listDefVal.Clear();
}
//itemsDict.Add(itemOld.Value, paramsDict);
//paramsDict.Clear();
}
- }
- if (profCurrOverMat != null)
- {
- //listDefVal.Clear();
- if (!paramsDict.ContainsKey(profCurrOverMat.Value))
+ if (profCurrMach != null)
{
- listDefValOverMat.Add(profCurrOverMat.DefaultVal.Trim());
- paramsDict.Add(profCurrOverMat.Value, listDefValOverMat);
- actDict.Add(profCurrOverMat.Value, profCurrOverMat.DefaultVal.Trim());
+ //listDefVal.Clear();
+ foreach (var param in profCurrMach.DefaultVal.Split(","))
+ {
+ listDefValCurrMach.Add(param.Trim());
+ if (!actDict.ContainsKey(profCurrMach.Value))
+ {
+ paramsDict.Add(profCurrMach.Value, listDefValCurrMach);
+ actDict.Add(profCurrMach.Value, profCurrMach.DefaultVal.Trim().Split(",")[0]);
+ //listDefVal.Clear();
+ }
+ //itemsDict.Add(itemOld.Value, paramsDict);
+ //paramsDict.Clear();
+ }
+ }
+ if (profCurrOverMat != null)
+ {
+ //listDefVal.Clear();
+ if (!paramsDict.ContainsKey(profCurrOverMat.Value))
+ {
+ listDefValOverMat.Add(profCurrOverMat.DefaultVal.Trim());
+ paramsDict.Add(profCurrOverMat.Value, listDefValOverMat);
+ actDict.Add(profCurrOverMat.Value, profCurrOverMat.DefaultVal.Trim());
+ }
}
}
+ foreach (var item in listRecordEdge.Where(x => x.Value != "type" && x.Value != "machining" && x.Value != "overmaterial"))
+ {
+ if (!itemsDictDef.ContainsKey(item.Value))
+ {
+ itemsDictDef.Add(item.Value, paramsDict);
+ }
+ if (!itemsDictAct.ContainsKey(item.Value))
+ {
+ itemsDictAct.Add(item.Value, actDict);
+ }
+ //defaultParamsList.Add(listDefVal);
+ //defaultDict.Add(itemOld.Label, listDefVal);
+ }
}
- foreach (var item in listRecordEdge.Where(x => x.Value != "type" && x.Value != "machining" && x.Value != "overmaterial"))
+ //actDict.Add(HwToShow.TableName, actParamsList);
+
+ jsonDef = JsonConvert.SerializeObject(itemsDictDef);
+ jsonAct = JsonConvert.SerializeObject(itemsDictAct);
+
+ doorOpToAdd = new DoorOpModel()
{
- if (!itemsDictDef.ContainsKey(item.Value))
- {
- itemsDictDef.Add(item.Value, paramsDict);
- }
- if (!itemsDictAct.ContainsKey(item.Value))
- {
- itemsDictAct.Add(item.Value, actDict);
- }
- //defaultParamsList.Add(listDefVal);
- //defaultDict.Add(itemOld.Label, listDefVal);
+ DateIns = adesso,
+ DateMod = adesso,
+ UserIdIns = userId,
+ UserIdMod = userId,
+ ObjectId = "Profiles",
+ DoorId = doorId,
+ JsoncConfigVal = jsonDef,
+ JsoncActVal = jsonAct,
+ userConfirm = userId,
+ DtConfirm = adesso
+ };
+ listOp.Add(doorOpToAdd);
+
+ #endregion Gestione Profiles
+
+ // salvo Door OP associate
+ bool fatto = await DoorOpInsert(doorId, listOp);
+
+ if (fatto)
+ {
+ answ = doorId;
}
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"createDoor | {doorId} in: {ts.TotalMilliseconds} ms");
}
- //actDict.Add(HwToShow.TableName, actParamsList);
-
- jsonDef = JsonConvert.SerializeObject(itemsDictDef);
- jsonAct = JsonConvert.SerializeObject(itemsDictAct);
-
- doorOpToAdd = new DoorOpModel()
+ catch (Exception exc)
{
- DateIns = adesso,
- DateMod = adesso,
- UserIdIns = userId,
- UserIdMod = userId,
- ObjectId = "Profiles",
- DoorId = doorId,
- JsoncConfigVal = jsonDef,
- JsoncActVal = jsonAct,
- userConfirm = userId,
- DtConfirm = adesso
- };
- listOp.Add(doorOpToAdd);
-
- #endregion Gestione Profiles
-
- // salvo Door OP associate
- bool fatto = await DoorOpInsert(doorId, listOp);
-
- if (fatto)
- {
- answ = doorId;
+ Log.Error($"Exception during createDoor: {exc}{Environment.NewLine}");
}
-
return answ;
}
@@ -985,41 +1031,53 @@ namespace WebDoorCreator.Data.Services
{
int newDoorId = 0;
var doorOps2Add = new List();
- var CurrDoor = await DoorGetByKey(doorId);
- var DoorOpsList = await DoorOpGetByDoorId(doorId);
- if (DoorOpsList != null)
+ try
{
- var doorOps2Clone = DoorOpsList?.Where(x => x.DoorId == doorId).ToList();
- //var door2Clone = CurrDoor;
- if (CurrDoor != null)
+ var CurrDoor = await DoorGetByKey(doorId);
+ var DoorOpsList = await DoorOpGetByDoorId(doorId);
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ if (DoorOpsList != null)
{
- var doorToAdd = CurrDoor.ObjClone(userName);
- // imposto dati per la porta...
- doorToAdd.OrderId = orderId;
- doorToAdd.ParentId = isClone ? CurrDoor.DoorId : 1;
- doorToAdd.Quantity = 1;
- doorToAdd.DoorExtCode = doorCode;
- doorToAdd.DoorDescript = doorDescr;
- // salvo!
- newDoorId = await DoorInsert(doorToAdd);
- if (newDoorId != 0 && doorOps2Clone != null)
+ var doorOps2Clone = DoorOpsList?.Where(x => x.DoorId == doorId).ToList();
+ //var door2Clone = CurrDoor;
+ if (CurrDoor != null)
{
- foreach (var item in doorOps2Clone)
- {
- var doorOp2Add = item.ObjClone(userName, newDoorId);
- doorOps2Add.Add(doorOp2Add);
- }
+ var doorToAdd = CurrDoor.ObjClone(userName);
+ // imposto dati per la porta...
+ doorToAdd.OrderId = orderId;
+ doorToAdd.ParentId = isClone ? CurrDoor.DoorId : 1;
+ doorToAdd.Quantity = 1;
+ doorToAdd.DoorExtCode = doorCode;
+ doorToAdd.DoorDescript = doorDescr;
// salvo!
- await DoorOpInsert(newDoorId, doorOps2Add);
+ newDoorId = await DoorInsert(doorToAdd);
+ if (newDoorId != 0 && doorOps2Clone != null)
+ {
+ foreach (var item in doorOps2Clone)
+ {
+ var doorOp2Add = item.ObjClone(userName, newDoorId);
+ doorOps2Add.Add(doorOp2Add);
+ }
+ // salvo!
+ await DoorOpInsert(newDoorId, doorOps2Add);
+ }
}
}
- }
- // await dbController.DoorModQty(NewQty, doorId, isAdd); svuoto cache
- await DoorFlushCache(doorId);
- await DoorOpFlushCache(doorId);
- await OrderDetailFlushCache(orderId);
- await OrdersFlushCache();
+ // await dbController.DoorModQty(NewQty, doorId, isAdd); svuoto cache
+ await DoorFlushCache(doorId);
+ await DoorOpFlushCache(doorId);
+ await OrderDetailFlushCache(orderId);
+ await OrdersFlushCache();
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorCloneToOrder | {doorId} | {orderId} in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorCloneToOrder: {exc}{Environment.NewLine}");
+ }
return newDoorId;
}
@@ -1030,15 +1088,28 @@ namespace WebDoorCreator.Data.Services
///
public async Task DoorDelete(DoorModel currRec)
{
- int DoorId = currRec.DoorId;
- int OrderId = currRec.OrderId;
- // elimino sul DB
- bool answ = await dbController.DoorDelete(DoorId);
- // svuoto cache
- await DoorFlushCache(DoorId);
- await DoorOpFlushCache(DoorId);
- await OrderDetailFlushCache(OrderId);
- await OrdersFlushCache();
+ bool answ = false;
+ try
+ {
+ int DoorId = currRec.DoorId;
+ int OrderId = currRec.OrderId;
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ // elimino sul DB
+ answ = await dbController.DoorDelete(DoorId);
+ // svuoto cache
+ await DoorFlushCache(DoorId);
+ await DoorOpFlushCache(DoorId);
+ await OrderDetailFlushCache(OrderId);
+ await OrdersFlushCache();
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorDelete | {DoorId} in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorDelete: {exc}{Environment.NewLine}");
+ }
return answ;
}
@@ -1049,14 +1120,27 @@ namespace WebDoorCreator.Data.Services
///
public async Task DoorFlushCache(int DoorId)
{
- RedisValue pattern = new RedisValue($"{Constants.rKeyDoor}:*");
- if (DoorId > 0)
+ bool answ = false;
+ try
{
- pattern = new RedisValue($"{Constants.rKeyDoor}:{DoorId}:*");
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ RedisValue pattern = new RedisValue($"{Constants.rKeyDoor}:*");
+ if (DoorId > 0)
+ {
+ pattern = new RedisValue($"{Constants.rKeyDoor}:{DoorId}:*");
+ }
+ answ = await ExecFlushRedisPattern(pattern);
+ pattern = new RedisValue($"{Constants.rKeyDoorsByOrder}:*");
+ answ = await ExecFlushRedisPattern(pattern);
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorDelete | {DoorId} in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorFlushCache: {exc}{Environment.NewLine}");
}
- bool answ = await ExecFlushRedisPattern(pattern);
- pattern = new RedisValue($"{Constants.rKeyDoorsByOrder}:*");
- answ = await ExecFlushRedisPattern(pattern);
return answ;
}
@@ -1065,19 +1149,26 @@ namespace WebDoorCreator.Data.Services
///
public async Task?> DoorGet2Del()
{
- await Task.Delay(1);
- string source = "DB";
List? dbResult = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- dbResult = dbController.DoorGet2Del();
- if (dbResult == null)
+ try
{
- dbResult = new List();
+ await Task.Delay(1);
+ string source = "DB";
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ dbResult = dbController.DoorGet2Del();
+ if (dbResult == null)
+ {
+ dbResult = new List();
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorGet2Del | {source} in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorGet2Del: {exc}{Environment.NewLine}");
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"DoorGet2Del | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
@@ -1088,37 +1179,44 @@ namespace WebDoorCreator.Data.Services
{
string source = "DB";
DoorModel? dbResult = new DoorModel();
- // cerco da cache
- string currKey = $"{Constants.rKeyDoor}:Single:{doorId}";
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string? rawData = await redisDb.StringGetAsync(currKey);
- if (!string.IsNullOrEmpty(rawData))
+ try
{
- source = "REDIS";
- var tempResult = JsonConvert.DeserializeObject(rawData);
- if (tempResult == null)
+ // cerco da cache
+ string currKey = $"{Constants.rKeyDoor}:Single:{doorId}";
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ string? rawData = await redisDb.StringGetAsync(currKey);
+ if (!string.IsNullOrEmpty(rawData))
{
- dbResult = new DoorModel();
+ source = "REDIS";
+ var tempResult = JsonConvert.DeserializeObject(rawData);
+ if (tempResult == null)
+ {
+ dbResult = new DoorModel();
+ }
+ else
+ {
+ dbResult = tempResult;
+ }
}
else
{
- dbResult = tempResult;
+ dbResult = dbController.DoorGetByKey(doorId);
+ rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
+ await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
+ if (dbResult == null)
+ {
+ dbResult = new DoorModel();
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorGetByKey | {source} in: {ts.TotalMilliseconds} ms");
}
- else
+ catch (Exception exc)
{
- dbResult = dbController.DoorGetByKey(doorId);
- rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
- await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
+ Log.Error($"Exception during DoorGetByKey: {exc}{Environment.NewLine}");
}
- if (dbResult == null)
- {
- dbResult = new DoorModel();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"DoorGetByKey | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
@@ -1129,37 +1227,44 @@ namespace WebDoorCreator.Data.Services
{
string source = "DB";
List? dbResult = new List();
- // cerco da cache
- string currKey = $"{Constants.rKeyDoorsByOrder}:{orderId}";
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string? rawData = await redisDb.StringGetAsync(currKey);
- if (!string.IsNullOrEmpty(rawData))
+ try
{
- source = "REDIS";
- var tempResult = JsonConvert.DeserializeObject>(rawData);
- if (tempResult == null)
+ // cerco da cache
+ string currKey = $"{Constants.rKeyDoorsByOrder}:{orderId}";
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ string? rawData = await redisDb.StringGetAsync(currKey);
+ if (!string.IsNullOrEmpty(rawData))
{
- dbResult = new List();
+ source = "REDIS";
+ var tempResult = JsonConvert.DeserializeObject>(rawData);
+ if (tempResult == null)
+ {
+ dbResult = new List();
+ }
+ else
+ {
+ dbResult = tempResult;
+ }
}
else
{
- dbResult = tempResult;
+ dbResult = dbController.DoorsGetByOrderId(orderId);
+ rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
+ await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
+ if (dbResult == null)
+ {
+ dbResult = new List();
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorGetByOrderId | {source} in: {ts.TotalMilliseconds} ms");
}
- else
+ catch (Exception exc)
{
- dbResult = dbController.DoorsGetByOrderId(orderId);
- rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
- await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
+ Log.Error($"Exception during DoorGetByOrderId: {exc}{Environment.NewLine}");
}
- if (dbResult == null)
- {
- dbResult = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"DoorGetByOrderId | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
@@ -1170,37 +1275,44 @@ namespace WebDoorCreator.Data.Services
{
string source = "DB";
List? dbResult = new List();
- // cerco da cache
- string currKey = $"{Constants.rKeyDoorLast}:{numRec}";
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string? rawData = await redisDb.StringGetAsync(currKey);
- if (!string.IsNullOrEmpty(rawData))
+ try
{
- source = "REDIS";
- var tempResult = JsonConvert.DeserializeObject>(rawData);
- if (tempResult == null)
+ // cerco da cache
+ string currKey = $"{Constants.rKeyDoorLast}:{numRec}";
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ string? rawData = await redisDb.StringGetAsync(currKey);
+ if (!string.IsNullOrEmpty(rawData))
{
- dbResult = new List();
+ source = "REDIS";
+ var tempResult = JsonConvert.DeserializeObject>(rawData);
+ if (tempResult == null)
+ {
+ dbResult = new List();
+ }
+ else
+ {
+ dbResult = tempResult;
+ }
}
else
{
- dbResult = tempResult;
+ dbResult = dbController.DoorsGetLast(numRec);
+ rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
+ await redisDb.StringSetAsync(currKey, rawData, FastCache);
}
+ if (dbResult == null)
+ {
+ dbResult = new List();
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorGetLast | {source} in: {ts.TotalMilliseconds} ms");
}
- else
+ catch (Exception exc)
{
- dbResult = dbController.DoorsGetLast(numRec);
- rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
- await redisDb.StringSetAsync(currKey, rawData, FastCache);
+ Log.Error($"Exception during DoorGetLast: {exc}{Environment.NewLine}");
}
- if (dbResult == null)
- {
- dbResult = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"DoorGetLast | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
@@ -1211,10 +1323,22 @@ namespace WebDoorCreator.Data.Services
///
public async Task DoorInsert(DoorModel newRec)
{
- var dbResult = await dbController.DoorInsert(newRec);
- // elimino cache redis dati ordine...
- await OrderDetailFlushCache(newRec.OrderId);
- await OrdersFlushCache();
+ int dbResult = 0;
+ try
+ {
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ dbResult = await dbController.DoorInsert(newRec);
+ // elimino cache redis dati ordine...
+ await OrderDetailFlushCache(newRec.OrderId);
+ await OrdersFlushCache();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorInsert | {newRec.DoorId} in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorInsert: {exc}{Environment.NewLine}");
+ }
return dbResult;
}
@@ -1225,12 +1349,24 @@ namespace WebDoorCreator.Data.Services
///
public async Task DoorOpDelete(DoorOpModel currDoorOp)
{
- var dbResult = await dbController.DoorOpDelete(currDoorOp);
- // elimino cache redis dati porta...
- bool answ = await DoorOpFlushCache(currDoorOp.DoorId);
- answ = answ && await DoorFlushCache(currDoorOp.DoorId);
- // elimino cache redis dati ordine...
- answ = answ && await OrdersFlushCache();
+ bool dbResult = false;
+ try
+ {
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ dbResult = await dbController.DoorOpDelete(currDoorOp);
+ // elimino cache redis dati porta...
+ bool answ = await DoorOpFlushCache(currDoorOp.DoorId);
+ answ = answ && await DoorFlushCache(currDoorOp.DoorId);
+ // elimino cache redis dati ordine...
+ answ = answ && await OrdersFlushCache();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorOpDelete | {currDoorOp.DoorOpId} in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorOpDelete: {exc}{Environment.NewLine}");
+ }
return dbResult;
}
@@ -1241,14 +1377,26 @@ namespace WebDoorCreator.Data.Services
///
public async Task DoorOpDeleteRange(List currDoorOpList)
{
- var dbResult = await dbController.DoorOpDeleteRange(currDoorOpList);
- // elimino cache redis dati porta...
- foreach (var item in currDoorOpList)
+ bool dbResult = false;
+ try
{
- bool answ = await DoorOpFlushCache(item.DoorId);
- answ = answ && await DoorFlushCache(item.DoorId);
- // elimino cache redis dati ordine...
- answ = answ && await OrdersFlushCache();
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ dbResult = await dbController.DoorOpDeleteRange(currDoorOpList);
+ // elimino cache redis dati porta...
+ foreach (var item in currDoorOpList)
+ {
+ bool answ = await DoorOpFlushCache(item.DoorId);
+ answ = answ && await DoorFlushCache(item.DoorId);
+ // elimino cache redis dati ordine...
+ answ = answ && await OrdersFlushCache();
+ }
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorOpDeleteRange in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorOpDeleteRange: {exc}{Environment.NewLine}");
}
return dbResult;
}
@@ -1260,12 +1408,24 @@ namespace WebDoorCreator.Data.Services
///
public async Task DoorOpFlushCache(int DoorId)
{
- RedisValue pattern = new RedisValue($"{Constants.rKeyDoorOp}*");
- if (DoorId > 0)
+ bool answ = false;
+ try
{
- pattern = new RedisValue($"{Constants.rKeyDoorOp}:{DoorId}*");
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ RedisValue pattern = new RedisValue($"{Constants.rKeyDoorOp}*");
+ if (DoorId > 0)
+ {
+ pattern = new RedisValue($"{Constants.rKeyDoorOp}:{DoorId}*");
+ }
+ answ = await ExecFlushRedisPattern(pattern);
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorOpFlushCache in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorOpFlushCache: {exc}{Environment.NewLine}");
}
- bool answ = await ExecFlushRedisPattern(pattern);
return answ;
}
@@ -1276,37 +1436,44 @@ namespace WebDoorCreator.Data.Services
{
string source = "DB";
List? dbResult = new List();
- // cerco da cache
- string currKey = $"{Constants.rKeyDoorOp}:{DoorId}";
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string? rawData = await redisDb.StringGetAsync(currKey);
- if (!string.IsNullOrEmpty(rawData))
+ try
{
- source = "REDIS";
- var tempResult = JsonConvert.DeserializeObject>(rawData);
- if (tempResult == null)
+ // cerco da cache
+ string currKey = $"{Constants.rKeyDoorOp}:{DoorId}";
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ string? rawData = await redisDb.StringGetAsync(currKey);
+ if (!string.IsNullOrEmpty(rawData))
{
- dbResult = new List();
+ source = "REDIS";
+ var tempResult = JsonConvert.DeserializeObject>(rawData);
+ if (tempResult == null)
+ {
+ dbResult = new List();
+ }
+ else
+ {
+ dbResult = tempResult;
+ }
}
else
{
- dbResult = tempResult;
+ dbResult = dbController.DoorOpGetByDoorId(DoorId);
+ rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
+ await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
+ if (dbResult == null)
+ {
+ dbResult = new List();
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorOpGetByDoorId | {source} in: {ts.TotalMilliseconds} ms");
}
- else
+ catch (Exception exc)
{
- dbResult = dbController.DoorOpGetByDoorId(DoorId);
- rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
- await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
+ Log.Error($"Exception during DoorOpFlushCache: {exc}{Environment.NewLine}");
}
- if (dbResult == null)
- {
- dbResult = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"DoorOpGetByDoorId | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
@@ -1318,16 +1485,23 @@ namespace WebDoorCreator.Data.Services
await Task.Delay(1);
string source = "DB";
DoorOpModel? dbResult = new DoorOpModel();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- dbResult = dbController.DoorOpGetById(doorOpId);
- if (dbResult == null)
+ try
{
- dbResult = new DoorOpModel();
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ dbResult = dbController.DoorOpGetById(doorOpId);
+ if (dbResult == null)
+ {
+ dbResult = new DoorOpModel();
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorOpGetById | {source} in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorOpGetById: {exc}{Environment.NewLine}");
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"DoorOpGetById | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
@@ -1338,32 +1512,39 @@ namespace WebDoorCreator.Data.Services
{
string resultDDF = "";
List ordListVal = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- var listOpAll = await DoorOpGetByDoorId(DoorId);
- if (listOpAll != null)
+ try
{
- List listOp = listOpAll.Where(x => x.userConfirm != "" && x.DtConfirm != null).ToList();
- if (listOp != null)
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ var listOpAll = await DoorOpGetByDoorId(DoorId);
+ if (listOpAll != null)
{
- // chiamo metodo x avewre DDF serializzato
- var CurrentCompoOrder = await ListValuesGetAll("*", "Hardware");
- if (CurrentCompoOrder != null)
+ List listOp = listOpAll.Where(x => x.userConfirm != "" && x.DtConfirm != null).ToList();
+ if (listOp != null)
{
- foreach (var item in CurrentCompoOrder.OrderBy(x => x.Ordinal).ToList())
+ // chiamo metodo x avewre DDF serializzato
+ var CurrentCompoOrder = await ListValuesGetAll("*", "Hardware");
+ if (CurrentCompoOrder != null)
{
- ordListVal.Add(item.TableName);
+ foreach (var item in CurrentCompoOrder.OrderBy(x => x.Ordinal).ToList())
+ {
+ ordListVal.Add(item.TableName);
+ }
}
+ // riordino
+ listOp = listOp.OrderBy(d => ordListVal.IndexOf(d.ObjectId)).ToList();
+ // converto in DDF!
+ resultDDF = currDdfConv.GetSerialized(listOp);
}
- // riordino
- listOp = listOp.OrderBy(d => ordListVal.IndexOf(d.ObjectId)).ToList();
- // converto in DDF!
- resultDDF = currDdfConv.GetSerialized(listOp);
}
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorOpGetDDF | in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorOpGetDDF: {exc}{Environment.NewLine}");
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"DoorOpGetDDF | in: {ts.TotalMilliseconds} ms");
return resultDDF;
}
@@ -1375,18 +1556,25 @@ namespace WebDoorCreator.Data.Services
{
List? dbResult = new List();
string source = "DB";
- // cerco da cache
- string currKey = $"{Constants.rKeyDoorOpType}:DEFAULT";
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- dbResult = await dbController.DoorOpTypeGetDefault();
- if (dbResult == null)
+ try
{
- dbResult = new List();
+ // cerco da cache
+ string currKey = $"{Constants.rKeyDoorOpType}:DEFAULT";
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ dbResult = await dbController.DoorOpTypeGetDefault();
+ if (dbResult == null)
+ {
+ dbResult = new List();
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorOpGetDefault | {source} in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorOpGetDefault: {exc}{Environment.NewLine}");
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"DoorOpGetDefault | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
@@ -1404,54 +1592,66 @@ namespace WebDoorCreator.Data.Services
Dictionary currValUpd = new Dictionary();
Dictionary> currParamsUpd = new Dictionary>();
string default2Design = "";
- // cerco il setup del template selezionato
- var listRecordTmp = await ListValuesGetAll(ObjectId, currTemplShape);
- if (listRecordTmp != null && currVal.ContainsKey("Folder") && currVal.ContainsKey(currTemplShape))
+ try
{
- string actKey = currVal[currTemplShape];
- var firstTemplate = listRecordTmp.Where(x => x.Value == actKey).FirstOrDefault();
- if (firstTemplate != null)
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ // cerco il setup del template selezionato
+ var listRecordTmp = await ListValuesGetAll(ObjectId, currTemplShape);
+ if (listRecordTmp != null && currVal.ContainsKey("Folder") && currVal.ContainsKey(currTemplShape))
{
- if (firstTemplate.DefaultVal != "")
+ string actKey = currVal[currTemplShape];
+ var firstTemplate = listRecordTmp.Where(x => x.Value == actKey).FirstOrDefault();
+ if (firstTemplate != null)
{
- default2Design = firstTemplate.DefaultVal;
- }
- else
- {
- default2Design = "1";
- }
- }
- // elimino dai valori di setup e attuali quanto non sia template/folder...
- currValUpd = currVal.Where(x => x.Key == "Folder" || x.Key == currTemplShape).ToDictionary(x => x.Key, x => x.Value);
- // preparo setup valori
- List listDefVal = new List();
- var listRecordGP = await ListValuesGetAll(ObjectId, $"Graphic Parameters{default2Design}");
- if (listRecordGP != null)
- {
- foreach (var item in listRecordGP)
- {
- if (item.isSerializable && item.DefaultVal.Contains(","))
+ if (firstTemplate.DefaultVal != "")
{
- listDefVal = item.DefaultVal.Trim().Split(",").ToList();
- currValUpd.Add(item.Value.Trim(), item.DefaultVal.Trim().Split(",")[0].Split("/")[0]);
+ default2Design = firstTemplate.DefaultVal;
}
else
{
- if (item.DefaultVal.Contains("/"))
+ default2Design = "1";
+ }
+ }
+ // elimino dai valori di setup e attuali quanto non sia template/folder...
+ currValUpd = currVal.Where(x => x.Key == "Folder" || x.Key == currTemplShape).ToDictionary(x => x.Key, x => x.Value);
+ // preparo setup valori
+ List listDefVal = new List();
+ var listRecordGP = await ListValuesGetAll(ObjectId, $"Graphic Parameters{default2Design}");
+ if (listRecordGP != null)
+ {
+ foreach (var item in listRecordGP)
+ {
+ if (item.isSerializable && item.DefaultVal.Contains(","))
{
- listDefVal = new List() { item.DefaultVal.Trim().Split("/")[0] };
- currValUpd.Add(item.Value.Trim(), item.DefaultVal.Trim().Split("/")[0]);
+ listDefVal = item.DefaultVal.Trim().Split(",").ToList();
+ currValUpd.Add(item.Value.Trim(), item.DefaultVal.Trim().Split(",")[0].Split("/")[0]);
}
else
{
- listDefVal = new List() { item.DefaultVal.Trim() };
- currValUpd.Add(item.Value.Trim(), item.DefaultVal.Trim());
+ if (item.DefaultVal.Contains("/"))
+ {
+ listDefVal = new List() { item.DefaultVal.Trim().Split("/")[0] };
+ currValUpd.Add(item.Value.Trim(), item.DefaultVal.Trim().Split("/")[0]);
+ }
+ else
+ {
+ listDefVal = new List() { item.DefaultVal.Trim() };
+ currValUpd.Add(item.Value.Trim(), item.DefaultVal.Trim());
+ }
}
+ //defaultParamsList.Add(listDefVal);
+ currParamsUpd.Add(item.Value.Trim(), listDefVal);
}
- //defaultParamsList.Add(listDefVal);
- currParamsUpd.Add(item.Value.Trim(), listDefVal);
}
}
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorOpGetUpdatedVals in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorOpGetUpdatedVals: {exc}{Environment.NewLine}");
}
return (currValUpd, currParamsUpd);
}
@@ -1464,12 +1664,25 @@ namespace WebDoorCreator.Data.Services
///
public async Task DoorOpInsert(int DoorId, List newOpList)
{
- var dbResult = await dbController.DoorOpInsert(newOpList);
- // elimino cache redis dati porta...
- bool answ = await DoorOpFlushCache(DoorId);
- answ = answ && await DoorFlushCache(DoorId);
- // elimino cache redis dati ordine...
- answ = answ && await OrdersFlushCache();
+ bool dbResult = false;
+ try
+ {
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ dbResult = await dbController.DoorOpInsert(newOpList);
+ // elimino cache redis dati porta...
+ bool answ = await DoorOpFlushCache(DoorId);
+ answ = answ && await DoorFlushCache(DoorId);
+ // elimino cache redis dati ordine...
+ answ = answ && await OrdersFlushCache();
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorOpInsert in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorOpInsert: {exc}{Environment.NewLine}");
+ }
return dbResult;
}
@@ -1484,66 +1697,78 @@ namespace WebDoorCreator.Data.Services
Dictionary? actDict = new Dictionary();
Dictionary? actDictNew = new Dictionary();
Dictionary>? defaultDictNew = new Dictionary>();
- // per prima cosa deserializzo i valori attuali dal record...
- if (!string.IsNullOrEmpty(currDoorOp.JsoncActVal))
+ try
{
- actDict = JsonConvert.DeserializeObject>(currDoorOp.JsoncActVal);
- // verifico di avere valori validi
- if (actDict != null)
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ // per prima cosa deserializzo i valori attuali dal record...
+ if (!string.IsNullOrEmpty(currDoorOp.JsoncActVal))
{
- // cerco il setup del template selezionato
- var listRecordTmp = await ListValuesGetAll(currDoorOp.ObjectId, "template");
- if (listRecordTmp != null && actDict.ContainsKey("Folder") && (actDict.ContainsKey("template") || actDict.ContainsKey("shape")))
+ actDict = JsonConvert.DeserializeObject>(currDoorOp.JsoncActVal);
+ // verifico di avere valori validi
+ if (actDict != null)
{
- string actKey = actDict["template"];// Path.Combine(actDict["Folder"], actDict["template"]);
- var firstTemplate = listRecordTmp.Where(x => x.Value == actKey).FirstOrDefault();
- if (firstTemplate != null)
+ // cerco il setup del template selezionato
+ var listRecordTmp = await ListValuesGetAll(currDoorOp.ObjectId, "template");
+ if (listRecordTmp != null && actDict.ContainsKey("Folder") && (actDict.ContainsKey("template") || actDict.ContainsKey("shape")))
{
- if (firstTemplate.DefaultVal != "")
+ string actKey = actDict["template"];// Path.Combine(actDict["Folder"], actDict["template"]);
+ var firstTemplate = listRecordTmp.Where(x => x.Value == actKey).FirstOrDefault();
+ if (firstTemplate != null)
{
- default2Design = firstTemplate.DefaultVal;
- }
- else
- {
- default2Design = "1";
- }
- }
- // elimino dai valori di setup e attuali quanto non sia template/folder...
- actDictNew = actDict.Where(x => x.Key == "Folder" || x.Key == "template").ToDictionary(x => x.Key, x => x.Value);
- // preparo setup valori
- List listDefVal = new List();
- var listRecordGP = await ListValuesGetAll(currDoorOp.ObjectId, $"Graphic Parameters{default2Design}");
- if (listRecordGP != null)
- {
- foreach (var item in listRecordGP)
- {
- if (item.isSerializable && item.DefaultVal.Contains(","))
+ if (firstTemplate.DefaultVal != "")
{
- listDefVal = item.DefaultVal.Trim().Split(",").ToList();
- actDictNew.Add(item.Value.Trim(), item.DefaultVal.Trim().Split(",")[0].Split("/")[0]);
+ default2Design = firstTemplate.DefaultVal;
}
else
{
- if (item.DefaultVal.Contains("/"))
+ default2Design = "1";
+ }
+ }
+ // elimino dai valori di setup e attuali quanto non sia template/folder...
+ actDictNew = actDict.Where(x => x.Key == "Folder" || x.Key == "template").ToDictionary(x => x.Key, x => x.Value);
+ // preparo setup valori
+ List listDefVal = new List();
+ var listRecordGP = await ListValuesGetAll(currDoorOp.ObjectId, $"Graphic Parameters{default2Design}");
+ if (listRecordGP != null)
+ {
+ foreach (var item in listRecordGP)
+ {
+ if (item.isSerializable && item.DefaultVal.Contains(","))
{
- listDefVal = new List() { item.DefaultVal.Trim().Split("/")[0] };
- actDictNew.Add(item.Value.Trim(), item.DefaultVal.Trim().Split("/")[0]);
+ listDefVal = item.DefaultVal.Trim().Split(",").ToList();
+ actDictNew.Add(item.Value.Trim(), item.DefaultVal.Trim().Split(",")[0].Split("/")[0]);
}
else
{
- listDefVal = new List() { item.DefaultVal.Trim() };
- actDictNew.Add(item.Value.Trim(), item.DefaultVal.Trim());
+ if (item.DefaultVal.Contains("/"))
+ {
+ listDefVal = new List() { item.DefaultVal.Trim().Split("/")[0] };
+ actDictNew.Add(item.Value.Trim(), item.DefaultVal.Trim().Split("/")[0]);
+ }
+ else
+ {
+ listDefVal = new List() { item.DefaultVal.Trim() };
+ actDictNew.Add(item.Value.Trim(), item.DefaultVal.Trim());
+ }
}
+ //defaultParamsList.Add(listDefVal);
+ defaultDictNew.Add(item.Value.Trim(), listDefVal);
}
- //defaultParamsList.Add(listDefVal);
- defaultDictNew.Add(item.Value.Trim(), listDefVal);
}
+ // ri-serializzo e salvo!
+ currDoorOp.JsoncActVal = JsonConvert.SerializeObject(actDictNew);
+ currDoorOp.JsoncConfigVal = JsonConvert.SerializeObject(defaultDictNew);
}
- // ri-serializzo e salvo!
- currDoorOp.JsoncActVal = JsonConvert.SerializeObject(actDictNew);
- currDoorOp.JsoncConfigVal = JsonConvert.SerializeObject(defaultDictNew);
}
}
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorOpSetupGraphParams in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorOpSetupGraphParams: {exc}{Environment.NewLine}");
}
return currDoorOp;
}
@@ -1555,32 +1780,44 @@ namespace WebDoorCreator.Data.Services
///
public async Task DoorOpTypeAddRange(List currRecList)
{
- string rootPathNew = _configuration.GetValue("CompoBaseDirs:NewCompoDir");
- string rootPathOld = _configuration.GetValue("CompoBaseDirs:CurrCompoDir");
-
- var dbResult = await dbController.DoorOpTypeAddRange(currRecList);
-
- foreach (var item in currRecList)
+ bool dbResult = false;
+ try
{
- var pathSplit = item.OpCode.Split("\\");
- var allDirectories = Directory.GetDirectories(rootPathNew, $"{pathSplit[pathSplit.Length - 3]}\\{pathSplit[pathSplit.Length - 2]}", SearchOption.AllDirectories);
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ string rootPathNew = _configuration.GetValue("CompoBaseDirs:NewCompoDir");
+ string rootPathOld = _configuration.GetValue("CompoBaseDirs:CurrCompoDir");
- foreach (string dir in allDirectories)
- {
- string dirToCreate = dir.Replace(rootPathNew, rootPathOld);
- Directory.CreateDirectory(dirToCreate);
- }
- var allFiles = Directory.GetFiles(Path.Combine(rootPathNew, pathSplit[pathSplit.Length - 3], pathSplit[pathSplit.Length - 2]), pathSplit.Last(), SearchOption.AllDirectories);
+ dbResult = await dbController.DoorOpTypeAddRange(currRecList);
- foreach (string newPath in allFiles)
+ foreach (var item in currRecList)
{
- File.Copy(newPath, newPath.Replace(rootPathNew, rootPathOld), true);
+ var pathSplit = item.OpCode.Split("\\");
+ var allDirectories = Directory.GetDirectories(rootPathNew, $"{pathSplit[pathSplit.Length - 3]}\\{pathSplit[pathSplit.Length - 2]}", SearchOption.AllDirectories);
+
+ foreach (string dir in allDirectories)
+ {
+ string dirToCreate = dir.Replace(rootPathNew, rootPathOld);
+ Directory.CreateDirectory(dirToCreate);
+ }
+ var allFiles = Directory.GetFiles(Path.Combine(rootPathNew, pathSplit[pathSplit.Length - 3], pathSplit[pathSplit.Length - 2]), pathSplit.Last(), SearchOption.AllDirectories);
+
+ foreach (string newPath in allFiles)
+ {
+ File.Copy(newPath, newPath.Replace(rootPathNew, rootPathOld), true);
+ }
}
+ // elimino cache redis dati porta...
+ bool answ = await ExecFlushRedisPattern(Constants.rKeyDoorOpType);
+
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorOpTypeAddRange in: {ts.TotalMilliseconds} ms");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorOpTypeAddRange: {exc}{Environment.NewLine}");
}
- //$"{pathSplit[pathSplit.Length - 3]}\\{pathSplit[pathSplit.Length - 2]}"
-
- // elimino cache redis dati porta...
- bool answ = await ExecFlushRedisPattern(Constants.rKeyDoorOpType);
return dbResult;
}
@@ -1592,18 +1829,25 @@ namespace WebDoorCreator.Data.Services
await Task.Delay(1);
string source = "DB";
List? dbResult = new List();
- // cerco da cache
- string currKey = $"{Constants.rKeyDoorOpType}";
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- dbResult = dbController.DoorOpTypeGetAll();
- if (dbResult == null)
+ try
{
- dbResult = new List();
+ // cerco da cache
+ string currKey = $"{Constants.rKeyDoorOpType}";
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ dbResult = dbController.DoorOpTypeGetAll();
+ if (dbResult == null)
+ {
+ dbResult = new List();
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorOpTypeGetAll | {source} in: {ts.TotalMilliseconds} ms"); stopWatch.Stop();
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Exception during DoorOpTypeGetAll: {exc}{Environment.NewLine}");
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"DoorOpTypeGetAll | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
@@ -1616,61 +1860,68 @@ namespace WebDoorCreator.Data.Services
List? dbResult = new List();
string currKey = "";
- // cerco da cache
- if (hwCode == "*")
+ try
{
- currKey = $"{Constants.rKeyDoorOpType}";
- }
- else
- {
- currKey = $"{Constants.rKeyDoorOpType}:{hwCode}";
- }
- if (hwCode == "*" && parentId == -1)
- {
- // extracting entire set
- currKey = $"{Constants.rKeyDoorOpType}";
- }
- else if (hwCode != "*" && parentId == -1)
- {
- currKey = $"{Constants.rKeyDoorOpType}:{hwCode}";
- }
- else if (hwCode == "*" && parentId >= 0)
- {
- currKey = $"{Constants.rKeyDoorOpType}:{parentId}";
- }
- else if (hwCode != "*" && parentId >= 0)
- {
- currKey = $"{Constants.rKeyDoorOpType}:{hwCode}:{parentId}";
- }
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string? rawData = await redisDb.StringGetAsync(currKey);
- if (!string.IsNullOrEmpty(rawData))
- {
- source = "REDIS";
- var tempResult = JsonConvert.DeserializeObject>(rawData);
- if (tempResult == null)
+ // cerco da cache
+ if (hwCode == "*")
{
- dbResult = new List();
+ currKey = $"{Constants.rKeyDoorOpType}";
}
else
{
- dbResult = tempResult;
+ currKey = $"{Constants.rKeyDoorOpType}:{hwCode}";
}
+ if (hwCode == "*" && parentId == -1)
+ {
+ // extracting entire set
+ currKey = $"{Constants.rKeyDoorOpType}";
+ }
+ else if (hwCode != "*" && parentId == -1)
+ {
+ currKey = $"{Constants.rKeyDoorOpType}:{hwCode}";
+ }
+ else if (hwCode == "*" && parentId >= 0)
+ {
+ currKey = $"{Constants.rKeyDoorOpType}:{parentId}";
+ }
+ else if (hwCode != "*" && parentId >= 0)
+ {
+ currKey = $"{Constants.rKeyDoorOpType}:{hwCode}:{parentId}";
+ }
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ string? rawData = await redisDb.StringGetAsync(currKey);
+ if (!string.IsNullOrEmpty(rawData))
+ {
+ source = "REDIS";
+ var tempResult = JsonConvert.DeserializeObject>(rawData);
+ if (tempResult == null)
+ {
+ dbResult = new List();
+ }
+ else
+ {
+ dbResult = tempResult;
+ }
+ }
+ else
+ {
+ dbResult = dbController.DoorOpTypeGetFiltered(hwCode, parentId);
+ rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
+ await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
+ }
+ if (dbResult == null)
+ {
+ dbResult = new List();
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DoorOpTypeGetByHwCode | {source} in: {ts.TotalMilliseconds} ms");
}
- else
+ catch (Exception exc)
{
- dbResult = dbController.DoorOpTypeGetFiltered(hwCode, parentId);
- rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
- await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
+ Log.Error($"Exception during DoorOpTypeGetByHwCode: {exc}{Environment.NewLine}");
}
- if (dbResult == null)
- {
- dbResult = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"DoorOpTypeGetByHwCode | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
@@ -1905,61 +2156,8 @@ namespace WebDoorCreator.Data.Services
List doorOpTypesList = new List();
MD5 md5 = MD5.Create();
- //ciclo nelle directrory per avere tutti gli hw e le relative path del file di origine
-#if false
- //string[] dirs = Directory.GetDirectories(rootPath);
- //List HwsList = new List();
- //List listActiveCompo = await CompoGetAllActive(Path.Combine(rootPath, @"Default.ini"));
- bool hwAdded = false;
- foreach (string dir in dirs)
- {
- string compoCode = "";
- string[] templateDirectories = Directory.GetDirectories(dir);
-
- string[] iniFiles = Directory.GetFiles(dir, "Config.ini");
-
- foreach (var file in iniFiles)
- {
- List lines = File.ReadAllLines(file).ToList();
- IniFile fIni = new IniFile(file);
-
- var compoName = fIni.ReadString("Compo", "Name", "COMPONAME");
- var compoT = fIni.ReadString("Template", "Name", "TEMPSHAPE");
- compoCode = compoName.Split("/")[0].Trim();
- }
- if (listActiveCompo.Contains(compoCode))
- {
- DoorOpTypeModel tempHwType = new DoorOpTypeModel()
- {
- ParentId = 0,
- Description = $"Hardware Type {compoCode.Replace(" ", "_")}",
- OpCode = @$"{dir}",
- HasHw = true,
- IsConcrete = true,
- HwCode = $"{compoCode}".Replace(" ", "_")
- };
- doorOpTypesList.Add(tempHwType);
- }
- }
- //scrivo su db hws
- hwAdded = await dbController.DoorOpTypeAddRange(doorOpTypesList);
-
- if (hwAdded)
- {
- //estraggo lista di hardware in dooroptype
- var temp = dbController.DoorOpTypeGetFiltered("*", 0);
- if (temp != null)
- {
- HwsList = temp;
- doorOpTypesList.Clear();
- }
- }
-#endif
-
//ciclo nelle directories usando la colonna opcode
//foreach (var itemOld in HwsList)
- //{
- //}
string dir = HwTpl.OpCode;
string compoCode = "";
string compoTempOrShape = "";
@@ -2526,35 +2724,10 @@ namespace WebDoorCreator.Data.Services
currFileLastMod = itemNew.lastModTime;
newMD5 = itemNew.FileMD5;
- // scansione memoria su memoria: sull'elenco oldFile, sostituendo rootPathNew con rootPathOld
- // copia è BRUTTO; non fare
-#if false
- var allFiles = Directory.GetFiles(itemNew.FileBaseDir, Path.GetFileName(itemNew.FileAbsPath).Split("\\")[Path.GetFileName(itemNew.FileAbsPath).Split("\\").Length - 1], SearchOption.AllDirectories);
- if (allFiles.Length > 0)
- {
- foreach (string newPath in allFiles)
- {
- File.Copy(newPath, newPath.Replace(rootPathNew, rootPathOld), true);
- }
- }
-#endif
var currTpl = oldFiles.Where(t => t.FileRelPath == itemNew.FileRelPath.Replace("NewComp", "CurComp") && t.FileMD5 == itemNew.FileMD5).FirstOrDefault();
- //var currTpl = oldFiles.Where(t => t.FileRelPath == itemOld.FileRelPath && t.FileMD5 == itemOld.FileMD5 && t.FileDim == itemOld.FileDim && t.lastModTime == itemOld.lastModTime).FirstOrDefault();
if (currTpl != null)
{
- // NON DEVO rileggere, ho tutto nel fileDTO della scansione precedente...
-#if false
- if (File.Exists(itemNew.FileAbsPath))
- {
- FileInfo fi = new FileInfo(currTpl.FileAbsPath);
- currFileDim = fi.Length;
- currFileLastMod = fi.LastWriteTime;
- var fileContent = File.ReadAllBytes(currTpl.FileAbsPath);
- var hash = md5.ComputeHash(fileContent);
- newMD5 = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
- }
-#endif
// verifica sul DB
archiviedFiles = dbController.DoorOpTypeGetByPath(currTpl.FileBaseDir);
@@ -2564,22 +2737,6 @@ namespace WebDoorCreator.Data.Services
tempStats.Add(0);
if (path2Search == null)
{
-#if false
- DoorOpTypeModel tempTpl = new DoorOpTypeModel()
- {
- ParentId = 0,
- Description = $"Template for {currTpl.HwCode}",
- OpCode = @$"{currTpl.FileAbsPath}",
- HasHw = true,
- IsConcrete = true,
- HwCode = currTpl.HwCode,
- FileDim = currFileDim,
- FileMD5 = newMD5,
- LastMod = currFileLastMod,
- status = 1
- };
- doorOpTypesList.Add(tempTpl);
-#endif
}
else if (path2Search.FileMD5 != newMD5 || path2Search.FileDim != currFileDim || path2Search.LastMod != currFileLastMod)
{
@@ -2589,7 +2746,6 @@ namespace WebDoorCreator.Data.Services
path2Search.Description = "modded";
path2Search.status = 2;
await dbController.DoorOpTypeUpdate(path2Search);
- //doorOpTypesList.Add(tempTpl);
}
}
else
@@ -2609,173 +2765,10 @@ namespace WebDoorCreator.Data.Services
};
doorOpTypesList.Add(tempTpl);
oldFiles.Add(itemNew);
- //tempStats.Add(1);
}
}
archiviedFiles.Clear();
-#if false
- foreach (var itemOld in oldFiles)
- {
- if (File.Exists(itemOld.FileAbsPath))
- {
- FileInfo fi = new FileInfo(itemOld.FileAbsPath);
- var fileContent = File.ReadAllBytes(itemOld.FileAbsPath);
- var hash = md5.ComputeHash(fileContent);
- newMD5 = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
- archiviedFiles = dbController.DoorOpTypeGetByPath(itemOld.FileBaseDir);
- }
- var path2Search = archiviedFiles
- .Where(x => x.OpCode == itemOld.FileAbsPath)
- .FirstOrDefault();
- if (path2Search != null)
- {
- string[] files = Directory.GetFiles(itemOld.FileBaseDir.Replace("CurComp", "NewComp"), "*");
-
- if (!files.Contains(path2Search.OpCode.Replace("CurComp", "NewComp")))
- {
- path2Search.ValidUntil = DateTime.Now.AddMinutes(-1);
- path2Search.status = -1;
- }
- else
- {
- path2Search.ValidUntil = new DateTime(3000, 1, 1);
- path2Search.status = -1;
- }
-
- await dbController.DoorOpTypeUpdate(path2Search);
- }
-#if false
- else
- {
- DoorOpTypeModel tempTpl = new DoorOpTypeModel()
- {
- ParentId = 0,
- Description = $"Template for {item.HwCode}",
- OpCode = @$"{item.FileAbsPath}",
- HasHw = true,
- IsConcrete = true,
- HwCode = item.HwCode,
- FileDim = currFileDim,
- FileMD5 = newMD5,
- LastMod = currFileLastMod,
- status = 1
- };
- doorOpTypesList.Add(tempTpl);
- }
-#endif
- }
-#endif
-
-#if false
- bool hwAdded = false;
- string rootPathNew = _configuration.GetValue("CompoBaseDirs:NewCompoDir");
- string rootPathCurr = _configuration.GetValue("CompoBaseDirs:CurrCompoDir");
- List doorOpTypesList = new List();
- List originalFiles = new List();
- List newFiles = new List();
- string[] dirs = Directory.GetDirectories(rootPathNew);
-
- //Cerco quali sono i componenti da scansionare
- List listActiveCompo = await CompoGetAllActive(Path.Combine(rootPathNew, @"Default.ini"));
- System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
- //Ciclo in tutte le cartelle ed estraggo le cartelle dei componenti
- foreach (string dir in dirs)
- {
- string compoCode = "";
-
- var archiviedHws = dbController.DoorOpTypeGetByPath(dir).Where(x => x.ParentId == 0).FirstOrDefault();
-
- List HwsList = new List();
- string[] iniFiles = Directory.GetFiles(dir, "Config.ini");
-
- foreach (var file in iniFiles)
- {
- List lines = File.ReadAllLines(file).ToList();
- IniFile fIni = new IniFile(file);
-
- var compoName = fIni.ReadString("Compo", "Name", "COMPONAME");
- var compoT = fIni.ReadString("Template", "Name", "TEMPSHAPE");
- compoCode = compoName.Split("/")[0].Trim();
- }
- if (listActiveCompo.Contains(compoCode))
- {
- DoorOpTypeModel tempHwType = new DoorOpTypeModel()
- {
- ParentId = 0,
- Description = $"Hardware Type {compoCode.Replace(" ", "_")}",
- OpCode = @$"{dir}",
- HasHw = true,
- IsConcrete = true,
- HwCode = $"{compoCode}".Replace(" ", "_")
- };
- if (archiviedHws == null)
- {
- doorOpTypesList.Add(tempHwType);
- }
-#if false
- else if (archiviedHws.OpCode == tempHwType.OpCode && archiviedHws.HwCode == tempHwType.HwCode)
- {
- doorOpTypesList.Add(tempHwType);
- }
-#endif
- if (doorOpTypesList.Count > 0)
- {
- //hwAdded = await dbController.DoorOpTypeAddRange(doorOpTypesList);
- }
- if (hwAdded)
- {
- //estraggo lista di hardware in dooroptype
- }
- }
- var temp = dbController.DoorOpTypeGetFiltered("*", 0);
- if (temp != null)
- {
- HwsList = temp;
- doorOpTypesList.Clear();
- }
-
- foreach (var item in HwsList)
- {
- string[] templateDirectories = Directory.GetDirectories(item.OpCode);
-
- foreach (var tplDir in templateDirectories)
- {
- string[] tpls = Directory.GetFiles(tplDir, "*");
- var archiviedFiles = dbController.DoorOpTypeGetByPath(tplDir);
- foreach (var tpl in tpls)
- {
- FileInfo fi = new FileInfo(tpl);
- var fileName = Path.GetFileName(tpl).Split("\\")[Path.GetFileName(tpl).Split("\\").Length - 1];
- var fileContent = File.ReadAllBytes(tpl);
- var hash = md5.ComputeHash(fileContent);
- var newMD5 = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
- List l = new List();
-
- var path2Search = archiviedFiles
- .Where(x => x.OpCode == tpl)
- .FirstOrDefault();
-
- if (path2Search == null)
- {
- var k = await ListValuesLuaNgeInsert(item);
- }
-
- //FileDTO currFileInfo = new FileDTO()
- //{
- // FilePath = fileName,
- // FileDim = fi.Length,
- // FileMD5 = newMD5,
- // lastModTime = fi.LastWriteTime
- //};
- //newFiles.Add()
- }
- }
- }
- }
-#endif
- //await dbController.DoorOpTypeAddRange(doorOpTypesList);
-
return doorOpTypesList;
}
@@ -2791,27 +2784,6 @@ namespace WebDoorCreator.Data.Services
string[] dirs = Directory.GetDirectories(rootPath);
-#if false
- System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
- //se cartella corrente è vuota copio e incollo tutto dalla cartella new
- if (dirs.Length == 0 && !isNew)
- {
- var allDirectories = Directory.GetDirectories(newDirPath, "*", SearchOption.AllDirectories);
-
- foreach (string dir in allDirectories)
- {
- string dirToCreate = dir.Replace(newDirPath, currDirPath);
- Directory.CreateDirectory(dirToCreate);
- }
- var allFiles = Directory.GetFiles(newDirPath, "*.*", SearchOption.AllDirectories);
-
- foreach (string newPath in allFiles)
- {
- File.Copy(newPath, newPath.Replace(newDirPath, currDirPath), true);
- }
- }
-#endif
-
using (MD5 md5 = MD5.Create())
{
foreach (var dir in dirs)
diff --git a/WebDoorCreator.UI/Pages/UserAdmin.razor.cs b/WebDoorCreator.UI/Pages/UserAdmin.razor.cs
index a7096fb..060f732 100644
--- a/WebDoorCreator.UI/Pages/UserAdmin.razor.cs
+++ b/WebDoorCreator.UI/Pages/UserAdmin.razor.cs
@@ -8,6 +8,7 @@ using WebDoorCreator.Data.DbModels;
using WebDoorCreator.Data.Services;
using WebDoorCreator.Data.User;
using WebDoorCreator.UI.Data;
+using NLog;
namespace WebDoorCreator.UI.Pages
{
@@ -713,9 +714,12 @@ namespace WebDoorCreator.UI.Pages
catch (Exception ex)
{
strError = ex.GetBaseException().Message;
+ Log.Error($"{strError}{Environment.NewLine}");
}
}
+ private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
+
#endregion Private Methods
}
}
\ No newline at end of file
diff --git a/WebDoorCreator.UI/WebDoorCreator.UI.csproj b/WebDoorCreator.UI/WebDoorCreator.UI.csproj
index f5387b2..befbed7 100644
--- a/WebDoorCreator.UI/WebDoorCreator.UI.csproj
+++ b/WebDoorCreator.UI/WebDoorCreator.UI.csproj
@@ -3,7 +3,7 @@
net6.0
enable
- 0.9.2308.0108
+ 0.9.2308.0109
enable
aspnet-WebDoorCreator.UI-dfe95fed-1398-4144-bd43-8b3a765d6608