PODL x FIMAT:
- Bozza metodi x inviare dati avvio/chiusura PODL (DA TESTARE!!!)
This commit is contained in:
+77
-19
@@ -2136,7 +2136,7 @@ namespace IOB_WIN_NEXT
|
||||
// effettua gestione import file se configurato...
|
||||
processFileImport();
|
||||
// effettua process ritorno ricette
|
||||
processRicetteFileRitorno();
|
||||
processRecipeFileRet();
|
||||
}
|
||||
else if (ciclo == gatherCycle.VLF)
|
||||
{
|
||||
@@ -2216,7 +2216,7 @@ namespace IOB_WIN_NEXT
|
||||
// effettua gestione import file se configurato...
|
||||
processFileImport();
|
||||
// effettua process ritorno ricette
|
||||
processRicetteFileRitorno();
|
||||
processRecipeFileRet();
|
||||
}
|
||||
|
||||
// provo a riconnettere SE abilitato tryRestart...
|
||||
@@ -5952,23 +5952,24 @@ namespace IOB_WIN_NEXT
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected virtual bool processRicetteFileRitorno()
|
||||
protected virtual bool processRecipeFileRet()
|
||||
{
|
||||
bool answ = false;
|
||||
// test file import da conf... se hasRecipe=true --> modalità tenditalia...
|
||||
if (hasRecipe)
|
||||
{
|
||||
// recupera i NUOVI file e li sposta in folder locale temp
|
||||
string remoPath = Path.Combine(pathList["path-locBase"], pathList["path-04-remR"]);
|
||||
string tempPath = Path.Combine(pathList["path-locBase"], pathList["path-03-Recv"], "TEMP");
|
||||
string remoPath = Path.Combine(pathList["path-locBase"], pathList["path-05-remR"]);
|
||||
string archBasePath = Path.Combine(pathList["path-locBase"], pathList["path-03-Recv"]);
|
||||
string tempPath = Path.Combine(archBasePath, "TEMP");
|
||||
baseUtils.checkDir(tempPath);
|
||||
bool okRetrieve = RecipeTaskDoneRetrieve(remoPath, tempPath);
|
||||
|
||||
// ora cerca nella folder locale e processa i files...
|
||||
bool okCheck = RecipeDoCheckFileProc(tempPath);
|
||||
bool okCheck = RecipeDoCheckFileProc(tempPath, archBasePath);
|
||||
|
||||
// verifica se sia da creare/inviare il record settimanale di consumo
|
||||
bool okSent = RecipeDoProcCons("W");
|
||||
bool okSent = RecipeDoProcCons(archBasePath, "W");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -5994,8 +5995,9 @@ namespace IOB_WIN_NEXT
|
||||
/// - accumulo consumo materiali
|
||||
/// </summary>
|
||||
/// <param name="localPath"></param>
|
||||
/// <param name="archBasePath"></param>
|
||||
/// <returns></returns>
|
||||
protected virtual bool RecipeDoCheckFileProc(string localPath)
|
||||
protected virtual bool RecipeDoCheckFileProc(string localPath, string archBasePath)
|
||||
{
|
||||
bool answ = false;
|
||||
int week = 0;
|
||||
@@ -6006,18 +6008,73 @@ namespace IOB_WIN_NEXT
|
||||
var fileList = Directory.GetFiles(localPath);
|
||||
if (fileList != null && fileList.Count() > 0)
|
||||
{
|
||||
// FIXME TODO !!! per ogni file ricevuto controlla se sia corrispondente ad un file
|
||||
// inviato (cerca PODL)
|
||||
foreach (var recipeFile in fileList)
|
||||
{
|
||||
// init var
|
||||
string rawVal = "";
|
||||
int idxPOdl = 0;
|
||||
// leggo ricetta
|
||||
var rawData = File.ReadAllLines(recipeFile);
|
||||
|
||||
// se trova PODL prova ad avviare/chiudere PODL relativo (eventualmente duplicandolo)
|
||||
// per ogni file ricevuto controlla se viene dal MES (cerca <Variant>PODL)
|
||||
string tokenSearch = "<Variant>PODL";
|
||||
// recupero riga PODL...
|
||||
var rowPodl = rawData.Where(x => x.Contains(tokenSearch)).FirstOrDefault();
|
||||
if (rowPodl != null)
|
||||
{
|
||||
DateTime dtStartPOdl = DateTime.Today;
|
||||
int duration = 0;
|
||||
DateTime dtEndPOdl = DateTime.Today.AddMinutes(10);
|
||||
string dtEve = "";
|
||||
string dtCurr = "";
|
||||
|
||||
// registra COMUNQUE ogni record di consumo materiale
|
||||
bool okSync = RecipeDoSyncRecipe("");
|
||||
// inizio ricerca PODL
|
||||
rawVal = rowPodl.Trim().Replace(tokenSearch, "").Replace("</Variant>", "");
|
||||
int.TryParse(rawVal, out idxPOdl);
|
||||
if (idxPOdl > 0)
|
||||
{
|
||||
// leggo inizio commessa
|
||||
tokenSearch = "<Date>";
|
||||
var rowStart = rawData.Where(x => x.Contains(tokenSearch)).FirstOrDefault();
|
||||
if (rowStart != null)
|
||||
{
|
||||
rawVal = rowPodl.Trim().Replace(tokenSearch, "").Replace("</Date>", "");
|
||||
DateTime.TryParse(rawVal, out dtStartPOdl);
|
||||
}
|
||||
|
||||
// archivio file in area settimanale corrispondente
|
||||
week = cal.GetWeekOfYear(adesso, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
|
||||
archPath = Path.Combine(pathList["path-locBase"], pathList["path-03-Recv"], $"{adesso:yyyy}", $"{week:00}");
|
||||
baseUtils.checkDir(archPath);
|
||||
// leggo durata commessa
|
||||
tokenSearch = "<DosDuration>";
|
||||
var rowDurSec = rawData.Where(x => x.Contains(tokenSearch)).FirstOrDefault();
|
||||
if (rowStart != null)
|
||||
{
|
||||
rawVal = rowPodl.Trim().Replace(tokenSearch, "").Replace("</DosDuration>", "");
|
||||
int.TryParse(rawVal, out duration);
|
||||
dtEndPOdl = dtStartPOdl.AddSeconds(duration);
|
||||
}
|
||||
|
||||
// prova ad avviare/chiudere PODL relativo (eventualmente duplicandolo)
|
||||
dtEve = $"{dtStartPOdl:yyyyMMddHHmmss}";
|
||||
dtCurr = $"{DateTime.Now:yyyyMMddHHmmss}";
|
||||
callUrl($"{urlOLDStartFromPODL}{idxPOdl}&dtEve={dtEve}&dtCurr={dtCurr}", false);
|
||||
|
||||
// ora chiamo chiusura...
|
||||
dtEve = $"{dtEndPOdl:yyyyMMddHHmmss}";
|
||||
dtCurr = $"{DateTime.Now:yyyyMMddHHmmss}";
|
||||
callUrl($"{urlPODLClose}{idxPOdl}&dtEve={dtEve}&dtCurr={dtCurr}", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// registra COMUNQUE ogni record di consumo materiale
|
||||
bool okSync = RecipeDoSyncRecipe("");
|
||||
|
||||
// archivio file in area settimanale corrispondente
|
||||
//week = cal.GetWeekOfYear(adesso, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
|
||||
//archPath = Path.Combine(archBasePath, $"{adesso:yyyy}", $"{week:00}");
|
||||
//baseUtils.checkDir(archPath);
|
||||
|
||||
// archivio file processato...
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -6025,9 +6082,10 @@ namespace IOB_WIN_NEXT
|
||||
/// <summary>
|
||||
/// Verifica se si debba registrare/inviare il report periodico di consumo indicato
|
||||
/// </summary>
|
||||
/// <param name="archBasePath"></param>
|
||||
/// <param name="repType">Report di consumo: D/W/M (day, week, month...)</param>
|
||||
/// <returns></returns>
|
||||
protected bool RecipeDoProcCons(string repType)
|
||||
protected bool RecipeDoProcCons(string archBasePath, string repType)
|
||||
{
|
||||
bool answ = false;
|
||||
|
||||
@@ -6228,7 +6286,7 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
bool fatto = false;
|
||||
// recupero elenco files...
|
||||
var fileList = Directory.GetFiles(localPath);
|
||||
var fileList = Directory.GetFiles(remotePath);
|
||||
string destName = "";
|
||||
if (fileList != null && fileList.Count() > 0)
|
||||
{
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace IOB_WIN_NEXT
|
||||
if (hasRecipe)
|
||||
{
|
||||
// effettua process ritorno ricette
|
||||
processRicetteFileRitorno();
|
||||
processRecipeFileRet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -724,7 +724,7 @@ namespace IOB_WIN_NEXT
|
||||
// effettua gestione import file...
|
||||
processFileImport();
|
||||
// effettua process ritorno ricette
|
||||
processRicetteFileRitorno();
|
||||
processRecipeFileRet();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user