Completo fix x reload e calcolo corretto DDF in caso di sovrapposizione richieste

This commit is contained in:
Samuele Locatelli
2024-03-11 12:51:04 +01:00
parent 2fa5a0df16
commit ab5757d0bd
10 changed files with 109 additions and 75 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>WebDoorCreator - Egalware</i>
<h4>Version: 0.9.2403.1110</h4>
<h4>Version: 0.9.2403.1112</h4>
<br /> Release note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2403.1110
0.9.2403.1112
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2403.1110</version>
<version>0.9.2403.1112</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>
-5
View File
@@ -151,11 +151,6 @@ namespace WebDoorCreator.Data.DDF
#region Protected Properties
#if false
protected Dictionary<string, List<Dictionary<string, string>>> dictDoorOP { get; set; } = new Dictionary<string, List<Dictionary<string, string>>>();
protected Dictionary<string, Dictionary<string, string>> dictBaseDoorOp { get; set; } = new Dictionary<string, Dictionary<string, string>>();
protected Dictionary<string, Dictionary<string, string>> dictBaseSwing { get; set; } = new Dictionary<string, Dictionary<string, string>>();
#endif
protected List<string> FootRows { get; set; } = new List<string>();
protected string FormatVers { get; set; } = "0";
protected List<string> HeadRows { get; set; } = new List<string>();
@@ -34,7 +34,7 @@
<div class="d-flex justify-content-between">
<div class=" py-1">
<HwSvgObj LineColor="#CFD8DC" LineWidth="8" ObjH="200" ObjW="700" EC_ExeFunct="()=> RecalcSVGs()" ObjId="Svg" ItemName="Recalc all the SVGs" ItemCount="0" ShowPlus="true" PlusOpacity="0%" BgColorFrom='@hexConverter("#2ECC71", 5)' BgColorTo="#2ECC71" ImagePath="images/icons/arrows-rotate-solid.svg"></HwSvgObj>
<HwSvgObj LineColor="#CFD8DC" LineWidth="8" ObjH="200" ObjW="700" EC_ExeFunct="()=> RecalcSVGs(false)" ObjId="Svg" ItemName="Recalc all the SVGs" ItemCount="0" ShowPlus="true" PlusOpacity="0%" BgColorFrom='@hexConverter("#2ECC71", 5)' BgColorTo="#2ECC71" ImagePath="images/icons/arrows-rotate-solid.svg"></HwSvgObj>
</div>
@if (isAddNew)
{
@@ -55,6 +55,8 @@ namespace WebDoorCreator.UI.Components.DoorMan
protected List<DoorOpModel> doorOps2Add = new List<DoorOpModel>();
protected string[] hexVals = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
#endregion Protected Fields
#region Protected Properties
@@ -253,20 +255,58 @@ namespace WebDoorCreator.UI.Components.DoorMan
return answ;
}
protected string hexConverter(string hexColor, int delta)
{
string answ = "";
if (hexColor != "" && hexColor != null)
{
var noHash = hexColor.Substring(1, hexColor.Length - 1);
StringBuilder sb = new StringBuilder();
foreach (var val in noHash)
{
sb.Append(newHexVal(val, delta));
}
answ = $"#{sb.ToString()}";
}
return answ;
}
protected async Task modalClose(bool isClose)
{
await Task.Delay(1);
isTpl = isClose;
await ReloadData();
}
private int lastOrderId = -1;
private DoorsSelectFilter lastFilt = new DoorsSelectFilter() { CurrPage = -1 };
protected string newHexVal(char str2Check, int delta)
{
string answ = "";
int runIdx = 0;
foreach (var item in hexVals)
{
if (item.ToLower() == str2Check.ToString().ToLower())
{
int currValIndex = Array.IndexOf(hexVals, item);
runIdx = currValIndex + delta;
runIdx = runIdx <= 15 ? runIdx : 15;
answ = hexVals[runIdx];
}
}
return answ;
}
protected override void OnInitialized()
{
WaitReloadSvg = Configuration.GetValue<int>("RuntimeOpt:WaitReloadSvg");
}
protected override async Task OnParametersSetAsync()
{
if (currOrderId != lastOrderId || !actFilter.Equals(lastFilt))
if (!actFilter.Equals(lastFilt))
{
lastOrderId = currOrderId;
lastFilt = actFilter.clone();
await ReloadData();
}
@@ -275,7 +315,7 @@ namespace WebDoorCreator.UI.Components.DoorMan
/// <summary>
/// Esecuzione ricalcolo SVG
/// </summary>
protected async void RecalcSVGs()
protected async void RecalcSVGs(bool force)
{
isRecalc = true;
// recupero elenco porte come list interi...
@@ -295,22 +335,30 @@ namespace WebDoorCreator.UI.Components.DoorMan
// chiamo reset richieste
var list2Proc = await QDService.ResetQueueByDoorList(doorIdList);
// se ho porte da processare --> chiamo save...
string currDDF = "";
int currDoorId = 0;
int currVers = 0;
foreach (var item in list2Proc)
if (force)
{
currDoorId = 0;
currVers = 0;
int.TryParse(item, out currDoorId);
if (currDoorId > 0)
// se ho porte da processare --> chiamo save...
string currDDF = "";
int currDoorId = 0;
int currVers = 0;
foreach (var item in list2Proc)
{
currDDF = await WDService.DoorOpGetDDF(currDoorId);
// versione corrente del DDF generato
currVers = await QDService.SendCalcReq(currDoorId, currDDF);
currDoorId = 0;
currVers = 0;
int.TryParse(item, out currDoorId);
if (currDoorId > 0)
{
currDDF = await WDService.DoorOpGetDDF(currDoorId);
// versione corrente del DDF generato
currVers = await QDService.SendCalcReq(currDoorId, currDDF);
}
}
}
else
{
// attesa prima di ricaricare 200/500 ms...
await Task.Delay(DoorsList.Count * (WaitReloadSvg / 3) * rnd.Next(900, 1200) / 1000);
}
}
isRecalc = false;
NavManager.NavigateTo(NavManager.Uri, true);
@@ -440,6 +488,14 @@ namespace WebDoorCreator.UI.Components.DoorMan
#endregion Protected Methods
#region Private Fields
private DoorsSelectFilter lastFilt = new DoorsSelectFilter() { CurrPage = -1 };
private Random rnd = new Random();
private int WaitReloadSvg = 100;
#endregion Private Fields
#region Private Properties
private int _totalCount { get; set; } = 0;
@@ -476,44 +532,5 @@ namespace WebDoorCreator.UI.Components.DoorMan
}
#endregion Private Properties
protected string[] hexVals = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
protected string newHexVal(char str2Check, int delta)
{
string answ = "";
int runIdx = 0;
foreach (var item in hexVals)
{
if (item.ToLower() == str2Check.ToString().ToLower())
{
int currValIndex = Array.IndexOf(hexVals, item);
runIdx = currValIndex + delta;
runIdx = runIdx <= 15 ? runIdx : 15;
answ = hexVals[runIdx];
}
}
return answ;
}
protected string hexConverter(string hexColor, int delta)
{
string answ = "";
if (hexColor != "" && hexColor != null)
{
var noHash = hexColor.Substring(1, hexColor.Length - 1);
StringBuilder sb = new StringBuilder();
foreach (var val in noHash)
{
sb.Append(newHexVal(val, delta));
}
answ = $"#{sb.ToString()}";
}
return answ;
}
}
}
@@ -43,7 +43,7 @@ else
}
else
{
<button class="btn btn-sm btn-primary me-1" @onclick="()=>setOrd2Show(item.OrderId)" title="Order detail"><i class="fa-solid fa-magnifying-glass"></i></button>
<button class="btn btn-sm btn-primary me-1" @onclick="()=>setOrd2Show(item.OrderId, true)" title="Order detail"><i class="fa-solid fa-magnifying-glass"></i></button>
<AuthorizeView Roles="SuperAdmin, DcaAdmin, DcaOrdMan, DcaProj" Context="OrderEdit">
<Authorized>
@if (item.OrderStatus < 30 || WDCUService.userRole == "DcaAdmin" || WDCUService.userRole == "SuperAdmin")
@@ -224,7 +224,7 @@ namespace WebDoorCreator.UI.Components.Order
if (localOrdId != 0)
{
await setOrd2Show(localOrdId);
await setOrd2Show(localOrdId, false);
}
}
}
@@ -267,16 +267,29 @@ namespace WebDoorCreator.UI.Components.Order
return $"api/Report/GetOrderReport?OrderId={orderId}&Format=PDF";
}
protected async Task setOrd2Show(int orderId)
private bool isLoading = false;
protected async Task setOrd2Show(int orderId, bool doSave)
{
await Task.Delay(1);
if (ListOrdersStatus == null && !isLoading)
{
await ReloadData();
}
else
{
await Task.Delay(200);
}
if (ListOrdersStatus != null)
{
var chosenOrd = ListOrdersStatus.Where(x => x.OrderId == orderId).FirstOrDefault();
if (chosenOrd != null)
{
Ord2Show = chosenOrd;
await localStorage.SetItemAsync("OrderId", orderId);
if (doSave)
{
await localStorage.SetItemAsync("OrderId", orderId);
}
await E_SetOrd2Show.InvokeAsync(chosenOrd);
}
}
@@ -406,6 +419,7 @@ namespace WebDoorCreator.UI.Components.Order
private async Task ReloadData()
{
isLoading = true;
ListOrdersStatus = null;
var domani = DateTime.Today.AddDays(1);
@@ -533,8 +547,7 @@ namespace WebDoorCreator.UI.Components.Order
}
}
}
await Task.Delay(1);
isLoading = false;
await InvokeAsync(StateHasChanged);
}
@@ -15,16 +15,18 @@ namespace WebDoorCreator.UI.Controllers
public DoorImageController(IConfiguration configuration, QueueDataService cQDService, WebDoorCreatorService cWDCService)
{
Log.Info("Starting DoorImageController");
Log.Trace("Starting DoorImageController");
_configuration = configuration;
WaitReloadSvg = _configuration.GetValue<int>("RuntimeOpt:WaitReloadSvg");
QDService = cQDService;
WDService = cWDCService;
Log.Info("Avviato DoorImageController");
Log.Trace("Avviato DoorImageController");
}
#endregion Public Constructors
private Random rnd = new Random();
#region Public Methods
// GET: api/DoorImage
@@ -44,7 +46,7 @@ namespace WebDoorCreator.UI.Controllers
string vetoReq = await QDService.DoorProcVetoGetAsync(DoorId);
if (string.IsNullOrEmpty(vetoReq))
{
await QDService.DoorProcVetoSetAsync(DoorId, 2000);
await QDService.DoorProcVetoSetAsync(DoorId, WaitReloadSvg * 20);
// richiede ricalcolo img
await SendRecalcReq(DoorId);
@@ -53,6 +55,13 @@ namespace WebDoorCreator.UI.Controllers
// riprova lettura
svgContent = await QDService.DoorGetLastSvg(DoorId);
}
else
{
// attesa causale per vedere SE riesce a leggere ugualmente...faccio rand (4..10)*wait reload...
await Task.Delay(WaitReloadSvg * rnd.Next(4, 10));
// riprovo lettura
svgContent = await QDService.DoorGetLastSvg(DoorId);
}
}
// se fosse vuoto...
if (string.IsNullOrEmpty(svgContent))
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>0.9.2403.1110</Version>
<Version>0.9.2403.1112</Version>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-WebDoorCreator.UI-dfe95fed-1398-4144-bd43-8b3a765d6608</UserSecretsId>
</PropertyGroup>