65d219dee9
- update parziale bootstrap5
132 lines
4.4 KiB
C#
132 lines
4.4 KiB
C#
using MapoDb;
|
|
using SteamWare;
|
|
using SteamWare.Logger;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace MP_MAG.WebUserControls
|
|
{
|
|
public partial class mod_enrollByAuthKey : System.Web.UI.UserControl
|
|
{
|
|
#region Internal Fields
|
|
|
|
/// <summary>
|
|
/// Oggetto datalayer specifico
|
|
/// </summary>
|
|
internal DataLayer DataLayerObj = new DataLayer();
|
|
|
|
#endregion Internal Fields
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// prova a fare enroll device data chiave...
|
|
/// </summary>
|
|
/// <param name="MatrOpr"></param>
|
|
/// <param name="userAgent"></param>
|
|
/// <param name="fatto"></param>
|
|
/// <param name="DeviceName"></param>
|
|
/// <param name="IPv4"></param>
|
|
/// <param name="userKey"></param>
|
|
/// <returns></returns>
|
|
private bool tryEnroll(int MatrOpr, string userAgent, bool fatto, string DeviceName, string IPv4, string userKey)
|
|
{
|
|
try
|
|
{
|
|
fatto = DataLayerObj.enrollDevice(userKey, IPv4, DeviceName, userAgent, MatrOpr);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
Logging.Instance.Info($"Errore in registrazione nuovo device con AuthKey utente: {Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
|
}
|
|
return fatto;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// resetto tutto
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAnnulla_Click(object sender, EventArgs e)
|
|
{
|
|
txtUserAuthKey.Text = "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// salvo nuovo device...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnConferma_Click(object sender, EventArgs e)
|
|
{
|
|
bool fatto = false;
|
|
// controllo se ho i dati...
|
|
string plainUserAuthKey = txtUserAuthKey.Text.Trim();
|
|
// in primis cerco il dipendente data la authKey...
|
|
int MatrOpr = 0;
|
|
try
|
|
{
|
|
MatrOpr = Convert.ToInt32(ddlIdxDipendente.SelectedValue);
|
|
}
|
|
catch
|
|
{ }
|
|
try
|
|
{
|
|
// controllo dipendente... che sia selezionato uno valido
|
|
if (MatrOpr > 0)
|
|
{
|
|
// recupero dati...
|
|
string userAgent = "";
|
|
string DeviceName = "";
|
|
string IPv4 = "";
|
|
userAgent = Request.UserAgent;
|
|
DeviceName = Request.UserHostName;
|
|
IPv4 = Request.UserHostName;
|
|
// calcolo authKey MD5...
|
|
string md5UserAuthKey = SteamCrypto.EncryptString(plainUserAuthKey, memLayer.ML.CRS("cookieName"));
|
|
if (DataLayerObj.taOp.getByMatrAuthKey(MatrOpr, md5UserAuthKey).Rows.Count > 0)
|
|
{
|
|
fatto = tryEnroll(MatrOpr, userAgent, fatto, DeviceName, IPv4, md5UserAuthKey);
|
|
}
|
|
// provo con "plainUserKey"
|
|
else if (DataLayerObj.taOp.getByMatrAuthKey(MatrOpr, plainUserAuthKey).Rows.Count > 0)
|
|
{
|
|
fatto = tryEnroll(MatrOpr, userAgent, fatto, DeviceName, IPv4, plainUserAuthKey);
|
|
}
|
|
else
|
|
{
|
|
lblWarning.Text = "AuthKey non trovata! richiedere reset ad Admin.";
|
|
lblWarning.Visible = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblWarning.Text = "Dipendente non trovato!";
|
|
lblWarning.Visible = true;
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
Logging.Instance.Info($"Errore in registrazione device: {Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
|
}
|
|
if (fatto)
|
|
{
|
|
Response.Redirect(memLayer.ML.CRS("mainPageMag"), true);
|
|
}
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |