487 lines
13 KiB
C#
487 lines
13 KiB
C#
using MagData;
|
|
using MapoDb;
|
|
using Newtonsoft.Json;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace MP_MAG
|
|
{
|
|
public class BaseUserControl : System.Web.UI.UserControl
|
|
{
|
|
#region Internal Fields
|
|
|
|
/// <summary>
|
|
/// Oggetto datalayer specifico
|
|
/// </summary>
|
|
internal DataLayer DataLayerObj = new DataLayer();
|
|
|
|
/// <summary>
|
|
/// Oggetto datalayer specifico
|
|
/// </summary>
|
|
internal MagDataLayer MagDataLayerObj = new MagDataLayer();
|
|
|
|
#endregion Internal Fields
|
|
|
|
#region Public Events
|
|
|
|
/// <summary>
|
|
/// Generico evento di richiesta AddNew
|
|
/// </summary>
|
|
public event EventHandler eh_addNew;
|
|
|
|
/// <summary>
|
|
/// Generico evento di richiesta refresh a parent
|
|
/// </summary>
|
|
public event EventHandler eh_doRefresh;
|
|
|
|
/// <summary>
|
|
/// Generico evento di richiesta refresh a parent
|
|
/// </summary>
|
|
public event EventHandler eh_doReset;
|
|
|
|
/// <summary>
|
|
/// Generico evento "stato editing"
|
|
/// </summary>
|
|
public event EventHandler eh_editing;
|
|
|
|
#endregion Public Events
|
|
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// Codice operatore salvato in cookie
|
|
/// </summary>
|
|
protected string cookieCodOpr
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.getCookieVal("CTrack_CodOpr");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Codice post salvato in cookie
|
|
/// </summary>
|
|
protected string cookieCodPost
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.getCookieVal("CTrack_CodPost");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rilegge i dati di prod da DB
|
|
/// </summary>
|
|
protected prodData getProdDataDb
|
|
{
|
|
// FIXME TODO: da rivedere gestione dei cookie di recupero dati x gestione...
|
|
get
|
|
{
|
|
prodData answ = null;
|
|
// leggo da DB ODL...
|
|
var tabOdl = MagDataLayer.man.taODL.getOpenByPost(cookieCodPost);
|
|
if (tabOdl.Count == 1)
|
|
{
|
|
var rigaOdl = tabOdl[0];
|
|
var tabArt = MagDataLayer.man.taAA.getByKey(rigaOdl.CodArticolo);
|
|
string codCli = rigaOdl.CodCli;
|
|
string descrArt = "ND";
|
|
if (tabArt.Count == 1)
|
|
{
|
|
descrArt = tabArt[0].DescrArt;
|
|
}
|
|
var tabEP2Q = MagDataLayer.man.taEP2Q.getByKey(cookieCodPost);
|
|
string printQueue = "";
|
|
if (tabEP2Q.Count == 1)
|
|
{
|
|
printQueue = tabEP2Q[0].PrintQueue;
|
|
}
|
|
answ = new prodData()
|
|
{
|
|
CodPost = cookieCodPost,
|
|
CodOpr = cookieCodOpr,
|
|
RifExt = rigaOdl.KeyRichiesta,
|
|
CurrODL = $"{rigaOdl.IdxODL}",
|
|
CurrArtCod = rigaOdl.CodArticolo,
|
|
CurrArtDesc = descrArt,
|
|
PrintQueue = printQueue,
|
|
CodCli = codCli
|
|
};
|
|
// ora descr articolo
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Codice Cliente
|
|
/// </summary>
|
|
public string CodCli
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
if (currProdData != null)
|
|
{
|
|
try
|
|
{
|
|
answ = currProdData.CodCli;
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Codice operatore
|
|
/// </summary>
|
|
public string CodOpr
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
if (currProdData != null)
|
|
{
|
|
try
|
|
{
|
|
answ = currProdData.CodOpr;
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Codice post
|
|
/// </summary>
|
|
public string CodPost
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
if (currProdData != null)
|
|
{
|
|
try
|
|
{
|
|
answ = currProdData.CodPost;
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Descr Articolo corrente x post
|
|
/// </summary>
|
|
public string CurrArtDesc
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
if (currProdData != null)
|
|
{
|
|
var dati = currProdData;
|
|
if (dati != null)
|
|
{
|
|
try
|
|
{
|
|
answ = $"{dati.CurrArtCod} | {dati.CurrArtDesc}";
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Articolo corrente x post
|
|
/// </summary>
|
|
public string CurrCodArt
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
if (currProdData != null)
|
|
{
|
|
answ = currProdData.CurrArtCod;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Dati correnti prod
|
|
/// </summary>
|
|
public MagData.prodPrintData currData
|
|
{
|
|
get
|
|
{
|
|
return MagDataLayerObj.currProdPrintData;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ODL corrente x post
|
|
/// </summary>
|
|
public string CurrOdl
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
if (currProdData != null)
|
|
{
|
|
answ = currProdData.CurrODL;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ODL corrente x post
|
|
/// </summary>
|
|
public string CurrOdlDesc
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
if (currProdData != null)
|
|
{
|
|
try
|
|
{
|
|
answ = $"ODL: {currProdData.CurrODL}";
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Dati correnti di produzione
|
|
/// FixMe Todo !!! : DA RIVEDERE: NON Può essere a livello redis condiviso se diverse postazioni...
|
|
/// </summary>
|
|
public prodData currProdData
|
|
{
|
|
get
|
|
{
|
|
prodData answ = null;
|
|
try
|
|
{
|
|
string rawData = memLayer.ML.getRSV("redProdKey");
|
|
if (!string.IsNullOrEmpty(rawData))
|
|
{
|
|
answ = JsonConvert.DeserializeObject<prodData>(rawData);
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
// se vuoto leggo da DB
|
|
if (answ == null)
|
|
{
|
|
answ = getProdDataDb;
|
|
// salvo in sessione
|
|
currProdData = answ;
|
|
}
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
string rawData = JsonConvert.SerializeObject(value);
|
|
memLayer.ML.setRSV(redProdKey, rawData, redProdKeyTTL);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Chiave redis dei dati di prod correnti
|
|
/// </summary>
|
|
public string redProdKey
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.redHash(memLayer.ML.CRS("redProdKey"));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// TTL dati redis x prod
|
|
/// </summary>
|
|
public int redProdKeyTTL
|
|
{
|
|
get
|
|
{
|
|
int answ = 60;
|
|
answ = memLayer.ML.CRI("redProdKeyTTL") > 0 ? memLayer.ML.CRI("redProdKeyTTL") : 60;
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rif esterno (da ODL)
|
|
/// </summary>
|
|
public string RifExt
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
if (currProdData != null)
|
|
{
|
|
try
|
|
{
|
|
answ = currProdData.RifExt;
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// titolo pagina
|
|
/// </summary>
|
|
public string titolo
|
|
{
|
|
get
|
|
{
|
|
return devicesAuthProxy.getPage(Request.Url).Replace(".aspx", "");
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Verifica se il cod articolo passato (tipicamente Eval DataGrid) sia OK con articolo corrente
|
|
/// </summary>
|
|
/// <param name="_codArt"></param>
|
|
/// <returns></returns>
|
|
public bool codArtOk(object _codArt)
|
|
{
|
|
bool answ = false;
|
|
if (_codArt != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(_codArt.ToString()))
|
|
{
|
|
answ = _codArt.ToString() == CurrCodArt;
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Chiamata evento add New
|
|
/// </summary>
|
|
public void raiseAddNew()
|
|
{
|
|
// se qualcuno ascolta sollevo evento nuovo valore...
|
|
if (eh_addNew != null)
|
|
{
|
|
eh_addNew(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Chiamata evento editing
|
|
/// </summary>
|
|
public void raiseEditing()
|
|
{
|
|
// se qualcuno ascolta sollevo evento nuovo valore...
|
|
if (eh_editing != null)
|
|
{
|
|
eh_editing(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Chiamata evento
|
|
/// </summary>
|
|
public void raiseEvent()
|
|
{
|
|
// se qualcuno ascolta sollevo evento nuovo valore...
|
|
if (eh_doRefresh != null)
|
|
{
|
|
eh_doRefresh(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Chiamata evento
|
|
/// </summary>
|
|
public void raiseReset()
|
|
{
|
|
// se qualcuno ascolta sollevo evento nuovo valore...
|
|
if (eh_doReset != null)
|
|
{
|
|
eh_doReset(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
public bool resetProdData()
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
// rileggo
|
|
prodPrintData newProdPrintData = MagDataLayerObj.currProdPrintData;
|
|
DateTime dtRif = DateTime.Now;
|
|
// calcolo
|
|
var tabOdl = DataLayerObj.taODL.getByIdx(newProdPrintData.IdxOdl, false);
|
|
// se ODL chiuso --> uso data chiusura x indicare data controllo
|
|
if (tabOdl.Rows.Count > 0)
|
|
{
|
|
newProdPrintData.QtaOdl = tabOdl[0].NumPezzi;
|
|
if (!tabOdl[0].IsDataFineNull())
|
|
{
|
|
dtRif = tabOdl[0].DataFine;
|
|
}
|
|
}
|
|
|
|
//2022.03.31 modifica stored lettura
|
|
var tabDatiProdAct = DataLayerObj.taStatoProd.getByMacchinaData(newProdPrintData.IdxMacchina, dtRif);
|
|
//var tabDatiProdAct = DataLayerObj.taStatoProd.GetData(newProdPrintData.IdxMacchina, dtRif);
|
|
|
|
if (tabDatiProdAct.Rows.Count > 0)
|
|
{
|
|
newProdPrintData.QtaConf = tabDatiProdAct[0].PzConfBuoni;
|
|
}
|
|
// salvo in oggetto dedicato...
|
|
MagDataLayerObj.currProdPrintData = newProdPrintData;
|
|
answ = true;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Wrapper traduzione termini
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(string lemma)
|
|
{
|
|
return SteamWare.user_std.UtSn.Traduci(lemma);
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
}
|
|
} |