Files
GMW/GMW_data/UserControl.cs
T
2019-06-10 17:23:52 +02:00

141 lines
4.0 KiB
C#

using SteamWare;
using System;
namespace GMW_data
{
public class UserControl : SteamWare.UserControl
{
/// <summary>
/// wrapper per log con salvataggio dell'IP del chiamante
/// </summary>
/// <param name="_testoPre"></param>
/// <returns></returns>
public bool httpLog(string _testoPre)
{
bool answ = false;
string postazione_IP = "";
try
{
postazione_IP = string.Format(" | {0} | ", Request.UserHostName);
}
catch
{ }
logger.lg.scriviLog(postazione_IP + _testoPre);
return answ;
}
/// <summary>
/// wrapper per log con salvataggio dell'IP del chiamante
/// </summary>
/// <param name="_testoPre"></param>
/// <returns></returns>
public bool httpLog(string testoLog, tipoLog tipo)
{
bool answ = false;
string postazione_IP = "";
try
{
postazione_IP = string.Format(" | {0} | ", Request.UserHostName);
}
catch
{ }
logger.lg.scriviLog(postazione_IP + testoLog, tipo);
return answ;
}
/// <summary>
/// CodCS in sessione...
/// </summary>
public string CodCs
{
get
{
string answ = memLayer.ML.StringSessionObj("CodCS");
// se lo perdesse lo recupera da DB
if (string.IsNullOrEmpty(answ))
{
answ = memLayer.ML.cdv("CodCS");
}
return answ;
}
}
/// <summary>
/// restituisce il nome della pagina corrente
/// </summary>
public string PagCorrente
{
get
{
string answ = "";
Uri MyUrl = Request.Url;
string delimStr = "/";
char[] delimiter = delimStr.ToCharArray();
string[] finalUrl = MyUrl.LocalPath.ToString().Split(delimiter);
int n = finalUrl.Length;
answ = finalUrl[n - 1].ToString();
DataLayer_AnagGen.PermessiRow riga = (DataLayer_AnagGen.PermessiRow)user_std.UtSn.permessi.Select(string.Format("URL = '{0}'", answ))[0];
answ = riga.NOME;
return answ;
}
}
/// <summary>
/// Verifica un particolare SE ABBIA un veto data la linea
/// </summary>
/// <param name="codParticolare"></param>
/// <returns></returns>
public virtual bool checkPartVetoByLinea(string codParticolare)
{
bool answ = false;
// cerco se avessi già in redis un controllo particolare/linea attivo e il suo risultato...
string mHash = memLayer.ML.redHash($"lineePartVeto:{Postazione.currCodLinea}:{codParticolare}");
if (memLayer.ML.getRSV(mHash) != null && memLayer.ML.getRSV(mHash) != "")
{
// recupero info...
bool.TryParse(memLayer.ML.getRSV(mHash), out answ);
}
else
{
// se non ho attributi sulal linea è già SENZA veto...
DS_magazzino.ConfLineaDataTable tabConf = MagClass.magazzino.taConfLin.getByLinea(Postazione.currCodLinea);
if (tabConf.Count > 0)
{
// verifico PRIMO RECORD x capire se sono in modalità "passa"
if (tabConf[0].Modo == 1)
{
//--> IMPOSTO VETO
answ = true;
// cerco il recordo del particolare x TOGLIERE VETO
foreach (var item in tabConf)
{
// se trovo il record corrente
if (item.Valore == codParticolare)
{
// tolgo veto ed esco!
answ = false;
break;
}
}
}
// modalità NON PASSA
else
{
// cerco il recordo del particolare x METTERE IL VETO
foreach (var item in tabConf)
{
// se trovo il record corrente
if (item.Valore == codParticolare)
{
// metto veto ed esco!
answ = true;
break;
}
}
}
}
// salvo in redis x 5 minuti il controllo fatto...
memLayer.ML.setRSV(mHash, answ.ToString(), 5 * 60);
}
// restituisco risultato!
return answ;
}
}
}