304 lines
13 KiB
C#
304 lines
13 KiB
C#
using NKC_SDK;
|
|
using SteamWare;
|
|
using System.Globalization;
|
|
|
|
namespace AppData
|
|
{
|
|
public class DataLayer
|
|
{
|
|
#region oggetti public
|
|
|
|
public DS_AppTableAdapters.BatchListTableAdapter taBL;
|
|
public DS_AppTableAdapters.BinsTableAdapter taBN;
|
|
public DS_AppTableAdapters.BinListTableAdapter taBNLS;
|
|
public DS_AppTableAdapters.CountersTableAdapter taCount;
|
|
public DS_AppTableAdapters.CartsTableAdapter taCR;
|
|
public DS_AppTableAdapters.ErrorsLogTableAdapter taEL;
|
|
public DS_AppTableAdapters.ItemListTableAdapter taIL;
|
|
public DS_AppTableAdapters.ImportLogTableAdapter taImpLog;
|
|
public DS_AppTableAdapters.ItemSearchDetailTableAdapter taISD;
|
|
public DS_AppTableAdapters.ItemValidationTableAdapter taIV;
|
|
public DS_AppTableAdapters.KitListTableAdapter taKL;
|
|
public DS_AppTableAdapters.MaterialsTableAdapter taMat;
|
|
public DS_AppTableAdapters.NestingTableAdapter taNest;
|
|
public DS_AppTableAdapters.OfflineOrderListTableAdapter taOffOL;
|
|
public DS_AppTableAdapters.OffOrd2ItemTableAdapter taOO2I;
|
|
public DS_AppTableAdapters.OrderListTableAdapter taOL;
|
|
public DS_AppTableAdapters.OtherItemTableAdapter taOtItem;
|
|
public DS_AppTableAdapters.PackListTableAdapter taPLD;
|
|
public DS_AppTableAdapters.PartValidParetoTableAdapter taPVP;
|
|
public DS_AppTableAdapters.RemnantsTableAdapter taRem;
|
|
public DS_AppTableAdapters.StackListTableAdapter taSTL;
|
|
public DS_AppTableAdapters.SheetListTableAdapter taSHL;
|
|
// reports
|
|
public DS_ReportTableAdapters.ElencoPostazioniTableAdapter taElPos;
|
|
public DS_ReportTableAdapters.PrintJobQueueTableAdapter taPJQ;
|
|
public DS_ReportTableAdapters.stp_prt_StackLabelTableAdapter taRepStack;
|
|
|
|
public DataLayer()
|
|
{
|
|
// inizializzaizone classe
|
|
initTA();
|
|
setupConnString();
|
|
}
|
|
|
|
private void setupConnString()
|
|
{
|
|
string connString = memLayer.ML.CRS("NKC_WFConnectionString");
|
|
taBL.Connection.ConnectionString = connString;
|
|
taBN.Connection.ConnectionString = connString;
|
|
taBNLS.Connection.ConnectionString = connString;
|
|
taCount.Connection.ConnectionString = connString;
|
|
taCR.Connection.ConnectionString = connString;
|
|
taEL.Connection.ConnectionString = connString;
|
|
taIL.Connection.ConnectionString = connString;
|
|
taImpLog.Connection.ConnectionString = connString;
|
|
taISD.Connection.ConnectionString = connString;
|
|
taIV.Connection.ConnectionString = connString;
|
|
taKL.Connection.ConnectionString = connString;
|
|
taMat.Connection.ConnectionString = connString;
|
|
taNest.Connection.ConnectionString = connString;
|
|
taOffOL.Connection.ConnectionString = connString;
|
|
taOO2I.Connection.ConnectionString = connString;
|
|
taOL.Connection.ConnectionString = connString;
|
|
taOtItem.Connection.ConnectionString = connString;
|
|
taPLD.Connection.ConnectionString = connString;
|
|
taPVP.Connection.ConnectionString = connString;
|
|
taRem.Connection.ConnectionString = connString;
|
|
taSTL.Connection.ConnectionString = connString;
|
|
taSHL.Connection.ConnectionString = connString;
|
|
// reports
|
|
taElPos.Connection.ConnectionString = connString;
|
|
taPJQ.Connection.ConnectionString = connString;
|
|
taRepStack.Connection.ConnectionString = connString;
|
|
}
|
|
private void initTA()
|
|
{
|
|
taBL = new DS_AppTableAdapters.BatchListTableAdapter();
|
|
taBN = new DS_AppTableAdapters.BinsTableAdapter();
|
|
taBNLS = new DS_AppTableAdapters.BinListTableAdapter();
|
|
taCount = new DS_AppTableAdapters.CountersTableAdapter();
|
|
taCR = new DS_AppTableAdapters.CartsTableAdapter();
|
|
taEL = new DS_AppTableAdapters.ErrorsLogTableAdapter();
|
|
taIL = new DS_AppTableAdapters.ItemListTableAdapter();
|
|
taImpLog = new DS_AppTableAdapters.ImportLogTableAdapter();
|
|
taISD = new DS_AppTableAdapters.ItemSearchDetailTableAdapter();
|
|
taIV = new DS_AppTableAdapters.ItemValidationTableAdapter();
|
|
taKL = new DS_AppTableAdapters.KitListTableAdapter();
|
|
taMat = new DS_AppTableAdapters.MaterialsTableAdapter();
|
|
taNest = new DS_AppTableAdapters.NestingTableAdapter();
|
|
taOffOL = new DS_AppTableAdapters.OfflineOrderListTableAdapter();
|
|
taOO2I = new DS_AppTableAdapters.OffOrd2ItemTableAdapter();
|
|
taOL = new DS_AppTableAdapters.OrderListTableAdapter();
|
|
taOtItem = new DS_AppTableAdapters.OtherItemTableAdapter();
|
|
taPLD = new DS_AppTableAdapters.PackListTableAdapter();
|
|
taPVP = new DS_AppTableAdapters.PartValidParetoTableAdapter();
|
|
taRem = new DS_AppTableAdapters.RemnantsTableAdapter();
|
|
taSTL = new DS_AppTableAdapters.StackListTableAdapter();
|
|
taSHL = new DS_AppTableAdapters.SheetListTableAdapter();
|
|
// reports
|
|
taElPos = new DS_ReportTableAdapters.ElencoPostazioniTableAdapter();
|
|
taPJQ = new DS_ReportTableAdapters.PrintJobQueueTableAdapter();
|
|
taRepStack = new DS_ReportTableAdapters.stp_prt_StackLabelTableAdapter();
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// oggetto static/singleton per fare chiamate sul datalayer
|
|
/// </summary>
|
|
public static DataLayer man = new DataLayer();
|
|
|
|
public string CodSoggCurrUser
|
|
{
|
|
get
|
|
{
|
|
return "O000123456";
|
|
}
|
|
}
|
|
public string CognNomeCurrUser
|
|
{
|
|
get
|
|
{
|
|
return "Mario Rossi";
|
|
}
|
|
}
|
|
|
|
public decodedData decodeBcode(string bcValue)
|
|
{
|
|
decodedData answ = new decodedData();
|
|
answ.rawData = bcValue;
|
|
if (bcValue.StartsWith("MT"))
|
|
{
|
|
answ.codeType = codeType.Material;
|
|
answ.code = bcValue.Replace("MT", "");
|
|
int codeInt = 0;
|
|
int.TryParse(answ.code, out codeInt);
|
|
answ.codeInt = codeInt;
|
|
answ.description = $"Material: {answ.code}";
|
|
}
|
|
else if (bcValue.StartsWith("BK"))
|
|
{
|
|
answ.codeType = codeType.Stack;
|
|
answ.code = bcValue.Replace("BK", "");
|
|
int codeInt = 0;
|
|
int.TryParse(answ.code, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codeInt);
|
|
answ.codeInt = codeInt;
|
|
answ.description = $"BUNK: {answ.code}";
|
|
}
|
|
else if (bcValue.StartsWith("IG"))
|
|
{
|
|
answ.codeType = codeType.ItemGeneric;
|
|
answ.code = bcValue.Replace("IG", "");
|
|
int codeInt = 0;
|
|
int.TryParse(answ.code, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codeInt);
|
|
answ.codeInt = codeInt;
|
|
answ.description = $"Item Generic: {answ.code}";
|
|
}
|
|
else if (bcValue.StartsWith("IX"))
|
|
{
|
|
answ.codeType = codeType.OtherItem;
|
|
answ.code = bcValue.Replace("IX", "");
|
|
int codeInt = 0;
|
|
int.TryParse(answ.code, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codeInt);
|
|
answ.codeInt = codeInt;
|
|
answ.description = $"Other Item: {answ.code}";
|
|
}
|
|
else if (bcValue.StartsWith("IT"))
|
|
{
|
|
answ.codeType = codeType.Item;
|
|
answ.code = bcValue.Replace("IT", "");
|
|
int codeInt = 0;
|
|
int.TryParse(answ.code, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codeInt);
|
|
answ.codeInt = codeInt;
|
|
answ.description = $"Item: {answ.code}";
|
|
}
|
|
else if (bcValue.StartsWith("CR"))
|
|
{
|
|
answ.codeType = codeType.Cart;
|
|
answ.code = bcValue.Replace("CR", "");
|
|
int codeInt = 0;
|
|
int.TryParse(answ.code, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codeInt);
|
|
answ.codeInt = codeInt;
|
|
answ.description = $"Cart: {answ.code}";
|
|
}
|
|
else if (bcValue.StartsWith("BN"))
|
|
{
|
|
answ.codeType = codeType.Bin;
|
|
answ.code = bcValue.Replace("BN", "");
|
|
int codeInt = 0;
|
|
int.TryParse(answ.code, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codeInt);
|
|
answ.codeInt = codeInt;
|
|
answ.description = $"Bin: {answ.code}";
|
|
}
|
|
else if (bcValue.StartsWith("BP"))
|
|
{
|
|
answ.codeType = codeType.BinProcessed;
|
|
answ.code = bcValue.Replace("BP", "");
|
|
int codeInt = 0;
|
|
int.TryParse(answ.code, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codeInt);
|
|
answ.codeInt = codeInt;
|
|
answ.description = $"Processed Bin: {answ.code}";
|
|
}
|
|
else if (bcValue.StartsWith("SS"))
|
|
{
|
|
answ.codeType = codeType.SecScreen;
|
|
answ.code = bcValue.Replace("SS", "");
|
|
int codeInt = 0;
|
|
int.TryParse(answ.code, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codeInt);
|
|
answ.codeInt = codeInt;
|
|
answ.description = $"Secondary Screen : {answ.code}";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// effettua la stampa di un documento
|
|
/// </summary>
|
|
/// <param name="keyParam">Codice UNIVOCO del documento</param>
|
|
/// <param name="printer">stampante specifica (da postazione o std da web.config, a cura dell'utente</param>
|
|
/// <param name="tipoDoc">Tipo documento richiesto</param>
|
|
/// <param name="clientIp">IP del chiamante</param>
|
|
/// <returns></returns>
|
|
public bool stampaDoc(string keyParam, string printer, tipoDocumento tipoDoc, string clientIp)
|
|
{
|
|
bool answ = false;
|
|
// controllo se esista UDC
|
|
if (checkDoc(tipoDoc, keyParam))
|
|
{
|
|
answ = reportPrinter.obj.stampaCartellino(tipoDoc, keyParam, printer);
|
|
if (answ)
|
|
{
|
|
logger.lg.scriviLog(string.Format(" | {0} | stampato UDC {1} | stampante {2} | tipo {3}", clientIp, keyParam, printer, tipoDoc), tipoLog.INFO);
|
|
}
|
|
else
|
|
{
|
|
logger.lg.scriviLog(string.Format("ERRORE | {0} | stampato UDC {1} | stampante {2} | tipo {3}", clientIp, keyParam, printer, tipoDoc), tipoLog.ERROR);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
logger.lg.scriviLog(string.Format(" | {0} | Richiesta stampa per DOC tipo {1} | stampante {2} | key {3}", clientIp, tipoDoc, printer, keyParam), tipoLog.ERROR);
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// verifica esistenza record da tipo doc + chiave...
|
|
/// </summary>
|
|
/// <param name="tipoDoc"></param>
|
|
/// <param name="keyParam"></param>
|
|
/// <returns></returns>
|
|
private bool checkDoc(tipoDocumento tipoDoc, string keyParam)
|
|
{
|
|
bool answ = false;
|
|
int intIdx = 0;
|
|
switch (tipoDoc)
|
|
{
|
|
case tipoDocumento.docBinPre:
|
|
break;
|
|
case tipoDocumento.docBinPost:
|
|
break;
|
|
case tipoDocumento.docCart:
|
|
break;
|
|
case tipoDocumento.docPart:
|
|
int.TryParse(keyParam, out intIdx);
|
|
var tabPart = taIL.getByKey(intIdx);
|
|
answ = tabPart.Count > 0;
|
|
break;
|
|
case tipoDocumento.docStack:
|
|
int.TryParse(keyParam, out intIdx);
|
|
var tabStack = taSTL.getByKey(intIdx);
|
|
answ = tabStack.Count > 0;
|
|
break;
|
|
case tipoDocumento.docND:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Recupera printer dato codPostazione
|
|
/// </summary>
|
|
/// <param name="codPost"></param>
|
|
/// <returns></returns>
|
|
public string getPrinter(string codPost)
|
|
{
|
|
string printer = "";
|
|
// recupero da DB...
|
|
try
|
|
{
|
|
var tabPost = DataLayer.man.taElPos.getByKey(codPost);
|
|
if (tabPost.Count == 1)
|
|
{
|
|
printer = tabPost[0].stampante;
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
return printer;
|
|
}
|
|
}
|
|
}
|