110 lines
2.7 KiB
C#
110 lines
2.7 KiB
C#
using GWMS.Data.DatabaseModels;
|
|
using GWMS.UI.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.JSInterop;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GWMS.UI.Components
|
|
{
|
|
public partial class ParamSetEditor
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public ParamSetModel currItem
|
|
{
|
|
get
|
|
{
|
|
return _currItem;
|
|
}
|
|
set
|
|
{
|
|
_currItem = value;
|
|
}
|
|
}
|
|
|
|
[Parameter]
|
|
public EventCallback<int> EC_DataReset { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<int> EC_DataUpdated { get; set; }
|
|
|
|
[Parameter]
|
|
public string IdxMacchina { get; set; } = "";
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Fields
|
|
|
|
protected ParamSetModel _currItem = new ParamSetModel();
|
|
|
|
#endregion Protected Fields
|
|
|
|
/// <summary>
|
|
/// fattore arrotondamento valori calcolati
|
|
/// </summary>
|
|
private int roundFactor = 100;
|
|
[Inject]
|
|
protected IConfiguration _configuration { get; set; } = null!;
|
|
protected override void OnParametersSet()
|
|
{
|
|
// fix arrotondamento
|
|
roundFactor = _configuration.GetValue<int>("RuntimeOpt:RoundFact", 10);
|
|
// aggiorno targetVal...
|
|
if (_currItem != null)
|
|
{
|
|
_currItem.TargetVal = Math.Round(_currItem.TargetVal * roundFactor) / roundFactor;
|
|
}
|
|
}
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected GWMSDataService DataService { get; set; }
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected string? FormatValueAsString(TValue? value)
|
|
{
|
|
return $"{value:N3}";
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private IJSRuntime JSRuntime { get; set; }
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task cancelUpdate()
|
|
{
|
|
await EC_DataReset.InvokeAsync(0);
|
|
}
|
|
|
|
private async Task saveUpdate()
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler modificare la programmazione del parametro?"))
|
|
return;
|
|
|
|
if (_currItem != null)
|
|
{
|
|
await DataService.ParamSetUpdateAsync(_currItem);
|
|
await EC_DataUpdated.InvokeAsync(0);
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("Record null!");
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |