329 lines
12 KiB
C#
329 lines
12 KiB
C#
using AppData;
|
|
using NKC_SDK;
|
|
using SteamWare;
|
|
using System;
|
|
|
|
namespace NKC_WF.WebUserControls
|
|
{
|
|
public partial class cmp_stackLoading : BaseUserControl
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
// svuoto input barcode...
|
|
if (enableBCode)
|
|
{
|
|
cmp_barcode.inputAcquired = "";
|
|
lastCmd = "";
|
|
}
|
|
cmp_stackNextloading.BatchId = BatchIdCurr;
|
|
raiseEvent();
|
|
doUpdate();
|
|
}
|
|
if (enableBCode)
|
|
{
|
|
cmp_barcode.eh_doRefresh += Cmp_barcode_eh_doRefresh;
|
|
}
|
|
fixDisplay();
|
|
}
|
|
|
|
private void fixDisplay()
|
|
{
|
|
cmp_barcode.Visible = enableBCode;
|
|
}
|
|
|
|
public bool enableBCode
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
bool.TryParse(hfEnableBCode.Value, out answ);
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
hfEnableBCode.Value = value.ToString();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Comando barcode letto
|
|
/// </summary>
|
|
protected string lastCmd
|
|
{
|
|
get
|
|
{
|
|
return hfBarcode.Value;
|
|
}
|
|
set
|
|
{
|
|
hfBarcode.Value = value;
|
|
}
|
|
}
|
|
public int BatchIdCurr
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
try
|
|
{
|
|
if (frmView.SelectedValue != null)
|
|
{
|
|
string selBatch = $"{frmView.SelectedValue}";
|
|
if (!string.IsNullOrEmpty(selBatch))
|
|
{
|
|
int.TryParse(selBatch, out answ);
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
public int StackId
|
|
{
|
|
set
|
|
{
|
|
hfStackId.Value = value.ToString();
|
|
lastCmd = "";
|
|
cmp_barcode.resetMessage();
|
|
doUpdate();
|
|
}
|
|
get
|
|
{
|
|
int answ = 0;
|
|
int.TryParse(hfStackId.Value, out answ);
|
|
return answ;
|
|
}
|
|
}
|
|
private void Cmp_barcode_eh_doRefresh(object sender, EventArgs e)
|
|
{
|
|
|
|
bool doRaiseEv = false;
|
|
// processo evento..
|
|
lastCmd = cmp_barcode.inputAcquired.ToUpper();
|
|
doRaiseEv = processLastCmd(doRaiseEv);
|
|
// reset comando
|
|
cmp_barcode.inputAcquired = "";
|
|
// aggiorno...
|
|
doUpdate();
|
|
// se richiesto faccio raiseEvent
|
|
if (doRaiseEv)
|
|
{
|
|
cmp_stackNextloading.doUpdate();
|
|
}
|
|
}
|
|
|
|
private bool processLastCmd(bool doRaiseEv)
|
|
{
|
|
if (string.IsNullOrEmpty(lastCmd))
|
|
{
|
|
doRaiseEv = true;
|
|
}
|
|
// processiamo barcode letto
|
|
decodedData decoData = DataLayer.man.decodeBcode(lastCmd);
|
|
switch (decoData.codeType)
|
|
{
|
|
case codeType.Stack:
|
|
// verifico SE lo stack esista...
|
|
DS_App.StackListDataTable tabStack = null;
|
|
try
|
|
{
|
|
tabStack = DataLayer.man.taSTL.getByKey(decoData.codeInt);
|
|
}
|
|
catch
|
|
{ }
|
|
if (tabStack != null && tabStack.Count == 0)
|
|
{
|
|
cmp_barcode.showOutput("badge badge-danger", $"{traduci("ErrBunkNotFound")}: {decoData.description}");
|
|
doRaiseEv = true;
|
|
}
|
|
else
|
|
{
|
|
// verifico non sia già in lavorazione
|
|
if (currentBunkAlreadyWorking(decoData.codeInt))
|
|
{
|
|
cmp_barcode.showOutput("badge badge-success", $"{traduci("ErrBunkInProc")}: {decoData.rawData}");
|
|
doRaiseEv = true;
|
|
}
|
|
else
|
|
{
|
|
// controllo sia quello RICHIESTO
|
|
if (decoData.codeInt == cmp_stackNextloading.StackIdReq)
|
|
{
|
|
// controllo se il bunk richiesto sia stato caricato coi materiali...
|
|
if (!isBunkFilled(decoData.codeInt))
|
|
{
|
|
cmp_barcode.showOutput("badge badge-danger", $"{traduci("ErrNextBunkNotReady")}: {decoData.rawData}");
|
|
doRaiseEv = true;
|
|
}
|
|
else
|
|
{
|
|
// verifico SE i BUNKS correnti siano tutti stati completati (NumSheet == NumWorking)
|
|
if (currentBunkPrinted)
|
|
{
|
|
cmp_barcode.showOutput("badge badge-success", $"{traduci("BunkOK")}: {decoData.rawData}");
|
|
ComLib.resetCurrBunk();
|
|
ComLib.taktMLCurrBunk = decoData.codeInt.ToString();
|
|
// processo DB e salvo che lo stack è stato caricato in MACHINE LOAD
|
|
int stackId = 0;
|
|
try
|
|
{
|
|
var tabStacks = DataLayer.man.taSTL.getByDtmx(decoData.rawData);
|
|
if (tabStack.Count == 1)
|
|
{
|
|
stackId = tabStack[0].StackID;
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
// SE HO uno stackId valido (>0)...
|
|
if (stackId > 0)
|
|
{
|
|
DataLayer.man.taSTL.updatePos(stackId, 5);
|
|
lgInfo($"cmp_stackLoading| taSTL.updatePos | POS --> 5 | stackId: {stackId}");
|
|
|
|
// controllo status del bunk nel suo insieme...
|
|
ComLib.updateBatchPositionByBunk(stackId);
|
|
lgInfo($"cmp_stackLoading| updateBatchPositionByBunk | stackId: {stackId}");
|
|
doRaiseEv = true;
|
|
}
|
|
ComLib.setReloadMU();
|
|
}
|
|
// altrimenti segnalo NON pronto x caricare prossimo
|
|
else
|
|
{
|
|
cmp_barcode.showOutput("badge badge-danger", $"{traduci("ErrPrevBunkNotReady")}: {decoData.rawData}");
|
|
doRaiseEv = true;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
cmp_barcode.showOutput("badge badge-danger", $"{traduci("ErrWrongBunk")}: {decoData.rawData}");
|
|
doRaiseEv = true;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
cmp_barcode.showOutput("text-danger", $"{traduci("UnknownData")}: {decoData.rawData} --> {traduci("NoValiAction")}");
|
|
doRaiseEv = true;
|
|
break;
|
|
}
|
|
|
|
return doRaiseEv;
|
|
}
|
|
|
|
protected bool currentBunkAlreadyWorking(int StackIdRequested)
|
|
{
|
|
bool answ = false;
|
|
// leggo i dati del bunk...
|
|
var currBunks = DataLayer.man.taSTL.getCurrByBatch(BatchIdCurr);
|
|
if (currBunks.Count > 0)
|
|
{
|
|
// verifico x ogni bunk corrente
|
|
foreach (var item in currBunks)
|
|
{
|
|
// verifico se numSheet = NumWorging
|
|
bool checkFound = item.StackID == StackIdRequested;
|
|
|
|
// update answ
|
|
answ = answ || checkFound;
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
protected bool currentBunkPrinted
|
|
{
|
|
get
|
|
{
|
|
bool answ = true;
|
|
// leggo i dati del bunk...
|
|
var currBunks = DataLayer.man.taSTL.getCurrByBatch(BatchIdCurr);
|
|
if (currBunks.Count > 0)
|
|
{
|
|
// verifico x ogni bunk corrente
|
|
foreach (var item in currBunks)
|
|
{
|
|
// verifico se numSheet = NumWorging
|
|
bool checkNum = item.NumSheets == item.NumSheetsWorking;
|
|
|
|
// update answ
|
|
answ = answ && checkNum;
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// verifica se il bunk sia stato completato come caricamento dei fogli richiesti)
|
|
/// </summary>
|
|
protected bool isBunkFilled(int BunkId)
|
|
{
|
|
bool answ = false;
|
|
// leggo i dati del bunk...
|
|
var currBunk = DataLayer.man.taSTL.getByKey(BunkId);
|
|
if (currBunk.Count == 1)
|
|
{
|
|
answ = currBunk[0].Position == 4;
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected void checkVisibility()
|
|
{
|
|
lblLoaded.Visible = StackId != 0;
|
|
frmView.Visible = !lblLoaded.Visible;
|
|
// fix div di simulazione
|
|
divSim.Visible = (memLayer.ML.CRS("environment") == "DEV" && !enableBCode);
|
|
}
|
|
|
|
public void doUpdate()
|
|
{
|
|
checkVisibility();
|
|
}
|
|
|
|
|
|
protected void timerLoad_Tick(object sender, EventArgs e)
|
|
{
|
|
checkVisibility();
|
|
cmp_stackNextloading.doUpdate();
|
|
}
|
|
|
|
protected void frmView_DataBound(object sender, EventArgs e)
|
|
{
|
|
cmp_stackNextloading.BatchId = BatchIdCurr;
|
|
raiseEvent();
|
|
}
|
|
|
|
protected void lbtAdvanceProd_Click(object sender, EventArgs e)
|
|
{
|
|
// chiama stored x cambiare dt dei vari processi governati dal prod...
|
|
var currStack = DataLayer.man.taSTL.getCurrByBatch(BatchIdCurr);
|
|
if (currStack != null)
|
|
{
|
|
if (currStack.Count > 0)
|
|
{
|
|
int stackIdCurr = currStack[0].StackID;
|
|
DataLayer.man.taSHL.advanceInStack(stackIdCurr);
|
|
lgInfo($"cmp_unloadSmart | MANUAL FORCED DATA | taSHL.advanceInStack | stackIdCurr: {stackIdCurr}");
|
|
}
|
|
doUpdate();
|
|
cmp_stackNextloading.doUpdate();
|
|
// segnalo avanzamento su redis x pagina unload
|
|
ComLib.advaceSheetRevByBunk(BatchIdCurr);
|
|
lgInfo($"cmp_unloadSmart | MANUAL FORCED DATA | ComLib.advaceSheetRevByBunk | BatchIdCurr: {BatchIdCurr}");
|
|
ComLib.setReloadMU();
|
|
// controllo update stato BATCH/BUNK
|
|
ComLib.updateBatchPosition(BatchIdCurr);
|
|
lgInfo($"cmp_unloadSmart | MANUAL FORCED DATA | ComLib.updateBatchPosition | BatchIdCurr: {BatchIdCurr}");
|
|
raiseEvent();
|
|
}
|
|
}
|
|
|
|
}
|
|
} |