Aggiunta gestione storica stats

This commit is contained in:
Samuele Locatelli
2025-01-21 08:48:33 +01:00
parent 512ad7f6b8
commit 0cb24a5f89
7 changed files with 76 additions and 27 deletions
+13
View File
@@ -35,6 +35,8 @@
trayMenu = new ContextMenuStrip(components);
timerCheck = new System.Windows.Forms.Timer(components);
timerTask = new System.Windows.Forms.Timer(components);
timer1 = new System.Windows.Forms.Timer(components);
timerStats = new System.Windows.Forms.Timer(components);
SuspendLayout();
//
// blazorWebView1
@@ -72,6 +74,15 @@
timerTask.Interval = 1000;
timerTask.Tick += timerTask_Tick;
//
// timer1
//
timer1.Interval = 1000;
//
// timerStats
//
timerStats.Interval = 600000;
timerStats.Tick += timerStats_Tick;
//
// BlazorForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
@@ -96,5 +107,7 @@
private ContextMenuStrip trayMenu;
private System.Windows.Forms.Timer timerCheck;
private System.Windows.Forms.Timer timerTask;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Timer timerStats;
}
}
+27 -3
View File
@@ -280,7 +280,7 @@ namespace EgwControlCenter.App
{
Stopwatch sw = new Stopwatch();
sw.Start();
CurrAssembly = System.Reflection.Assembly.GetExecutingAssembly().GetName();
CurrAssembly = Assembly.GetExecutingAssembly().GetName();
Log.Trace($"EgalWare's AppControlCenter Init, v.{CurrAssembly.Version}");
// sistemo grafica TRAY ICON
SetupTrayIcon();
@@ -412,12 +412,21 @@ namespace EgwControlCenter.App
private void StartTimer()
{
// timer controlli da conf
timerCheck.Interval = (ACService.RefreshPeriod * 1000);
// sistemo timer
// timer statistiche a 30 min fisso x ora
timerStats.Interval = 1000 * 60 * 30;
// avvio timer
timerCheck.Start();
timerTask.Start();
timerStats.Start();
}
/// <summary>
/// Esecuzione task di verifica stato app
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void timerCheck_Tick(object sender, EventArgs e)
{
// fermo task...
@@ -429,7 +438,22 @@ namespace EgwControlCenter.App
}
/// <summary>
/// Timer task (3 sec base)
/// Gestione timer statistiche
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void timerStats_Tick(object sender, EventArgs e)
{
// fermo task...
timerStats.Stop();
// esegue controllo task
await ACService.SendStats();
// riavvio task x evitare sovrapposizioni in debug
timerStats.Start();
}
/// <summary>
/// Timer task (1 sec base)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
+6
View File
@@ -296,6 +296,12 @@
<metadata name="timerTask.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>351, 17</value>
</metadata>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>351, 17</value>
</metadata>
<metadata name="timerStats.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>439, 17</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAMDAAAAEAIACoJQAAFgAAACgAAAAwAAAAYAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.2.2501.2019</Version>
<Version>1.2.2501.2108</Version>
<Configurations>Debug;Release;DEBUG_Local</Configurations>
</PropertyGroup>
<ItemGroup>
@@ -4,8 +4,8 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<ApplicationRevision>2019</ApplicationRevision>
<ApplicationVersion>1.2.2501.2019</ApplicationVersion>
<ApplicationRevision>2108</ApplicationRevision>
<ApplicationVersion>1.2.2501.2108</ApplicationVersion>
<BootstrapperEnabled>True</BootstrapperEnabled>
<Configuration>Release</Configuration>
<CreateWebPageOnPublish>True</CreateWebPageOnPublish>
+24 -18
View File
@@ -38,8 +38,8 @@ namespace EgwControlCenter.Core
{
try
{
Assembly assembly = Assembly.GetExecutingAssembly();
string startDir = Path.GetDirectoryName(assembly.Location)!;
mainAssembly = Assembly.GetCallingAssembly();
string startDir = Path.GetDirectoryName(mainAssembly.Location)!;
ConfDir = startDir;
CodImpiego = SLicManager.CodImpiego();
// setup RuntimConf (da gestire anche con set remoto...)
@@ -596,9 +596,7 @@ namespace EgwControlCenter.Core
#region Protected Fields
protected string DeviceName = "";
protected UpdateMan updateMan = new UpdateMan();
protected UpdateMan updateManAuth = new UpdateMan("SWDownloader", "viaD@nte16");
#endregion Protected Fields
@@ -670,7 +668,10 @@ namespace EgwControlCenter.Core
protected async Task DoSendRunStats()
{
// recupero statistiche
var statsData = StatsCollector.CurrentInfo();
Dictionary<string, string> statsData = StatsCollector.CurrentInfo();
// aggiungo versione alle statistiche
statsData.Add("Version", $"{mainAssembly.GetName().Version}");
//serializzo
string rawData = JsonConvert.SerializeObject(statsData);
Dictionary<string, string> statsInfo = new Dictionary<string, string>();
// chiave: RunStats
@@ -698,6 +699,8 @@ namespace EgwControlCenter.Core
/// </summary>
private DateTime lastCheckDone = DateTime.Today.AddMonths(-1);
private Assembly mainAssembly = Assembly.GetExecutingAssembly();
/// <summary>
/// Numero di controlli fast (5 sec medi) dei task prima di tornare alla gestione lenta (2 min)
/// </summary>
@@ -872,25 +875,23 @@ namespace EgwControlCenter.Core
case CoreEnum.EgwAccTask.DeviceInfoGet:
Dictionary<string, string> currDevInfo = DeviceInfoDict();
taskVal = JsonConvert.SerializeObject(currDevInfo, Formatting.Indented);
taskVal = JsonConvert.SerializeObject(currDevInfo);
break;
case CoreEnum.EgwAccTask.ForceCheck:
Dictionary<string, string> fcDetail = new Dictionary<string, string>();
fcDetail.Add("ExecStart", $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
Dictionary<string, string> fcRes = new Dictionary<string, string>();
fcRes.Add("ExecStart", $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
await DoFullCheckAsync(true);
sw.Stop();
fcDetail.Add("Completed", $"App Check done in {sw.Elapsed.TotalMilliseconds:N0}ms");
taskVal = JsonConvert.SerializeObject(fcDetail, Formatting.Indented);
fcRes.Add("Completed", $"App Check done in {sw.Elapsed.TotalMilliseconds:N0}ms");
taskVal = JsonConvert.SerializeObject(fcRes);
break;
case CoreEnum.EgwAccTask.ForceReload:
Dictionary<string, string> fcReload = new Dictionary<string, string>();
fcReload.Add("ExecReload", $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
Dictionary<string, string> frRes = new Dictionary<string, string>();
frRes.Add("ExecReload", $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
sw.Stop();
// mando subito conferma esecuzione...
fcReload.Add("ExecReload", $"Reload Requested...");
taskVal = JsonConvert.SerializeObject(fcReload, Formatting.Indented);
taskVal = JsonConvert.SerializeObject(frRes);
// sollevo evento
if (EA_ReloadRequested != null)
{
@@ -899,11 +900,11 @@ namespace EgwControlCenter.Core
break;
case CoreEnum.EgwAccTask.ForceUpdate:
Dictionary<string, string> fcUpdate = new Dictionary<string, string>();
fcUpdate.Add("ExecStart", $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
Dictionary<string, string> fuRes = new Dictionary<string, string>();
fuRes.Add("ExecStart", $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
sw.Stop();
// mando subito conferma esecuzione...
taskVal = JsonConvert.SerializeObject(fcUpdate, Formatting.Indented);
taskVal = JsonConvert.SerializeObject(fuRes);
// sollevo evento
if (EA_RestartRequested != null)
{
@@ -912,7 +913,12 @@ namespace EgwControlCenter.Core
break;
case CoreEnum.EgwAccTask.OxyLicenseGet:
Dictionary<string, string> olgRes = new Dictionary<string, string>();
await DoSendLicInfo();
sw.Stop();
// mando subito conferma esecuzione...
olgRes.Add("LicInfoCompleted", $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
taskVal = JsonConvert.SerializeObject(olgRes);
break;
//case CoreEnum.EgwAccTask.ParamDictReset:
+3 -3
View File
@@ -47,8 +47,6 @@ namespace EgwControlCenter.Core
public static Dictionary<string, string> CurrentInfo()
{
Dictionary<string, string> result = new Dictionary<string, string>();
// in primis metto uptime
result.Add("Uptime", UptimeCurr);
// ciclo sugli oggetti calcolando durate e ultima call
foreach (var item in Counter)
{
@@ -56,7 +54,9 @@ namespace EgwControlCenter.Core
result.Add(item.Key, sRec);
result.Add($"{item.Key}Last", $"{LastCall[item.Key]:yyyy-MM-dd HH:mm:ss}");
}
// infine metto stata avvio e uptime
result.Add("Startup", $"{StartTime:yyyy-MM-dd HH:mm:ss}");
result.Add("Uptime", UptimeCurr);
return result;
}