204 lines
5.2 KiB
C#
204 lines
5.2 KiB
C#
using Core;
|
|
using LiMan.DB.DBModels;
|
|
using LiMan.UI.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LiMan.UI.Components
|
|
{
|
|
public partial class Activations
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public bool CanEdit { get; set; } = false;
|
|
|
|
[Parameter]
|
|
public EventCallback<int> DataReset { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<int> DataUpdated { get; set; }
|
|
|
|
[Parameter]
|
|
public LicenzaModel MasterLicence
|
|
{
|
|
get
|
|
{
|
|
return _masterLic;
|
|
}
|
|
set
|
|
{
|
|
_masterLic = value;
|
|
var pUpd = Task.Run(async () => await ReloadAllData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public string checkSelect(int IdxSubLic)
|
|
{
|
|
string answ = "";
|
|
if (currRecord != null)
|
|
{
|
|
try
|
|
{
|
|
answ = (currRecord.IdxSubLic == IdxSubLic) ? "table-info" : "";
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
public string decryptAuthKey(string authKey)
|
|
{
|
|
string answ = authKey;
|
|
try
|
|
{
|
|
string passphrase = (MasterLicence.CodApp == "GPW") ? "AuthGPW" : MasterLicence.CodApp;
|
|
answ = SteamCrypto.DecryptString(authKey, passphrase);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Fields
|
|
|
|
protected SubLicenzaModel _currRecord = new SubLicenzaModel();
|
|
protected LicenzaModel _masterLic = new LicenzaModel();
|
|
protected bool showKey = false;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected LiManDataService DataService { get; set; }
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected async void close()
|
|
{
|
|
await DataReset.InvokeAsync(0);
|
|
}
|
|
|
|
/// <summary> formatta testo secondo scadenza: scadenza < oggi --> verde scadenza > oggi -->
|
|
/// rosso </summary> <param name="scadenza"></param> <returns></returns>
|
|
protected string cssScadenza(DateTime scadenza)
|
|
{
|
|
string answ = "text-dark";
|
|
double periodo = scadenza.Subtract(DateTime.Today).TotalDays;
|
|
if (periodo <= 0)
|
|
{
|
|
answ = "text-success";
|
|
}
|
|
else
|
|
{
|
|
answ = "text-danger";
|
|
}
|
|
|
|
return answ;
|
|
}
|
|
|
|
protected async Task Remove(SubLicenzaModel selRecord)
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare in modo forzato la licenza? Operazione irreversibile."))
|
|
return;
|
|
|
|
// chiamo procedura sblocco...
|
|
await DataService.AttivazioneDelete(selRecord.IdxSubLic);
|
|
//await ResetData();
|
|
await DataUpdated.InvokeAsync(0);
|
|
}
|
|
|
|
protected async Task ResetData()
|
|
{
|
|
await fullReload();
|
|
}
|
|
|
|
protected void showDecrypt()
|
|
{
|
|
showKey = !showKey;
|
|
}
|
|
|
|
protected async Task UnLock(SubLicenzaModel selRecord)
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare il blocco? la data di scadenza verrà impostata a ieri liberando la licenza per cancellazioni o rimozioni."))
|
|
return;
|
|
|
|
// chiamo procedura sblocco...
|
|
await DataService.AttivazioneUnlock(selRecord.IdxSubLic);
|
|
//await ResetData();
|
|
await DataUpdated.InvokeAsync(0);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private List<SubLicenzaModel> ListRecords;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private SubLicenzaModel currRecord
|
|
{
|
|
get
|
|
{
|
|
return _currRecord;
|
|
}
|
|
set
|
|
{
|
|
_currRecord = value;
|
|
}
|
|
}
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
[Inject]
|
|
private IJSRuntime JSRuntime { get; set; }
|
|
|
|
private bool showKeyGen { get; set; } = false;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task fullReload()
|
|
{
|
|
await DataService.FlushRedisCache();
|
|
await ReloadAllData();
|
|
}
|
|
|
|
private async Task ReloadAllData()
|
|
{
|
|
isLoading = true;
|
|
ListRecords = null;
|
|
await Task.Delay(1);
|
|
ListRecords = MasterLicence.Attivazioni.ToList();
|
|
//SearchRecords = await LMDService.AttivazioniGetByLic(MasterLicence.IdxLic);
|
|
await Task.Delay(1);
|
|
isLoading = false;
|
|
}
|
|
|
|
private void ToggleKeyGen()
|
|
{
|
|
showKeyGen = !showKeyGen;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |