Aggiunto btn x forzare syncDb

This commit is contained in:
Samuele Locatelli
2022-10-18 11:28:59 +02:00
parent 094ce0d181
commit f56a7e5164
6 changed files with 109 additions and 60 deletions
+1
View File
@@ -15,6 +15,7 @@ else
@if (currRecord != null && !showStats && isCurrOdl)
{
<div class="col-6 col-lg-8">
<button @onclick="() => forceSyncDb()" class="btn btn-success btn-sm btn-">Forza sync dati ODL <i class="bi bi-fast-forward-circle"></i></button>
</div>
<div class="col-6 col-lg-4 text-end">
@*<div class="px-2 input-group" title="Selezionare Data-Ora chiusura ODL">
+104 -56
View File
@@ -1,10 +1,8 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Data;
using MP.Data.DatabaseModels;
using MP.SPEC.Data;
using MP.SPEC.Pages;
using System.Xml.Linq;
using MP.SPEC.Services;
namespace MP.SPEC.Components
{
@@ -45,34 +43,10 @@ namespace MP.SPEC.Components
return MP.Data.Utils.FormDurata(durataMin);
}
//oggetto contenente le funzioni del code behind che sono jsInvokable
private DotNetObjectReference<ListODL>? objRef;
#if false //FUNZIONA SE IL METODO TriggerDotNetInstanceMethod() E' IN ONCLICK BOTTONE
[JSInvokable]
public void setHelper()
{
objRef = DotNetObjectReference.Create(this);
}
[JSInvokable]
public void svuotaRecord()
{
currRecord = null;
}
public async Task TriggerDotNetInstanceMethod()
{
await JSRuntime.InvokeVoidAsync("recordDeselect", objRef);
}
#endif
#endregion Public Methods
#region Protected Properties
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
@@ -82,6 +56,9 @@ namespace MP.SPEC.Components
[Inject]
protected MessageService MessageService { get; set; } = null!;
[Inject]
protected IOApiService MpIoApiCall { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
@@ -105,6 +82,34 @@ namespace MP.SPEC.Components
await reloadData();
}
protected string colorChanger(string colorCSS)
{
string answ = "";
if (colorCSS == "yellow")
{
answ = "text-dark";
}
return answ;
}
/// <summary>
/// Richiesta invio sync all'IOB-WIN
/// </summary>
/// <returns></returns>
protected async Task forceSyncDb()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sei sicuro di voler reinviare i dati (Articoli, PODL) all'impianto?"))
return;
if (currRecord != null)
{
await callSyncDb(currRecord.IdxMacchina);
// ricarica...
await selectRecord(null);
}
await reloadData();
}
protected override async Task OnInitializedAsync()
{
ListStati = await MDService.AnagStatiComm();
@@ -117,24 +122,6 @@ namespace MP.SPEC.Components
await reloadData();
}
protected string colorChanger(string colorCSS)
{
string answ = "";
if (colorCSS == "yellow")
{
answ = "text-dark";
}
return answ;
}
//protected double durataMin(DateTime? DataInizio, DateTime? DataFine)
//{
// DateTime end = DataInizio != null ? (DateTime)DataFine : DateTime.Now;
// var tsDurata = (end).Subtract((DateTime)DataInizio);
// return tsDurata.TotalMinutes;
//}
protected async void OnSeachUpdated()
{
await InvokeAsync(() =>
@@ -145,12 +132,18 @@ namespace MP.SPEC.Components
});
}
// return tsDurata.TotalMinutes;
//}
protected async Task resetSel()
{
await selectRecord(null);
await reloadData();
}
//protected double durataMin(DateTime? DataInizio, DateTime? DataFine)
//{
// DateTime end = DataInizio != null ? (DateTime)DataFine : DateTime.Now;
// var tsDurata = (end).Subtract((DateTime)DataInizio);
protected async Task selectRecord(ODLModel? currRec)
{
showStats = true;
@@ -167,6 +160,7 @@ namespace MP.SPEC.Components
ListOdlStats = null;
}
}
protected async Task selectStatRecord(ODLModel? currRec)
{
showStats = true;
@@ -205,16 +199,36 @@ namespace MP.SPEC.Components
private ODLModel? currRecord = null;
private ODLModel? statRecord = null;
private List<StatODLModel>? ListOdlStats;
private List<ODLModel>? ListRecords;
private List<ListValues>? ListStati;
//oggetto contenente le funzioni del code behind che sono jsInvokable
private DotNetObjectReference<ListODL>? objRef;
#if false //FUNZIONA SE IL METODO TriggerDotNetInstanceMethod() E' IN ONCLICK BOTTONE
[JSInvokable]
public void setHelper()
{
objRef = DotNetObjectReference.Create(this);
}
[JSInvokable]
public void svuotaRecord()
{
currRecord = null;
}
public async Task TriggerDotNetInstanceMethod()
{
await JSRuntime.InvokeVoidAsync("recordDeselect", objRef);
}
#endif
private List<ODLModel>? SearchRecords;
private ODLModel? statRecord = null;
#endregion Private Fields
#region Private Properties
@@ -242,17 +256,33 @@ namespace MP.SPEC.Components
}
private DateTime selDtFine { get; set; } = DateTime.Now;
private bool showStats { get; set; } = false;
#if false
private List<double>? ListOdlStatsData = new List<double>();
private List<string>? ListOdlStatsLabels = new List<string>();
#endif
private int totalCount { get; set; } = 0;
#endregion Private Properties
#region Private Methods
/// <summary>
/// Chiama metodo x chiedere sync DB
/// </summary>
/// <param name="selRec"></param>
/// <returns></returns>
private async Task addTask2Exe(string idxMacc, string taskName, string taskVal)
{
// compongo URL e chiamo
string restUrl = $"IOB/addTask2Exe/{idxMacc}?taskName={taskName}&taskVal={taskVal}";
try
{
var response = await MpIoApiCall.callMpIoUrlGet(restUrl);
}
catch (Exception exc)
{
}
}
private double calcolaPerc(double durata)
{
double answ = 0;
@@ -277,6 +307,28 @@ namespace MP.SPEC.Components
}
return answ;
}
/// <summary>
/// Chiama metodo x chiedere sync DB
/// </summary>
/// <param name="IdxMacc"></param>
/// <returns></returns>
private async Task callSyncDb(string IdxMacc)
{
// chiamo aggiunta task SyncDb...
await addTask2Exe(IdxMacc, "syncDbData", "");
}
#if false
private List<double>? ListOdlStatsData = new List<double>();
private List<string>? ListOdlStatsLabels = new List<string>();
#endif
private async void MessageService_EA_PageUpdated()
{
await reloadData();
}
private string pbStyle(string css)
{
string answ = "";
@@ -284,7 +336,7 @@ namespace MP.SPEC.Components
{
if (css == "yellow")
{
answ ="orange";
answ = "orange";
}
else if (css == "blue")
{
@@ -297,10 +349,6 @@ namespace MP.SPEC.Components
}
return answ;
}
private async void MessageService_EA_PageUpdated()
{
await reloadData();
}
private async Task reloadData()
{
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.16.2210.1810</Version>
<Version>6.16.2210.1811</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2210.1810</h4>
<h4>Versione: 6.16.2210.1811</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2210.1810
6.16.2210.1811
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2210.1810</version>
<version>6.16.2210.1811</version>
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>