diff --git a/EgwControlCenter.App/BlazorForm.cs b/EgwControlCenter.App/BlazorForm.cs
index 8591993..c0c7b9f 100644
--- a/EgwControlCenter.App/BlazorForm.cs
+++ b/EgwControlCenter.App/BlazorForm.cs
@@ -163,6 +163,11 @@ namespace EgwControlCenter.App
}
}
+ ///
+ /// Evento completamento caricamento app
+ ///
+ ///
+ ///
private async void BlazorForm_Load(object sender, EventArgs e)
{
SetPosition();
@@ -183,6 +188,11 @@ namespace EgwControlCenter.App
await ACService.SendStats();
}
+ ///
+ /// Evento post resize
+ ///
+ ///
+ ///
private void BlazorForm_Resize(object sender, EventArgs e)
{
CheckFormVisibility();
diff --git a/EgwControlCenter.Core/AppControlService.cs b/EgwControlCenter.Core/AppControlService.cs
index 3208cae..985bf50 100644
--- a/EgwControlCenter.Core/AppControlService.cs
+++ b/EgwControlCenter.Core/AppControlService.cs
@@ -291,6 +291,7 @@ namespace EgwControlCenter.Core
CloudCallActive = false;
return tVal;
}
+
///
/// Chiamata verifica attivazioni
///
@@ -449,61 +450,6 @@ namespace EgwControlCenter.Core
}
}
- ///
- /// Invia info di reboot effettuato (spostando da req/run a done...)
- ///
- ///
- public async Task SendRebooted()
- {
- // preparo un task di reboot da inviare
- var task2send = new Dictionary();
- task2send.Add("ExecStart", $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
- await CurrCheck.TaskSetRunning(DeviceName, task2send);
- await Task.Delay(500);
- await CurrCheck.TaskSetDone(DeviceName, task2send);
-
- }
-
- ///
- /// Invia info licenza (se disponibili)
- ///
- ///
- public async Task SendLicInfo()
- {
- if (CurrCheck.LicenceFilesDict.Count > 0)
- {
- // serializzo risultato
- string rawData = JsonConvert.SerializeObject(CurrCheck.LicenceFilesDict);
- Dictionary licInfo = new Dictionary();
- // chiave: LicInfo
- licInfo.Add("LicInfo", rawData);
- // invio!
- await CurrCheck.TaskSetDone(DeviceName, licInfo);
- }
- }
- ///
- /// Invia info configurazione (directory)
- ///
- ///
- public async Task SendConfTarget()
- {
- // preparo un task di conf da inviare
- var task2send = new Dictionary();
- string rawConf = JsonConvert.SerializeObject(CurrCheck.CurrPatrolCont.TargetList);
- task2send.Add("TargetList", rawConf);
- await Task.Delay(500);
- await CurrCheck.TaskSetDone(DeviceName, task2send);
- }
- ///
- /// Invia info satats preliminari
- ///
- ///
- public async Task SendStats()
- {
- // invio statistiche esecuzione...
- await DoSendRunStats();
- }
-
///
/// Restituisce un codice di auth temporaneo INT da impiegare x autorizzare
///
@@ -589,6 +535,62 @@ namespace EgwControlCenter.Core
ReportConfigUpd();
}
+ ///
+ /// Invia info configurazione (directory)
+ ///
+ ///
+ public async Task SendConfTarget()
+ {
+ // preparo un task di conf da inviare
+ var task2send = new Dictionary();
+ string rawConf = JsonConvert.SerializeObject(CurrCheck.CurrPatrolCont.TargetList);
+ task2send.Add("TargetList", rawConf);
+ await Task.Delay(500);
+ await CurrCheck.TaskSetDone(DeviceName, task2send);
+ }
+
+ ///
+ /// Invia info licenza (se disponibili)
+ ///
+ ///
+ public async Task SendLicInfo()
+ {
+ if (CurrCheck.LicenceFilesDict.Count > 0)
+ {
+ // serializzo risultato
+ string rawData = JsonConvert.SerializeObject(CurrCheck.LicenceFilesDict);
+ Dictionary licInfo = new Dictionary();
+ // chiave: LicInfo
+ licInfo.Add("LicInfo", rawData);
+ // invio!
+ await CurrCheck.TaskSetDone(DeviceName, licInfo);
+ }
+ }
+
+ ///
+ /// Invia info di reboot effettuato (spostando da req/run a done...)
+ ///
+ ///
+ public async Task SendRebooted()
+ {
+ // preparo un task di reboot da inviare
+ var task2send = new Dictionary();
+ task2send.Add("ExecStart", $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
+ await CurrCheck.TaskSetRunning(DeviceName, task2send);
+ await Task.Delay(500);
+ await CurrCheck.TaskSetDone(DeviceName, task2send);
+ }
+
+ ///
+ /// Invia info satats preliminari
+ ///
+ ///
+ public async Task SendStats()
+ {
+ // invio statistiche esecuzione...
+ await DoSendRunStats();
+ }
+
#endregion Public Methods
#region Protected Fields
@@ -654,7 +656,7 @@ namespace EgwControlCenter.Core
// serializzo risultato
string rawData = JsonConvert.SerializeObject(CurrCheck.LicenceFilesDict);
Dictionary licInfo = new Dictionary();
- // chiave: LicInfo
+ // chiave: LicInfo
licInfo.Add("LicInfo", rawData);
// invio!
await CurrCheck.TaskSetDone(DeviceName, licInfo);
@@ -671,7 +673,7 @@ namespace EgwControlCenter.Core
var statsData = StatsCollector.CurrentInfo();
string rawData = JsonConvert.SerializeObject(statsData);
Dictionary statsInfo = new Dictionary();
- // chiave: RunStats
+ // chiave: RunStats
statsInfo.Add("RunStats", rawData);
// invio!
await CurrCheck.TaskSetDone(DeviceName, statsInfo);
@@ -936,7 +938,8 @@ namespace EgwControlCenter.Core
else
{
// se valido sovrascrivo e salvo!
- CurrCheck.CurrPatrolCont.TargetList= newTargetList;
+ CurrCheck.CurrPatrolCont.TargetList = newTargetList;
+ CurrCheck.SaveConfig();
}
}
break;
diff --git a/EgwControlCenter.Core/CoreEnum.cs b/EgwControlCenter.Core/CoreEnum.cs
index a0fb9a6..af1fcda 100644
--- a/EgwControlCenter.Core/CoreEnum.cs
+++ b/EgwControlCenter.Core/CoreEnum.cs
@@ -66,7 +66,12 @@ namespace EgwControlCenter.Core
///
/// Upsert di parametri operativi (gestiti in remoto)
///
- ParamUpsert
+ ParamUpsert,
+
+ ///
+ /// Upsert valori TargetList (gestiti in remoto)
+ ///
+ TargetListUpsert
}
public enum TipoLicenza
diff --git a/EgwControlCenter.Core/ReleaseChecker.cs b/EgwControlCenter.Core/ReleaseChecker.cs
index e15bb63..71835eb 100644
--- a/EgwControlCenter.Core/ReleaseChecker.cs
+++ b/EgwControlCenter.Core/ReleaseChecker.cs
@@ -105,6 +105,11 @@ namespace EgwControlCenter.Core
///
public PatrolSettings CurrPatrolCont { get; set; } = new PatrolSettings();
+ ///
+ /// Dizionario files licenze trovati
+ ///
+ public Dictionary LicenceFilesDict { get; set; } = new Dictionary();
+
///
/// Elenco degli oggetti stato dei programmi monitorati
///
@@ -579,6 +584,18 @@ namespace EgwControlCenter.Core
return taskReq;
}
+ ///
+ /// Invia un dizionario di task completato (x richieste o salvataggio da EgwACC)
+ ///
+ ///
+ ///
+ public async Task TaskSetDone(string devName, Dictionary taskRes)
+ {
+ string answ = await TaskPostInfo(devName, taskRes, "done");
+ return answ;
+ }
+
///
/// Invia un dizionario che dovrebbe comprendere tutte le richieste task 8da chiudere) + eventuali altri dati da salvare
///
@@ -592,60 +609,108 @@ namespace EgwControlCenter.Core
}
///
- /// Metodo effettivo invio post info sul task
+ /// Aggiorna info files licenza (se configurato e se trovate)
///
- ///
- ///
+ ///
///
- private async Task TaskPostInfo(string devName, Dictionary taskRes, string action)
+ public bool UpdateLicenceInfo()
{
- string answ = "";
- try
+ /*-------------------------------------------
+ * Ricerca licenze: algoritmo
+ * - parte da un percorso di base
+ * - cerca x ogni cartella la sottocartella /Config/ i files *.ini
+ * - prende i files che contengono "Licence="
+ * - considera solo i file con valore valido x Licence
+ * - prende il relativo file *.lic indicato (stessa folder)
+ * - legge e riporta intero contenuto nel record dizionario:
+ * - chiave = percorso file *.lic
+ * - valore = contenuto file
+ *-------------------------------------------*/
+
+ bool fatto = false;
+ // nuovo obj licenze...
+ Dictionary newLicDict = new Dictionary();
+ // ciclo SOLO gli oggetti licenza info
+ var licTgt = CurrPatrolCont
+ .TargetList
+ .Where(x => x.ApplicationType == CoreEnum.AppType.LicenceApp)
+ .ToList();
+ int numFound = 0;
+ foreach (var item in licTgt)
{
- // preparo richiesta...
- TaskResultDTO currReq = new TaskResultDTO()
+ try
{
- AppKey = CurrPatrolCont.AppKey,
- CodImp = CodImpiego,
- MastKey = "",
- DataPayload = taskRes
- };
- // client chiamate rest
- var client = new RestClient(restOptStd);
- // Chiamo il metodo!
- var actReq = new RestRequest($"/api/apptask/{action}/{devName}", Method.Post);
- string payload = JsonConvert.SerializeObject(currReq);
- actReq.AddJsonBody(payload);
- // effettuo vera chiamata
- var currResp = await client.PostAsync(actReq);
- if (currResp.StatusCode == System.Net.HttpStatusCode.OK && currResp.Content != null)
- {
- answ = $"{currResp.Content}";
+ // verifico contenuto secondo tipo
+ if (item != null && item.IsEnabled)
+ {
+ // processo la folder indicata e cerco tutte le macchine contenute
+ if (Directory.Exists(item.BasePath))
+ {
+ // recupero elenco sottodirectory = possibili conf applicativi
+ var dirList = Directory.GetDirectories(item.BasePath);
+ // ciclo x cercare i files...
+ foreach (var currDir in dirList)
+ {
+ string prgName = Path.GetFileName(currDir);
+ // compongo ricerca della cartella Config dentro la folder target
+ string confPath = Path.Combine(currDir, "Config");
+ // verifico se esiste directory...
+ if (Directory.Exists(confPath))
+ {
+ // cerco se ci sia un file di quelli richiesti...
+ var fileFound = Directory.GetFiles(confPath, item.SearchPattern);
+ if (fileFound != null && fileFound.Count() > 0)
+ {
+ // ciclo su tutti i file candidati...
+ foreach (var file in fileFound)
+ {
+ // vincolo dei soli file con nome uguale alla folder ancestor...
+ string iniName = Path.GetFileName(file);
+ if (iniName.StartsWith($"{prgName}."))
+ {
+ string licName = LicSearchFileName(file);
+ if (!string.IsNullOrEmpty(licName))
+ {
+ var contDir = Path.GetDirectoryName(file);
+ if (!string.IsNullOrEmpty(contDir))
+ {
+ string licPath = Path.Combine(contDir, licName);
+ if (File.Exists(licPath))
+ {
+ // leggo il contenuto e salvo...
+ var licContent = File.ReadAllText(licPath);
+ if (!newLicDict.ContainsKey(licPath))
+ {
+ newLicDict.Add(licPath, licContent);
+ numFound++;
+ }
+ else
+ {
+ newLicDict[licPath] = licContent;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
- else
+ catch (Exception exc)
{
- Log.Error($"Errore in ricezione REST services TaskPostInfo | action: {action} | statusCode{currResp.StatusCode} | content: {currResp.Content}");
+ Log.Error($"Eccezione in UpdateLicenceInfo{Environment.NewLine}{exc}");
}
}
- catch (Exception exc)
- {
- Log.Error($"Eccezione in fase gestione REST services TaskPostInfo | action: {action}{Environment.NewLine}{exc}");
- }
+ // aggiorno obj...
+ LicenceFilesDict = newLicDict;
+ // salvo info licenze...
+ SaveLicDict();
+ fatto = numFound > 0;
- return answ;
- }
-
- ///
- /// Invia un dizionario di task completato (x richieste o salvataggio da EgwACC)
- ///
- ///
- ///
- public async Task TaskSetDone(string devName, Dictionary taskRes)
- {
- string answ = await TaskPostInfo(devName, taskRes, "done");
- return answ;
+ return fatto;
}
///
@@ -675,7 +740,6 @@ namespace EgwControlCenter.Core
{
switch (item.ApplicationType)
{
-
case CoreEnum.AppType.Machine:
// processo la folder indicata e cerco tutte le macchine contenute
if (Directory.Exists(item.BasePath))
@@ -786,151 +850,6 @@ namespace EgwControlCenter.Core
return fatto;
}
- ///
- /// Aggiorna info files licenza (se configurato e se trovate)
- ///
- ///
- ///
- public bool UpdateLicenceInfo()
- {
- /*-------------------------------------------
- * Ricerca licenze: algoritmo
- * - parte da un percorso di base
- * - cerca x ogni cartella la sottocartella /Config/ i files *.ini
- * - prende i files che contengono "Licence="
- * - considera solo i file con valore valido x Licence
- * - prende il relativo file *.lic indicato (stessa folder)
- * - legge e riporta intero contenuto nel record dizionario:
- * - chiave = percorso file *.lic
- * - valore = contenuto file
- *-------------------------------------------*/
-
- bool fatto = false;
- // nuovo obj licenze...
- Dictionary newLicDict = new Dictionary();
- // ciclo SOLO gli oggetti licenza info
- var licTgt = CurrPatrolCont
- .TargetList
- .Where(x => x.ApplicationType == CoreEnum.AppType.LicenceApp)
- .ToList();
- int numFound = 0;
- foreach (var item in licTgt)
- {
- try
- {
- // verifico contenuto secondo tipo
- if (item != null && item.IsEnabled)
- {
- // processo la folder indicata e cerco tutte le macchine contenute
- if (Directory.Exists(item.BasePath))
- {
- // recupero elenco sottodirectory = possibili conf applicativi
- var dirList = Directory.GetDirectories(item.BasePath);
- // ciclo x cercare i files...
- foreach (var currDir in dirList)
- {
- string prgName = Path.GetFileName(currDir);
- // compongo ricerca della cartella Config dentro la folder target
- string confPath = Path.Combine(currDir, "Config");
- // verifico se esiste directory...
- if (Directory.Exists(confPath))
- {
- // cerco se ci sia un file di quelli richiesti...
- var fileFound = Directory.GetFiles(confPath, item.SearchPattern);
- if (fileFound != null && fileFound.Count() > 0)
- {
- // ciclo su tutti i file candidati...
- foreach (var file in fileFound)
- {
- // vincolo dei soli file con nome uguale alla folder ancestor...
- string iniName = Path.GetFileName(file);
- if (iniName.StartsWith($"{prgName}."))
- {
- string licName = LicSearchFileName(file);
- if (!string.IsNullOrEmpty(licName))
- {
- var contDir = Path.GetDirectoryName(file);
- if (!string.IsNullOrEmpty(contDir))
- {
- string licPath = Path.Combine(contDir, licName);
- if (File.Exists(licPath))
- {
- // leggo il contenuto e salvo...
- var licContent = File.ReadAllText(licPath);
- if (!newLicDict.ContainsKey(licPath))
- {
- newLicDict.Add(licPath, licContent);
- numFound++;
- }
- else
- {
- newLicDict[licPath] = licContent;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- catch (Exception exc)
- {
- Log.Error($"Eccezione in UpdateLicenceInfo{Environment.NewLine}{exc}");
- }
- }
- // aggiorno obj...
- LicenceFilesDict = newLicDict;
- // salvo info licenze...
- SaveLicDict();
- fatto = numFound > 0;
-
- return fatto;
- }
-
- ///
- /// Processa il file ini (se esistente) cercando file licenza e se lo trova restituisce il nome del file...
- ///
- /// File ini da processare
- /// max num di linee da verificare
- ///
- private string LicSearchFileName(string iniPath, int maxLines = 20)
- {
- string answ = "";
- string licToken = "Licence=";
- if (File.Exists(iniPath))
- {
- try
- {
- using (StreamReader reader = new StreamReader(iniPath))
- {
- for (int i = 0; i < maxLines; i++)
- {
- if (reader.EndOfStream)
- break;
-
- var line = reader.ReadLine();
- if (!string.IsNullOrEmpty(line))
- {
- if (line.Contains(licToken))
- {
- answ = line.Replace(licToken, "").Trim();
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- Log.Error($"Error during LicSearchFileName: {Environment.NewLine}{ex}");
- }
- }
- return answ;
- }
-
#endregion Public Methods
#region Protected Properties
@@ -946,11 +865,6 @@ namespace EgwControlCenter.Core
///
protected List ListStatus { get; set; } = new List();
- ///
- /// Dizionario files licenze trovati
- ///
- public Dictionary LicenceFilesDict { get; set; } = new Dictionary();
-
#endregion Protected Properties
#region Private Fields
@@ -995,7 +909,9 @@ namespace EgwControlCenter.Core
private string CodImpiego { get; set; } = "";
private string ConfName { get; set; } = "";
+
private Dictionary CriticalRelCurrent { get; set; } = new Dictionary();
+
private string DataDir { get; set; } = "";
///
@@ -1007,8 +923,20 @@ namespace EgwControlCenter.Core
}
private string ERName { get; set; } = "EnrollReq.json";
- private string LSName { get; set; } = "LastStatus.json";
+
+ ///
+ /// Path file salvataggio LicenceInfo
+ ///
+ private string LicInfoPath
+ {
+ get => Path.Combine(DataDir, LIName);
+ //get => Path.Combine(ApplicationDeployment.CurrentDeployment.DataDirectory, LSName);
+ }
+
private string LIName { get; set; } = "LicInfo.json";
+
+ private string LSName { get; set; } = "LastStatus.json";
+
private SubLicManager SLicManager { get; set; } = new SubLicManager();
///
@@ -1018,14 +946,6 @@ namespace EgwControlCenter.Core
{
get => Path.Combine(DataDir, LSName);
}
- ///
- /// Path file salvataggio LicenceInfo
- ///
- private string LicInfoPath
- {
- get => Path.Combine(DataDir, LIName);
- //get => Path.Combine(ApplicationDeployment.CurrentDeployment.DataDirectory, LSName);
- }
#endregion Private Properties
@@ -1317,6 +1237,46 @@ namespace EgwControlCenter.Core
ReloadData();
}
+ ///
+ /// Processa il file ini (se esistente) cercando file licenza e se lo trova restituisce il nome del file...
+ ///
+ /// File ini da processare
+ /// max num di linee da verificare
+ ///
+ private string LicSearchFileName(string iniPath, int maxLines = 20)
+ {
+ string answ = "";
+ string licToken = "Licence=";
+ if (File.Exists(iniPath))
+ {
+ try
+ {
+ using (StreamReader reader = new StreamReader(iniPath))
+ {
+ for (int i = 0; i < maxLines; i++)
+ {
+ if (reader.EndOfStream)
+ break;
+
+ var line = reader.ReadLine();
+ if (!string.IsNullOrEmpty(line))
+ {
+ if (line.Contains(licToken))
+ {
+ answ = line.Replace(licToken, "").Trim();
+ }
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Log.Error($"Error during LicSearchFileName: {Environment.NewLine}{ex}");
+ }
+ }
+ return answ;
+ }
+
///
/// Recupera oggetto releaseDTO da file indicato
///
@@ -1415,11 +1375,23 @@ namespace EgwControlCenter.Core
var rawData = File.ReadAllText(LicInfoPath);
if (!string.IsNullOrEmpty(rawData))
{
- LicenceFilesDict = JsonConvert.DeserializeObject>(rawData) ?? new Dictionary();
+ LicenceFilesDict = JsonConvert.DeserializeObject>(rawData) ?? new Dictionary();
}
}
}
+ ///
+ /// Effettua salvataggio obj status
+ ///
+ private void SaveLicDict()
+ {
+ var rawData = JsonConvert.SerializeObject(LicenceFilesDict, Formatting.Indented);
+ if (rawData != null && rawData.Length > 2)
+ {
+ File.WriteAllText(LicInfoPath, rawData);
+ }
+ }
+
///
/// Effettua salvataggio obj status
///
@@ -1448,15 +1420,48 @@ namespace EgwControlCenter.Core
}
///
- /// Effettua salvataggio obj status
+ /// Metodo effettivo invio post info sul task
///
- private void SaveLicDict()
+ ///
+ ///
+ ///
+ private async Task TaskPostInfo(string devName, Dictionary taskRes, string action)
{
- var rawData = JsonConvert.SerializeObject(LicenceFilesDict, Formatting.Indented);
- if (rawData != null && rawData.Length > 2)
+ string answ = "";
+ try
{
- File.WriteAllText(LicInfoPath, rawData);
+ // preparo richiesta...
+ TaskResultDTO currReq = new TaskResultDTO()
+ {
+ AppKey = CurrPatrolCont.AppKey,
+ CodImp = CodImpiego,
+ MastKey = "",
+ DataPayload = taskRes
+ };
+ // client chiamate rest
+ var client = new RestClient(restOptStd);
+ // Chiamo il metodo!
+ var actReq = new RestRequest($"/api/apptask/{action}/{devName}", Method.Post);
+ string payload = JsonConvert.SerializeObject(currReq);
+ actReq.AddJsonBody(payload);
+ // effettuo vera chiamata
+ var currResp = await client.PostAsync(actReq);
+ if (currResp.StatusCode == System.Net.HttpStatusCode.OK && currResp.Content != null)
+ {
+ answ = $"{currResp.Content}";
+ }
+ else
+ {
+ Log.Error($"Errore in ricezione REST services TaskPostInfo | action: {action} | statusCode{currResp.StatusCode} | content: {currResp.Content}");
+ }
}
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in fase gestione REST services TaskPostInfo | action: {action}{Environment.NewLine}{exc}");
+ }
+
+ return answ;
}
#endregion Private Methods