94 lines
2.7 KiB
C#
94 lines
2.7 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
// <Auto-Generated>
|
|
// This is here so CodeMaid doesn't reorganize this document
|
|
// </Auto-Generated>
|
|
namespace LiMan.DB.DBModels
|
|
{
|
|
[Table("EnrollRequest")]
|
|
public partial class EnrollRequestModel
|
|
{
|
|
/// <summary>
|
|
/// ID univoco
|
|
/// </summary>
|
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
public int IdReq { get; set; }
|
|
|
|
/// <summary>
|
|
/// Passcode usato epr autorizzare (rnd al momento della richiesta)
|
|
/// </summary>
|
|
public int Passcode { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Payload richiesta, ovvero la serializzazione json di un Dict[string,string] delle info ricevute
|
|
/// </summary>
|
|
public string ReqPayload { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// DataOra richiesta enroll
|
|
/// </summary>
|
|
public DateTime DtReq { get; set; } = DateTime.Now;
|
|
|
|
/// <summary>
|
|
/// DataOra approvazione
|
|
/// </summary>
|
|
public DateTime? DtAppr { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Username approvatore
|
|
/// </summary>
|
|
public string UserAppr { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Licenza fornita in risposta alla richiesta
|
|
/// </summary>
|
|
public int IdxLic { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Indica Scaduta se non approvata e richiesta da oltre 15 minuti
|
|
/// </summary>
|
|
[NotMapped]
|
|
public bool IsScaduta
|
|
{
|
|
get => DtAppr == null && DateTime.Now.Subtract(DtReq).TotalMinutes > 15;
|
|
}
|
|
[NotMapped]
|
|
public Dictionary<string, string> DictAttrib
|
|
{
|
|
get
|
|
{
|
|
Dictionary<string, string> answ = new Dictionary<string, string>();
|
|
if (!string.IsNullOrEmpty(ReqPayload))
|
|
{
|
|
try
|
|
{
|
|
answ = JsonConvert.DeserializeObject<Dictionary<string, string>>(ReqPayload);
|
|
}
|
|
catch { }
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
public int DictNumKVP()
|
|
{
|
|
return DictAttrib.Count;
|
|
}
|
|
public Dictionary<string, string> DictAttribShort(int numMax)
|
|
{
|
|
Dictionary<string, string> answ = DictAttrib;
|
|
if (answ.Count > numMax)
|
|
{
|
|
answ = answ.Take(numMax).ToDictionary(x => x.Key, x => x.Value);
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
}
|