401 lines
14 KiB
C#
401 lines
14 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using SteamWare;
|
|
|
|
namespace GMW_data
|
|
{
|
|
/// <summary>
|
|
/// classe gestione operazioni con terminalino
|
|
/// </summary>
|
|
public class TermClass
|
|
{
|
|
#region area table adapters
|
|
|
|
// variabile di tipo table adapter
|
|
#if false
|
|
public DS_magazzinoTableAdapters.AnagMagTableAdapter taAnagMag;
|
|
public DS_magazzinoTableAdapters.BlocchiTableAdapter taBlocchi;
|
|
public DS_magazzinoTableAdapters.CelleTableAdapter taCelle;
|
|
public DS_magazzinoTableAdapters.TipoCellaTableAdapter taTipoCella;
|
|
public DS_magazzinoTableAdapters.ElencoCartelliniTableAdapter taCartellini;
|
|
public DS_magazzinoTableAdapters.PosizioneUdcCorrenteTableAdapter taPosUdcCorr;
|
|
public DS_magazzinoTableAdapters.PosizioneUdcStoricoTableAdapter taPosUdcStorico;
|
|
public DS_magazzinoTableAdapters.V_MagazziniOverviewTableAdapter taMagOverw;
|
|
public DS_magazzinoTableAdapters.V_DettMagPartTableAdapter taDettMagPart;
|
|
public DS_magazzinoTableAdapters.v_UdcDetailTableAdapter taDettUDC;
|
|
public DS_magazzinoTableAdapters.ElencoListePrelievoTableAdapter taElencoListePrelievo;
|
|
public DS_magazzinoTableAdapters.ElencoCartelliniTableAdapter taElencoCartellini;
|
|
public DS_magazzinoTableAdapters.RigheListePrelievoTableAdapter taRigheListePrelievo;
|
|
public DS_magazzinoTableAdapters.TipoListaPrelievoTableAdapter taTipoListaPrelievo;
|
|
public DS_magazzinoTableAdapters.V_ParticolariOverviewTableAdapter taVParticolariOverwiew;
|
|
public DS_magazzinoTableAdapters.v_particolariEsponenteFiguraTableAdapter taPartExpFig;
|
|
#endif
|
|
|
|
|
|
/// <summary>
|
|
/// init dei table adapters
|
|
/// </summary>
|
|
protected void initTA()
|
|
{
|
|
// istanzio oggetto
|
|
#if false
|
|
taAnagMag = new GMW_data.DS_magazzinoTableAdapters.AnagMagTableAdapter();
|
|
taBlocchi = new GMW_data.DS_magazzinoTableAdapters.BlocchiTableAdapter();
|
|
taCelle = new GMW_data.DS_magazzinoTableAdapters.CelleTableAdapter();
|
|
taTipoCella = new GMW_data.DS_magazzinoTableAdapters.TipoCellaTableAdapter();
|
|
taCartellini = new GMW_data.DS_magazzinoTableAdapters.ElencoCartelliniTableAdapter();
|
|
taPosUdcCorr = new GMW_data.DS_magazzinoTableAdapters.PosizioneUdcCorrenteTableAdapter();
|
|
taPosUdcStorico = new GMW_data.DS_magazzinoTableAdapters.PosizioneUdcStoricoTableAdapter();
|
|
taMagOverw = new GMW_data.DS_magazzinoTableAdapters.V_MagazziniOverviewTableAdapter();
|
|
taDettMagPart = new GMW_data.DS_magazzinoTableAdapters.V_DettMagPartTableAdapter();
|
|
taDettUDC = new GMW_data.DS_magazzinoTableAdapters.v_UdcDetailTableAdapter();
|
|
taElencoListePrelievo = new GMW_data.DS_magazzinoTableAdapters.ElencoListePrelievoTableAdapter();
|
|
taElencoCartellini = new GMW_data.DS_magazzinoTableAdapters.ElencoCartelliniTableAdapter();
|
|
taRigheListePrelievo = new GMW_data.DS_magazzinoTableAdapters.RigheListePrelievoTableAdapter();
|
|
taTipoListaPrelievo = new GMW_data.DS_magazzinoTableAdapters.TipoListaPrelievoTableAdapter();
|
|
taVParticolariOverwiew = new GMW_data.DS_magazzinoTableAdapters.V_ParticolariOverviewTableAdapter();
|
|
taPartExpFig = new GMW_data.DS_magazzinoTableAdapters.v_particolariEsponenteFiguraTableAdapter();
|
|
#endif
|
|
}
|
|
/// <summary>
|
|
/// effettua setup dei connection strings da web.config delal singola applicazione
|
|
/// </summary>
|
|
protected virtual void setupConnectionStringBase()
|
|
{
|
|
// connections del db
|
|
#if false
|
|
taAnagMag.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taBlocchi.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taCelle.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taTipoCella.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taCartellini.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taPosUdcCorr.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taPosUdcStorico.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taMagOverw.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taDettMagPart.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taDettUDC.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taElencoListePrelievo.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taElencoCartellini.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taRigheListePrelievo.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taTipoListaPrelievo.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taVParticolariOverwiew.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
taPartExpFig.Connection.ConnectionString = memLayer.ML.confReadString("GMWConnectionString");
|
|
#endif
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Inizializzazione
|
|
|
|
protected TermClass()
|
|
{
|
|
initTA();
|
|
setupConnectionStringBase();
|
|
}
|
|
|
|
/// <summary>
|
|
/// oggetto static per fare chiamate sul magazzino
|
|
/// </summary>
|
|
public static TermClass Ter = new TermClass();
|
|
|
|
#endregion
|
|
|
|
#region metodi protected
|
|
|
|
#if false
|
|
/// <summary>
|
|
/// aggiunge le righe liste di prelievo necessarie a soddisfare la richiesta in logica FIFO dato un elenco di cartellini, la qta totale da allocare e la lista attuale
|
|
/// </summary>
|
|
/// <param name="QtaTot"></param>
|
|
/// <param name="codListaAttuale"></param>
|
|
/// <param name="tabellaElencoCartellini"></param>
|
|
private void allocaRigheListaPrelievo(decimal QtaTot, string codListaAttuale, DS_magazzino.ElencoCartelliniDataTable tabellaElencoCartellini)
|
|
{
|
|
//ricavo il valore UDC della riga del più vecchio
|
|
string udcAttuale;
|
|
bool qtaOk = false;
|
|
bool dataFinished = false;
|
|
int progrUdc = 0;
|
|
int numUdcDisponibili = tabellaElencoCartellini.Rows.Count;
|
|
// contiene la quantità della riga attuale
|
|
decimal qtaRiga;
|
|
// somma progressiva della qta allocata - calcolo da db!
|
|
decimal qtaAllocata = taElencoListePrelievo.getByCodLista(codListaAttuale)[0].Prelevato;
|
|
//ciclo WHILE per lo riempimento FIFO con UDC secondo richiesta a partire da elenco fornito
|
|
while (!qtaOk && !dataFinished)
|
|
{
|
|
/*
|
|
* crea una riga in righelistaprelievo passando come valori
|
|
* il codlista attuale ricavato da sopr
|
|
* l'UDC dal primo della tabella getOlderUDC
|
|
*
|
|
*
|
|
* recupero quantità dalla riga corrente;
|
|
*
|
|
* imposto proposto a 1;
|
|
* imposto prelevato 0;
|
|
* taRighelistePreliveo.Insert;
|
|
*
|
|
* qtaAllocata = qtaAllocata + Qta di questa riga (riuso il valore della colonna QTA
|
|
* tabella[contatore]; contatore++;
|
|
* qtaOk = (qtaAllocata >= qtaRichiesta)
|
|
* dataFinished = (contatore >= numRighe);
|
|
*
|
|
* */
|
|
// ricavo la riga più vecchia
|
|
qtaRiga = tabellaElencoCartellini[progrUdc].Qta;
|
|
udcAttuale = tabellaElencoCartellini[progrUdc].UDC;
|
|
// eseguo query di insert
|
|
taRigheListePrelievo.Insert(codListaAttuale, udcAttuale, qtaRiga, true, false);
|
|
|
|
//incremento qta allocata
|
|
qtaAllocata = (qtaAllocata + qtaRiga);
|
|
//incremento contatore
|
|
progrUdc++;
|
|
|
|
// verifico le condizioni, false se non cambia nulla true se cambia e si esce dal while
|
|
qtaOk = (qtaAllocata >= QtaTot);
|
|
dataFinished = (progrUdc >= numUdcDisponibili);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#endregion
|
|
|
|
#region Metodi esposti
|
|
|
|
/// <summary>
|
|
/// Verifica il login utente andando a controllare il CodSoggetto da RilPro e salvando in sessione un oggetto user_std x l'utente corrispondente al cod soggetto secondo la tab soggetti2utente
|
|
/// </summary>
|
|
/// <param name="CodSoggetto"></param>
|
|
/// <returns>tipo di errore codificato</returns>
|
|
public esitoLoginTerm doUserLogin(string CodSoggetto)
|
|
{
|
|
esitoLoginTerm answ = esitoLoginTerm.errore;
|
|
try
|
|
{
|
|
// verifico che il cod operatore passato sia valido per RilPro.AnagOperatori e Soggetti2Utente
|
|
int trovatiAnagOp = DataProxy.obj.taAnagOperatore.getByCodSoggetto(CodSoggetto).Rows.Count;
|
|
int trovatiS2U = DataProxy.obj.taSogg2Oper.getByCodSoggetto(CodSoggetto).Rows.Count;
|
|
if (trovatiAnagOp == 1)
|
|
{
|
|
if (trovatiS2U == 1)
|
|
{
|
|
// è ok, proseguo facendo avvio user
|
|
DS_Applicazione.Soggetti2UtenteRow rigaOp = DataProxy.obj.taSogg2Oper.getByCodSoggetto(CodSoggetto)[0];
|
|
// inizializzo utente con dati operatore
|
|
user_std _utente = new user_std();
|
|
user_std.UtSn.isForcedUser = true;
|
|
bool fatto = _utente.startUpUtente(rigaOp.DOMINIO, rigaOp.USER_NAME);
|
|
if (fatto)
|
|
{
|
|
answ = esitoLoginTerm.ok;
|
|
logger.lg.scriviLog(String.Format("Forced user identity ok: logged as \t {0}\\{1}", user_std.UtSn.dominio, user_std.UtSn.utente), tipoLog.STARTUP);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
logger.lg.scriviLog(string.Format("Attenzione: trovati {0} utenti in RilPro AnagOperatori e {1} utenti in Soggetti2Utente per il CodSoggetto {2}: login impossibile!", trovatiAnagOp, trovatiS2U, CodSoggetto), tipoLog.ERROR);
|
|
answ = esitoLoginTerm.errore_noUser;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
logger.lg.scriviLog(string.Format("Attenzione: trovati {0} utenti in RilPro AnagOperatori e {1} utenti in Soggetti2Utente per il CodSoggetto {2}: login impossibile!", trovatiAnagOp, trovatiS2U, CodSoggetto), tipoLog.ERROR);
|
|
answ = esitoLoginTerm.errore_noCodSogg;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in TermClass.doUserLogin per il CodSoggetto {0}: eccezione {1}", CodSoggetto, e), tipoLog.FATAL);
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// verifica se il codice barcode letto sia un particoalre con codice tipo "P"
|
|
/// </summary>
|
|
/// <param name="barcodeIN"></param>
|
|
/// <returns></returns>
|
|
public bool isParticolare(string barcodeIN)
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
answ = utils.obj.taSelParticolari.getByConditioValue(barcodeIN, "P").Rows.Count == 1;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// verifica se il codice barcode letto sia un anima
|
|
/// </summary>
|
|
/// <param name="barcodeIN"></param>
|
|
/// <returns></returns>
|
|
public bool isAnima(string barcodeIN)
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
answ = utils.obj.taSelParticolari.getByConditioValue(barcodeIN, "A").Rows.Count == 1;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// verifica il codice barcode letto e restituisce il tipo di valore corrisponente
|
|
/// </summary>
|
|
/// <param name="barcodeIN"></param>
|
|
/// <returns></returns>
|
|
public tipoCodiceBarcode riconosciBarcode(string barcodeIN)
|
|
{
|
|
tipoCodiceBarcode answ = tipoCodiceBarcode.ND;
|
|
if (barcodeIN != "")
|
|
{
|
|
// cerco se sia un particolare...
|
|
if (utils.obj.taSelParticolari.getByConditioValue(barcodeIN,"*").Rows.Count == 1)
|
|
{
|
|
answ = tipoCodiceBarcode.Particolare;
|
|
}
|
|
// se non lo è continuo
|
|
if (answ == tipoCodiceBarcode.ND)
|
|
{
|
|
switch (barcodeIN.Substring(0, 1))
|
|
{
|
|
case "O":
|
|
answ = tipoCodiceBarcode.Operatore;
|
|
break;
|
|
case "K":
|
|
answ = tipoCodiceBarcode.ListaPrelievo;
|
|
break;
|
|
//case "P":
|
|
//case "A":
|
|
// answ = tipoCodiceBarcode.Particolare;
|
|
// break;
|
|
case "U":
|
|
answ = tipoCodiceBarcode.UDC;
|
|
break;
|
|
case "S":
|
|
answ = tipoCodiceBarcode.Cella;
|
|
break;
|
|
default:
|
|
// cerco se la stringa intera abbia un match con le celle...
|
|
if (MagClass.magazzino.taCelle.getByCodCella(barcodeIN).Rows.Count == 1)
|
|
{
|
|
answ = tipoCodiceBarcode.Cella;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// effettua il reset di tutti i valori in sesisone salvati a valle della scansione di un barcode
|
|
/// </summary>
|
|
/// <param name="resetUdc">true/false se resettare UDC selezionato</param>
|
|
/// <param name="resetCella">true/false se resettare Cella selezionata</param>
|
|
/// <param name="resetPArticolare">true/false se resettare Particolare selezionato</param>
|
|
public void resetScanBarcode(bool resetUdc, bool resetCella, bool resetParticolare)
|
|
{
|
|
if (resetCella)
|
|
{
|
|
memLayer.ML.emptySessionVal("IdxCella_sel");
|
|
memLayer.ML.emptySessionVal("codCella_sel");
|
|
}
|
|
if (resetParticolare)
|
|
{
|
|
memLayer.ML.emptySessionVal("Particolare_sel");
|
|
}
|
|
if (resetUdc)
|
|
{
|
|
memLayer.ML.emptySessionVal("UDC_sel");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// definisce i tipi di codice che il barcode può leggere
|
|
/// </summary>
|
|
public enum tipoCodiceBarcode
|
|
{
|
|
/// <summary>
|
|
/// Tipo non riconosciuto
|
|
/// </summary>
|
|
ND,
|
|
/// <summary>
|
|
/// [O] - il barcode rappresenta un codice operatore
|
|
/// </summary>
|
|
Operatore,
|
|
/// <summary>
|
|
/// [K] - il barcode rappresenta una lista di prelievo
|
|
/// </summary>
|
|
ListaPrelievo,
|
|
/// <summary>
|
|
/// [U] - il barcode rappresenta un UDC
|
|
/// </summary>
|
|
UDC,
|
|
/// <summary>
|
|
/// il barcode rappresenta un particolare
|
|
/// </summary>
|
|
Particolare,
|
|
/// <summary>
|
|
/// Cella [S]
|
|
/// </summary>
|
|
Cella,
|
|
/// <summary>
|
|
/// codice gitterbox
|
|
/// </summary>
|
|
Gitterbox,
|
|
/// <summary>
|
|
/// Codice PartNumber come sottoinsieme (iniziale ) di datamatrix BMW
|
|
/// </summary>
|
|
PartNumber,
|
|
/// <summary>
|
|
/// Codice datamatrix
|
|
/// </summary>
|
|
DataMatrix,
|
|
/// <summary>
|
|
/// codice che indica un comando (prefisso da web.config)
|
|
/// </summary>
|
|
Comando,
|
|
/// <summary>
|
|
/// Assieme Logico
|
|
/// </summary>
|
|
AL,
|
|
/// <summary>
|
|
/// Trattamento Termico
|
|
/// </summary>
|
|
TT,
|
|
/// <summary>
|
|
/// Codice di imballo
|
|
/// </summary>
|
|
Imballo
|
|
}
|
|
/// <summary>
|
|
/// elenco degli esiti per una sessione di login da terminalino
|
|
/// </summary>
|
|
public enum esitoLoginTerm
|
|
{
|
|
/// <summary>
|
|
/// tutto ok, come true
|
|
/// </summary>
|
|
ok,
|
|
/// <summary>
|
|
/// non è andata, errore generico
|
|
/// </summary>
|
|
errore,
|
|
/// <summary>
|
|
/// errore x mancanza record in tab operatori di RilPro x CodSoggetto
|
|
/// </summary>
|
|
errore_noCodSogg,
|
|
/// <summary>
|
|
/// errore mancanza username corrisponende all'operatore il cui cod soggetto è stato passato
|
|
/// </summary>
|
|
errore_noUser
|
|
} |