Update eliminazione parametri (da testare)

This commit is contained in:
Samuele Locatelli
2021-10-25 16:43:32 +02:00
parent 7f4a678b94
commit 78c8e78caa
8 changed files with 107 additions and 78 deletions
+1 -1
View File
@@ -364,7 +364,7 @@ namespace GWMS.UI.Controllers
try
{
List<objItem> currParams = await _DataService.getCurrObjItems(id);
// ora per ogni valore RICEVUTO costruisco un oggetto in innnovazioni da inviare...x salvare in stato parametri...
// ora per ogni valore RICEVUTO costruisco un oggetto in innovazioni da inviare...x salvare in stato parametri...
List<objItem> innovazioni = new List<objItem>();
foreach (var item in rawData.fluxData)
{
+34 -1
View File
@@ -624,7 +624,6 @@ namespace GWMS.UI.Data
.OrderByDescending(x => x.writable)
.ThenBy(x => x.name)
.ToList();
//answ.Sort((a, b) => (a.name.CompareTo(b.name)));
}
}
catch (Exception exc)
@@ -1083,6 +1082,40 @@ namespace GWMS.UI.Data
{ }
}
/// <summary>
/// Rimuove un item da parametri correnti x IOB
/// </summary>
/// <param name="idxMacchina"></param>
/// <param name="currValues"></param>
/// <returns></returns>
public async Task<bool> remObjItem(string idxMacchina, objItem item2rem)
{
bool answ = false;
if (item2rem != null)
{
string cacheKey = currParametersHash(idxMacchina);
string rawData;
var redisDataList = await distributedCache.GetAsync(cacheKey);
if (redisDataList != null)
{
rawData = Encoding.UTF8.GetString(redisDataList);
var actValues = JsonConvert.DeserializeObject<List<objItem>>(rawData);
// cerco e rimuovo
var remCand = actValues
.Where(x => x.uid == item2rem.uid)
.FirstOrDefault();
if (remCand != null)
{
actValues.Remove(remCand);
}
// salvo!
rawData = JsonConvert.SerializeObject(actValues);
await distributedCache.SetAsync(cacheKey, Encoding.UTF8.GetBytes(rawData));
}
}
return answ;
}
/// <summary>
/// RIMUOVE un PARAMETRO OPZIONALE dall'elenco di quelli salvati
/// </summary>
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Version>1.0.2110.2510</Version>
<Version>1.0.2110.2516</Version>
<UserSecretsId>95c9f021-52d1-4390-a670-5810b7b777b0</UserSecretsId>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
+11 -2
View File
@@ -13,7 +13,7 @@
<div class="d-flex justify-content-end">
<div class="p-2">
<div class="form-group mb-0">
<Button id="btnReset" class="btn btn-info btn-sm btn-block" Clicked="ResetFilter" title="Reset Filter"><span class="oi oi-loop-circular"></span></Button>
<Button id="btnReload" class="btn btn-info btn-sm btn-block" Clicked="() => ForceReload()" title="Reset Filter"><span class="oi oi-loop-circular"></span></Button>
</div>
</div>
<div class="p-2">
@@ -66,6 +66,7 @@
<th>Valore attuale/richiesto</th>
<th>Update</th>
<th class="text-right">Last message</th>
<th></th>
@*<th class="text-right">Carico <i class="fas fa-truck-moving"></i></th>
<th class="text-right">Ordine <i class="fas fa-file"></i></th>*@
</tr>
@@ -104,11 +105,19 @@
<span class="small text-info"> <i class="fas fa-arrow-left"></i> @record.reqValue</span>
}
</td>
<td>@record.lastRead.ToString("yyyy.MM.dd hh:mm:ss")</td>
<td>@record.lastRead.ToString("yyyy.MM.dd HH:mm:ss")</td>
<td>
<div>@record.lastMessage</div>
<div class="small">@record.lastRequest</div>
</td>
<td>
@if (editAll)
{
<button class="btn btn-sm btn-danger" title="Elimina parametro" @onclick="() => RemoveItem(record)">
<i class="fas fa-trash"></i>
</button>
}
</td>
</tr>
}
</tbody>
+57 -70
View File
@@ -39,6 +39,23 @@ namespace GWMS.UI.Pages
private bool isLoading { get; set; } = false;
private string SelPlantCode
{
get
{
string answ = "";
// cerco in elenco
var currPlant = PlantsList
.Where(x => x.PlantId == SelPlantId)
.FirstOrDefault();
if (currPlant != null)
{
answ = currPlant.PlantCode;
}
return answ;
}
}
private int SelPlantId
{
get
@@ -61,24 +78,6 @@ namespace GWMS.UI.Pages
}
}
private string SelPlantCode
{
get
{
string answ = "";
// cerco in elenco
var currPlant = PlantsList
.Where(x => x.PlantId == SelPlantId)
.FirstOrDefault();
if (currPlant != null)
{
answ = currPlant.PlantCode;
}
return answ;
}
}
#endregion Private Properties
#region Protected Properties
@@ -136,6 +135,20 @@ namespace GWMS.UI.Pages
}
}
protected bool editAll
{
get
{
bool answ = false;
var currMode = GetQueryParm("currMode");
if (!string.IsNullOrEmpty(currMode))
{
answ = currMode.Equals("debug");
}
return answ;
}
}
[Inject]
protected IJSRuntime JSRuntime { get; set; }
@@ -157,11 +170,6 @@ namespace GWMS.UI.Pages
#endregion Protected Properties
#region Public Properties
#endregion Public Properties
#region Private Methods
/// <summary>
@@ -217,46 +225,23 @@ namespace GWMS.UI.Pages
#region Protected Methods
#if false
/// <summary>
/// Creazione nuovo record Ordine
/// </summary>
protected void CreateNew(PlantLevSumDTO currItem)
{
var currPlant = PlantsList.Where(x => x.PlantId == SelPlantId).FirstOrDefault();
if (currPlant != null)
{
DateTime ordDate = currItem.DataRif.AddDays(-1);
// creo un nuovo record
currRecord = new OrderModel()
{
DtOrder = ordDate,
PlantId = SelPlantId,
SupplierId = SelSupplierId,
OrderDesc = $"Ord Man {currPlant.PlantDesc} - {ordDate}",
TransporterId = 1,
OrderCode = $"O{currPlant.PlantCode}{ordDate:yyMMddHHmm}",
LevelStart = Math.Round(currItem.LevelMin),
LevelEnd = Math.Round(currItem.LevelMax),
DtExecStart = currItem.FillStart,
DtExecEnd = currItem.FillEnd,
ExecutionQty = Math.Ceiling((currItem.LevelMax - currItem.LevelMin) / currItem.DeltaMin) * currItem.DeltaMin,
OrderQty = Math.Ceiling((currItem.LevelMax - currItem.LevelMin) / 2000) * 2000
};
}
}
#endif
protected void Edit(objItem selRecord)
{
// rileggo dal DB il record corrente...
var pUpd = Task.Run(async () =>
{
currRecord = selRecord;
});
pUpd.Wait();
currRecord = selRecord;
}
protected async Task ForceReload()
{
await ReloadAllData();
}
// Blazor: get query parm from the URL
protected string GetQueryParm(string parmName)
{
var uriBuilder = new UriBuilder(NavManager.Uri);
var q = System.Web.HttpUtility.ParseQueryString(uriBuilder.Query);
return q[parmName] ?? "";
}
protected override async Task OnInitializedAsync()
{
@@ -291,22 +276,24 @@ namespace GWMS.UI.Pages
await ReloadData();
}
protected async Task RemoveItem(objItem selRecord)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler rimuovere il parametro {selRecord.uid} ({selRecord.name})?"))
return;
if (selRecord != null)
{
await DataService.remObjItem(SelPlantCode, selRecord);
}
await ReloadAllData();
}
protected void ResetData()
{
DataService.rollBackEdit(currRecord);
currRecord = null;
}
protected async Task ResetFilter()
{
SelPlantId = 0;
currRecord = null;
ListRecords = null;
AppMService.Order_Filter = SelectOrderData.Init(5, 10);
await DataService.PlantsAnalisysReset(AppMService.Order_Filter);
await ReloadAllData();
}
protected void Select(objItem selRecord)
{
// applico filtro da selezione
@@ -352,4 +339,4 @@ namespace GWMS.UI.Pages
#endregion Public Methods
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>GWMS - Gas Warehouse Management System</i>
<h4>Versione: 1.0.2110.2510</h4>
<h4>Versione: 1.0.2110.2516</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.0.2110.2510
1.0.2110.2516
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.0.2110.2510</version>
<version>1.0.2110.2516</version>
<url>http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html</changelog>
<mandatory>false</mandatory>