Nuovo progetto CORE x API + UI
This commit is contained in:
@@ -0,0 +1,210 @@
|
||||
using GPW.CORE.Data;
|
||||
using GPW.CORE.Data.DbModels;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace GPW.CORE.UI.Data
|
||||
{
|
||||
public class MessageService
|
||||
{
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private string _pageIcon = "";
|
||||
|
||||
private string _pageName = "";
|
||||
|
||||
private string _searchVal = "";
|
||||
|
||||
private DipendentiModel _rigaDip;
|
||||
|
||||
private bool showSearch;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Events
|
||||
|
||||
public event Action EA_HideSearch = null!;
|
||||
|
||||
public event Action EA_PageUpdated = null!;
|
||||
|
||||
public event Action EA_SearchUpdated = null!;
|
||||
|
||||
public event Action EA_ShowSearch = null!;
|
||||
|
||||
#endregion Public Events
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public string PageIcon
|
||||
{
|
||||
get => _pageIcon;
|
||||
set
|
||||
{
|
||||
if (_pageIcon != value)
|
||||
{
|
||||
_pageIcon = value;
|
||||
ReportPageUpd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string PageName
|
||||
{
|
||||
get => _pageName;
|
||||
set
|
||||
{
|
||||
if (_pageName != value)
|
||||
{
|
||||
_pageName = value;
|
||||
ReportPageUpd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string SearchVal
|
||||
{
|
||||
get => _searchVal;
|
||||
set
|
||||
{
|
||||
if (_searchVal != value)
|
||||
{
|
||||
_searchVal = value;
|
||||
|
||||
if (EA_SearchUpdated != null)
|
||||
{
|
||||
EA_SearchUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DipendentiModel? RigaDip
|
||||
{
|
||||
get => _rigaDip;
|
||||
set
|
||||
{
|
||||
if (_rigaDip != value)
|
||||
{
|
||||
_rigaDip = value;
|
||||
|
||||
if (EA_SearchUpdated != null)
|
||||
{
|
||||
EA_SearchUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int IdxDipendente
|
||||
{
|
||||
get
|
||||
{
|
||||
int answ = 0;
|
||||
if (_rigaDip != null)
|
||||
{
|
||||
answ = _rigaDip.IdxDipendente;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsActive
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = false;
|
||||
if (_rigaDip != null)
|
||||
{
|
||||
answ = (bool)_rigaDip.Attivo;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
public bool PayloadOk { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Calcola HASH del codice impiego = payload utente
|
||||
/// </summary>
|
||||
/// <param name="rigaDip"></param>
|
||||
/// <returns></returns>
|
||||
public string HashDip
|
||||
{
|
||||
get
|
||||
{
|
||||
string hash = "";
|
||||
string answ = "";
|
||||
if (_rigaDip != null)
|
||||
{
|
||||
answ = $"{_rigaDip.IdxDipendente}|{_rigaDip.Cognome}.{_rigaDip.Nome}|{_rigaDip.Cf}|{_rigaDip.DataAssunzione:yyyyMMdd}|{_rigaDip.Email}|{_rigaDip.Matricola}";
|
||||
}
|
||||
// hashing!
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
byte[] InputBytes = Encoding.UTF8.GetBytes(answ);
|
||||
var byteHash = md5.ComputeHash(InputBytes);
|
||||
hash = BitConverter.ToString(byteHash).Replace("-", "").ToLowerInvariant();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowSearch
|
||||
{
|
||||
get => showSearch;
|
||||
set
|
||||
{
|
||||
if (showSearch != value)
|
||||
{
|
||||
showSearch = value;
|
||||
if (showSearch)
|
||||
{
|
||||
if (EA_ShowSearch != null)
|
||||
{
|
||||
EA_ShowSearch?.Invoke();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (EA_HideSearch != null)
|
||||
{
|
||||
EA_HideSearch?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public RegAttivitaModel? recordRA { get; set; } = null;
|
||||
public RegAttivitaModel? clonedRA { get; set; } = null;
|
||||
|
||||
|
||||
public int selWeekNum { get; set; } = 0;
|
||||
public int selYear { get; set; } = DateTime.Today.Year;
|
||||
|
||||
public DateTime targetDate { get; set; } = DateTime.Today;
|
||||
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void ReportPageUpd()
|
||||
{
|
||||
if (EA_PageUpdated != null)
|
||||
{
|
||||
EA_PageUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void ReportSearch()
|
||||
{
|
||||
if (EA_SearchUpdated != null)
|
||||
{
|
||||
EA_SearchUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user