Aggiunta possibilità "autoapprovazione" pdf SE

- superadmin
-url con ?config=debug
This commit is contained in:
Samuele Locatelli
2024-06-19 09:25:24 +02:00
parent 85259f334c
commit e1addcf11b
6 changed files with 72 additions and 5 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>WebDoorCreator - Egalware</i>
<h4>Version: 0.9.2405.0919</h4>
<h4>Version: 0.9.2406.1909</h4>
<br /> Release note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2405.0919
0.9.2406.1909
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2405.0919</version>
<version>0.9.2406.1909</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>
@@ -101,6 +101,11 @@ namespace WebDoorCreator.UI.Components.Hardware
[Inject]
protected WDCVocabularyService WDVService { get; set; } = null!;
[Inject]
protected NavigationManager NavMan { get; set; } = null!;
[Inject]
protected WDCUserService WDCUService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
@@ -225,6 +230,14 @@ namespace WebDoorCreator.UI.Components.Hardware
JsoncConfigVal = jsonDef,
JsoncActVal = jsonAct
};
// se debug + superadmin --> auto confirm
if (autoApprove)
{
doorOpToAdd.userConfirm = UserId;
doorOpToAdd.DtConfirm = DateTime.Now;
}
listOp.Add(doorOpToAdd);
// salvo Door OP associate
bool fatto = await WDCService.DoorOpInsert(DoorId, listOp);
@@ -239,6 +252,7 @@ namespace WebDoorCreator.UI.Components.Hardware
}
}
}
private bool autoApprove = false;
/// <summary>
/// Gestione update da oggetto sottostante
@@ -261,10 +275,25 @@ namespace WebDoorCreator.UI.Components.Hardware
DoorOp2ModList.Add(currItem);
}
}
/// <summary>
/// Blazor: get query parm from the URL
/// </summary>
/// <param name="parmName"></param>
/// <returns></returns>
protected string GetQueryParm(string parmName)
{
var uriBuilder = new UriBuilder(NavMan.Uri);
var q = System.Web.HttpUtility.ParseQueryString(uriBuilder.Query);
return q[parmName] ?? "";
}
protected override async Task OnInitializedAsync()
{
await Task.Delay(1);
var currMode = GetQueryParm("currMode");
if (!string.IsNullOrEmpty(currMode) && WDCUService.userRole == "SuperAdmin")
{
autoApprove = currMode.Equals("debug");
}
WDCRefresh.EA_ConfDoorOp += WDCRefresh_EA_ConfDoorOp;
}
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using Newtonsoft.Json;
using NLog;
using System;
using WebDoorCreator.Data.DbModels;
using WebDoorCreator.Data.Services;
using WebDoorCreator.UI.Data;
@@ -90,6 +91,10 @@ namespace WebDoorCreator.UI.Components.Hardware
protected List<ListValuesModel>? listValuesFiles { get; set; } = null!;
protected List<ListValuesModel>? listValuesFname { get; set; } = null!;
protected List<ListValuesModel>? listValuesHW { get; set; } = null!;
[Inject]
protected NavigationManager NavMan { get; set; } = null!;
protected List<string> ordListVal { get; set; } = new List<string>();
[Inject]
@@ -142,6 +147,9 @@ namespace WebDoorCreator.UI.Components.Hardware
[Inject]
protected WebDoorCreatorService WDCService { get; set; } = null!;
[Inject]
protected WDCUserService WDCUService { get; set; } = null!;
[Inject]
protected WDCVocabularyService WDVService { get; set; } = null!;
@@ -199,6 +207,12 @@ namespace WebDoorCreator.UI.Components.Hardware
// salvo i NUOVI valori...
DoorOpInst.CurrVals = dictValCurr;
DoorOpInst.GraphicParams = graphicParams;
// se debug + superadmin --> auto confirm
if (autoApprove && string.IsNullOrEmpty(DoorOpInst.userConfirm))
{
DoorOpInst.userConfirm = WDCUService.userId;
DoorOpInst.DtConfirm = DateTime.Now;
}
// salvo!
List<DoorOpModel> doorOpUpd = new List<DoorOpModel>() { DoorOpInst };
await WDCService.DoorOpUpdate(doorOpUpd);
@@ -211,6 +225,18 @@ namespace WebDoorCreator.UI.Components.Hardware
}
}
/// <summary>
/// Blazor: get query parm from the URL
/// </summary>
/// <param name="parmName"></param>
/// <returns></returns>
protected string GetQueryParm(string parmName)
{
var uriBuilder = new UriBuilder(NavMan.Uri);
var q = System.Web.HttpUtility.ParseQueryString(uriBuilder.Query);
return q[parmName] ?? "";
}
protected string getTrad(string objId)
{
string answ = "";
@@ -235,6 +261,12 @@ namespace WebDoorCreator.UI.Components.Hardware
hasChanged = currSer != origSer;
if (hasChanged)
{
// se debug + superadmin --> auto confirm
if (autoApprove && string.IsNullOrEmpty(DoorOpInst.userConfirm))
{
DoorOpInst.userConfirm = WDCUService.userId;
DoorOpInst.DtConfirm = DateTime.Now;
}
DoorOpInst.JsoncActVal = JsonConvert.SerializeObject(dictValCurr);
Task.Run(async () =>
{
@@ -256,6 +288,11 @@ namespace WebDoorCreator.UI.Components.Hardware
protected override void OnInitialized()
{
base.OnInitialized();
var currMode = GetQueryParm("currMode");
if (!string.IsNullOrEmpty(currMode) && WDCUService.userRole == "SuperAdmin")
{
autoApprove = currMode.Equals("debug");
}
string vers = config.GetValue<string>("ConfDDF:VersNumber");
bool remDoorOp = config.GetValue<bool>("ConfDDF:RemoveDoorOps");
var headRows = config.GetSection("ConfDDF:Header").Get<List<string>>();
@@ -328,6 +365,7 @@ namespace WebDoorCreator.UI.Components.Hardware
#region Private Fields
private static Logger Log = LogManager.GetCurrentClassLogger();
private bool autoApprove = false;
#endregion Private Fields
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>0.9.2405.0919</Version>
<Version>0.9.2406.1909</Version>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-WebDoorCreator.UI-dfe95fed-1398-4144-bd43-8b3a765d6608</UserSecretsId>
</PropertyGroup>