update comportamento x mantenere ordinato elenco IOB

This commit is contained in:
Samuele E. Locatelli
2020-03-07 11:10:35 +01:00
parent dc83900b36
commit 0359ac1735
3 changed files with 27 additions and 20 deletions
Binary file not shown.
+26 -19
View File
@@ -2,6 +2,7 @@ using Newtonsoft.Json;
using SteamWare.Logger;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
using System.Drawing;
@@ -200,7 +201,6 @@ namespace IOB_MAN
private void ElencoIOB_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
{
//updateStatus();
}
private void ElencoIOB_AddingNew(object sender, System.ComponentModel.AddingNewEventArgs e)
@@ -274,7 +274,8 @@ namespace IOB_MAN
/// Avvio di un child process da parametro ARG
/// </summary>
/// <param name="procArg"></param>
private void startChildProc(string procArg)
/// <param name="indice"></param>
private void startChildProc(string procArg, int indice = -1)
{
ProcessStartInfo psi = null;
// da testare x aprire chiudere risorsa...
@@ -296,9 +297,15 @@ namespace IOB_MAN
newIob.startTime = adesso;
newIob.pID = p.Id;
newIob.isRunning = true;
// aggiungo a datasource
ElencoIOB.Add(newIob);
// aggiungo a datasource, se indice -1 aggiungendo e basta, altrimenti alla posizione richiesta...
if (indice == -1)
{
ElencoIOB.Add(newIob);
}
else
{
ElencoIOB.Insert(indice, newIob);
}
utils.lgInfo($"Avviato child process per {procArg} | pid: {p.Id}");
}
@@ -449,21 +456,23 @@ namespace IOB_MAN
private void processAutoRestart()
{
// verifico se ci siano processi (da ARGS LIST) NON running --> li riavvio!
List<iobAdapt> proc2restart = new List<iobAdapt>();
List<iobAdapt> proc2close = new List<iobAdapt>();
Dictionary<int, iobAdapt> proc2restart = new Dictionary<int, iobAdapt>();
Dictionary<int, iobAdapt> proc2close = new Dictionary<int, iobAdapt>();
int indice = 0;
foreach (iobAdapt item in ElencoIOB.List)
{
// se NON comunica da troppo (ultima comunicazione è > 5 minuti fa...)
if (!item.plcOk)
{
proc2close.Add(item);
proc2close.Add(indice, item);
}
// se NON E' running
if (!item.isRunning)
{
// segno da eliminare e riavviare
proc2restart.Add(item);
proc2restart.Add(indice, item);
}
indice++;
}
// SE abilitato autorestart...
@@ -473,26 +482,26 @@ namespace IOB_MAN
foreach (var item in proc2close)
{
ElencoIOB.Remove(item);
utils.lgInfo($"Chiusura processo non in PLC-Online | IOB: {item.CodIOB} | pid: {item.pID}");
utils.lgInfo($"Chiusura processo non in PLC-Online | IOB: {item.Value.CodIOB} | pid: {item.Value.pID}");
// chiudo!
closeSingleChild(item);
closeSingleChild(item.Value);
}
foreach (var item in proc2close)
{
// riavvio!
startChildProc(item.CodIOB);
startChildProc(item.Value.CodIOB, item.Key);
}
// se ho da riavviare... elimino!
foreach (var item in proc2restart)
foreach (var dictVal in proc2restart)
{
ElencoIOB.Remove(item);
utils.lgInfo($"Chiusura processo non in running | IOB: {item.CodIOB} | pid: {item.pID}");
ElencoIOB.Remove(dictVal.Value);
utils.lgInfo($"Chiusura processo non in running | IOB: {dictVal.Value.CodIOB} | pid: {dictVal.Value.pID}");
}
// li faccio ripartire!
foreach (var item in proc2restart)
{
startChildProc(item.CodIOB);
startChildProc(item.Value.CodIOB, item.Key);
}
// update!
@@ -743,8 +752,6 @@ namespace IOB_MAN
int pid = -1;
if (e.RowIndex >= 0)
{
//dgvManagedItems.CurrentCell = dgvManagedItems.Rows[e.RowIndex].Cells[0];
dgvManagedItems.Rows[e.RowIndex].Selected = true;
using (var riga = dgvManagedItems.Rows[e.RowIndex])
{
@@ -1078,7 +1085,7 @@ namespace IOB_MAN
// verifico che sia già chiuso...
if (((iobAdapt)ElencoIOB[riga.Index]).isRunning == false)
{
startChildProc(((iobAdapt)ElencoIOB[riga.Index]).CodIOB);
startChildProc(((iobAdapt)ElencoIOB[riga.Index]).CodIOB, riga.Index);
// rimuovo vecchia riga...
ElencoIOB.RemoveAt(riga.Index);
}
Vendored
+1 -1
View File
@@ -9,7 +9,7 @@ pipeline {
steps {
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
withEnv(['NEXT_BUILD_NUMBER=687']) {
withEnv(['NEXT_BUILD_NUMBER=688']) {
// env.versionNumber = VersionNumber(versionNumberString : '3.0.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
env.versionNumber = VersionNumber(versionNumberString : '3.0.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
env.APP_NAME = 'MAPO-IOB-WIN'