222 lines
6.8 KiB
C#
222 lines
6.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using SteamWare;
|
|
|
|
namespace PUB.WebUserControls
|
|
{
|
|
public partial class mod_elencoRichResetUtenti : System.Web.UI.UserControl
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
divDetail.Visible = false;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// ultimo comando letto da link button
|
|
/// </summary>
|
|
public string lastCmd { get; set; }
|
|
/// <summary>
|
|
/// gestione evento novo record
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
#if false
|
|
// richiamo pagina di edit senza parametri x metodo NEW
|
|
Response.Redirect("AccettazioneEdit");
|
|
#endif
|
|
}
|
|
public bool toBool(object value)
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
answ = Convert.ToBoolean(value);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// evento selezione paziente...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// recupero dati utente...
|
|
string USER_NAME = "";
|
|
try
|
|
{
|
|
USER_NAME = grView.SelectedDataKey["USER_NAME"].ToString();
|
|
}
|
|
catch
|
|
{ }
|
|
if (USER_NAME != "")
|
|
{
|
|
switch (lastCmd)
|
|
{
|
|
case "+1":
|
|
devicesAuthProxy.stObj.taUtenti.UpdateNumAuth(1, USER_NAME);
|
|
break;
|
|
case "-1":
|
|
devicesAuthProxy.stObj.taUtenti.UpdateNumAuth(-1, USER_NAME);
|
|
break;
|
|
case "Disattiva":
|
|
case "Attiva":
|
|
devicesAuthProxy.stObj.taUtenti.ToggleAttivo(SteamwareStrings.pseudoRandomString(20), USER_NAME);
|
|
break;
|
|
case "NoReset":
|
|
devicesAuthProxy.stObj.taUtenti.rejectResetAK(USER_NAME);
|
|
break;
|
|
case "ResetKeyAndDevices":
|
|
devicesAuthProxy.stObj.taUtenti.ResetKeyAndDevices(SteamwareStrings.pseudoRandomString(20), USER_NAME);
|
|
break;
|
|
case "SendMail":
|
|
// cerco chiave...
|
|
string AuthKey = "";
|
|
try
|
|
{
|
|
AuthKey = devicesAuthProxy.stObj.taUtenti.getByEmail(USER_NAME)[0].authKey;
|
|
}
|
|
catch
|
|
{ }
|
|
if (USER_NAME != "" && AuthKey != "")
|
|
{
|
|
string siteName = memLayer.ML.CRS("SiteName");
|
|
string body = "Salve,<br/><br/>Questo è un messaggio automatico generato da {3} a nome dell'amministratore della piattaforma.<br/><br/><a href=\"{0}/jumper?UserAuthkey={1}&USER_NAME={2}\">Prego cliccare sul seguente link (oppure copiare lo stesso ed incollarlo sul browser preferito)</a> per abilitare l'accesso a {3}.<br/><br/>Cordialmente.";
|
|
string subject = string.Format("Autorizzazione accesso a {0}", siteName);
|
|
// invio email!
|
|
devicesAuthProxy.stObj.sendEmailAuthKey(USER_NAME, AuthKey, siteName, subject, body);
|
|
}
|
|
break;
|
|
case "Edit":
|
|
// mostro dettaglio..
|
|
divDetail.Visible = true;
|
|
frmDetail.ChangeMode(FormViewMode.Edit);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
grView.DataBind();
|
|
}
|
|
|
|
protected void grView_RowCommand(object sender, GridViewCommandEventArgs e)
|
|
{
|
|
// salvo il command argument...
|
|
lastCmd = e.CommandArgument.ToString();
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// wrapper traduzione
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(string lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma);
|
|
}
|
|
/// <summary>
|
|
/// reset
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lnkReset_Click(object sender, EventArgs e)
|
|
{
|
|
grView.SelectedIndex = -1;
|
|
divDetail.Visible = false;
|
|
}
|
|
/// <summary>
|
|
/// Aggiunge tutti i permessi mancanti
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lnbAddNew_Click(object sender, EventArgs e)
|
|
{
|
|
#if false
|
|
// chiamo stored x creazione diritti missing
|
|
devicesAuthProxy.stObj.taDiritti.AddMissing(grView.SelectedValue.ToString(), "X999", memLayer.ML.confReadString("CodModulo"));
|
|
// update visualizzazione
|
|
grViewDiritti.DataBind();
|
|
#endif
|
|
}
|
|
/// <summary>
|
|
/// Aggiunge un utente con permesso base (hard coded!!!)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lnbAddNewUser_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
// uso email fuffa dataora@steamware...
|
|
string email = string.Format("{0:yyyyMMdd-HHmmss}@steamware.net", DateTime.Now);
|
|
// chiamo stored x creazione diritti missing
|
|
devicesAuthProxy.stObj.taUtenti.InsertQueryAndRight(email, "Cognome", "Nome", DateTime.Now.ToString("yyMMdd-HHmmss"), 1, memLayer.ML.confReadString("CodGruppo"), memLayer.ML.confReadString("CodCDC"), memLayer.ML.confReadString("CodModulo"), memLayer.ML.confReadString("CodFunzione"));
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(exc.ToString(), tipoLog.EXCEPTION);
|
|
}
|
|
// update visualizzazione
|
|
grView.DataBind();
|
|
}
|
|
/// <summary>
|
|
/// verifica se ci siano diritti da aggiungere
|
|
/// </summary>
|
|
public bool canAddDiritti
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
// conto se ci siano diritti missing...
|
|
try
|
|
{
|
|
int assegnati = devicesAuthProxy.stObj.taDiritti.getByUserModulo(grView.SelectedValue.ToString(), memLayer.ML.confReadString("CodModulo")).Rows.Count;
|
|
int disponibili = devicesAuthProxy.stObj.taFunzione.GetData().Rows.Count;
|
|
if (disponibili > assegnati) answ = true;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// verifica se sia cancellabile OVVERO NON ci siano diritti
|
|
/// </summary>
|
|
public bool canBeDeleted(object email)
|
|
{
|
|
bool answ = false;
|
|
// conto se ci siano diritti missing...
|
|
try
|
|
{
|
|
int assegnati = devicesAuthProxy.stObj.taDiritti.getByUserModulo(email.ToString(), memLayer.ML.confReadString("CodModulo")).Rows.Count;
|
|
if (assegnati == 0) answ = true;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// post aggiornamento aggiorno visualizzazioni
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void odsUserDet_Updated(object sender, ObjectDataSourceStatusEventArgs e)
|
|
{
|
|
grView.DataBind();
|
|
}
|
|
|
|
}
|
|
} |