Modifica condizioni check in chiusura/raivvio app x evitare problemi notturni
This commit is contained in:
@@ -214,39 +214,73 @@ namespace IOB_MAN.Core.Services
|
||||
{
|
||||
isBusy = true;
|
||||
CheckRunningChild();
|
||||
// provo a chiudere tutti 1:1 per pID
|
||||
var listPID = ListIobAdapters
|
||||
.Where(x => x.isRunning)
|
||||
.Select(x => x.pID)
|
||||
.ToList();
|
||||
#if true
|
||||
Parallel.ForEach(listPID, pID =>
|
||||
if (ListIobAdapters.Count > 0)
|
||||
{
|
||||
List<int> listPID = new List<int>();
|
||||
try
|
||||
{
|
||||
ForceKillByPID(pID);
|
||||
});
|
||||
#else
|
||||
foreach(var pID in listPID)
|
||||
{
|
||||
ForceKillByPID(pID);
|
||||
}
|
||||
#endif
|
||||
// provo a chiudere tutti 1:1 per pID
|
||||
listPID = ListIobAdapters
|
||||
.Where(x => x.isRunning)
|
||||
.Select(x => x.pID)
|
||||
.ToList();
|
||||
|
||||
// chiudo per nome SE rimasti
|
||||
var listNames = currIobConf
|
||||
.ListTarget
|
||||
.Select(x => x.Value.ExeName)
|
||||
.Where(x => !string.IsNullOrEmpty(x))
|
||||
.Distinct().ToList();
|
||||
Parallel.ForEach(listNames, prgName =>
|
||||
{
|
||||
ForceKillByName(prgName);
|
||||
});
|
||||
// aspetto 100ms
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione DoCloseAll.01:{Environment.NewLine}{exc}");
|
||||
}
|
||||
if (listPID.Count > 0)
|
||||
{
|
||||
Parallel.ForEach(listPID, pID =>
|
||||
{
|
||||
ForceKillByPID(pID);
|
||||
});
|
||||
// aspetto 100ms
|
||||
Task.Delay(100);
|
||||
}
|
||||
|
||||
#if false
|
||||
List<string> listNames = new List<string>();
|
||||
try
|
||||
{
|
||||
// chiudo per nome SE rimasti
|
||||
listNames = currIobConf
|
||||
.ListTarget
|
||||
.Select(x => x.Value.ExeName)
|
||||
.Where(x => !string.IsNullOrEmpty(x))
|
||||
.Distinct().ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione DoCloseAll.02:{Environment.NewLine}{exc}");
|
||||
}
|
||||
#endif
|
||||
List<string> listNames = ListIobNames();
|
||||
if (listNames.Count > 0)
|
||||
{
|
||||
Parallel.ForEach(listNames, prgName =>
|
||||
{
|
||||
ForceKillByName(prgName);
|
||||
});
|
||||
}
|
||||
}
|
||||
// verifico nuovamente i processi
|
||||
CheckRunningChild();
|
||||
var stillRunList = ListIobAdapters
|
||||
.Where(x => x.isRunning)
|
||||
.ToList();
|
||||
List<IobAdapt> stillRunList = new List<IobAdapt>();
|
||||
if (ListIobAdapters.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
stillRunList = ListIobAdapters
|
||||
.Where(x => x.isRunning)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione DoCloseAll.03:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
// eventuale chiusura
|
||||
if (stillRunList != null && stillRunList.Count > 0)
|
||||
{
|
||||
@@ -256,7 +290,6 @@ namespace IOB_MAN.Core.Services
|
||||
ForceKillByName(item.ExeName);
|
||||
}
|
||||
}
|
||||
|
||||
// verifico se resettare
|
||||
if (doReset)
|
||||
{
|
||||
@@ -270,6 +303,34 @@ namespace IOB_MAN.Core.Services
|
||||
isBusy = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco degli EXE Names degli IOB gestiti (x chiamate di cleanup/chiusura)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<string> ListIobNames()
|
||||
{
|
||||
List<string> listNames = new List<string>();
|
||||
if (currIobConf != null && currIobConf.ListTarget != null && currIobConf.ListTarget.Count > 0)
|
||||
{
|
||||
// chiudo per nome SE rimasti
|
||||
listNames = currIobConf
|
||||
.ListTarget
|
||||
.Select(x => x.Value.ExeName)
|
||||
.Where(x => !string.IsNullOrEmpty(x))
|
||||
.Distinct().ToList();
|
||||
#if false
|
||||
try
|
||||
{
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione DoCloseAll.02:{Environment.NewLine}{exc}");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return listNames;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apre il child selezionato
|
||||
/// </summary>
|
||||
@@ -729,7 +790,7 @@ namespace IOB_MAN.Core.Services
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private bool checkIstance(IobAdapt item, List<Process> processList)
|
||||
private bool checkInstance(IobAdapt item, List<Process> processList)
|
||||
{
|
||||
bool needRem = false;
|
||||
if (!isBusy)
|
||||
@@ -830,11 +891,14 @@ namespace IOB_MAN.Core.Services
|
||||
);
|
||||
// ciclo controllo
|
||||
var list2check = concList.ToList();
|
||||
Parallel.ForEach(ListIobAdapters, item =>
|
||||
if (list2check != null && list2check.Count > 0)
|
||||
{
|
||||
needRem = checkIstance(item, list2check);
|
||||
Parallel.ForEach(ListIobAdapters, item =>
|
||||
{
|
||||
needRem = checkInstance(item, list2check);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
sw.Stop();
|
||||
@@ -893,11 +957,14 @@ namespace IOB_MAN.Core.Services
|
||||
);
|
||||
// ciclo controllo
|
||||
var list2check = concList.ToList();
|
||||
Parallel.ForEach(ListIobAdapters, item =>
|
||||
if (list2check != null && list2check.Count > 0)
|
||||
{
|
||||
needRem = checkIstance(item, list2check);
|
||||
Parallel.ForEach(ListIobAdapters, item =>
|
||||
{
|
||||
needRem = checkInstance(item, list2check);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
sw.Stop();
|
||||
@@ -1089,7 +1156,6 @@ namespace IOB_MAN.Core.Services
|
||||
|
||||
if (startProc)
|
||||
{
|
||||
|
||||
// chiudo eventuali processi in RUN
|
||||
DoCloseAll(false);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>4.0.2512.0608</Version>
|
||||
<Version>4.0.2512.1208</Version>
|
||||
<Configurations>Debug;Release;Remote_DEBUG</Configurations>
|
||||
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
Reference in New Issue
Block a user