fix null string check errors

This commit is contained in:
Samuele E. Locatelli
2020-09-07 11:13:34 +02:00
parent 485cd8cd6f
commit 535b04e3b6
22 changed files with 1764 additions and 1740 deletions
+9
View File
@@ -29,3 +29,12 @@ dotnet_diagnostic.CA1044.severity = none
# CA1304: Specificare CultureInfo
dotnet_diagnostic.CA1304.severity = silent
# CA1303: Non passare valori letterali come parametri localizzati
dotnet_diagnostic.CA1303.severity = none
# CA1030: Usare gli eventi dove appropriato
dotnet_diagnostic.CA1030.severity = none
# CA1056: Le proprietà Uri non devono essere stringhe
dotnet_diagnostic.CA1056.severity = none
@@ -126,17 +126,20 @@ namespace GPW_Admin.WebUserControls
/// <param name="e"></param>
protected void imgClona_Click(object sender, ImageClickEventArgs e)
{
ImageButton lbtn = (ImageButton)sender;
int idxRa = 0;
try
if (sender != null)
{
idxRa = Convert.ToInt32(lbtn.CommandArgument);
ImageButton lbtn = (ImageButton)sender;
int idxRa = 0;
try
{
idxRa = Convert.ToInt32(lbtn.CommandArgument);
}
catch
{ }
// chiamo clona!
DataProxy.DP.taRA.clonaRecord(idxRa);
updateControl();
}
catch
{ }
// chiamo clona!
DataProxy.DP.taRA.clonaRecord(idxRa);
updateControl();
}
/// <summary>
/// fa update del controllo e chiama evento update esterno
@@ -227,26 +230,29 @@ namespace GPW_Admin.WebUserControls
/// <param name="e"></param>
protected void grView_RowDataBound(object sender, GridViewRowEventArgs e)
{
// controllo la riga
GridViewRow riga = e.Row;
if (grView.EditIndex >= 0 || grView.ShowFooter)
if (e != null)
{
try
// controllo la riga
GridViewRow riga = e.Row;
if (grView.EditIndex >= 0 || grView.ShowFooter)
{
//pre-seleziono idx progetto x ods fase...
DropDownList ddlProj_int = (DropDownList)riga.FindControl("ddlProgetto");
if (idxProjSel >= 0 && (ddlProj_int != null))
try
{
ddlProj_int.SelectedValue = idxProjSel.ToString();
}
DropDownList ddlFase_int = (DropDownList)riga.FindControl("ddlFase");
if (idxFaseSel >= 0 && (ddlFase_int != null))
{
ddlFase_int.SelectedValue = idxFaseSel.ToString();
//pre-seleziono idx progetto x ods fase...
DropDownList ddlProj_int = (DropDownList)riga.FindControl("ddlProgetto");
if (idxProjSel >= 0 && (ddlProj_int != null))
{
ddlProj_int.SelectedValue = idxProjSel.ToString();
}
DropDownList ddlFase_int = (DropDownList)riga.FindControl("ddlFase");
if (idxFaseSel >= 0 && (ddlFase_int != null))
{
ddlFase_int.SelectedValue = idxFaseSel.ToString();
}
}
catch
{ }
}
catch
{ }
}
}
/// <summary>
@@ -269,58 +275,61 @@ namespace GPW_Admin.WebUserControls
/// <param name="e"></param>
protected void ddlProgetto_SelectedIndexChanged(object sender, EventArgs e)
{
// salvo in session idxProjSel!
DropDownList ddlProj_int = (DropDownList)sender;
idxProjSel = Convert.ToInt32(ddlProj_int.SelectedValue);
// ricarico dati fasi
odsFase.DataBind();
// se in insert salvo orari e testo...
DateTime inizio = DateTime.Now;
DateTime fine = DateTime.Now;
string descr = "";
if (stato == statoControllo.insert)
if (sender != null)
{
inizio = ((mod_dateTime)grView.FooterRow.FindControl("dtInizio")).valoreDateTime;
fine = ((mod_dateTime)grView.FooterRow.FindControl("dtFine")).valoreDateTime;
descr = ((TextBox)grView.FooterRow.FindControl("txtDescrizione")).Text;
}
else
{
// se è edit...
int idx = grView.EditIndex;
inizio = ((mod_dateTime)grView.Rows[idx].FindControl("dtInizio")).valoreDateTime;
fine = ((mod_dateTime)grView.Rows[idx].FindControl("dtFine")).valoreDateTime;
descr = ((TextBox)grView.Rows[idx].FindControl("txtDescrizione")).Text;
}
refreshControlli();
// se in insert riporto orari e testo...
if (stato == statoControllo.insert)
{
((mod_dateTime)grView.FooterRow.FindControl("dtInizio")).valoreDateTime = inizio;
((mod_dateTime)grView.FooterRow.FindControl("dtFine")).valoreDateTime = fine;
((TextBox)grView.FooterRow.FindControl("txtDescrizione")).Text = descr;
try
// salvo in session idxProjSel!
DropDownList ddlProj_int = (DropDownList)sender;
idxProjSel = Convert.ToInt32(ddlProj_int.SelectedValue);
// ricarico dati fasi
odsFase.DataBind();
// se in insert salvo orari e testo...
DateTime inizio = DateTime.Now;
DateTime fine = DateTime.Now;
string descr = "";
if (stato == statoControllo.insert)
{
DropDownList ddlFase_int = (DropDownList)grView.FooterRow.FindControl("ddlFase");
ddlFase_int.SelectedIndex = 1;
inizio = ((mod_dateTime)grView.FooterRow.FindControl("dtInizio")).valoreDateTime;
fine = ((mod_dateTime)grView.FooterRow.FindControl("dtFine")).valoreDateTime;
descr = ((TextBox)grView.FooterRow.FindControl("txtDescrizione")).Text;
}
catch
{ }
}
else
{
// se è edit...
int idx = grView.EditIndex;
((mod_dateTime)grView.Rows[idx].FindControl("dtInizio")).valoreDateTime = inizio;
((mod_dateTime)grView.Rows[idx].FindControl("dtFine")).valoreDateTime = fine;
((TextBox)grView.Rows[idx].FindControl("txtDescrizione")).Text = descr;
try
else
{
DropDownList ddlFase_int = (DropDownList)grView.Rows[idx].FindControl("ddlFase");
ddlFase_int.SelectedIndex = 1;
// se è edit...
int idx = grView.EditIndex;
inizio = ((mod_dateTime)grView.Rows[idx].FindControl("dtInizio")).valoreDateTime;
fine = ((mod_dateTime)grView.Rows[idx].FindControl("dtFine")).valoreDateTime;
descr = ((TextBox)grView.Rows[idx].FindControl("txtDescrizione")).Text;
}
refreshControlli();
// se in insert riporto orari e testo...
if (stato == statoControllo.insert)
{
((mod_dateTime)grView.FooterRow.FindControl("dtInizio")).valoreDateTime = inizio;
((mod_dateTime)grView.FooterRow.FindControl("dtFine")).valoreDateTime = fine;
((TextBox)grView.FooterRow.FindControl("txtDescrizione")).Text = descr;
try
{
DropDownList ddlFase_int = (DropDownList)grView.FooterRow.FindControl("ddlFase");
ddlFase_int.SelectedIndex = 1;
}
catch
{ }
}
else
{
// se è edit...
int idx = grView.EditIndex;
((mod_dateTime)grView.Rows[idx].FindControl("dtInizio")).valoreDateTime = inizio;
((mod_dateTime)grView.Rows[idx].FindControl("dtFine")).valoreDateTime = fine;
((TextBox)grView.Rows[idx].FindControl("txtDescrizione")).Text = descr;
try
{
DropDownList ddlFase_int = (DropDownList)grView.Rows[idx].FindControl("ddlFase");
ddlFase_int.SelectedIndex = 1;
}
catch
{ }
}
catch
{ }
}
}
/// <summary>
@@ -358,19 +367,22 @@ namespace GPW_Admin.WebUserControls
/// <param name="e"></param>
protected void grView_RowCommand(object sender, GridViewCommandEventArgs e)
{
switch (e.CommandName)
if (e != null)
{
case "Cancel":
stato = statoControllo.item;
updateControl();
break;
case "Insert":
doInsert();
stato = statoControllo.item;
updateControl();
break;
default:
break;
switch (e.CommandName)
{
case "Cancel":
stato = statoControllo.item;
updateControl();
break;
case "Insert":
doInsert();
stato = statoControllo.item;
updateControl();
break;
default:
break;
}
}
}
@@ -89,13 +89,16 @@ namespace GPW_Admin.WebUserControls
/// <param name="e"></param>
protected void chkAttivo_CheckedChanged(object sender, EventArgs e)
{
// chiamo update attivo/non attivo...
CheckBox chkBox = (CheckBox)sender;
DataProxy.DP.taAP.updateAttivo(chkBox.Checked, memLayer.ML.IntSessionObj("idxProgetto_sel"));
fmView.DataBind();
if (eh_nuovoValore != null)
if (sender != null)
{
eh_nuovoValore(this, new EventArgs());
// chiamo update attivo/non attivo...
CheckBox chkBox = (CheckBox)sender;
DataProxy.DP.taAP.updateAttivo(chkBox.Checked, memLayer.ML.IntSessionObj("idxProgetto_sel"));
fmView.DataBind();
if (eh_nuovoValore != null)
{
eh_nuovoValore(this, new EventArgs());
}
}
}
/// <summary>
+1 -1
View File
@@ -296,7 +296,7 @@ public partial class mod_filtro : ApplicationUserControl
{
dlFilt.DataSource = _ods;
dlFilt.DataBind();
if (_valore != "")
if (!string.IsNullOrEmpty(_valore))
{
dlFilt.SelectedValue = _valore;
@@ -9,125 +9,125 @@ using System.Web.UI.WebControls;
namespace GPW_Admin.WebUserControls
{
public partial class mod_gestCalendario : System.Web.UI.UserControl
{
public partial class mod_gestCalendario : System.Web.UI.UserControl
{
/// <summary>
/// effettua traduzione del lemma
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
public string traduci(string lemma)
{
return user_std.UtSn.Traduci(lemma);
}
protected void Page_Load(object sender, EventArgs e)
{
grView.PageSize = utils.pageSize;
if (!Page.IsPostBack)
{
anno = DateTime.Now.Year;
intervalloDate currAnno = new intervalloDate
/// <summary>
/// effettua traduzione del lemma
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
public string traduci(string lemma)
{
inizio = DateTime.Today.AddYears(-2),
fine = DateTime.Today.AddYears(1)
};
mod_periodoAnalisi.intervalloAnalisi = currAnno;
lbtSetupYear.DataBind();
DateTime oggi = DateTime.Today;
inizioFerie = oggi.AddDays(1);
fineFerie = oggi.AddDays(2);
}
}
DateTime inizioFerie
{
get
{
DateTime answ = DateTime.Today;
DateTime.TryParse(txtInizio.Text, out answ);
return answ;
}
set
{
txtInizio.Text = value.ToString("yyyy-MM-dd");
}
}
DateTime fineFerie
{
get
{
DateTime answ = DateTime.Today;
DateTime.TryParse(txtFine.Text, out answ);
return answ;
}
set
{
txtFine.Text = value.ToString("yyyy-MM-dd");
}
}
/// <summary>
/// Anno corrente
/// </summary>
protected int anno
{
get
{
int answ = 0;
int.TryParse(txtAnno.Text, out answ);
return answ;
}
set
{
txtAnno.Text = value.ToString();
}
}
protected void lbtSetupYear_Click(object sender, EventArgs e)
{
setupFestAnno(anno);
}
private void setupFestAnno(int reqYear)
{
// recupero elenco festività
List<EventDetail> elencoFest = SteamWare.calendarMan.elencoFestAnno(reqYear);
// inserisco 1:1
if (elencoFest.Count > 0)
{
foreach (var item in elencoFest)
{
DataProxy.DP.taCFF.upsertQuery(item.when, "FEST", item.what);
return user_std.UtSn.Traduci(lemma);
}
}
doUpdate();
}
public void doUpdate()
{
// aggiorno!
grView.DataBind();
}
protected void lbtShowFerie_Click(object sender, EventArgs e)
{
divInsFerie.Visible = !divInsFerie.Visible;
}
protected void lbtSave_Click(object sender, EventArgs e)
{
int numGG = (int)fineFerie.Subtract(inizioFerie).TotalDays;
DateTime currDate = inizioFerie;
int currYear = DateTime.Today.Year;
// aggiungo ferie x periodo selezionato...
for (int i = 0; i < numGG; i++)
{
var currDay = inizioFerie.AddDays(i).DayOfWeek;
// controllo che NON SIA sabato/domenica...
if (currDay != DayOfWeek.Saturday && currDay != DayOfWeek.Sunday)
protected void Page_Load(object sender, EventArgs e)
{
DataProxy.DP.taCFF.upsertQuery(inizioFerie.AddDays(i), ddlCodGiustInsNew.SelectedValue, txtDescrizione.Text);
grView.PageSize = utils.pageSize;
if (!Page.IsPostBack)
{
anno = DateTime.Now.Year;
intervalloDate currAnno = new intervalloDate
{
inizio = DateTime.Today.AddYears(-2),
fine = DateTime.Today.AddYears(1)
};
mod_periodoAnalisi.intervalloAnalisi = currAnno;
lbtSetupYear.DataBind();
DateTime oggi = DateTime.Today;
inizioFerie = oggi.AddDays(1);
fineFerie = oggi.AddDays(2);
}
}
DateTime inizioFerie
{
get
{
DateTime answ = DateTime.Today;
_=DateTime.TryParse(txtInizio.Text, out answ);
return answ;
}
set
{
txtInizio.Text = value.ToString("yyyy-MM-dd");
}
}
DateTime fineFerie
{
get
{
DateTime answ = DateTime.Today;
_ = DateTime.TryParse(txtFine.Text, out answ);
return answ;
}
set
{
txtFine.Text = value.ToString("yyyy-MM-dd");
}
}
/// <summary>
/// Anno corrente
/// </summary>
protected int anno
{
get
{
int answ = 0;
_ = int.TryParse(txtAnno.Text, out answ);
return answ;
}
set
{
txtAnno.Text = value.ToString();
}
}
protected void lbtSetupYear_Click(object sender, EventArgs e)
{
setupFestAnno(anno);
}
private void setupFestAnno(int reqYear)
{
// recupero elenco festività
List<EventDetail> elencoFest = SteamWare.calendarMan.elencoFestAnno(reqYear);
// inserisco 1:1
if (elencoFest.Count > 0)
{
foreach (var item in elencoFest)
{
DataProxy.DP.taCFF.upsertQuery(item.when, "FEST", item.what);
}
}
doUpdate();
}
public void doUpdate()
{
// aggiorno!
grView.DataBind();
}
protected void lbtShowFerie_Click(object sender, EventArgs e)
{
divInsFerie.Visible = !divInsFerie.Visible;
}
protected void lbtSave_Click(object sender, EventArgs e)
{
int numGG = (int)fineFerie.Subtract(inizioFerie).TotalDays;
DateTime currDate = inizioFerie;
int currYear = DateTime.Today.Year;
// aggiungo ferie x periodo selezionato...
for (int i = 0; i < numGG; i++)
{
var currDay = inizioFerie.AddDays(i).DayOfWeek;
// controllo che NON SIA sabato/domenica...
if (currDay != DayOfWeek.Saturday && currDay != DayOfWeek.Sunday)
{
DataProxy.DP.taCFF.upsertQuery(inizioFerie.AddDays(i), ddlCodGiustInsNew.SelectedValue, txtDescrizione.Text);
}
}
// rieseguo insert festività x anno del periodo...
setupFestAnno(inizioFerie.Year);
}
}
// rieseguo insert festività x anno del periodo...
setupFestAnno(inizioFerie.Year);
}
}
}
@@ -97,7 +97,7 @@ public partial class mod_menuTop : ApplicationUserControl
{
lnkShowHide.Text = user_std.UtSn.Traduci("lnkShowHide");
lblTitle.Text = user_std.UtSn.Traduci(SteamWare.memLayer.ML.confReadString("titleApp"));
if (_titleString != "")
if (!string.IsNullOrEmpty(_titleString))
{
// traduzione di tutti i termini
lblMessUtente.Text = user_std.UtSn.Traduci(_titleString);
@@ -151,7 +151,7 @@
<asp:Label ID="lblIsOkTim" runat="server" Text="T" ForeColor="Red" Visible='<%# invBool(Eval("isOkTim")) %>' ToolTip="Errore Entrata/Uscita: non corrispondono." />
<asp:Label ID="lblIsOkApp" runat="server" Text="A" ForeColor="Red" Visible='<%# invBool(Eval("isOkApp")) %>' ToolTip="Errore: timbrature non approvate." />
<asp:Label ID="lblIsOkLav" runat="server" Text="O" ForeColor="Red" Visible='<%# invBool(Eval("isOkLav")) %>' ToolTip="Errore: manca copertura ore ordinarie." />
<asp:Label ID="lblChkFun" runat="server" Text='<%# Eval("chkFunCod") %>' ForeColor='<%# coloreMPP(Eval("minMpp")) %>' Visible='<%# Eval("chkFunCod").ToString() != "" %>' ToolTip='<%# Eval("chkFunRes") %>' />
<asp:Label ID="lblChkFun" runat="server" Text='<%# Eval("chkFunCod") %>' ForeColor='<%# coloreMPP(Eval("minMpp")) %>' Visible='<%# !string.IsNullOrEmpty(Eval("chkFunCod").ToString()) %>' ToolTip='<%# Eval("chkFunRes") %>' />
<asp:Label ID="lblIsOk" runat="server" Text="Ok" ForeColor="Green" Visible='<%# toBool(Eval("isOk")) %>' ToolTip="Errore di uno o più fra timbrature / giustificativi / approvazione" />
</b>
</ItemTemplate>
@@ -19,8 +19,8 @@ public partial class mod_ricercaGenerica : ApplicationUserControl
#endregion
# region area protected
#region area protected
protected override void Page_Load(object sender, EventArgs e)
{
base.Page_Load(sender, e);
@@ -88,7 +88,7 @@ public partial class mod_ricercaGenerica : ApplicationUserControl
/// </summary>
public void updateText()
{
if (SteamWare.memLayer.ML.StringSessionObj("valoreCercato") != "" && !Page.IsPostBack)
if (!string.IsNullOrEmpty(memLayer.ML.StringSessionObj("valoreCercato")) && !Page.IsPostBack)
{
testoRicerca = SteamWare.memLayer.ML.StringSessionObj("valoreCercato");
}
@@ -215,7 +215,7 @@ namespace GPW.WebUserControls
/// </summary>
private void checkBarcode()
{
if (barcodeIn != "")
if (!string.IsNullOrEmpty(barcodeIn))
{
// mostro i buttons enabled
btnEntrata.Enabled = true;
File diff suppressed because it is too large Load Diff
@@ -296,7 +296,7 @@ public partial class mod_filtro : ApplicationUserControl
{
dlFilt.DataSource = _ods;
dlFilt.DataBind();
if (_valore != "")
if (!string.IsNullOrEmpty(_valore))
{
dlFilt.SelectedValue = _valore;
@@ -97,7 +97,7 @@ public partial class mod_menuTop : ApplicationUserControl
{
lnkShowHide.Text = user_std.UtSn.Traduci("lnkShowHide");
lblTitle.Text = user_std.UtSn.Traduci(SteamWare.memLayer.ML.confReadString("titleApp"));
if (_titleString != "")
if (!string.IsNullOrEmpty(_titleString))
{
// traduzione di tutti i termini
lblMessUtente.Text = user_std.UtSn.Traduci(_titleString);
@@ -41,7 +41,7 @@ namespace GPW_Commesse.WebUserControls
{
set
{
if (value != "")
if (!string.IsNullOrEmpty(value))
{
memLayer.ML.setSessionVal("returnUrl", value);
lbHome.Visible = true;
@@ -88,7 +88,7 @@ public partial class mod_ricercaGenerica : ApplicationUserControl
/// </summary>
public void updateText()
{
if (SteamWare.memLayer.ML.StringSessionObj("valoreCercato") != "" && !Page.IsPostBack)
if (!string.IsNullOrEmpty(memLayer.ML.StringSessionObj("valoreCercato")) && !Page.IsPostBack)
{
testoRicerca = SteamWare.memLayer.ML.StringSessionObj("valoreCercato");
}
+325 -325
View File
@@ -7,352 +7,352 @@ using SteamWare;
namespace GPW_data
{
public class utils
{
/// <summary>
/// avvio oggetti utils
/// </summary>
protected utils()
public class utils
{
}
/// <summary>
/// restituisce elenco clienti trasformato in dictionary
/// </summary>
/// <returns></returns>
protected Dictionary<string, string> ricaricaElencoClienti()
{
Dictionary<string, string> answ = new Dictionary<string, string>();
// recupero elenco clienti da dataproxy
foreach (DS_Applicazione.AnagClientiRow riga in DataProxy.DP.taAnCli.GetData())
{
answ.Add(riga.idxCliente.ToString(), riga.RagSociale);
}
return answ;
}
/// <summary>
/// singleton accesso metodo
/// </summary>
public static utils mng = new utils();
/// <summary>
/// dim pagina gridView in sessione
/// </summary>
public static int pageSize
{
get
{
int answ = 20;
try
/// <summary>
/// avvio oggetti utils
/// </summary>
protected utils()
{
answ = SteamWare.memLayer.ML.IntSessionObj("pageSize");
if (answ <= 0) answ = 20;
}
catch
{ }
return answ;
}
set
{
SteamWare.memLayer.ML.setSessionVal("pageSize", value);
}
}
/// <summary>
/// oggetto elenco clienti organizzato come dizionario con chiave idxCliente e valore la ragione sociale
/// </summary>
public Dictionary<string, string> elencoClienti
{
set
{
string redKey = memLayer.ML.redHash("elencoClienti");
string rawData = JsonConvert.SerializeObject(value);
memLayer.ML.setRSV(redKey, rawData, 60);
}
get
{
Dictionary<string, string> answ = new Dictionary<string, string>();
string redKey = memLayer.ML.redHash("elencoClienti");
string rawData = memLayer.ML.getRSV(redKey);
if (!string.IsNullOrEmpty(rawData))
/// <summary>
/// restituisce elenco clienti trasformato in dictionary
/// </summary>
/// <returns></returns>
protected Dictionary<string, string> ricaricaElencoClienti()
{
try
{
answ = JsonConvert.DeserializeObject<Dictionary<string, string>>(rawData);
}
catch
{ }
Dictionary<string, string> answ = new Dictionary<string, string>();
// recupero elenco clienti da dataproxy
foreach (DS_Applicazione.AnagClientiRow riga in DataProxy.DP.taAnCli.GetData())
{
answ.Add(riga.idxCliente.ToString(), riga.RagSociale);
}
return answ;
}
if (answ.Count == 0)
/// <summary>
/// singleton accesso metodo
/// </summary>
public static utils mng = new utils();
/// <summary>
/// dim pagina gridView in sessione
/// </summary>
public static int pageSize
{
answ = ricaricaElencoClienti();
elencoClienti = answ;
}
return answ;
}
}
/// <summary>
/// Effettua un insieme di controlli sulle anomalie delel timbrature/orari e invia le relative eventuali email
/// </summary>
/// <returns></returns>
public bool checkAnomalie()
{
bool answ = false;
try
{
// log richiesta!
logger.lg.scriviLog("Richiesto controllo anomalie!", tipoLog.INFO);
/*******************************************************
* controllo le varie anomalie delle timbrature:
*
* (A) mancate approvazioni --> admin
* (B) entrate <> uscite --> admin, user
* (C) mancata copertura orario --> admin
*
* (D) mancata copertura commesse (2 be done)
*
* recupero elenco dip interessati x le varie anomalie con stp_DipendentiAndAnomalie
* e poi da timbrExpl recupero le singole istanze di record errori
*
*******************************************************/
// setup valori base
string fromEmail = memLayer.ML.confReadString("_fromEmail");
string adminEmail = memLayer.ML.confReadString("adminAnomalieEmail");
string adminContinuatoEmail = memLayer.ML.confReadString("adminContinuatoEmail");
string adminOreLavEmail = memLayer.ML.confReadString("adminOreLavEmail");
string oggettoEmail = "";
string corpoEmail = "";
DS_Applicazione.stp_DipendentiAndAnomalieDataTable tabDipAndAnom = new DS_Applicazione.stp_DipendentiAndAnomalieDataTable();
DS_Applicazione.TimbratureExplDataTable tabTimbExpl = new DS_Applicazione.TimbratureExplDataTable();
DS_Applicazione.TE_RA_ExplDataTable tabTimbRegAtt = new DS_Applicazione.TE_RA_ExplDataTable();
DateTime adesso = DateTime.Now;
int gg2Chk = memLayer.ML.confReadInt("gg2Chk");
int gg2ChkCont = memLayer.ML.confReadInt("gg2ChkCont");
int gg2ChkOreCaricate = memLayer.ML.confReadInt("gg2ChkOreCaricate");
// (A) recupero mancate approvazioni, mando solo ad admin
if (memLayer.ML.confReadBool("checkAnomAppr"))
{
tabTimbExpl = DataProxy.DP.taTimbExpl.getByDipAnomalia(0, adesso.AddDays(-gg2Chk), adesso.AddHours(1), true, false, false);
// se ho trovato record...
if (tabTimbExpl.Rows.Count > 0)
{
logger.lg.scriviLog("Trovate anomalie mancate approvazioni, invio email ad admin", tipoLog.INFO);
oggettoEmail = "Anomalie GPW: Approvazione Timbrature";
if (memLayer.ML.confReadBool("includeDirectUrl"))
get
{
corpoEmail = string.Format("Risultano a sistema le seguenti anomalie:<br/><a href=\"{0}A1/approvTimbrature.aspx\">timbrature da approvare</a><br/><br/>", memLayer.ML.confReadString("baseUrl"));
}
else
{
corpoEmail = "Risultano a sistema le seguenti anomalie: timbrature da approvare<br/>";
}
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
corpoEmail += "| -- DATA --\t| Dipendente<br/>";
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
foreach (DS_Applicazione.TimbratureExplRow riga in tabTimbExpl)
{
corpoEmail += string.Format("| {0:yyyy.MM.dd ddd}\t| {1}<br/>", riga.dataLav, riga.CognomeNome);
}
corpoEmail += SteamwareStrings.charLine('-', 80);
gestEmail.geAuth.mandaEmail(fromEmail, adminEmail, oggettoEmail, corpoEmail);
}
}
// (B) recupero errori entrate/uscite, mando ad admin + utenti
if (memLayer.ML.confReadBool("checkAnomTimb"))
{
tabDipAndAnom = DataProxy.DP.taDipAnom.GetData(adesso.AddDays(-gg2Chk), adesso.AddHours(1), false, true, false);
tabTimbExpl = DataProxy.DP.taTimbExpl.getByDipAnomalia(0, adesso.AddDays(-gg2Chk), adesso.AddHours(1), false, true, false);
// se ho trovato record...
if (tabTimbExpl.Rows.Count > 0)
{
logger.lg.scriviLog("Trovate anomalie timbrature IN/OUT non corrispondenti, invio email!", tipoLog.INFO);
// mando email ad admin!
oggettoEmail = "Anomalie GPW: Timbrature mancanti";
if (memLayer.ML.confReadBool("includeDirectUrl"))
{
corpoEmail = string.Format("Risultano a sistema le seguenti anomalie:<br/><a href=\"{0}A1/reviewTimbrature.aspx\">timbrature mancanti / non corrispondenti</a><br/><br/>", memLayer.ML.confReadString("baseUrl"));
}
else
{
corpoEmail = "Risultano a sistema le seguenti anomalie: timbrature mancanti<br/>";
}
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
corpoEmail += "| -- DATA --\t| Dipendente<br/>";
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
foreach (DS_Applicazione.TimbratureExplRow riga in tabTimbExpl)
{
corpoEmail += string.Format("| {0:yyyy.MM.dd ddd}\t| {1}<br/>", riga.dataLav, riga.CognomeNome);
}
corpoEmail += SteamwareStrings.charLine('-', 80);
gestEmail.geAuth.mandaEmail(fromEmail, adminEmail, oggettoEmail, corpoEmail);
// re richiesto invio email utenti x warning entrate/uscrite
if (memLayer.ML.confReadBool("sendEmailToUser"))
{
// mando singole email ai dipendenti SE C'è EMAIL!!!!
foreach (DS_Applicazione.stp_DipendentiAndAnomalieRow rigaDip in tabDipAndAnom)
{
if (rigaDip.email != "")
int answ = 20;
try
{
tabTimbExpl = DataProxy.DP.taTimbExpl.getByDipAnomalia(rigaDip.idxDipendente, adesso.AddDays(-gg2Chk), adesso.AddHours(1), false, true, false);
// reimposto testo
if (memLayer.ML.confReadBool("includeDirectUrl"))
{
corpoEmail = string.Format("Risultano a sistema le seguenti anomalie:<br/><a href=\"{0}A4/commesseUtente.aspx\">timbrature mancanti / non corrispondenti</a><br/><br/>", memLayer.ML.confReadString("baseUrl"));
}
else
{
corpoEmail = "Risultano a sistema le seguenti anomalie: timbrature mancanti / non corrispondenti<br/>";
}
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
corpoEmail += "| -- DATA --\t| -- Dipendente --<br/>";
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
foreach (DS_Applicazione.TimbratureExplRow riga in tabTimbExpl)
{
corpoEmail += string.Format("| {0:yyyy.MM.dd ddd}\t| {1}<br/>", riga.dataLav, riga.CognomeNome);
}
corpoEmail += SteamwareStrings.charLine('-', 80);
gestEmail.geAuth.mandaEmail(fromEmail, rigaDip.email, oggettoEmail, corpoEmail);
answ = SteamWare.memLayer.ML.IntSessionObj("pageSize");
if (answ <= 0) answ = 20;
}
}
catch
{ }
return answ;
}
set
{
SteamWare.memLayer.ML.setSessionVal("pageSize", value);
}
}
}
/// <summary>
/// oggetto elenco clienti organizzato come dizionario con chiave idxCliente e valore la ragione sociale
/// </summary>
public Dictionary<string, string> elencoClienti
{
set
{
string redKey = memLayer.ML.redHash("elencoClienti");
string rawData = JsonConvert.SerializeObject(value);
memLayer.ML.setRSV(redKey, rawData, 60);
}
get
{
Dictionary<string, string> answ = new Dictionary<string, string>();
string redKey = memLayer.ML.redHash("elencoClienti");
string rawData = memLayer.ML.getRSV(redKey);
if (!string.IsNullOrEmpty(rawData))
{
try
{
answ = JsonConvert.DeserializeObject<Dictionary<string, string>>(rawData);
}
catch
{ }
}
if (answ.Count == 0)
{
answ = ricaricaElencoClienti();
elencoClienti = answ;
}
return answ;
}
}
/// <summary>
/// Effettua un insieme di controlli sulle anomalie delel timbrature/orari e invia le relative eventuali email
/// </summary>
/// <returns></returns>
public bool checkAnomalie()
{
bool answ = false;
try
{
// log richiesta!
logger.lg.scriviLog("Richiesto controllo anomalie!", tipoLog.INFO);
/*******************************************************
* controllo le varie anomalie delle timbrature:
*
* (A) mancate approvazioni --> admin
* (B) entrate <> uscite --> admin, user
* (C) mancata copertura orario --> admin
*
* (D) mancata copertura commesse (2 be done)
*
* recupero elenco dip interessati x le varie anomalie con stp_DipendentiAndAnomalie
* e poi da timbrExpl recupero le singole istanze di record errori
*
*******************************************************/
// (C) recupero errori mancata copertura orario, mando ad admin
if (memLayer.ML.confReadBool("checkAnomOreLav"))
{
tabDipAndAnom = DataProxy.DP.taDipAnom.GetData(adesso.AddDays(-gg2Chk), adesso.AddHours(1), false, false, true);
tabTimbExpl = DataProxy.DP.taTimbExpl.getByDipAnomalia(0, adesso.AddDays(-gg2Chk), adesso.AddHours(1), false, false, true);
// se ho trovato record...
if (tabTimbExpl.Rows.Count > 0)
{
logger.lg.scriviLog("Trovate anomalie copertura orario, invio email!", tipoLog.INFO);
// mando email ad admin!
oggettoEmail = "Anomalie GPW: Ore timbrate";
if (memLayer.ML.confReadBool("includeDirectUrl"))
{
corpoEmail = string.Format("Risultano a sistema le seguenti anomalie:<br/><a href=\"{0}A1/reviewTimbrature.aspx\">Orario timbrato non suff a copertura standard</a><br/><br/>", memLayer.ML.confReadString("baseUrl"));
}
else
{
corpoEmail = "Risultano a sistema le seguenti anomalie: Orario timbrato non suff a copertura standard<br/>";
}
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
corpoEmail += "| -- DATA --\t| -- Dipendente --<br/>";
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
foreach (DS_Applicazione.TimbratureExplRow riga in tabTimbExpl)
{
corpoEmail += string.Format("| {0:yyyy.MM.dd ddd}\t| {1}<br/>", riga.dataLav, riga.CognomeNome);
}
corpoEmail += SteamwareStrings.charLine('-', 80);
gestEmail.geAuth.mandaEmail(fromEmail, adminEmail, oggettoEmail, corpoEmail);
}
}
// setup valori base
string fromEmail = memLayer.ML.confReadString("_fromEmail");
string adminEmail = memLayer.ML.confReadString("adminAnomalieEmail");
string adminContinuatoEmail = memLayer.ML.confReadString("adminContinuatoEmail");
string adminOreLavEmail = memLayer.ML.confReadString("adminOreLavEmail");
string oggettoEmail = "";
string corpoEmail = "";
DS_Applicazione.stp_DipendentiAndAnomalieDataTable tabDipAndAnom = new DS_Applicazione.stp_DipendentiAndAnomalieDataTable();
DS_Applicazione.TimbratureExplDataTable tabTimbExpl = new DS_Applicazione.TimbratureExplDataTable();
DS_Applicazione.TE_RA_ExplDataTable tabTimbRegAtt = new DS_Applicazione.TE_RA_ExplDataTable();
DateTime adesso = DateTime.Now;
int gg2Chk = memLayer.ML.confReadInt("gg2Chk");
int gg2ChkCont = memLayer.ML.confReadInt("gg2ChkCont");
int gg2ChkOreCaricate = memLayer.ML.confReadInt("gg2ChkOreCaricate");
// (D) recupero errori copertura ore lavorate / ore caricate a commessa...
if (memLayer.ML.confReadBool("checkAnomOreLavComm"))
{
tabTimbRegAtt = DataProxy.DP.taTimbRegAtt.GetData(0, adesso.AddDays(-gg2ChkOreCaricate), adesso.AddHours(1), true, memLayer.ML.confReadInt("maxErrMin"), memLayer.ML.confReadInt("maxErrPlus"));
// sulla tabella seleziono SE NON E' OK colonna okLavCom
if (((DS_Applicazione.TE_RA_ExplRow[])tabTimbRegAtt.Select(" okLavCom = 0 ")).Length > 0)
{
logger.lg.scriviLog("Trovate anomalie ore lavorate / commesse caricate, invio email!", tipoLog.INFO);
// mando email ad admin!
oggettoEmail = "Anomalie GPW: Ore Caricate a commessa";
if (memLayer.ML.confReadBool("includeDirectUrl"))
// (A) recupero mancate approvazioni, mando solo ad admin
if (memLayer.ML.confReadBool("checkAnomAppr"))
{
tabTimbExpl = DataProxy.DP.taTimbExpl.getByDipAnomalia(0, adesso.AddDays(-gg2Chk), adesso.AddHours(1), true, false, false);
// se ho trovato record...
if (tabTimbExpl.Rows.Count > 0)
{
logger.lg.scriviLog("Trovate anomalie mancate approvazioni, invio email ad admin", tipoLog.INFO);
oggettoEmail = "Anomalie GPW: Approvazione Timbrature";
if (memLayer.ML.confReadBool("includeDirectUrl"))
{
corpoEmail = string.Format("Risultano a sistema le seguenti anomalie:<br/><a href=\"{0}A1/approvTimbrature.aspx\">timbrature da approvare</a><br/><br/>", memLayer.ML.confReadString("baseUrl"));
}
else
{
corpoEmail = "Risultano a sistema le seguenti anomalie: timbrature da approvare<br/>";
}
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
corpoEmail += "| -- DATA --\t| Dipendente<br/>";
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
foreach (DS_Applicazione.TimbratureExplRow riga in tabTimbExpl)
{
corpoEmail += string.Format("| {0:yyyy.MM.dd ddd}\t| {1}<br/>", riga.dataLav, riga.CognomeNome);
}
corpoEmail += SteamwareStrings.charLine('-', 80);
gestEmail.geAuth.mandaEmail(fromEmail, adminEmail, oggettoEmail, corpoEmail);
}
}
// (B) recupero errori entrate/uscite, mando ad admin + utenti
if (memLayer.ML.confReadBool("checkAnomTimb"))
{
tabDipAndAnom = DataProxy.DP.taDipAnom.GetData(adesso.AddDays(-gg2Chk), adesso.AddHours(1), false, true, false);
tabTimbExpl = DataProxy.DP.taTimbExpl.getByDipAnomalia(0, adesso.AddDays(-gg2Chk), adesso.AddHours(1), false, true, false);
// se ho trovato record...
if (tabTimbExpl.Rows.Count > 0)
{
logger.lg.scriviLog("Trovate anomalie timbrature IN/OUT non corrispondenti, invio email!", tipoLog.INFO);
// mando email ad admin!
oggettoEmail = "Anomalie GPW: Timbrature mancanti";
if (memLayer.ML.confReadBool("includeDirectUrl"))
{
corpoEmail = string.Format("Risultano a sistema le seguenti anomalie:<br/><a href=\"{0}A1/reviewTimbrature.aspx\">timbrature mancanti / non corrispondenti</a><br/><br/>", memLayer.ML.confReadString("baseUrl"));
}
else
{
corpoEmail = "Risultano a sistema le seguenti anomalie: timbrature mancanti<br/>";
}
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
corpoEmail += "| -- DATA --\t| Dipendente<br/>";
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
foreach (DS_Applicazione.TimbratureExplRow riga in tabTimbExpl)
{
corpoEmail += string.Format("| {0:yyyy.MM.dd ddd}\t| {1}<br/>", riga.dataLav, riga.CognomeNome);
}
corpoEmail += SteamwareStrings.charLine('-', 80);
gestEmail.geAuth.mandaEmail(fromEmail, adminEmail, oggettoEmail, corpoEmail);
// re richiesto invio email utenti x warning entrate/uscrite
if (memLayer.ML.confReadBool("sendEmailToUser"))
{
// mando singole email ai dipendenti SE C'è EMAIL!!!!
foreach (DS_Applicazione.stp_DipendentiAndAnomalieRow rigaDip in tabDipAndAnom)
{
if (!string.IsNullOrEmpty(rigaDip.email))
{
tabTimbExpl = DataProxy.DP.taTimbExpl.getByDipAnomalia(rigaDip.idxDipendente, adesso.AddDays(-gg2Chk), adesso.AddHours(1), false, true, false);
// reimposto testo
if (memLayer.ML.confReadBool("includeDirectUrl"))
{
corpoEmail = string.Format("Risultano a sistema le seguenti anomalie:<br/><a href=\"{0}A4/commesseUtente.aspx\">timbrature mancanti / non corrispondenti</a><br/><br/>", memLayer.ML.confReadString("baseUrl"));
}
else
{
corpoEmail = "Risultano a sistema le seguenti anomalie: timbrature mancanti / non corrispondenti<br/>";
}
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
corpoEmail += "| -- DATA --\t| -- Dipendente --<br/>";
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
foreach (DS_Applicazione.TimbratureExplRow riga in tabTimbExpl)
{
corpoEmail += string.Format("| {0:yyyy.MM.dd ddd}\t| {1}<br/>", riga.dataLav, riga.CognomeNome);
}
corpoEmail += SteamwareStrings.charLine('-', 80);
gestEmail.geAuth.mandaEmail(fromEmail, rigaDip.email, oggettoEmail, corpoEmail);
}
}
}
}
}
// (C) recupero errori mancata copertura orario, mando ad admin
if (memLayer.ML.confReadBool("checkAnomOreLav"))
{
tabDipAndAnom = DataProxy.DP.taDipAnom.GetData(adesso.AddDays(-gg2Chk), adesso.AddHours(1), false, false, true);
tabTimbExpl = DataProxy.DP.taTimbExpl.getByDipAnomalia(0, adesso.AddDays(-gg2Chk), adesso.AddHours(1), false, false, true);
// se ho trovato record...
if (tabTimbExpl.Rows.Count > 0)
{
logger.lg.scriviLog("Trovate anomalie copertura orario, invio email!", tipoLog.INFO);
// mando email ad admin!
oggettoEmail = "Anomalie GPW: Ore timbrate";
if (memLayer.ML.confReadBool("includeDirectUrl"))
{
corpoEmail = string.Format("Risultano a sistema le seguenti anomalie:<br/><a href=\"{0}A1/reviewTimbrature.aspx\">Orario timbrato non suff a copertura standard</a><br/><br/>", memLayer.ML.confReadString("baseUrl"));
}
else
{
corpoEmail = "Risultano a sistema le seguenti anomalie: Orario timbrato non suff a copertura standard<br/>";
}
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
corpoEmail += "| -- DATA --\t| -- Dipendente --<br/>";
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
foreach (DS_Applicazione.TimbratureExplRow riga in tabTimbExpl)
{
corpoEmail += string.Format("| {0:yyyy.MM.dd ddd}\t| {1}<br/>", riga.dataLav, riga.CognomeNome);
}
corpoEmail += SteamwareStrings.charLine('-', 80);
gestEmail.geAuth.mandaEmail(fromEmail, adminEmail, oggettoEmail, corpoEmail);
}
}
// (D) recupero errori copertura ore lavorate / ore caricate a commessa...
if (memLayer.ML.confReadBool("checkAnomOreLavComm"))
{
tabTimbRegAtt = DataProxy.DP.taTimbRegAtt.GetData(0, adesso.AddDays(-gg2ChkOreCaricate), adesso.AddHours(1), true, memLayer.ML.confReadInt("maxErrMin"), memLayer.ML.confReadInt("maxErrPlus"));
// sulla tabella seleziono SE NON E' OK colonna okLavCom
if (((DS_Applicazione.TE_RA_ExplRow[])tabTimbRegAtt.Select(" okLavCom = 0 ")).Length > 0)
{
logger.lg.scriviLog("Trovate anomalie ore lavorate / commesse caricate, invio email!", tipoLog.INFO);
// mando email ad admin!
oggettoEmail = "Anomalie GPW: Ore Caricate a commessa";
if (memLayer.ML.confReadBool("includeDirectUrl"))
{
corpoEmail = string.Format("Risultano a sistema le seguenti anomalie:<br/><a href=\"{0}A1/reviewTimbrature.aspx\">ore caricate a commessa non corrispondenti ad ore lavorate secondo range {1} min / {2} min</a><br/><br/>", memLayer.ML.confReadString("baseUrl"), memLayer.ML.confReadInt("maxErrMin"), memLayer.ML.confReadInt("maxErrPlus"));
}
else
{
corpoEmail = "Risultano a sistema le seguenti anomalie: ore caricate a commessa non corrispondenti ad ore lavorate<br/>";
}
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
corpoEmail += "| -- DATA --\t| -- Dipendente --\t\t| Progetti<br/>";
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
foreach (DS_Applicazione.TE_RA_ExplRow riga in (DS_Applicazione.TE_RA_ExplRow[])tabTimbRegAtt.Select(" okLavCom = 0 "))
{
corpoEmail += string.Format("| {0:yyyy.MM.dd ddd}\t| {1}\t| {2}<br/>", riga.dataLav, riga.CognomeNome, riga.progetti);
}
corpoEmail += SteamwareStrings.charLine('-', 80);
gestEmail.geAuth.mandaEmail(fromEmail, adminOreLavEmail, oggettoEmail, corpoEmail);
}
}
// (E) cerco anomalie x orario continuato (no Pausa Pranzo, solo 1 IN, 1 OUT)
if (memLayer.ML.confReadBool("checkAnomContinuato"))
{
tabTimbExpl = DataProxy.DP.taTimbExpl.getContinuato(0, adesso.AddDays(-gg2ChkCont), adesso.AddHours(1));
// se ho trovato record...
if (tabTimbExpl.Rows.Count > 0)
{
logger.lg.scriviLog("Trovate anomalie orario continuato, invio email ad admin", tipoLog.INFO);
oggettoEmail = "Anomalie GPW: Orario Continuato";
if (memLayer.ML.confReadBool("includeDirectUrl"))
{
corpoEmail = string.Format("Risultano a sistema le seguenti anomalie:<br/><a href=\"{0}A1/approvTimbrature.aspx\">orari continuati da approvare</a><br/><br/>", memLayer.ML.confReadString("baseUrl"));
}
else
{
corpoEmail = "Risultano a sistema le seguenti anomalie: orari continuati da approvare<br/>";
}
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
corpoEmail += "| -- DATA --\t| Dipendente<br/>";
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
foreach (DS_Applicazione.TimbratureExplRow riga in tabTimbExpl)
{
corpoEmail += string.Format("| {0:yyyy.MM.dd ddd}\t| {1}<br/>", riga.dataLav, riga.CognomeNome);
}
corpoEmail += SteamwareStrings.charLine('-', 80);
gestEmail.geAuth.mandaEmail(fromEmail, adminContinuatoEmail, oggettoEmail, corpoEmail);
}
}
answ = true;
}
catch (Exception exc)
{
corpoEmail = string.Format("Risultano a sistema le seguenti anomalie:<br/><a href=\"{0}A1/reviewTimbrature.aspx\">ore caricate a commessa non corrispondenti ad ore lavorate secondo range {1} min / {2} min</a><br/><br/>", memLayer.ML.confReadString("baseUrl"), memLayer.ML.confReadInt("maxErrMin"), memLayer.ML.confReadInt("maxErrPlus"));
logger.lg.scriviLog(string.Format("Errore in procedura check & invio email{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
answ = false;
}
//registro evento
DataProxy.DP.taRE.Insert(DateTime.Now, "checkAnomalie", "-");
return answ;
}
/// <summary>
/// Verifica ed eventualmente esegue gli script quotidiani tra cui il check anomalie
/// </summary>
/// <returns></returns>
public bool dailyDuties()
{
bool answ = false;
if (memLayer.ML.confReadBool("enableDailyCheck"))
{
if (memLayer.ML.confReadInt("_logLevel") > 5) logger.lg.scriviLog("Richiesto Check Daily Duties", tipoLog.INFO);
int firstHour2Check = memLayer.ML.confReadInt("firstHour2Check");
// controllo sfasato di x ore come da we.config se ci sia già stato il check quotidiano anomalie (con relative email)
if (DataProxy.DP.taRE.getByDataEv("checkAnomalie", DateTime.Now.AddHours(-firstHour2Check).Date).Rows.Count == 0)
{
// chiamo check anomalie
checkAnomalie();
//registro evento
DataProxy.DP.taRE.Insert(DateTime.Now.AddHours(-firstHour2Check), "dailyDuties", "-");
}
}
else
{
corpoEmail = "Risultano a sistema le seguenti anomalie: ore caricate a commessa non corrispondenti ad ore lavorate<br/>";
if (memLayer.ML.confReadInt("_logLevel") > 5) logger.lg.scriviLog("DISABILITATO Check Daily Duties", tipoLog.INFO);
}
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
corpoEmail += "| -- DATA --\t| -- Dipendente --\t\t| Progetti<br/>";
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
foreach (DS_Applicazione.TE_RA_ExplRow riga in (DS_Applicazione.TE_RA_ExplRow[])tabTimbRegAtt.Select(" okLavCom = 0 "))
{
corpoEmail += string.Format("| {0:yyyy.MM.dd ddd}\t| {1}\t| {2}<br/>", riga.dataLav, riga.CognomeNome, riga.progetti);
}
corpoEmail += SteamwareStrings.charLine('-', 80);
gestEmail.geAuth.mandaEmail(fromEmail, adminOreLavEmail, oggettoEmail, corpoEmail);
}
return answ;
}
// (E) cerco anomalie x orario continuato (no Pausa Pranzo, solo 1 IN, 1 OUT)
if (memLayer.ML.confReadBool("checkAnomContinuato"))
/// <summary>
/// formatta le ore in ore:minuti
/// </summary>
/// <param name="oreCent">ore centesimali (0,00)</param>
/// <returns></returns>
public static string formOreMin(decimal oreCent)
{
tabTimbExpl = DataProxy.DP.taTimbExpl.getContinuato(0, adesso.AddDays(-gg2ChkCont), adesso.AddHours(1));
// se ho trovato record...
if (tabTimbExpl.Rows.Count > 0)
{
logger.lg.scriviLog("Trovate anomalie orario continuato, invio email ad admin", tipoLog.INFO);
oggettoEmail = "Anomalie GPW: Orario Continuato";
if (memLayer.ML.confReadBool("includeDirectUrl"))
{
corpoEmail = string.Format("Risultano a sistema le seguenti anomalie:<br/><a href=\"{0}A1/approvTimbrature.aspx\">orari continuati da approvare</a><br/><br/>", memLayer.ML.confReadString("baseUrl"));
}
else
{
corpoEmail = "Risultano a sistema le seguenti anomalie: orari continuati da approvare<br/>";
}
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
corpoEmail += "| -- DATA --\t| Dipendente<br/>";
corpoEmail += string.Format("{0}<br/>", SteamwareStrings.charLine('-', 80));
foreach (DS_Applicazione.TimbratureExplRow riga in tabTimbExpl)
{
corpoEmail += string.Format("| {0:yyyy.MM.dd ddd}\t| {1}<br/>", riga.dataLav, riga.CognomeNome);
}
corpoEmail += SteamwareStrings.charLine('-', 80);
gestEmail.geAuth.mandaEmail(fromEmail, adminContinuatoEmail, oggettoEmail, corpoEmail);
}
return string.Format("{0}:{1:00}", Math.Floor(oreCent), Math.Round((oreCent - Math.Floor(oreCent)) * 60));
}
answ = true;
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Errore in procedura check & invio email{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
answ = false;
}
//registro evento
DataProxy.DP.taRE.Insert(DateTime.Now, "checkAnomalie", "-");
return answ;
}
/// <summary>
/// Verifica ed eventualmente esegue gli script quotidiani tra cui il check anomalie
/// </summary>
/// <returns></returns>
public bool dailyDuties()
{
bool answ = false;
if (memLayer.ML.confReadBool("enableDailyCheck"))
{
if (memLayer.ML.confReadInt("_logLevel") > 5) logger.lg.scriviLog("Richiesto Check Daily Duties", tipoLog.INFO);
int firstHour2Check = memLayer.ML.confReadInt("firstHour2Check");
// controllo sfasato di x ore come da we.config se ci sia già stato il check quotidiano anomalie (con relative email)
if (DataProxy.DP.taRE.getByDataEv("checkAnomalie", DateTime.Now.AddHours(-firstHour2Check).Date).Rows.Count == 0)
{
// chiamo check anomalie
checkAnomalie();
//registro evento
DataProxy.DP.taRE.Insert(DateTime.Now.AddHours(-firstHour2Check), "dailyDuties", "-");
}
}
else
{
if (memLayer.ML.confReadInt("_logLevel") > 5) logger.lg.scriviLog("DISABILITATO Check Daily Duties", tipoLog.INFO);
}
return answ;
}
/// <summary>
/// formatta le ore in ore:minuti
/// </summary>
/// <param name="oreCent">ore centesimali (0,00)</param>
/// <returns></returns>
public static string formOreMin(decimal oreCent)
{
return string.Format("{0}:{1:00}", Math.Floor(oreCent), Math.Round((oreCent - Math.Floor(oreCent)) * 60));
}
}
}
+12 -12
View File
@@ -4,18 +4,18 @@ using System.Threading;
namespace GPW_Smart
{
public partial class ErrorPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
public partial class ErrorPage : System.Web.UI.Page
{
string currPage = user_std.pagCorrente != "" ? user_std.pagCorrente : "Default";
string prevPage = user_std.pagPrecedente != "" ? user_std.pagPrecedente : "Default";
string errorPageRedirect = memLayer.ML.confReadString("errorPageRedirect");
memLayer.ML.setSessionVal("nextPage", currPage);
memLayer.ML.setSessionVal("pagPrecedente", prevPage);
logger.lg.scriviLog($"ErrorPage chiamata: currPage {currPage} | currPage: {currPage} --> Redirect a {errorPageRedirect}", tipoLog.INFO);
Thread.Sleep(50);
Response.Redirect(errorPageRedirect);
protected void Page_Load(object sender, EventArgs e)
{
string currPage = !string.IsNullOrEmpty(user_std.pagCorrente) ? user_std.pagCorrente : "Default";
string prevPage = !string.IsNullOrEmpty(user_std.pagPrecedente) ? user_std.pagPrecedente : "Default";
string errorPageRedirect = memLayer.ML.confReadString("errorPageRedirect");
memLayer.ML.setSessionVal("nextPage", currPage);
memLayer.ML.setSessionVal("pagPrecedente", prevPage);
logger.lg.scriviLog($"ErrorPage chiamata: currPage {currPage} | currPage: {currPage} --> Redirect a {errorPageRedirect}", tipoLog.INFO);
Thread.Sleep(50);
Response.Redirect(errorPageRedirect);
}
}
}
}
+99 -99
View File
@@ -3,115 +3,115 @@ using System;
namespace GPW_Smart
{
public partial class Reset : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
public partial class Reset : System.Web.UI.Page
{
string paginaPrec = user_std.pagPrecedente;
string action = memLayer.ML.QSS("Action");
string nextPage = memLayer.ML.StringSessionObj("nextPage");
string testo = "";
long recPrev = 0;
long recPost = 0;
if (action != "")
{
if (action.Contains("C"))
protected void Page_Load(object sender, EventArgs e)
{
recPrev = Cache.Count;
if (recPrev > 0)
{
try
string paginaPrec = user_std.pagPrecedente;
string action = memLayer.ML.QSS("Action");
string nextPage = memLayer.ML.StringSessionObj("nextPage");
string testo = "";
long recPrev = 0;
long recPost = 0;
if (!string.IsNullOrEmpty(action))
{
// reset dati in cache...
memLayer.ML.flushRegisteredCache();
recPost = Cache.Count;
testo += string.Format("<hr/>Reset Cache: {0} --> {1}</br>", recPrev, recPost);
if (action.Contains("C"))
{
recPrev = Cache.Count;
if (recPrev > 0)
{
try
{
// reset dati in cache...
memLayer.ML.flushRegisteredCache();
recPost = Cache.Count;
testo += string.Format("<hr/>Reset Cache: {0} --> {1}</br>", recPrev, recPost);
}
catch
{ }
}
}
if (action.Contains("D"))
{
recPrev = memLayer.ML.numRecAppConf;
if (recPrev > 0)
{
try
{
// reset dati in cache x DbConfig...
memLayer.ML.resetAppConf();
recPost = memLayer.ML.numRecAppConf;
testo += string.Format("<hr/>Reset DB AppConf: {0} --> {1}</br>", recPrev, recPost);
}
catch
{ }
}
}
if (action.Contains("R"))
{
recPrev = memLayer.ML.numRecRedis;
if (recPrev > 0)
{
try
{
// reset dati in cache x DbConfig...
memLayer.ML.redFlushKey("**");
recPost = memLayer.ML.numRecRedis;
testo += string.Format("<hr/>Reset Redis: {0} --> {1}</br>", recPrev, recPost);
}
catch
{ }
}
}
if (action.Contains("S"))
{
recPrev = Session.Count;
if (recPrev > 0)
{
try
{
// reset dati in sessione...
Session.Clear();
recPost = Session.Count;
testo += string.Format("<hr/>Reset Sessione: {0} --> {1}</br>", recPrev, recPost);
}
catch
{ }
}
}
if (action.Contains("V"))
{
recPrev = DataWrap.DW.numRecVoc;
if (recPrev > 0)
{
try
{
// aggiorno vocabolario
DataWrap.DW.resetVocabolario();
recPost = DataWrap.DW.numRecVoc;
testo += string.Format("<hr/>Reset Vocabolario: {0} --> {1}</br>", recPrev, recPost);
}
catch
{ }
}
}
}
catch
{ }
}
}
if (action.Contains("D"))
{
recPrev = memLayer.ML.numRecAppConf;
if (recPrev > 0)
{
try
lblOut.Text = testo;
if (!string.IsNullOrEmpty(nextPage))
{
// reset dati in cache x DbConfig...
memLayer.ML.resetAppConf();
recPost = memLayer.ML.numRecAppConf;
testo += string.Format("<hr/>Reset DB AppConf: {0} --> {1}</br>", recPrev, recPost);
logger.lg.scriviLog(string.Format("Reset {0} OK: redirect a pag {1}", action, nextPage), tipoLog.INFO);
Response.Redirect(nextPage);
}
catch
{ }
}
}
if (action.Contains("R"))
{
recPrev = memLayer.ML.numRecRedis;
if (recPrev > 0)
{
try
else if (!string.IsNullOrEmpty(paginaPrec))
{
// reset dati in cache x DbConfig...
memLayer.ML.redFlushKey("**");
recPost = memLayer.ML.numRecRedis;
testo += string.Format("<hr/>Reset Redis: {0} --> {1}</br>", recPrev, recPost);
logger.lg.scriviLog(string.Format("Reset {0} OK: redirect a pag {1}", action, paginaPrec), tipoLog.INFO);
Response.Redirect(nextPage);
}
catch
{ }
}
}
if (action.Contains("S"))
{
recPrev = Session.Count;
if (recPrev > 0)
{
try
else
{
// reset dati in sessione...
Session.Clear();
recPost = Session.Count;
testo += string.Format("<hr/>Reset Sessione: {0} --> {1}</br>", recPrev, recPost);
logger.lg.scriviLog(string.Format("Reset {0} OK: redirect a pag {1}", action, "Default"), tipoLog.INFO);
Response.Redirect("Default");
}
catch
{ }
}
}
if (action.Contains("V"))
{
recPrev = DataWrap.DW.numRecVoc;
if (recPrev > 0)
{
try
{
// aggiorno vocabolario
DataWrap.DW.resetVocabolario();
recPost = DataWrap.DW.numRecVoc;
testo += string.Format("<hr/>Reset Vocabolario: {0} --> {1}</br>", recPrev, recPost);
}
catch
{ }
}
}
}
lblOut.Text = testo;
if (nextPage != "")
{
logger.lg.scriviLog(string.Format("Reset {0} OK: redirect a pag {1}", action, nextPage), tipoLog.INFO);
Response.Redirect(nextPage);
}
else if (paginaPrec != "")
{
logger.lg.scriviLog(string.Format("Reset {0} OK: redirect a pag {1}", action, paginaPrec), tipoLog.INFO);
Response.Redirect(nextPage);
}
else
{
logger.lg.scriviLog(string.Format("Reset {0} OK: redirect a pag {1}", action, "Default"), tipoLog.INFO);
Response.Redirect("Default");
}
}
}
}
+213 -213
View File
@@ -6,231 +6,231 @@ using System.Web.UI;
namespace GPW_Smart.WebUserControls
{
public partial class cmp_menuTop : System.Web.UI.UserControl
{
/// <summary>
/// user agent corrente
/// </summary>
protected string userAgent = "";
/// <summary>
/// IP corrente
/// </summary>
protected string postazione_IP = "";
/// <summary>
/// gestione evento refresh
/// </summary>
public event EventHandler eh_doRefresh;
protected bool _disableCheckCookie = false;
public bool disableCheckCookie
public partial class cmp_menuTop : System.Web.UI.UserControl
{
get
{
return _disableCheckCookie;
}
set
{
_disableCheckCookie = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
checkPages();
searchVal = "";
ulLinks.DataBind();
}
if (!disableCheckCookie)
{
// controllo se c'è utente in sessione.. SE NON disabilitato...
checkUser();
}
// sistemo visualizzazione
postazione_IP = Request.UserHostName;
try
{
lblSwData.Text = memLayer.ML.StringSessionObj("cognomeNome");
}
catch
{
lblSwData.Text = "GPW";
}
}
/// <summary>
/// Verifica le pagine x capire se siano cambiate...
/// </summary>
private void checkPages()
{
if (nomePagina != user_std.pagCorrente)
{
user_std.pagPrecedente = user_std.pagCorrente != "" ? user_std.pagCorrente : nomePagina;
user_std.pagCorrente = nomePagina;
}
}
/// <summary>
/// Nome pagina (parte finale url)
/// </summary>
public string nomePagina
{
get
{
return devicesAuthProxy.getPage(Request.Url).Replace(".aspx", "");
}
}
/// <summary>
/// verifica presenza utente autorizzato in sessione
/// </summary>
private void checkUser()
{
if (!memLayer.ML.isInSessionObject("idxDipendente"))
{
// controllo cookie device...
checkAuthCookieGPW();
}
}
/// <summary>
/// verifica al presenza di un cookie VALIDO per autorizzare il device
/// </summary>
private void checkAuthCookieGPW()
{
try
{
HttpCookie cookie = Request.Cookies["AuthGPW"];
if (cookie == null || string.IsNullOrEmpty(cookie.Value ))
/// <summary>
/// user agent corrente
/// </summary>
protected string userAgent = "";
/// <summary>
/// IP corrente
/// </summary>
protected string postazione_IP = "";
/// <summary>
/// gestione evento refresh
/// </summary>
public event EventHandler eh_doRefresh;
protected bool _disableCheckCookie = false;
public bool disableCheckCookie
{
// rimando pagina x registrazione devices
Response.Redirect("~/regNewDevice.aspx");
}
else
{
// ricavo utente da cookie...
string devSecret = cookie.Value;
DS_Applicazione.AnagDevicesRow device = null;
// cerco il device...ogni dipendente può averne + di 1 registrato a suo nome...
int idxDipendente = 0;
try
{
device = DataProxy.DP.taAnagDev.getByDeviceSecret(devSecret)[0];
idxDipendente = device.idxDipendente;
}
catch
{ }
if (idxDipendente > 0)
{
// aggiorno descrizione (user agent) ed IP...
userAgent = Request.UserAgent;
postazione_IP = Request.UserHostName;
// controllo IP e DeviceDescription x eventuale update
if ((device.lastIPv4 != postazione_IP) || (device.Description != userAgent))
get
{
// salvo ultimo "contatto" del device aggiornando descrizione ed IP
DataProxy.DP.taAnagDev.updateIP(device.IdxDevice, DateTime.Now, postazione_IP, userAgent);
return _disableCheckCookie;
}
// salvo in sessione utente
memLayer.ML.setSessionVal("idxDipendente", idxDipendente);
string CognomeNome = "";
string email = "";
string hashEmail = "";
set
{
_disableCheckCookie = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
checkPages();
searchVal = "";
ulLinks.DataBind();
}
if (!disableCheckCookie)
{
// controllo se c'è utente in sessione.. SE NON disabilitato...
checkUser();
}
// sistemo visualizzazione
postazione_IP = Request.UserHostName;
try
{
DS_Applicazione.DipendentiRow rigaDip = DataProxy.DP.taDipendenti.getByIdx(idxDipendente)[0];
CognomeNome = string.Format("{0} {1}", rigaDip.Cognome, rigaDip.Nome);
email = rigaDip.email;
hashEmail = SteamCrypto.getHashStringMD5(email);
lblSwData.Text = memLayer.ML.StringSessionObj("cognomeNome");
}
catch
{ }
memLayer.ML.setSessionVal("cognomeNome", CognomeNome);
memLayer.ML.setSessionVal("email", email);
memLayer.ML.setSessionVal("hashEmail", hashEmail);
}
else
{
// svuoto cookie...
memLayer.ML.emptyCookieVal("AuthGPW");
// rimando pagina x registrazione devices
Response.Redirect("~/regNewDevice.aspx");
}
{
lblSwData.Text = "GPW";
}
}
/// <summary>
/// Verifica le pagine x capire se siano cambiate...
/// </summary>
private void checkPages()
{
if (nomePagina != user_std.pagCorrente)
{
user_std.pagPrecedente = !string.IsNullOrEmpty(user_std.pagCorrente) ? user_std.pagCorrente : nomePagina;
user_std.pagCorrente = nomePagina;
}
}
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Errore in checkAuthCookie:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
}
}
/// <summary>
/// imposta visibilità search globale
/// </summary>
public bool showSearch
{
get
{
return divSearch.Visible;
}
set
{
divSearch.Visible = value;
}
}
protected void txtSearch_TextChanged(object sender, EventArgs e)
{
doSearch();
}
/// <summary>
/// Nome pagina (parte finale url)
/// </summary>
public string nomePagina
{
get
{
return devicesAuthProxy.getPage(Request.Url).Replace(".aspx", "");
}
}
private void doSearch()
{
// se searchVal !=""
if (searchVal != "")
{
memLayer.ML.setSessionVal("valoreSearch", searchVal);
}
else
{
memLayer.ML.emptySessionVal("valoreSearch");
}
// se qualcuno ascolta sollevo evento nuovo valore...
if (eh_doRefresh != null)
{
eh_doRefresh(this, new EventArgs());
}
}
/// <summary>
/// verifica presenza utente autorizzato in sessione
/// </summary>
private void checkUser()
{
if (!memLayer.ML.isInSessionObject("idxDipendente"))
{
// controllo cookie device...
checkAuthCookieGPW();
}
}
/// <summary>
/// verifica al presenza di un cookie VALIDO per autorizzare il device
/// </summary>
private void checkAuthCookieGPW()
{
try
{
HttpCookie cookie = Request.Cookies["AuthGPW"];
if (cookie == null || string.IsNullOrEmpty(cookie.Value))
{
// rimando pagina x registrazione devices
Response.Redirect("~/regNewDevice.aspx");
}
else
{
// ricavo utente da cookie...
string devSecret = cookie.Value;
DS_Applicazione.AnagDevicesRow device = null;
// cerco il device...ogni dipendente può averne + di 1 registrato a suo nome...
int idxDipendente = 0;
try
{
device = DataProxy.DP.taAnagDev.getByDeviceSecret(devSecret)[0];
idxDipendente = device.idxDipendente;
}
catch
{ }
if (idxDipendente > 0)
{
// aggiorno descrizione (user agent) ed IP...
userAgent = Request.UserAgent;
postazione_IP = Request.UserHostName;
// controllo IP e DeviceDescription x eventuale update
if ((device.lastIPv4 != postazione_IP) || (device.Description != userAgent))
{
// salvo ultimo "contatto" del device aggiornando descrizione ed IP
DataProxy.DP.taAnagDev.updateIP(device.IdxDevice, DateTime.Now, postazione_IP, userAgent);
}
// salvo in sessione utente
memLayer.ML.setSessionVal("idxDipendente", idxDipendente);
string CognomeNome = "";
string email = "";
string hashEmail = "";
try
{
DS_Applicazione.DipendentiRow rigaDip = DataProxy.DP.taDipendenti.getByIdx(idxDipendente)[0];
CognomeNome = string.Format("{0} {1}", rigaDip.Cognome, rigaDip.Nome);
email = rigaDip.email;
hashEmail = SteamCrypto.getHashStringMD5(email);
}
catch
{ }
memLayer.ML.setSessionVal("cognomeNome", CognomeNome);
memLayer.ML.setSessionVal("email", email);
memLayer.ML.setSessionVal("hashEmail", hashEmail);
}
else
{
// svuoto cookie...
memLayer.ML.emptyCookieVal("AuthGPW");
// rimando pagina x registrazione devices
Response.Redirect("~/regNewDevice.aspx");
}
}
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Errore in checkAuthCookie:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
}
}
/// <summary>
/// imposta visibilità search globale
/// </summary>
public bool showSearch
{
get
{
return divSearch.Visible;
}
set
{
divSearch.Visible = value;
}
}
/// <summary>
/// Valore ricerca attivo
/// </summary>
protected string searchVal
{
get
{
return txtSearch.Text.Trim();
}
set
{
txtSearch.Text = value.Trim();
}
}
protected void txtSearch_TextChanged(object sender, EventArgs e)
{
doSearch();
}
protected void lbtSearch_Click(object sender, EventArgs e)
{
doSearch();
private void doSearch()
{
// se searchVal !=""
if (!string.IsNullOrEmpty(searchVal))
{
memLayer.ML.setSessionVal("valoreSearch", searchVal);
}
else
{
memLayer.ML.emptySessionVal("valoreSearch");
}
// se qualcuno ascolta sollevo evento nuovo valore...
if (eh_doRefresh != null)
{
eh_doRefresh(this, new EventArgs());
}
}
/// <summary>
/// Valore ricerca attivo
/// </summary>
protected string searchVal
{
get
{
return txtSearch.Text.Trim();
}
set
{
txtSearch.Text = value.Trim();
}
}
protected void lbtSearch_Click(object sender, EventArgs e)
{
doSearch();
}
/// <summary>
/// calcola SE aggiungere "active" alla pag corrente
/// </summary>
/// <param name="pageName"></param>
/// <returns></returns>
public string cssActive(string pageName)
{
string answ = "";
//if (pageName == PagCorrente())
if (pageName == nomePagina)
{
answ = "active";
}
return answ;
}
}
/// <summary>
/// calcola SE aggiungere "active" alla pag corrente
/// </summary>
/// <param name="pageName"></param>
/// <returns></returns>
public string cssActive(string pageName)
{
string answ = "";
//if (pageName == PagCorrente())
if (pageName == nomePagina)
{
answ = "active";
}
return answ;
}
}
}
+282 -282
View File
@@ -7,303 +7,303 @@ using System.Web.UI.WebControls;
namespace GPW.WebUserControls
{
public partial class mod_commAttivita : System.Web.UI.UserControl
{
/// <summary>
/// Hash di base x ricerca CLIENTE da idxFase
/// </summary>
protected string rhCliByIF { get; set; }
/// <summary>
/// Hash di base x ricerca PROGETTO da idxFase
/// </summary>
protected string rhProjByIF { get; set; }
/// <summary>
/// Hash di base x ricerca IdxProgetto da idxFase
/// </summary>
protected string rhIPByIF { get; set; }
/// <summary>
/// Hash di base x ricerca FASE da idxFase
/// </summary>
protected string rhFaseByIF { get; set; }
protected void Page_Load(object sender, EventArgs e)
public partial class mod_commAttivita : System.Web.UI.UserControl
{
if (!Page.IsPostBack)
{
// controllo se ho una data selezionata da URL
if (memLayer.ML.QSS("dataRif") != "")
/// <summary>
/// Hash di base x ricerca CLIENTE da idxFase
/// </summary>
protected string rhCliByIF { get; set; }
/// <summary>
/// Hash di base x ricerca PROGETTO da idxFase
/// </summary>
protected string rhProjByIF { get; set; }
/// <summary>
/// Hash di base x ricerca IdxProgetto da idxFase
/// </summary>
protected string rhIPByIF { get; set; }
/// <summary>
/// Hash di base x ricerca FASE da idxFase
/// </summary>
protected string rhFaseByIF { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
dataRif = memLayer.ML.QSD("dataRif");
if (!Page.IsPostBack)
{
// controllo se ho una data selezionata da URL
if (!string.IsNullOrEmpty(memLayer.ML.QSS("dataRif")))
{
dataRif = memLayer.ML.QSD("dataRif");
}
setupPage();
}
rhCliByIF = memLayer.ML.redHash("cliByIdxFase:");
rhIPByIF = memLayer.ML.redHash("idxProjByIdxFase:");
rhProjByIF = memLayer.ML.redHash("projByIdxFase:");
rhFaseByIF = memLayer.ML.redHash("faseByIdxFase:");
grView.DataBind();
}
setupPage();
}
rhCliByIF = memLayer.ML.redHash("cliByIdxFase:");
rhIPByIF = memLayer.ML.redHash("idxProjByIdxFase:");
rhProjByIF = memLayer.ML.redHash("projByIdxFase:");
rhFaseByIF = memLayer.ML.redHash("faseByIdxFase:");
grView.DataBind();
}
/// <summary>
/// pagina di return a fine editing
/// </summary>
public string returnPage
{
get
{
string answ = memLayer.ML.confReadString("baseUrl");
try
/// <summary>
/// pagina di return a fine editing
/// </summary>
public string returnPage
{
answ = memLayer.ML.StringSessionObj("returnPage");
get
{
string answ = memLayer.ML.confReadString("baseUrl");
try
{
answ = memLayer.ML.StringSessionObj("returnPage");
}
catch
{ }
return answ;
}
set
{
memLayer.ML.setSessionVal("returnPage", value);
}
}
catch
{ }
return answ;
}
set
{
memLayer.ML.setSessionVal("returnPage", value);
}
}
/// <summary>
/// data riferimento (selezionata) da session
/// </summary>
public DateTime dataRif
{
get
{
DateTime answ = DateTime.Now;
// cerco in session...
if (memLayer.ML.isInSessionObject("dataRif"))
/// <summary>
/// data riferimento (selezionata) da session
/// </summary>
public DateTime dataRif
{
try
{
get
{
DateTime answ = DateTime.Now;
// cerco in session...
if (memLayer.ML.isInSessionObject("dataRif"))
{
try
{
answ = Convert.ToDateTime(memLayer.ML.objSessionObj("dataRif"));
}
catch
{ }
answ = Convert.ToDateTime(memLayer.ML.objSessionObj("dataRif"));
}
catch
{ }
}
// altrimenti cerco in URL e salvo in session...
else if (!string.IsNullOrEmpty(memLayer.ML.QSS("dataRif")))
{
answ = memLayer.ML.QSD("dataRif");
dataRif = answ;
}
// restituisco!
return answ;
}
set
{
memLayer.ML.setSessionVal("dataRif", value);
}
}
// altrimenti cerco in URL e salvo in session...
else if (memLayer.ML.QSS("dataRif") != "")
/// <summary>
/// imposta la pagina
/// </summary>
private void setupPage()
{
answ = memLayer.ML.QSD("dataRif");
dataRif = answ;
// salvo dataFrom/To x visualizzazione attivita
txtData.Text = dataRif.ToString("yyyy-MM-dd");
// recupero dati della commessa utente giornaliera...
try
{
int maxErrMinus = memLayer.ML.confReadInt("maxErrMinus");
int maxErrPlus = memLayer.ML.confReadInt("maxErrPlus");
DS_Applicazione.v_logCommUtRow rigaLog = DataProxy.DP.taLCU.getByIdxDipDate(memLayer.ML.IntSessionObj("idxDipendente"), dataRif, dataRif.AddDays(1), maxErrMinus, maxErrPlus)[0];
lblTotOreRA.Text = string.Format("<b>{0:0.##}</b> / <b>{1:0.##}</b> h", rigaLog.h_com, rigaLog.h_lav);
}
catch
{
lblTotOreRA.Text = "...";
}
memLayer.ML.setSessionVal("dataFromRA", dataRif.Date);
memLayer.ML.setSessionVal("dataToRA", dataRif.AddDays(1).Date);
}
/// <summary>
/// Cerca associazione idxProj <--> idxFase da cache o da Db
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
protected int idxProjByIdxFase(int idxFase)
{
int idxPrj = 0;
string answ = memLayer.ML.getRSV($"{rhIPByIF}{idxFase}");
if (!string.IsNullOrEmpty(answ))
{
// cerco di convertire!
int.TryParse(answ, out idxPrj);
}
if (idxPrj == 0)
{
DS_Applicazione.AnagFasiRow fase = DataProxy.DP.taAF.getByIdxSmart(idxFase)[0];
idxPrj = Convert.ToInt32(fase.idxProgetto);
memLayer.ML.setRSV($"{rhIPByIF}{idxFase}", idxPrj.ToString(), memLayer.ML.CRI("shotTimeCache"));
}
return idxPrj;
}
// restituisco!
return answ;
}
set
{
memLayer.ML.setSessionVal("dataRif", value);
}
}
/// <summary>
/// imposta la pagina
/// </summary>
private void setupPage()
{
// salvo dataFrom/To x visualizzazione attivita
txtData.Text = dataRif.ToString("yyyy-MM-dd");
// recupero dati della commessa utente giornaliera...
try
{
int maxErrMinus = memLayer.ML.confReadInt("maxErrMinus");
int maxErrPlus = memLayer.ML.confReadInt("maxErrPlus");
DS_Applicazione.v_logCommUtRow rigaLog = DataProxy.DP.taLCU.getByIdxDipDate(memLayer.ML.IntSessionObj("idxDipendente"), dataRif, dataRif.AddDays(1), maxErrMinus, maxErrPlus)[0];
lblTotOreRA.Text = string.Format("<b>{0:0.##}</b> / <b>{1:0.##}</b> h", rigaLog.h_com, rigaLog.h_lav);
}
catch
{
lblTotOreRA.Text = "...";
}
memLayer.ML.setSessionVal("dataFromRA", dataRif.Date);
memLayer.ML.setSessionVal("dataToRA", dataRif.AddDays(1).Date);
}
/// <summary>
/// Cerca associazione idxProj <--> idxFase da cache o da Db
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
protected int idxProjByIdxFase(int idxFase)
{
int idxPrj = 0;
string answ = memLayer.ML.getRSV($"{rhIPByIF}{idxFase}");
if (!string.IsNullOrEmpty(answ))
{
// cerco di convertire!
int.TryParse(answ, out idxPrj);
}
if (idxPrj == 0)
{
DS_Applicazione.AnagFasiRow fase = DataProxy.DP.taAF.getByIdxSmart(idxFase)[0];
idxPrj = Convert.ToInt32(fase.idxProgetto);
memLayer.ML.setRSV($"{rhIPByIF}{idxFase}", idxPrj.ToString(), memLayer.ML.CRI("shotTimeCache"));
}
return idxPrj;
}
/// <summary>
/// recupera cliente da idxFase
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
public string cliByIdxFase(object _idxFase)
{
string answ = "";
int idxFase = 0;
int.TryParse(_idxFase.ToString(), out idxFase);
answ = memLayer.ML.getRSV($"{rhCliByIF}{idxFase}");
if (string.IsNullOrEmpty(answ))
{
answ = getCliByDb(idxFase);
memLayer.ML.setRSV($"{rhCliByIF}{idxFase}", answ, memLayer.ML.CRI("shotTimeCache"));
}
return answ;
}
/// <summary>
/// Cerca dati cliente da idxFase su DB
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
private string getCliByDb(int idxFase)
{
string answ = "";
try
{
int idxPrj = idxProjByIdxFase(idxFase);
DS_Applicazione.AnagProgettiRow progetto = DataProxy.DP.taAP.getByIdxProjSmart(idxPrj)[0];
answ = DataProxy.DP.taAnCli.getByIdx(progetto.idxCliente)[0].RagSociale;
}
catch
{ }
return answ;
}
/// <summary>
/// recupera cliente da idxFase
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
public string cliByIdxFase(object _idxFase)
{
string answ = "";
int idxFase = 0;
int.TryParse(_idxFase.ToString(), out idxFase);
answ = memLayer.ML.getRSV($"{rhCliByIF}{idxFase}");
if (string.IsNullOrEmpty(answ))
{
answ = getCliByDb(idxFase);
memLayer.ML.setRSV($"{rhCliByIF}{idxFase}", answ, memLayer.ML.CRI("shotTimeCache"));
}
return answ;
}
/// <summary>
/// Cerca dati cliente da idxFase su DB
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
private string getCliByDb(int idxFase)
{
string answ = "";
try
{
int idxPrj = idxProjByIdxFase(idxFase);
DS_Applicazione.AnagProgettiRow progetto = DataProxy.DP.taAP.getByIdxProjSmart(idxPrj)[0];
answ = DataProxy.DP.taAnCli.getByIdx(progetto.idxCliente)[0].RagSociale;
}
catch
{ }
return answ;
}
/// <summary>
/// recupera progetto da idxFase
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
public string prjByIdxFase(object _idxFase)
{
string answ = "";
int idxFase = 0;
int.TryParse(_idxFase.ToString(), out idxFase);
answ = memLayer.ML.getRSV($"{rhProjByIF}{idxFase}");
if (string.IsNullOrEmpty(answ))
{
answ = getProjByDb(idxFase);
memLayer.ML.setRSV($"{rhProjByIF}{idxFase}", answ, memLayer.ML.CRI("shotTimeCache"));
}
return answ;
}
/// <summary>
/// Cerca dati progetto da idxFase su DB
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
private string getProjByDb(int idxFase)
{
string answ = "";
try
{
int idxPrj = idxProjByIdxFase(idxFase);
DS_Applicazione.AnagProgettiRow progetto = DataProxy.DP.taAP.getByIdxProjSmart(idxPrj)[0];
answ = progetto.nomeProj;
}
catch
{ }
return answ;
}
/// <summary>
/// recupera progetto da idxFase
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
public string prjByIdxFase(object _idxFase)
{
string answ = "";
int idxFase = 0;
int.TryParse(_idxFase.ToString(), out idxFase);
answ = memLayer.ML.getRSV($"{rhProjByIF}{idxFase}");
if (string.IsNullOrEmpty(answ))
{
answ = getProjByDb(idxFase);
memLayer.ML.setRSV($"{rhProjByIF}{idxFase}", answ, memLayer.ML.CRI("shotTimeCache"));
}
return answ;
}
/// <summary>
/// Cerca dati progetto da idxFase su DB
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
private string getProjByDb(int idxFase)
{
string answ = "";
try
{
int idxPrj = idxProjByIdxFase(idxFase);
DS_Applicazione.AnagProgettiRow progetto = DataProxy.DP.taAP.getByIdxProjSmart(idxPrj)[0];
answ = progetto.nomeProj;
}
catch
{ }
return answ;
}
/// <summary>
/// recupera descrizione e nome fase da idxFase
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
public string faseByIdx(object _idxFase)
{
string answ = "";
int idxFase = 0;
int.TryParse(_idxFase.ToString(), out idxFase);
answ = memLayer.ML.getRSV($"{rhFaseByIF}{idxFase}");
if (string.IsNullOrEmpty(answ))
{
answ = getFaseByDb(idxFase);
memLayer.ML.setRSV($"{rhFaseByIF}{idxFase}", answ, memLayer.ML.CRI("shotTimeCache"));
}
return answ;
}
/// <summary>
/// Cerca dati fase da idxFase su DB
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
private string getFaseByDb(int idxFase)
{
string answ = "";
try
{
DS_Applicazione.AnagFasiRow fase = DataProxy.DP.taAF.getByIdxSmart(idxFase)[0];
answ = string.Format("{0} <i>({1})</i>", fase.nomeFase, fase.descrizioneFase);
}
catch
{ }
return answ;
}
/// <summary>
/// recupera descrizione e nome fase da idxFase
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
public string faseByIdx(object _idxFase)
{
string answ = "";
int idxFase = 0;
int.TryParse(_idxFase.ToString(), out idxFase);
answ = memLayer.ML.getRSV($"{rhFaseByIF}{idxFase}");
if (string.IsNullOrEmpty(answ))
{
answ = getFaseByDb(idxFase);
memLayer.ML.setRSV($"{rhFaseByIF}{idxFase}", answ, memLayer.ML.CRI("shotTimeCache"));
}
return answ;
}
/// <summary>
/// Cerca dati fase da idxFase su DB
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
private string getFaseByDb(int idxFase)
{
string answ = "";
try
{
DS_Applicazione.AnagFasiRow fase = DataProxy.DP.taAF.getByIdxSmart(idxFase)[0];
answ = string.Format("{0} <i>({1})</i>", fase.nomeFase, fase.descrizioneFase);
}
catch
{ }
return answ;
}
/// <summary>
/// rimanda ad edit
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lnkEdit_Click(object sender, EventArgs e)
{
// salvo
LinkButton lbtn = (LinkButton)sender;
memLayer.ML.setSessionVal("idxRASel", lbtn.CommandArgument);
// redirect!
Response.Redirect("attivitaIns.aspx");
}
/// <summary>
/// rimanda ad edit
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lnkClona_Click(object sender, EventArgs e)
{
// salvo
LinkButton lbtn = (LinkButton)sender;
int idxRa = 0;
try
{
idxRa = Convert.ToInt32(lbtn.CommandArgument);
}
catch
{ }
// chiamo clona!
DataProxy.DP.taRA.clonaRecord(idxRa);
//update!
setupPage();
grView.DataBind();
}
protected void lnkCreateNew_Click(object sender, EventArgs e)
{
memLayer.ML.emptySessionVal("idxRASel");
// redirect!
Response.Redirect("attivitaIns.aspx");
}
/// <summary>
/// rimanda ad edit
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lnkEdit_Click(object sender, EventArgs e)
{
// salvo
LinkButton lbtn = (LinkButton)sender;
memLayer.ML.setSessionVal("idxRASel", lbtn.CommandArgument);
// redirect!
Response.Redirect("attivitaIns.aspx");
}
/// <summary>
/// rimanda ad edit
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lnkClona_Click(object sender, EventArgs e)
{
// salvo
LinkButton lbtn = (LinkButton)sender;
int idxRa = 0;
try
{
idxRa = Convert.ToInt32(lbtn.CommandArgument);
}
catch
{ }
// chiamo clona!
DataProxy.DP.taRA.clonaRecord(idxRa);
//update!
setupPage();
grView.DataBind();
}
protected void lnkCreateNew_Click(object sender, EventArgs e)
{
memLayer.ML.emptySessionVal("idxRASel");
// redirect!
Response.Redirect("attivitaIns.aspx");
}
protected void txtData_TextChanged(object sender, EventArgs e)
{
DateTime newData = DateTime.Today;
DateTime.TryParse(txtData.Text, out newData);
dataRif = newData;
setupPage();
grView.DataBind();
protected void txtData_TextChanged(object sender, EventArgs e)
{
DateTime newData = DateTime.Today;
DateTime.TryParse(txtData.Text, out newData);
dataRif = newData;
setupPage();
grView.DataBind();
}
}
}
}
@@ -31,7 +31,7 @@ namespace GPW.WebUserControls
}
catch
{ }
if (destinatario != "" && idxDipendente > 0)
if (!string.IsNullOrEmpty(destinatario) && idxDipendente > 0)
{
// invio email...
fatto = DataProxy.DP.sendUserAuthEmail(destinatario, UserAuthKey, idxDipendente);
@@ -37,7 +37,7 @@ namespace GPW.WebUserControls
catch
{ }
// se ci sono i dati effettua tentativo di AutoEnroll del device
if (idxDipendente > 0 && UserAuthKey != "")
if (idxDipendente > 0 && !string.IsNullOrEmpty(UserAuthKey))
{
DeviceName = Request.UserHostName;
IPv4 = Request.UserHostName;
@@ -44,7 +44,7 @@ namespace GPW.WebUserControls
catch
{ }
// se ho trovato un email...
if (destinatario != "" && idxDipendente > 0)
if (!string.IsNullOrEmpty(destinatario) && idxDipendente > 0)
{
DataProxy.DP.sendUserAuthEmail(destinatario, UserAuthKey, idxDipendente);
}