tentativo gestione rilettura status con file locked
This commit is contained in:
+45
-37
@@ -609,6 +609,7 @@ namespace IOB_WIN
|
||||
// leggo il file dela produzione HARD CODED...
|
||||
var sessStatus = confE63.ActiveSessions[4];
|
||||
string currStatus = "00000";
|
||||
bool readDone = false;
|
||||
DateTime adesso = DateTime.Now;
|
||||
if (sessStatus != null)
|
||||
{
|
||||
@@ -618,52 +619,49 @@ namespace IOB_WIN
|
||||
string fileName = $"{BaseDir}\\{sessStatus.SessionName}.DAT";
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
#if false
|
||||
// leggo il file...
|
||||
string[] rawLines = File.ReadAllLines(fileName);
|
||||
int numRow = rawLines.Length;
|
||||
#endif
|
||||
|
||||
string rawData = "";
|
||||
using (var fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
using (var textReader = new StreamReader(fileStream))
|
||||
{
|
||||
rawData = textReader.ReadToEnd();
|
||||
}
|
||||
// ora splitto in linee
|
||||
string[] rawLines = Regex.Split(rawData, "\r\n|\r|\n");
|
||||
int numRow = rawLines.Length;
|
||||
|
||||
// devo avere almeno 2 righe...
|
||||
if (numRow >= 2)
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
string[] statusData = rawLines[1].Split(',');
|
||||
currStatus = statusData[2].Trim();
|
||||
if (!string.IsNullOrEmpty(currStatus))
|
||||
{
|
||||
currDispData.semIn = Semaforo.SV;
|
||||
}
|
||||
// ora splitto in linee
|
||||
string[] rawLines = Regex.Split(rawData, "\r\n|\r|\n");
|
||||
int numRow = rawLines.Length;
|
||||
|
||||
// salvo in cache!
|
||||
Last_CurrStatus.Value = currStatus;
|
||||
Last_CurrStatus.ValidUntil = DateTime.Now.AddSeconds(15);
|
||||
// devo avere almeno 2 righe...
|
||||
if (numRow >= 2)
|
||||
{
|
||||
string[] statusData = rawLines[1].Split(',');
|
||||
currStatus = statusData[2].Trim();
|
||||
if (!string.IsNullOrEmpty(currStatus))
|
||||
{
|
||||
currDispData.semIn = Semaforo.SV;
|
||||
}
|
||||
readDone = true;
|
||||
// salvo in cache!
|
||||
Last_CurrStatus.Value = currStatus;
|
||||
Last_CurrStatus.ValidUntil = DateTime.Now.AddSeconds(15);
|
||||
|
||||
// ora verifico SE siano validi anche le dataora dei valori letti (< 20 sec ritardo da ora...)
|
||||
string data = statusData[0].Trim();
|
||||
string ora = statusData[1].Trim();
|
||||
DateTime lastPub = adesso.AddMinutes(-1);
|
||||
CultureInfo provider = CultureInfo.InvariantCulture;
|
||||
try
|
||||
{
|
||||
lastPub = DateTime.ParseExact($"{data} {ora}", "yyyyMMdd HH:mm:ss", provider);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
if (Math.Abs(lastPub.Subtract(adesso).TotalSeconds) > maxDelaySec)
|
||||
{
|
||||
sessStatus.SessionValidUntil = adesso;
|
||||
// elimino file RSP...
|
||||
cleanupResp(sessStatus.SessionName);
|
||||
// ora verifico SE siano validi anche le dataora dei valori letti (< 20 sec ritardo da ora...)
|
||||
string data = statusData[0].Trim();
|
||||
string ora = statusData[1].Trim();
|
||||
DateTime lastPub = adesso.AddMinutes(-1);
|
||||
CultureInfo provider = CultureInfo.InvariantCulture;
|
||||
try
|
||||
{
|
||||
lastPub = DateTime.ParseExact($"{data} {ora}", "yyyyMMdd HH:mm:ss", provider);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
if (Math.Abs(lastPub.Subtract(adesso).TotalSeconds) > maxDelaySec)
|
||||
{
|
||||
sessStatus.SessionValidUntil = adesso;
|
||||
// elimino file RSP...
|
||||
cleanupResp(sessStatus.SessionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -678,6 +676,16 @@ namespace IOB_WIN
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!readDone)
|
||||
{
|
||||
// se valido RILEGGO ultimo curr status
|
||||
if (Last_CurrStatus.ValidUntil > adesso)
|
||||
{
|
||||
currStatus = Last_CurrStatus.Value;
|
||||
}
|
||||
}
|
||||
|
||||
// processo il currentStatus... parto da poweron
|
||||
B_input = currStatus[0] == '1' ? 0 : 1;
|
||||
// ora MODE
|
||||
|
||||
Vendored
+1
-1
@@ -9,7 +9,7 @@ pipeline {
|
||||
steps {
|
||||
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
|
||||
script {
|
||||
withEnv(['NEXT_BUILD_NUMBER=714']) {
|
||||
withEnv(['NEXT_BUILD_NUMBER=715']) {
|
||||
// env.versionNumber = VersionNumber(versionNumberString : '3.3.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
|
||||
env.versionNumber = VersionNumber(versionNumberString : '3.3.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
|
||||
env.APP_NAME = 'MAPO-IOB-WIN'
|
||||
|
||||
@@ -11,6 +11,8 @@ git push . %baseBranch%:IOB/MTC
|
||||
git push . %baseBranch%:IobMan
|
||||
git push . %baseBranch%:master
|
||||
|
||||
REM Faccio SEMPRE push remoto di branch di partenza
|
||||
git push gitlab.steamware %baseBranch%:%baseBranch%
|
||||
|
||||
if "%pushRemote%" == "y" ( git push gitlab.steamware %baseBranch%:develop )
|
||||
if "%pushRemote%" == "y" ( git push gitlab.steamware %baseBranch%:IOB-NET )
|
||||
|
||||
Reference in New Issue
Block a user