diff --git a/IOB-UT-NEXT/IOB-UT-NEXT.csproj b/IOB-UT-NEXT/IOB-UT-NEXT.csproj
index 2e2ea9d1..61e934f4 100644
--- a/IOB-UT-NEXT/IOB-UT-NEXT.csproj
+++ b/IOB-UT-NEXT/IOB-UT-NEXT.csproj
@@ -84,8 +84,8 @@
..\packages\SharpZipLib.1.3.1\lib\net45\ICSharpCode.SharpZipLib.dll
-
- ..\packages\MapoSDK.6.14.2211.3010\lib\MapoSDK.dll
+
+ ..\packages\MapoSDK.6.14.2211.3016\lib\MapoSDK.dll
..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll
diff --git a/IOB-UT-NEXT/Objects.cs b/IOB-UT-NEXT/Objects.cs
index d7cd69eb..5d76a33e 100644
--- a/IOB-UT-NEXT/Objects.cs
+++ b/IOB-UT-NEXT/Objects.cs
@@ -815,4 +815,5 @@ namespace IOB_UT_NEXT
#endregion Public Properties
}
+
}
\ No newline at end of file
diff --git a/IOB-UT-NEXT/packages.config b/IOB-UT-NEXT/packages.config
index e48167f4..6d534f73 100644
--- a/IOB-UT-NEXT/packages.config
+++ b/IOB-UT-NEXT/packages.config
@@ -2,7 +2,7 @@
-
+
diff --git a/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj b/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj
index 43010d3b..0d403cc0 100644
--- a/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj
+++ b/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj
@@ -137,8 +137,8 @@
False
ExtLib\krcc.dll
-
- ..\packages\MapoSDK.6.14.2211.3010\lib\MapoSDK.dll
+
+ ..\packages\MapoSDK.6.14.2211.3016\lib\MapoSDK.dll
..\packages\MathNet.Numerics.4.15.0\lib\net461\MathNet.Numerics.dll
diff --git a/IOB-WIN-NEXT/IobGeneric.cs b/IOB-WIN-NEXT/IobGeneric.cs
index 1da732f0..a08be818 100644
--- a/IOB-WIN-NEXT/IobGeneric.cs
+++ b/IOB-WIN-NEXT/IobGeneric.cs
@@ -3,6 +3,7 @@ using IOB_UT_NEXT;
using MapoSDK;
using MathNet.Numerics.Statistics;
using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections;
@@ -44,8 +45,9 @@ namespace IOB_WIN_NEXT
/// Procedura di import file...
///
///
- protected virtual void importFile(string fileItem)
+ protected virtual bool importFile(string fileItem)
{
+ return false;
}
///
/// Effettua eventuale file import, archiviando file importati
@@ -59,6 +61,12 @@ namespace IOB_WIN_NEXT
// verifico esistenza folders...
if (Directory.Exists(fileImportFolder))
{
+ // verifico archivio
+ string dirArchive = $"{fileImportFolder}/archive";
+ if (!Directory.Exists(dirArchive))
+ {
+ Directory.CreateDirectory(dirArchive);
+ }
// cerco files
var listFiles = Directory.GetFiles(fileImportFolder, fileImportType);
// se li trovo --> chiamo import!
@@ -66,7 +74,40 @@ namespace IOB_WIN_NEXT
{
foreach (var fileItem in listFiles)
{
- importFile(fileItem);
+ string errore = "";
+ answ = importFile(fileItem);
+ if (!answ)
+ {
+ errore = $"Errore in fase di importFile x {fileItem}";
+ }
+ else
+ {
+ // provo forzare send...
+ answ = svuotaCodaRawTransf(true);
+ if (!answ)
+ {
+ errore = $"Errore in fase di invio dati svuotaCodaRawTransf x {fileItem}";
+ }
+ else
+ {
+ // sposto file...
+ File.Move(fileItem, $"{dirArchive}/{Path.GetFileName(fileItem)}");
+ }
+ }
+ // log eventuali errori
+ if (!answ)
+ {
+ string dirError = $"{fileImportFolder}/errors";
+ if (!Directory.Exists(dirError))
+ {
+ Directory.CreateDirectory(dirError);
+ }
+ // sposto file...
+ File.Move(fileItem, $"{dirError}/{Path.GetFileName(fileItem)}");
+ // segno errore!
+ string fileError = $"{fileImportFolder}/errors.log";
+ File.AppendAllText(fileError, errore);
+ }
}
}
}
@@ -941,6 +982,44 @@ namespace IOB_WIN_NEXT
}
}
+ ///
+ /// URL per recupero dati ODL alla data...
+ ///
+ public string urlGetOdlAtDate(DateTime dtRif)
+ {
+ string answ = "";
+ try
+ {
+ answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getOdlAtDate/{cIobConf.codIOB}?dateRif={dtRif:yyyyMMdd}";
+ }
+ catch (Exception exc)
+ {
+ lgError(exc, $"Errore in composizione urlGetOdlAtDate per {dtRif}{Environment.NewLine}{exc}");
+ }
+ return answ;
+ }
+
+
+ ///
+ /// URL per chiamata generazione ODL giornalieri alla data
+ ///
+ public string urlFixDailyOdl
+ {
+ get
+ {
+ string answ = "";
+ try
+ {
+ answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/fixDailyOdl/{cIobConf.codIOB}";
+ }
+ catch (Exception exc)
+ {
+ lgError(exc, "Errore in composizione urlFixDailyOdl");
+ }
+ return answ;
+ }
+ }
+
///
/// URL per recupero PODL correnti x macchina...
///
@@ -1575,7 +1654,17 @@ namespace IOB_WIN_NEXT
* */
// serializzo il valore...
- BaseRawTransf newVal = new BaseRawTransf(DateTime.Now, (Newtonsoft.Json.Linq.JObject)mesContent, mesType);
+ JObject njObj;
+ if (mesType == rawTransfType.IcoelBatch || mesType == rawTransfType.IcoelVarInfo)
+ {
+ njObj = (JObject)mesContent;
+ }
+ else
+ {
+ njObj = (JObject)JToken.FromObject(mesContent);
+ }
+ BaseRawTransf newVal = new BaseRawTransf(DateTime.Now, njObj, mesType);
+
string encodedVal = JsonConvert.SerializeObject(newVal);
// --> accodo (valore già formattato)!
QueueRawTransf.Enqueue(encodedVal);
@@ -2149,6 +2238,15 @@ namespace IOB_WIN_NEXT
}
else
{
+ // anche se NON connesso alcuni task di bassa freq li eseguo...
+ if (ciclo == gatherCycle.LF)
+ {
+ // verifico se devo gestire cambio ODL in modo automatico
+ processAutoOdl();
+ // effettua gestione import file se configurato...
+ processFileImport();
+ }
+
// provo a riconnettere SE abilitato tryRestart...
if (adpTryRestart && !connectionOk)
{
@@ -2460,7 +2558,9 @@ namespace IOB_WIN_NEXT
{
rawResult = rawResult.Substring(0, rawResult.Length - 1);
}
- answ = "{" + $"\"rawTransfData\":[{rawResult}]" + "}";
+ answ = $"[{rawResult}]";
+
+ //answ = "{" + $"\"rawTransfData\":[{rawResult}]" + "}";
break;
@@ -2640,6 +2740,11 @@ namespace IOB_WIN_NEXT
lgInfo($"isRunning: {isRunning} | pzCountResetted: {pzCountResetted} | forceResetInRun: {forceResetInRun} | contapezziIOB: {contapezziIOB} | contapezziPLC: {contapezziPLC}");
}
}
+ else if (CHANGE_ODL_MODE == "DAILY")
+ {
+ // chiamo stored x creare ODL giornalieri alla data...
+ string autoOdlRes = utils.callUrl(urlFixDailyOdl);
+ }
else if (CHANGE_ODL_MODE == "TIME")
{
// carico i parametri di configurazione x reset ODL...
@@ -3437,8 +3542,9 @@ namespace IOB_WIN_NEXT
///
///
///
- public void sendDataBlock(urlType tipoUrl, List listQueueVal)
+ public bool sendDataBlock(urlType tipoUrl, List listQueueVal, bool force = false)
{
+ bool fatto = false;
// init obj display
newDisplayData currDispData = new newDisplayData();
if (listQueueVal != null)
@@ -3455,7 +3561,7 @@ namespace IOB_WIN_NEXT
if (!DemoOut)
{
// SE server alive...
- if (checkServerAlive)
+ if (checkServerAlive || false)
{
// chiamo URL!
string answ = callUrlWithPayload(lastUrl, payload, doAsync);
@@ -3466,6 +3572,7 @@ namespace IOB_WIN_NEXT
// se "OK" verde, altrimenti errore --> ROSSO
if (answ.Contains("OK"))
{
+ fatto = true;
currDispData.semOut = Semaforo.SV;
// se oltre 1 min NON era online --> check pezzi!
if (DateTime.Now.Subtract(lastIobOnline).TotalMinutes > 1 && !isMulti)
@@ -3503,6 +3610,7 @@ namespace IOB_WIN_NEXT
}
}
raiseRefresh(currDispData);
+ return fatto;
}
///
@@ -5720,7 +5828,16 @@ namespace IOB_WIN_NEXT
FileDecod = memMap.fileDecod;
}
}
-
+
+ ///
+ /// Cleanup stringa x impiego tipo ident da char dubbi
+ ///
+ ///
+ ///
+ protected string strFixId(string origData)
+ {
+ return origData.Replace(".", "").Replace(" ", "_");
+ }
///
/// Effettua chiamata MP-IO per tentare chiusura ODL corrente della macchina
@@ -6572,8 +6689,9 @@ namespace IOB_WIN_NEXT
///
/// Processo la coda RawTransf...
///
- private void svuotaCodaRawTransf()
+ private bool svuotaCodaRawTransf(bool force = false)
{
+ bool fatto = false;
// verifico SE la coda abbia dei valori...
if (QueueRawTransf.Count > 0)
{
@@ -6584,9 +6702,9 @@ namespace IOB_WIN_NEXT
if (QueueRawTransf.Count > 0)
{
string currVal = "";
- if (MPOnline)
+ if (MPOnline || force)
{
- if (IobOnline)
+ if (IobOnline || force)
{
List listaValori = new List();
// se ho + di maxJsonData elementi --> invio un set di dati alla volta
@@ -6598,16 +6716,19 @@ namespace IOB_WIN_NEXT
QueueRawTransf.TryDequeue(out currVal);
listaValori.Add(currVal);
}
- sendDataBlock(urlType.RawTransf, listaValori);
+ fatto = sendDataBlock(urlType.RawTransf, listaValori, force);
}
else
{
// invio in blocco
listaValori = QueueRawTransf.ToList();
// invio
- sendDataBlock(urlType.RawTransf, listaValori);
- // svuoto!
- QueueRawTransf = new ConcurrentQueue();
+ fatto = sendDataBlock(urlType.RawTransf, listaValori, force);
+ if (fatto)
+ {
+ // svuoto se ha fatto!
+ QueueRawTransf = new ConcurrentQueue();
+ }
}
}
else
@@ -6626,6 +6747,7 @@ namespace IOB_WIN_NEXT
}
}
}
+ return fatto;
}
///
@@ -6690,7 +6812,7 @@ namespace IOB_WIN_NEXT
///
/// Cerca di inviare su un altro thread i vari dati accumulati...
///
- private void trySendValues()
+ protected void trySendValues()
{
// init obj display
newDisplayData currDispData = new newDisplayData();
diff --git a/IOB-WIN-NEXT/IobModbusTCPCenterfrigo.cs b/IOB-WIN-NEXT/IobModbusTCPCenterfrigo.cs
index 6683db57..659e7f8c 100644
--- a/IOB-WIN-NEXT/IobModbusTCPCenterfrigo.cs
+++ b/IOB-WIN-NEXT/IobModbusTCPCenterfrigo.cs
@@ -1,5 +1,9 @@
-using EasyModbus;
+using IOB_UT_NEXT;
+using MapoSDK;
using System;
+using System.Collections.Generic;
+using System.IO;
+using static MapoSDK.WharehouseData;
namespace IOB_WIN_NEXT
{
@@ -98,6 +102,139 @@ namespace IOB_WIN_NEXT
B_input = byteSignals;
}
+ ///
+ /// Procedura di import file... formato excel Giacovelli
+ ///
+ ///
+ protected override bool importFile(string fileItem)
+ {
+ bool fatto = false;
+ int numErr = 0;
+ // test procedura di import files excel x Giacovelli...
+ var currExcel = new ExcelMan(fileItem);
+ // creo lista dati in formato RegGiacenze...
+ Dictionary listaGiac = new Dictionary();
+ var dtSet = currExcel.getDataSet();
+ if (dtSet != null && dtSet.Tables != null && dtSet.Tables.Count > 0)
+ {
+ string nomeFile = Path.GetFileName(fileItem);
+ nomeFile = nomeFile.Substring(0, nomeFile.LastIndexOf("."));
+ var elSheet = dtSet.Tables;
+ int idxTab = 0;
+ //cerco lo sheet corretto se > 1
+ if (dtSet.Tables.Count > 1)
+ {
+ for (int i = 0; i < dtSet.Tables.Count; i++)
+ {
+ if (nomeFile.Contains(dtSet.Tables[i].TableName))
+ {
+ idxTab = i;
+ }
+ }
+ }
+ var tabella = dtSet.Tables[idxTab];
+ int numRighe = tabella.Rows.Count;
+ int idxODL = 0;
+ DateTime dataDoc = DateTime.Today;
+ DateTime.TryParse(nomeFile, out dataDoc);
+ // cerco lotto x giornata...
+ string sIdxODL = utils.callUrl(urlGetOdlAtDate(dataDoc));
+ int.TryParse(sIdxODL, out idxODL);
+ for (int i = 0; i < numRighe; i++)
+ {
+ if (numErr < 5)
+ {
+ try
+ {
+ // variabili di appoggio...
+ DateTime dtRif = DateTime.Today;
+ double qtyTot = 0;
+ int numPack = 0;
+ string ddt = tabella.Rows[i].ItemArray[FileDecod["ExtDoc"]].ToString().Trim();
+ string prod = tabella.Rows[i].ItemArray[FileDecod["Product"]].ToString().Trim();
+ string variety = tabella.Rows[i].ItemArray[FileDecod["Variety"]].ToString().Trim();
+ string suppl = tabella.Rows[i].ItemArray[FileDecod["Supplier"]].ToString().Trim();
+ string sDate = tabella.Rows[i].ItemArray[FileDecod["DateRif"]].ToString().Trim();
+ string sQty = tabella.Rows[i].ItemArray[FileDecod["QtyTot"]].ToString().Trim();
+ string sNum = tabella.Rows[i].ItemArray[FileDecod["NumPack"]].ToString().Trim();
+ string numPed = tabella.Rows[i].ItemArray[FileDecod["NumPed"]].ToString().Trim();
+ string packPed = tabella.Rows[i].ItemArray[FileDecod["PackPed"]].ToString().Trim();
+ string pesoPack = tabella.Rows[i].ItemArray[FileDecod["PesoPack"]].ToString().Trim();
+ DateTime.TryParse(sDate, out dtRif);
+ int.TryParse(sNum, out numPack);
+ double.TryParse(sQty, out qtyTot);
+ string identRG = ddt.Length > 2 ? $"{strFixId(ddt)}.{strFixId(prod)}.{strFixId(variety)}.{strFixId(suppl)}" : $"{dtRif:yyyyMMdd}.{strFixId(prod)}.{strFixId(variety)}.{strFixId(suppl)}";
+ string notes = $"{numPed}x{packPed}x{pesoPack}";
+ // verifico di avere dati per proseguire...
+ bool checkIdent = !string.IsNullOrEmpty($"{prod}{variety}{suppl}");
+ bool checkHeaderKo = (ddt == "DDT" || prod == "PRODOTTO");
+ if (checkIdent && !checkHeaderKo)
+ {
+ BatchRec newRow = new BatchRec()
+ {
+ IdxODL = idxODL,
+ IdentRG = identRG,
+ DateRif = dtRif,
+ ExtDoc = ddt,
+ Product = prod,
+ Variety = variety,
+ Supplier = suppl,
+ NumPack = numPack,
+ QtyTot = qtyTot,
+ Notes = notes
+ };
+ // verifico: se manca aggiungo
+ if (!listaGiac.ContainsKey(identRG))
+ {
+ listaGiac.Add(identRG, newRow);
+ }
+ else
+ {
+ // altrimenti aggiorno giacenza con valori numerici
+ listaGiac[identRG].NumPack += newRow.NumPack;
+ listaGiac[identRG].QtyTot += newRow.QtyTot;
+ }
+ }
+ else
+ {
+ numErr++;
+ }
+ }
+ catch (Exception exc)
+ {
+ numErr++;
+ }
+ }
+ }
+ }
+ if (listaGiac.Count > 0)
+ {
+ // converto in una nuova lista...
+ int rCounter = 1;
+ Dictionary list2Send = new Dictionary();
+ foreach (var item in listaGiac)
+ {
+ list2Send.Add(rCounter, item.Value);
+ rCounter++;
+ }
+ // ora invio i file con json...
+ accodaRawData(rawTransfType.RegGiacenze, list2Send);
+ fatto = true;
+ }
+ return fatto;
+ }
+
+ ///
+ /// Effettua sync dati
+ ///
+ protected override void processDataSync()
+ {
+ // richiesta check autoODL
+ processAutoOdl();
+ // effettua gestione import file...
+ processFileImport();
+ }
+
#endregion Protected Methods
}
}
\ No newline at end of file
diff --git a/IOB-WIN-NEXT/IobModbusTCPSaim.cs b/IOB-WIN-NEXT/IobModbusTCPSaim.cs
index b98cfdea..02d238a3 100644
--- a/IOB-WIN-NEXT/IobModbusTCPSaim.cs
+++ b/IOB-WIN-NEXT/IobModbusTCPSaim.cs
@@ -1,5 +1,9 @@
-using EasyModbus;
+using IOB_UT_NEXT;
+using MapoSDK;
using System;
+using System.Collections.Generic;
+using System.IO;
+using static MapoSDK.WharehouseData;
namespace IOB_WIN_NEXT
{
@@ -43,7 +47,6 @@ namespace IOB_WIN_NEXT
lgError($"Eccezione in processDynData iniziale x ModBus TCP SAIM:{Environment.NewLine}{exc}");
}
}
-
}
#endregion Public Constructors
@@ -51,23 +54,13 @@ namespace IOB_WIN_NEXT
#region Protected Properties
///
- /// Restituisce status di WORK (auto + lavora), hard coded
+ /// Restituisce controllo IN ALLARME
///
- protected bool WorkState
+ protected bool AlarmState
{
get
{
- return testIntCondition("WorkIntCond");
- }
- }
- ///
- /// Restituisce status di Manuale, hard coded
- ///
- protected bool ManualState
- {
- get
- {
- return testIntCondition("ManualIntCond");
+ return testIntCondition("AlarmIntCond");
}
}
@@ -83,15 +76,16 @@ namespace IOB_WIN_NEXT
}
///
- /// Restituisce controllo IN ALLARME
+ /// Restituisce status di Manuale, hard coded
///
- protected bool AlarmState
+ protected bool ManualState
{
get
{
- return testIntCondition("AlarmIntCond");
+ return testIntCondition("ManualIntCond");
}
}
+
///
/// Restituisce status di LAVORA, hard coded
///
@@ -103,6 +97,17 @@ namespace IOB_WIN_NEXT
}
}
+ ///
+ /// Restituisce status di WORK (auto + lavora), hard coded
+ ///
+ protected bool WorkState
+ {
+ get
+ {
+ return testIntCondition("WorkIntCond");
+ }
+ }
+
#endregion Protected Properties
#region Protected Methods
@@ -169,10 +174,139 @@ namespace IOB_WIN_NEXT
B_input = byteSignals;
}
+ ///
+ /// Procedura di import file... formato excel Giacovelli
+ ///
+ ///
+ protected override bool importFile(string fileItem)
+ {
+ bool fatto = false;
+ int numErr = 0;
+ // test procedura di import files excel x Giacovelli...
+ var currExcel = new ExcelMan(fileItem);
+ // creo lista dati in formato RegGiacenze...
+ Dictionary listaGiac = new Dictionary();
+ var dtSet = currExcel.getDataSet();
+ if (dtSet != null && dtSet.Tables != null && dtSet.Tables.Count > 0)
+ {
+ string nomeFile = Path.GetFileName(fileItem);
+ nomeFile = nomeFile.Substring(0, nomeFile.LastIndexOf("."));
+ var elSheet = dtSet.Tables;
+ int idxTab = 0;
+ //cerco lo sheet corretto se > 1
+ if (dtSet.Tables.Count > 1)
+ {
+ for (int i = 0; i < dtSet.Tables.Count; i++)
+ {
+ if (nomeFile.Contains(dtSet.Tables[i].TableName))
+ {
+ idxTab = i;
+ }
+ }
+ }
+ var tabella = dtSet.Tables[idxTab];
+ int numRighe = tabella.Rows.Count;
+ int idxODL = 0;
+ DateTime dataDoc = DateTime.Today;
+ DateTime.TryParse(nomeFile, out dataDoc);
+ // cerco lotto x giornata...
+ string sIdxODL = utils.callUrl(urlGetOdlAtDate(dataDoc));
+ int.TryParse(sIdxODL, out idxODL);
+ for (int i = 0; i < numRighe; i++)
+ {
+ if (numErr < 5)
+ {
+ try
+ {
+ // variabili di appoggio...
+ DateTime dtRif = DateTime.Today;
+ double qtyTot = 0;
+ int numPack = 0;
+ string ddt = tabella.Rows[i].ItemArray[FileDecod["ExtDoc"]].ToString().Trim();
+ string prod = tabella.Rows[i].ItemArray[FileDecod["Product"]].ToString().Trim();
+ string variety = tabella.Rows[i].ItemArray[FileDecod["Variety"]].ToString().Trim();
+ string suppl = tabella.Rows[i].ItemArray[FileDecod["Supplier"]].ToString().Trim();
+ string sDate = tabella.Rows[i].ItemArray[FileDecod["DateRif"]].ToString().Trim();
+ string sQty = tabella.Rows[i].ItemArray[FileDecod["QtyTot"]].ToString().Trim();
+ string sNum = tabella.Rows[i].ItemArray[FileDecod["NumPack"]].ToString().Trim();
+ string numPed = tabella.Rows[i].ItemArray[FileDecod["NumPed"]].ToString().Trim();
+ string packPed = tabella.Rows[i].ItemArray[FileDecod["PackPed"]].ToString().Trim();
+ string pesoPack = tabella.Rows[i].ItemArray[FileDecod["PesoPack"]].ToString().Trim();
+ DateTime.TryParse(sDate, out dtRif);
+ int.TryParse(sNum, out numPack);
+ double.TryParse(sQty, out qtyTot);
+ string identRG = ddt.Length > 2 ? $"{strFixId(ddt)}.{strFixId(prod)}.{strFixId(variety)}.{strFixId(suppl)}" : $"{dtRif:yyyyMMdd}.{strFixId(prod)}.{strFixId(variety)}.{strFixId(suppl)}";
+ string notes = $"{numPed}x{packPed}x{pesoPack}";
+ // verifico di avere dati per proseguire...
+ bool checkIdent = !string.IsNullOrEmpty($"{prod}{variety}{suppl}");
+ bool checkHeaderKo = (ddt == "DDT" || prod == "PRODOTTO");
+ if (checkIdent && !checkHeaderKo)
+ {
+ BatchRec newRow = new BatchRec()
+ {
+ IdxODL = idxODL,
+ IdentRG = identRG,
+ DateRif = dtRif,
+ ExtDoc = ddt,
+ Product = prod,
+ Variety = variety,
+ Supplier = suppl,
+ NumPack = numPack,
+ QtyTot = qtyTot,
+ Notes = notes
+ };
+ // verifico: se manca aggiungo
+ if (!listaGiac.ContainsKey(identRG))
+ {
+ listaGiac.Add(identRG, newRow);
+ }
+ else
+ {
+ // altrimenti aggiorno giacenza con valori numerici
+ listaGiac[identRG].NumPack += newRow.NumPack;
+ listaGiac[identRG].QtyTot += newRow.QtyTot;
+ }
+ }
+ else
+ {
+ numErr++;
+ }
+ }
+ catch (Exception exc)
+ {
+ numErr++;
+ }
+ }
+ }
+ }
+ if (listaGiac.Count > 0)
+ {
+ // converto in una nuova lista...
+ int rCounter = 1;
+ Dictionary list2Send = new Dictionary();
+ foreach (var item in listaGiac)
+ {
+ list2Send.Add(rCounter, item.Value);
+ rCounter++;
+ }
+ // ora invio i file con json...
+ accodaRawData(rawTransfType.RegGiacenze, list2Send);
+ fatto = true;
+ }
+ return fatto;
+ }
+
+ ///
+ /// Effettua sync dati
+ ///
+ protected override void processDataSync()
+ {
+ // richiesta check autoODL
+ processAutoOdl();
+ // effettua gestione import file...
+ processFileImport();
+ }
+
#endregion Protected Methods
-
- #region Private Methods
-
- #endregion Private Methods
}
}
\ No newline at end of file
diff --git a/IOB-WIN-NEXT/IobSimula.cs b/IOB-WIN-NEXT/IobSimula.cs
index 1eb6d18d..7e64f427 100644
--- a/IOB-WIN-NEXT/IobSimula.cs
+++ b/IOB-WIN-NEXT/IobSimula.cs
@@ -3,6 +3,7 @@ using MapoSDK;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using static IOB_UT_NEXT.CustomObj;
using static MapoSDK.WharehouseData;
@@ -519,65 +520,122 @@ namespace IOB_WIN_NEXT
/// Procedura di import file... formato excel Giacovelli
///
///
- protected override void importFile(string fileItem)
+ protected override bool importFile(string fileItem)
{
+ bool fatto = false;
+ int numErr = 0;
// test procedura di import files excel x Giacovelli...
var currExcel = new ExcelMan(fileItem);
-
// creo lista dati in formato RegGiacenze...
Dictionary listaGiac = new Dictionary();
-
var dtSet = currExcel.getDataSet();
-
if (dtSet != null && dtSet.Tables != null && dtSet.Tables.Count > 0)
{
- var tabella = dtSet.Tables[0];
+ string nomeFile = Path.GetFileName(fileItem);
+ nomeFile = nomeFile.Substring(0, nomeFile.LastIndexOf("."));
+ var elSheet = dtSet.Tables;
+ int idxTab = 0;
+ //cerco lo sheet corretto se > 1
+ if (dtSet.Tables.Count > 1)
+ {
+ for (int i = 0; i < dtSet.Tables.Count; i++)
+ {
+ if (nomeFile.Contains(dtSet.Tables[i].TableName))
+ {
+ idxTab = i;
+ }
+ }
+ }
+ var tabella = dtSet.Tables[idxTab];
int numRighe = tabella.Rows.Count;
+ int idxODL = 0;
+ DateTime dataDoc = DateTime.Today;
+ DateTime.TryParse(nomeFile, out dataDoc);
+ // cerco lotto x giornata...
+ string sIdxODL = utils.callUrl(urlGetOdlAtDate(dataDoc));
+ int.TryParse(sIdxODL, out idxODL);
for (int i = 0; i < numRighe; i++)
{
- // variabili di appoggio...
- DateTime dtRif = DateTime.Today;
- double qtyTot = 0;
- int numPack = 0;
- string ddt = tabella.Rows[i].ItemArray[FileDecod["ExtDoc"]].ToString();
- string prod = tabella.Rows[i].ItemArray[FileDecod["Product"]].ToString();
- string variety = tabella.Rows[i].ItemArray[FileDecod["Variety"]].ToString();
- string suppl = tabella.Rows[i].ItemArray[FileDecod["Supplier"]].ToString();
- string sDate = tabella.Rows[i].ItemArray[FileDecod["DateRif"]].ToString();
- string sQty = tabella.Rows[i].ItemArray[FileDecod["QtyTot"]].ToString();
- string sNum = tabella.Rows[i].ItemArray[FileDecod["NumPack"]].ToString();
- DateTime.TryParse(sDate, out dtRif);
- int.TryParse(sNum, out numPack);
- double.TryParse(sQty, out qtyTot);
- BatchRec newRow = new BatchRec()
+ if (numErr < 5)
{
- DateRif = dtRif,
- ExtDoc = ddt,
- Ident = $"{ddt}.{prod}.{variety}.{suppl}",
- Product = prod,
- Supplier = suppl,
- Variety = variety,
- NumPack = numPack,
- QtyTot = qtyTot
- };
- //newRow.Product = tabella.Rows[i].ItemArray[FileDecod["Product"]].ToString();
- //newRow.ExtDoc = tabella.Rows[i].ItemArray[FileDecod["ExtDoc"]].ToString();
- // verifico: se manca aggiungo
- if (!listaGiac.ContainsKey(newRow.Ident))
- {
- listaGiac.Add(newRow.Ident, newRow);
+ try
+ {
+ // variabili di appoggio...
+ DateTime dtRif = DateTime.Today;
+ double qtyTot = 0;
+ int numPack = 0;
+ string ddt = tabella.Rows[i].ItemArray[FileDecod["ExtDoc"]].ToString().Trim();
+ string prod = tabella.Rows[i].ItemArray[FileDecod["Product"]].ToString().Trim();
+ string variety = tabella.Rows[i].ItemArray[FileDecod["Variety"]].ToString().Trim();
+ string suppl = tabella.Rows[i].ItemArray[FileDecod["Supplier"]].ToString().Trim();
+ string sDate = tabella.Rows[i].ItemArray[FileDecod["DateRif"]].ToString().Trim();
+ string sQty = tabella.Rows[i].ItemArray[FileDecod["QtyTot"]].ToString().Trim();
+ string sNum = tabella.Rows[i].ItemArray[FileDecod["NumPack"]].ToString().Trim();
+ string numPed = tabella.Rows[i].ItemArray[FileDecod["NumPed"]].ToString().Trim();
+ string packPed = tabella.Rows[i].ItemArray[FileDecod["PackPed"]].ToString().Trim();
+ string pesoPack = tabella.Rows[i].ItemArray[FileDecod["PesoPack"]].ToString().Trim();
+ DateTime.TryParse(sDate, out dtRif);
+ int.TryParse(sNum, out numPack);
+ double.TryParse(sQty, out qtyTot);
+ string identRG = ddt.Length > 2 ? $"{strFixId(ddt)}.{strFixId(prod)}.{strFixId(variety)}.{strFixId(suppl)}" : $"{dtRif:yyyyMMdd}.{strFixId(prod)}.{strFixId(variety)}.{strFixId(suppl)}";
+ string notes = $"{numPed}x{packPed}x{pesoPack}";
+ // verifico di avere dati per proseguire...
+ bool checkIdent = !string.IsNullOrEmpty($"{prod}{variety}{suppl}");
+ bool checkHeaderKo = (ddt == "DDT" || prod == "PRODOTTO");
+ if (checkIdent && !checkHeaderKo)
+ {
+ BatchRec newRow = new BatchRec()
+ {
+ IdxODL = idxODL,
+ IdentRG = identRG,
+ DateRif = dtRif,
+ ExtDoc = ddt,
+ Product = prod,
+ Variety = variety,
+ Supplier = suppl,
+ NumPack = numPack,
+ QtyTot = qtyTot,
+ Notes = notes
+ };
+ // verifico: se manca aggiungo
+ if (!listaGiac.ContainsKey(identRG))
+ {
+ listaGiac.Add(identRG, newRow);
+ }
+ else
+ {
+ // altrimenti aggiorno giacenza con valori numerici
+ listaGiac[identRG].NumPack += newRow.NumPack;
+ listaGiac[identRG].QtyTot += newRow.QtyTot;
+ }
+ }
+ else
+ {
+ numErr++;
+ }
+ }
+ catch (Exception exc)
+ {
+ numErr++;
+ }
}
- else
- {
- // altrimenti aggiorno giacenza con valori numerici
- listaGiac[newRow.Ident].NumPack += newRow.NumPack;
- listaGiac[newRow.Ident].QtyTot += newRow.QtyTot;
- }
-
}
}
- // ora invio i file con json...
-
+ if (listaGiac.Count > 0)
+ {
+ // converto in una nuova lista...
+ int rCounter = 1;
+ Dictionary list2Send = new Dictionary();
+ foreach (var item in listaGiac)
+ {
+ list2Send.Add(rCounter, item.Value);
+ rCounter++;
+ }
+ // ora invio i file con json...
+ accodaRawData(rawTransfType.RegGiacenze, list2Send);
+ fatto = true;
+ }
+ return fatto;
}
///
@@ -760,6 +818,11 @@ namespace IOB_WIN_NEXT
var taskGet = iobGetDataFromServer();
var taskWrite = iobWriteLocalCSV();
var taskSend = iobSendFTP("");
+
+ // richiesta check autoODL
+ processAutoOdl();
+ // effettua gestione import file...
+ processFileImport();
}
///
diff --git a/IOB-WIN-NEXT/packages.config b/IOB-WIN-NEXT/packages.config
index fa2f6e02..94c44ac8 100644
--- a/IOB-WIN-NEXT/packages.config
+++ b/IOB-WIN-NEXT/packages.config
@@ -8,7 +8,7 @@
-
+