ok gestione nuova dooroptypes

This commit is contained in:
zaccaria.majid
2023-06-06 11:56:56 +02:00
parent 43eba22eb3
commit ac115ac7ee
7 changed files with 86 additions and 24 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>WebDoorCreator - Egalware</i>
<h4>Version: 0.9.2306.0609</h4>
<h4>Version: 0.9.2306.0611</h4>
<br /> Release note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2306.0609
0.9.2306.0611
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2306.0609</version>
<version>0.9.2306.0611</version>
<url>http://nexus.steamware.net/repository/SWS/WDC/stable/WDC.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/WDC/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>
@@ -525,14 +525,14 @@ namespace WebDoorCreator.Data.Controllers
/// Retrieving data from door operation type table filtered by Hw Code
/// </summary>
/// <returns></returns>
public List<DoorOpTypeModel> DoorOpTypeGetByHwCode(string hwCode)
public List<DoorOpTypeModel> DoorOpTypeGetFiltered(string hwCode, int parentId)
{
List<DoorOpTypeModel> dbResult = new List<DoorOpTypeModel>();
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
{
try
{
if (hwCode == "*")
if (hwCode == "*" && parentId == -1)
{
// extracting entire set
dbResult = localDbCtx
@@ -540,7 +540,7 @@ namespace WebDoorCreator.Data.Controllers
.OrderBy(x => x.DoorOpTypId)
.ToList();
}
else
else if(hwCode != "*" && parentId == -1)
{
dbResult = localDbCtx
.DbSetDoorOpType
@@ -548,6 +548,22 @@ namespace WebDoorCreator.Data.Controllers
.OrderBy(x => x.DoorOpTypId)
.ToList();
}
else if(hwCode == "*" && parentId >= 0)
{
dbResult = localDbCtx
.DbSetDoorOpType
.Where(x => x.ParentId == parentId)
.OrderBy(x => x.DoorOpTypId)
.ToList();
}
else if(hwCode != "*" && parentId >= 0)
{
dbResult = localDbCtx
.DbSetDoorOpType
.Where(x => (x.ParentId == parentId) && x.HwCode == hwCode)
.OrderBy(x => x.DoorOpTypId)
.ToList();
}
}
catch (Exception exc)
{
@@ -1793,7 +1793,7 @@ namespace WebDoorCreator.Data.Services
/// <summary>
/// Door Operation Types
/// </summary>
public async Task<List<DoorOpTypeModel>?> DoorOpTypeGetByHwCode(string hwCode)
public async Task<List<DoorOpTypeModel>?> DoorOpTypeGetByHwCode(string hwCode, int parentId)
{
string source = "DB";
@@ -1808,7 +1808,23 @@ namespace WebDoorCreator.Data.Services
{
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);
@@ -1824,10 +1840,11 @@ namespace WebDoorCreator.Data.Services
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.DoorOpTypeGetByHwCode(hwCode);
dbResult = dbController.DoorOpTypeGetFiltered(hwCode, parentId);
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
@@ -1845,9 +1862,45 @@ namespace WebDoorCreator.Data.Services
{
List<ListValuesTempModel> values = new List<ListValuesTempModel>();
List<DoorOpTypeModel> doorOpTypesList = new List<DoorOpTypeModel>();
List<DoorOpTypeModel> HwsList = new List<DoorOpTypeModel>();
string[] dirs = Directory.GetDirectories(rootPath);
bool hwAdded = false;
//ciclo nelle directrory per beccare tutti gli hw e le relatice path del file di origine
foreach (string dir in dirs)
{
string compoCode = "";
string[] templateDirectories = Directory.GetDirectories(dir);
string[] iniFiles = Directory.GetFiles(dir, "Config.ini");
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();
}
}
//ciclo nelle directories usando la colonna opcode
foreach (var item in HwsList)
{
string dir = item.OpCode;
string compoCode = "";
string compoTempOrShape = "";
string[] templateDirectories = Directory.GetDirectories(dir);
@@ -1870,15 +1923,7 @@ namespace WebDoorCreator.Data.Services
compoCode = compoName.Split("/")[0].Trim();
compoTempOrShape = compoT.Split("/")[0].Trim();
}
DoorOpTypeModel tempHwType = new DoorOpTypeModel()
{
Description = $"Hardware Type {compoCode.Replace(" ", "_")}",
OpCode = @$"{dir}",
HasHw = true,
IsConcrete = true,
HwCode = $"{compoCode}".Replace(" ", "_")
};
doorOpTypesList.Add(tempHwType);
string[] templateFiles = Directory.GetFiles(templateDirectory);
if (templateFiles.Length > 0)
{
@@ -1938,6 +1983,7 @@ namespace WebDoorCreator.Data.Services
DoorOpTypeModel tempType = new DoorOpTypeModel()
{
ParentId = item.DoorOpTypId,
Description = $"Template for {compoCode.Replace(" ", "_")}",
OpCode = @$"{dir}\{tName[tName.Length - 1]}\{Path.GetFileName(templateFile)}",
HasHw = true,
@@ -52,11 +52,11 @@ namespace WebDoorCreator.UI.Components.Hardware
protected async Task ReloadData()
{
var temp = await WDCService.DoorOpTypeGetByHwCode("*");
if(temp != null)
{
//doorOpTypes = temp.Where(x=>x.);
}
//var temp = await WDCService.DoorOpTypeGetByHwCode("*");
//if(temp != null)
//{
// //doorOpTypes = temp.Where(x=>x.);
//}
}
}
}
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>0.9.2306.0609</Version>
<Version>0.9.2306.0611</Version>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-WebDoorCreator.UI-dfe95fed-1398-4144-bd43-8b3a765d6608</UserSecretsId>
</PropertyGroup>