289 lines
9.1 KiB
C#
289 lines
9.1 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.CodeDom.Compiler;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using Microsoft.VisualBasic.Devices;
|
|
|
|
namespace CMS_SC
|
|
{
|
|
public partial class About : System.Web.UI.Page
|
|
{
|
|
protected Assembly assembly = Assembly.GetExecutingAssembly();
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
// faccio reset... sessioni e vocabolario..
|
|
doReset();
|
|
}
|
|
}
|
|
|
|
private void doReset()
|
|
{
|
|
string action = memLayer.ML.QSS("Action");
|
|
string testo = "<h3>Reset Actions</h3>";
|
|
long recPrev = 0;
|
|
long recPost = 0;
|
|
if (action != "")
|
|
{
|
|
if (action.Contains("C"))
|
|
{
|
|
recPrev = Cache.Count;
|
|
// reset dati in cache...
|
|
memLayer.ML.flushRegisteredCache();
|
|
recPost = Cache.Count;
|
|
testo += string.Format("Reset Cache: {0} --> {1}</br>", recPrev, recPost);
|
|
}
|
|
if (action.Contains("D"))
|
|
{
|
|
recPrev = memLayer.ML.numRecAppConf;
|
|
// reset dati in cache x DbConfig...
|
|
memLayer.ML.resetAppConf();
|
|
recPost = memLayer.ML.numRecAppConf;
|
|
testo += string.Format("Reset DB AppConf: {0} --> {1}</br>", recPrev, recPost);
|
|
}
|
|
if (action.Contains("R"))
|
|
{
|
|
recPrev = memLayer.ML.numRecRedis;
|
|
// reset dati in cache x DbConfig...
|
|
memLayer.ML.redFlushKey("**");
|
|
recPost = memLayer.ML.numRecRedis;
|
|
testo += string.Format("Reset Redis: {0} --> {1}</br>", recPrev, recPost);
|
|
}
|
|
if (action.Contains("S"))
|
|
{
|
|
recPrev = Session.Count;
|
|
// reset dati in sessione...
|
|
Session.Clear();
|
|
recPost = Session.Count;
|
|
testo += string.Format("Reset Sessione: {0} --> {1}</br>", recPrev, recPost);
|
|
}
|
|
if (action.Contains("V"))
|
|
{
|
|
recPrev = DataWrap.DW.numRecVoc;
|
|
// aggiorno vocabolario
|
|
DataWrap.DW.resetVocabolario();
|
|
recPost = DataWrap.DW.numRecVoc;
|
|
testo += string.Format("Reset Vocabolario: {0} --> {1}</br>", recPrev, recPost);
|
|
}
|
|
}
|
|
lblOut.Text = testo;
|
|
}
|
|
/// <summary>
|
|
/// Restitusice l'elenco pareto (decrescente) delle dimensioni browser registrate
|
|
/// </summary>
|
|
public string paretoBrowserSize
|
|
{
|
|
get
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
string redHash = memLayer.ML.redHash("COUNT:wh:*");
|
|
int numRec = memLayer.ML.redCountKey(redHash);
|
|
List<KeyValuePair<string, int>> kvp = memLayer.ML.redGetCounterByKey(redHash, memLayer.kvpOrderBy.ValDesc);
|
|
// riordino elenco
|
|
|
|
sb.AppendLine(string.Format("Trovate {0} combinazioni", numRec));
|
|
foreach (var item in kvp)
|
|
{
|
|
sb.AppendLine(string.Format("{0}: {1}", item.Key.Replace(memLayer.ML.redHash("COUNT:wh:"), ""), item.Value));
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Formatta un numero da int a size in Kb/Mb/Gb/Tb
|
|
/// </summary>
|
|
/// <param name="rawSize"></param>
|
|
/// <returns></returns>
|
|
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]);
|
|
}
|
|
/// <summary>
|
|
/// Dati sui server redis...
|
|
/// </summary>
|
|
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<string, System.Collections.Generic.KeyValuePair<string, string>> 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)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in redisServersData{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Stringa timing
|
|
/// </summary>
|
|
/// <param name="time"></param>
|
|
/// <returns></returns>
|
|
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);
|
|
}
|
|
/// <summary>
|
|
/// Statistiche server
|
|
/// </summary>
|
|
public string ServerStats
|
|
{
|
|
get
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
try
|
|
{
|
|
// calcoli preliminari
|
|
TimeSpan uptime;
|
|
using (var uptimeCounter = new PerformanceCounter("System", "System Up Time"))
|
|
{
|
|
uptimeCounter.NextValue();
|
|
uptime = TimeSpan.FromSeconds(uptimeCounter.NextValue());
|
|
}
|
|
var computer = new ComputerInfo();
|
|
|
|
// compongo output
|
|
sb.AppendLine(string.Format("NAME: {0}", Environment.MachineName));
|
|
sb.AppendLine(Environment.OSVersion.VersionString);
|
|
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)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in ServerStats{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
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();
|
|
}
|
|
}
|
|
public string mainAssembly
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = assembly.FullName;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
public string runtimeImg
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = assembly.ImageRuntimeVersion;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Num di librerie inserite
|
|
/// </summary>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
} |