261 lines
7.2 KiB
C#
261 lines
7.2 KiB
C#
using Core;
|
|
using Core.DTO;
|
|
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;
|
|
using static Core.Enum;
|
|
|
|
namespace LiMan.UI.Components
|
|
{
|
|
public partial class TicketsHP
|
|
{
|
|
#region Public Properties
|
|
|
|
[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 checkSelectTick(int currTicket)
|
|
{
|
|
string answ = "";
|
|
if (currTicket != 0)
|
|
{
|
|
try
|
|
{
|
|
answ = (currTicket == idxTicketSel) ? "table-info" : "";
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
public string decryptAuthKey(string authKey)
|
|
{
|
|
string answ = authKey;
|
|
try
|
|
{
|
|
answ = SteamCrypto.DecryptString(authKey, "AuthGPW");
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Fields
|
|
|
|
protected SubLicenzaModel _currRecord = new SubLicenzaModel();
|
|
protected LicenzaModel _masterLic = new LicenzaModel();
|
|
protected TipologiaTicket currTipo = TipologiaTicket.ND;
|
|
protected int idxTicketSel = 0;
|
|
protected bool showKey = false;
|
|
protected StatoRichiesta StatusSel = StatoRichiesta.ND;
|
|
|
|
#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);
|
|
}
|
|
|
|
protected async void closeDet()
|
|
{
|
|
await ReloadAllData();
|
|
}
|
|
|
|
/// <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 override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadAllData();
|
|
}
|
|
|
|
//protected string rowsel = "background:red";
|
|
protected async Task ResetData()
|
|
{
|
|
await FullReload();
|
|
}
|
|
|
|
protected void showDecrypt()
|
|
{
|
|
showKey = !showKey;
|
|
}
|
|
|
|
protected async Task showDet(TicketModel currTicket)
|
|
{
|
|
// salvo ticket sel
|
|
idxTicketSel = currTicket.IdxTicket;
|
|
StatusSel = currTicket.Status;
|
|
currTipo = currTicket.TType;
|
|
FileAttached = await DataService.FileGetFilt(idxTicketSel);
|
|
//rowsel = "background-color:red";
|
|
// mostro SOLO le attivazioni di cui ho ticket attivi...
|
|
ListActivations = MasterLicence
|
|
.Attivazioni
|
|
.Where(a => a.IdxSubLic == currTicket.IdxSubLic)
|
|
.ToList();
|
|
}
|
|
|
|
//protected void showDet(TicketModel currTicket)
|
|
//{
|
|
// // salvo ticket sel
|
|
// idxTicketSel = currTicket.IdxTicket;
|
|
// StatusSel = currTicket.Status;
|
|
// currTipo = currTicket.TType;
|
|
// FileAttached = await LMDService.FileGetFilt(idxTicketSel);
|
|
// // mostro SOLO le attivazioni di cui ho ticket attivi...
|
|
// ListActivations = MasterLicence
|
|
// .Attivazioni
|
|
// .Where(a => a.IdxSubLic == currTicket.IdxSubLic)
|
|
// .ToList();
|
|
//}
|
|
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 DataUpdated.InvokeAsync(0);
|
|
}
|
|
|
|
protected async void updateStato(StatoRichiesta nuovoStato)
|
|
{
|
|
if (nuovoStato == StatoRichiesta.Approvata || nuovoStato == StatoRichiesta.Rifiutata)
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Confermi l'azione richiesta? Ricorda che in caso di approvazione/rifiuto va modificato preventivamente il record dell'Attivazione coinvolta."))
|
|
return;
|
|
}
|
|
if (idxTicketSel > 0)
|
|
{
|
|
// salvo presa in carico ticket
|
|
await DataService.TicketUpdateState(idxTicketSel, nuovoStato);
|
|
await DataUpdated.InvokeAsync(0);
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private List<FileAttachModel> FileAttached;
|
|
private List<SubLicenzaModel> ListActivations;
|
|
private List<TicketModel> 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; }
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task FullReload()
|
|
{
|
|
await DataService.FlushRedisCache();
|
|
await ReloadAllData();
|
|
}
|
|
|
|
private async Task ReloadAllData()
|
|
{
|
|
isLoading = true;
|
|
ListActivations = null;
|
|
idxTicketSel = 0;
|
|
await Task.Delay(1);
|
|
ListRecords = MasterLicence.Tickets.ToList();
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |