diff --git a/MP.AppAuth/HwSwInfo.cs b/MP.AppAuth/HwSwInfo.cs new file mode 100644 index 00000000..c08ebfbe --- /dev/null +++ b/MP.AppAuth/HwSwInfo.cs @@ -0,0 +1,276 @@ +using NLog; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace MP.AppAuth +{ + /// + /// Helper x estrarre dati sintetici su HW, Software, librerie installate... + /// + public class HwSwInfo + { + #region Private Fields + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields + + #region Protected Fields + + /// + /// Assembly di base + /// + protected Assembly assembly = Assembly.GetExecutingAssembly(); + + #endregion Protected Fields + + #region Public Constructors + + /// + /// Istanza base + /// + public HwSwInfo() + { + assembly = Assembly.GetExecutingAssembly(); + } + + public HwSwInfo(Assembly targetAssembly) + { + assembly = targetAssembly; + } + + #endregion Public Constructors + +#if false + /// + /// Singleton! + /// + public static HwSwInfo man = new HwSwInfo(); +#endif + + #region Public Properties + + /// + /// Statistiche IIS + /// + public string IISStats + { + get + { + StringBuilder sb = new StringBuilder(); + using (var iis = Process.GetCurrentProcess()) + { + //Process iis = Process.GetCurrentProcess(); + sb.AppendLine(string.Format("UPTIME: {0}", ToDateString(DateTime.Now - iis.StartTime))); + sb.AppendLine(string.Format("Priority: {0}", iis.PriorityClass)); + sb.AppendLine(string.Format("Physical Memory Used: {0}", memFormat(iis.WorkingSet64))); + sb.AppendLine(string.Format("Virtual Memory Used: {0}", memFormat(iis.VirtualMemorySize64))); + } + return sb.ToString(); + } + } + + /// + /// Versioni di ogni libreria compresa + /// + public string librariesVers + { + get + { + string answ = ""; + try + { + AssemblyName[] referencedAssemblyNames = assembly.GetReferencedAssemblies(); + foreach (AssemblyName referencedAssemblyName in referencedAssemblyNames.OrderBy(n => n.Name)) + { + answ += referencedAssemblyName.FullName + Environment.NewLine; + } + } + catch + { } + return answ; + } + } + + /// + /// Nome MainAssembly + /// + public string mainAssembly + { + get + { + string answ = ""; + try + { + answ = assembly.FullName; + } + catch + { } + return answ; + } + } + + /// + /// Num di librerie inserite + /// + public int numLibraries + { + get + { + int numLib = 0; ; + try + { + AssemblyName[] referencedAssemblyNames = assembly.GetReferencedAssemblies(); + foreach (AssemblyName referencedAssemblyName in referencedAssemblyNames.OrderBy(n => n.Name)) + { + numLib++; + } + } + catch + { } + return numLib; + } + } + + ///// + ///// Dati sui server redis... + ///// + //public string redisServersData + //{ + // get + // { + // StringBuilder sb = new StringBuilder(); + // try + // { + // var servData = memLayer.ML.redServInfo(); + // foreach (var item in servData) + // { + // sb.AppendLine(string.Format("Server: {0} | {1} | {2}", item, item.Version, item.ServerType)); + // // da completare con altre info?!? + // var srvInfo = item.Info(); + // // esporto un pò di info x gruppo... + // foreach (IGrouping> capitolo in srvInfo) + // { + // sb.AppendLine("----------------------------------------------"); + // sb.AppendLine(string.Format("Capitolo: {0}", capitolo.Key)); + // sb.AppendLine("----------------------------------------------"); + // foreach (var kvp in capitolo) + // { + // sb.AppendLine(string.Format("{0}:{1}", kvp.Key, kvp.Value)); + // } + + // sb.AppendLine(); + // } + // } + // } + // catch (Exception exc) + // { + // Log.Error($"Errore in redisServersData{Environment.NewLine}{exc}"); + // } + // return sb.ToString(); + // } + //} + + /// + /// Runtime assembly + /// + public string runtimeImg + { + get + { + string answ = ""; + try + { + answ = assembly.ImageRuntimeVersion; + } + catch + { } + return answ; + } + } + + /// + /// Statistiche server + /// + public string ServerStats + { + get + { + StringBuilder sb = new StringBuilder(); + try + { + // calcoli preliminari + + // compongo output + sb.AppendLine(string.Format("NAME: {0}", Environment.MachineName)); + sb.AppendLine(System.Runtime.InteropServices.RuntimeInformation.OSDescription); + sb.AppendLine(System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription); + sb.AppendLine(string.Format("OS 64bit: {0} | PROC 64bit: {1}", Environment.Is64BitOperatingSystem, Environment.Is64BitProcess)); + //sb.AppendLine(string.Format("SYS UPTIME: {0}", ToDateString(uptime))); + sb.AppendLine(string.Format("CPU: {0}", Environment.ProcessorCount)); + //sb.AppendLine(string.Format("RAM: {0}", memFormat(computer.TotalPhysicalMemory))); + //sb.AppendLine(string.Format("Virtual Memory: {0}", memFormat(computer.TotalVirtualMemory))); + //sb.AppendLine(string.Format("Available RAM: {0}", memFormat(computer.AvailablePhysicalMemory))); + //sb.AppendLine(string.Format("Available Virtual Memory: {0}", memFormat(computer.AvailableVirtualMemory))); + sb.AppendLine(string.Format("DIR: {0}", Environment.CurrentDirectory)); + sb.AppendLine(string.Format("USER: {0} | USER: {1}", Environment.UserDomainName, Environment.UserName)); + } + catch (Exception exc) + { + Log.Error($"Errore in ServerStats{Environment.NewLine}{exc}"); + } + return sb.ToString(); + } + } + + #endregion Public Properties + + #region Public Methods + + /// + /// Singleton! + /// + public static HwSwInfo man(Assembly targetAssembly) + { + HwSwInfo answ = new HwSwInfo(targetAssembly); + return answ; + } + + /// + /// Formatta un numero da int a size in Kb/Mb/Gb/Tb + /// + /// + /// + public string memFormat(double rawSize) + { + string[] sizes = { "B", "KB", "MB", "GB", "TB" }; + int order = 0; + while (rawSize >= 1024 && order < sizes.Length - 1) + { + order++; + rawSize = rawSize / 1024; + } + + // Adjust the format string to your preferences. For example "{0:0.#}{1}" would + // show a single decimal place, and no space. + return String.Format("{0:0.##} {1}", rawSize, sizes[order]); + } + + /// + /// Stringa timing in gg, ore, ... da timespan + /// + /// + /// + public string ToDateString(TimeSpan time) + { + return string.Format("{0}gg, {1:00}:{2:00}:{3:00} (h:m:s)", time.Days, time.Hours, time.Minutes, time.Seconds); + } + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj index 0b71cd86..243ca7f5 100644 --- a/MP.Land/MP.Land.csproj +++ b/MP.Land/MP.Land.csproj @@ -3,7 +3,7 @@ net5.0 MP.Land - 1.1.2109.2116 + 1.1.2109.2117 diff --git a/MP.Land/Pages/SysInfo.razor b/MP.Land/Pages/SysInfo.razor new file mode 100644 index 00000000..5b5c2c2a --- /dev/null +++ b/MP.Land/Pages/SysInfo.razor @@ -0,0 +1,161 @@ +@page "/SysInfo" +@using MP.AppAuth +@using MP.Land.Data +@using Microsoft.Extensions.Configuration + +@inject MessageService AppMService +@inject IConfiguration Configuration + +
+
+
+
+
+
+
+

@Titolo

+
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
Environment
+
+

@Environment

+
+
+
+
Main DB Conf
+
+

@DbNameExample

+
+
+
+
.net framework
+
+

@currHwSwInfo.runtimeImg

+
+
+
+
Main Assembly
+
+

@currHwSwInfo.mainAssembly

+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
Server Stats
+
+

+

@currHwSwInfo.ServerStats
+

+
+
+
+
IIS Stats
+
+

+

@currHwSwInfo.IISStats
+

+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
Elenco librerie
+ @currHwSwInfo.numLibraries +
+

+

@currHwSwInfo.librariesVers
+

+
+
+
+
+
+
+
+
+
+
+
+
+@code { + + // imposto i vari dati da mostrare a video senza indicare come bypassare... + protected string Titolo = "MAPO System Info"; + protected string Messaggio = "HW & SW details"; + protected HwSwInfo currHwSwInfo = HwSwInfo.man(System.Reflection.Assembly.GetExecutingAssembly()); + protected string DbNameExample + { + get + { + string answ = Configuration["ConnectionStrings:DefaultConnection"]; + if (answ.IndexOf(";User ID=") > 0) + { + answ = answ.Substring(0, answ.IndexOf(";User ID=")); + } + return answ; + } + } + protected string Environment + { + get + { + string answ = Configuration["Environment"]; + return answ; + } + } + + //string connStr = memLayer.ML.confReadString("DbConfConnectionString"); + //currHwSwInfo = currHwSwInfo; +} \ No newline at end of file diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html index c29839f6..65defe79 100644 --- a/MP.Land/Resources/ChangeLog.html +++ b/MP.Land/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo gestione Programmi MAPO -

Versione: 1.1.2109.2116

+

Versione: 1.1.2109.2117


Note di rilascio: