update comportamento IOB-MAN
This commit is contained in:
+96
-54
@@ -44,6 +44,11 @@ namespace IOB_MAN
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// elenco item da rimuovere x check andato male...
|
||||
/// </summary>
|
||||
protected static List<iobAdapt> item2rem = new List<iobAdapt>();
|
||||
|
||||
/// <summary>
|
||||
/// Ramo applicazione (x update)
|
||||
/// </summary>
|
||||
@@ -64,6 +69,21 @@ namespace IOB_MAN
|
||||
/// </summary>
|
||||
protected int forceCheckPeriod = 60000;
|
||||
|
||||
/// <summary>
|
||||
/// Indica ultimo stato del check di restart...
|
||||
/// </summary>
|
||||
protected bool lastHlRestart = false;
|
||||
|
||||
/// <summary>
|
||||
/// Totale processi avviati - ULTIMO dato mostrato
|
||||
/// </summary>
|
||||
protected int lastNumProcAvviati = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Totale processi running - ULTIMO dato mostrato
|
||||
/// </summary>
|
||||
protected int lastNumProcRunning = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Totale processi avviati
|
||||
/// </summary>
|
||||
@@ -92,7 +112,7 @@ namespace IOB_MAN
|
||||
/// <summary>
|
||||
/// Counter del timer UI
|
||||
/// </summary>
|
||||
protected int uiPeriod = 200;
|
||||
protected int uiPeriod = 250;
|
||||
|
||||
/// <summary>
|
||||
/// Ms di attesa x uscita processo (std)
|
||||
@@ -328,38 +348,46 @@ namespace IOB_MAN
|
||||
btnClose.Enabled = selected;
|
||||
}
|
||||
|
||||
private bool checkIstance(iobAdapt item, List<iobAdapt> item2rem, Process[] processList)
|
||||
private bool checkIstance(iobAdapt item, Process[] processList)
|
||||
{
|
||||
bool needRem;
|
||||
// verifico se esista il processo...
|
||||
try
|
||||
{
|
||||
if (processList.Length > 0)
|
||||
{
|
||||
Process p = myGetProcByID(processList, item.pID);
|
||||
needRem = p.HasExited;
|
||||
}
|
||||
else
|
||||
{
|
||||
needRem = true;
|
||||
}
|
||||
}
|
||||
catch
|
||||
// verifico se non sia già stato segnato x rimozione...)
|
||||
if (item2rem.Find(x => x.pID == item.pID) != null)
|
||||
{
|
||||
needRem = true;
|
||||
}
|
||||
if (needRem)
|
||||
{
|
||||
if (!item2rem.Contains(item))
|
||||
{
|
||||
item2rem.Add(item);
|
||||
}
|
||||
item.isRunning = false;
|
||||
numProcRunning--;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.isRunning = true;
|
||||
// verifico se esista il processo...
|
||||
try
|
||||
{
|
||||
if (processList.Length > 0)
|
||||
{
|
||||
Process p = myGetProcByID(processList, item.pID);
|
||||
needRem = p.HasExited;
|
||||
}
|
||||
else
|
||||
{
|
||||
needRem = true;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
needRem = true;
|
||||
}
|
||||
if (needRem)
|
||||
{
|
||||
if (!item2rem.Contains(item))
|
||||
{
|
||||
item2rem.Add(item);
|
||||
}
|
||||
item.isRunning = false;
|
||||
numProcRunning--;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.isRunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
return needRem;
|
||||
@@ -402,11 +430,12 @@ namespace IOB_MAN
|
||||
/// </summary>
|
||||
private void checkRunningchild()
|
||||
{
|
||||
List<iobAdapt> item2rem = new List<iobAdapt>();
|
||||
IList<iobAdapt> allItems = (IList<iobAdapt>)ElencoIOB.List;
|
||||
bool needRem = false;
|
||||
|
||||
#if false
|
||||
numProcRunning = numProcAvviati;
|
||||
#endif
|
||||
|
||||
// 2020.02.01 passato chiamata specifica x leggere in 1 sola volta TUTTO elenco processi (x nome)...
|
||||
Process[] processList = Process.GetProcessesByName(TargetName);
|
||||
@@ -414,7 +443,7 @@ namespace IOB_MAN
|
||||
// ciclo
|
||||
Parallel.ForEach(allItems, item =>
|
||||
{
|
||||
needRem = checkIstance(item, item2rem, processList);
|
||||
needRem = checkIstance(item, processList);
|
||||
}
|
||||
);
|
||||
// aggiorno datagrid!
|
||||
@@ -477,8 +506,7 @@ namespace IOB_MAN
|
||||
/// <param name="doReset">resetta elenco</param>
|
||||
private void closeAllChild(bool doReset)
|
||||
{
|
||||
List<iobAdapt> item2rem = new List<iobAdapt>();
|
||||
|
||||
item2rem.Clear();
|
||||
foreach (iobAdapt item in ElencoIOB.List)
|
||||
{
|
||||
item2rem.Add(item);
|
||||
@@ -529,6 +557,8 @@ namespace IOB_MAN
|
||||
ElencoIOB.Clear();
|
||||
numProcAvviati = 0;
|
||||
}
|
||||
// resetto
|
||||
item2rem.Clear();
|
||||
numProcRunning = 0;
|
||||
// update!
|
||||
updateStatus();
|
||||
@@ -692,7 +722,7 @@ namespace IOB_MAN
|
||||
|
||||
private void ElencoIOB_AddingNew(object sender, System.ComponentModel.AddingNewEventArgs e)
|
||||
{
|
||||
updateStatus();
|
||||
//updateStatus();
|
||||
}
|
||||
|
||||
private void ElencoIOB_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
|
||||
@@ -908,7 +938,7 @@ namespace IOB_MAN
|
||||
/// <param name="e"></param>
|
||||
private void MainTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
MainTimer.Stop();
|
||||
//MainTimer.Stop();
|
||||
if (!checkRunning)
|
||||
{
|
||||
//checkProcessStatusAsync();
|
||||
@@ -922,7 +952,7 @@ namespace IOB_MAN
|
||||
Logging.Instance.Error($"MainTimer_Tick {exc}");
|
||||
}
|
||||
}
|
||||
MainTimer.Start();
|
||||
//MainTimer.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1097,6 +1127,7 @@ namespace IOB_MAN
|
||||
{
|
||||
ElencoIOB.Insert(indice, newIob);
|
||||
}
|
||||
numProcRunning++;
|
||||
utils.lgInfo($"Avviato child process per {procArg} | pid: {p.Id}");
|
||||
}
|
||||
|
||||
@@ -1106,10 +1137,10 @@ namespace IOB_MAN
|
||||
|
||||
private void UI_Timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
UI_Timer.Stop();
|
||||
//UI_Timer.Stop();
|
||||
Task result = updateProgBarAsync();
|
||||
result.Wait();
|
||||
UI_Timer.Start();
|
||||
//UI_Timer.Start();
|
||||
}
|
||||
|
||||
private void updateIOBWINToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
@@ -1141,8 +1172,14 @@ namespace IOB_MAN
|
||||
{
|
||||
synchronizationContext.Post(new SendOrPostCallback(o =>
|
||||
{
|
||||
// aggiorno labels
|
||||
tsslNumProc.Text = $"Configurati {ArgsList.Count} processi | Avviati: {numProcAvviati} | Attivi: {numProcRunning}";
|
||||
// aggiorno SOLO SE sono variati...
|
||||
if (lastNumProcAvviati != numProcAvviati || lastNumProcRunning != numProcRunning)
|
||||
{
|
||||
// aggiorno labels
|
||||
tsslNumProc.Text = $"Configurati {ArgsList.Count} processi | Avviati: {numProcAvviati} | Attivi: {numProcRunning}";
|
||||
lastNumProcAvviati = numProcAvviati;
|
||||
lastNumProcRunning = numProcRunning;
|
||||
}
|
||||
bool hlRestart = false;
|
||||
// colore da num proc...
|
||||
if (numProcRunning == ArgsList.Count)
|
||||
@@ -1159,26 +1196,31 @@ namespace IOB_MAN
|
||||
tsslNumProc.ForeColor = Color.OrangeRed;
|
||||
hlRestart = true;
|
||||
}
|
||||
// fix autorestart...
|
||||
if (hlRestart)
|
||||
// se è variato...
|
||||
if (hlRestart != lastHlRestart)
|
||||
{
|
||||
chkAutoRestart.ForeColor = System.Drawing.Color.Red;
|
||||
chkAutoRestart.Text = "Auto Restart!!!";
|
||||
txtTOutAutoCheck.Visible = true;
|
||||
btnMoreTOut.Visible = true;
|
||||
// se NON checked aggiorno contatore...
|
||||
if (!chkAutoRestart.Checked)
|
||||
lastHlRestart = hlRestart;
|
||||
// fix autorestart...
|
||||
if (hlRestart)
|
||||
{
|
||||
tOutAutocheck--;
|
||||
txtTOutAutoCheck.Text = $"{(tOutAutocheck / (1000 / (utils.CRI("checkPeriod"))))}";
|
||||
chkAutoRestart.ForeColor = System.Drawing.Color.Red;
|
||||
chkAutoRestart.Text = "Auto Restart!!!";
|
||||
txtTOutAutoCheck.Visible = true;
|
||||
btnMoreTOut.Visible = true;
|
||||
// se NON checked aggiorno contatore...
|
||||
if (!chkAutoRestart.Checked)
|
||||
{
|
||||
tOutAutocheck--;
|
||||
txtTOutAutoCheck.Text = $"{(tOutAutocheck / (1000 / (utils.CRI("checkPeriod"))))}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
chkAutoRestart.ForeColor = DefaultForeColor;
|
||||
chkAutoRestart.Text = "Auto Restart";
|
||||
txtTOutAutoCheck.Visible = false;
|
||||
btnMoreTOut.Visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
chkAutoRestart.ForeColor = DefaultForeColor;
|
||||
chkAutoRestart.Text = "Auto Restart";
|
||||
txtTOutAutoCheck.Visible = false;
|
||||
btnMoreTOut.Visible = false;
|
||||
}
|
||||
}), "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user