diff --git a/Vrh.Log4Pro.MaintenanceConsole/Manager - WebApplicationManager.cs b/Vrh.Log4Pro.MaintenanceConsole/Manager - WebApplicationManager.cs index 582f5cd..4c06a13 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/Manager - WebApplicationManager.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/Manager - WebApplicationManager.cs @@ -21,7 +21,6 @@ using System.Xml.Linq; namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS { - #region WebApplicationManager public static class WebApplicationManager { internal const string XMLCONNECTIONSTRING = "config=MAINTENANCECONSOLE_WEBAPPLICATIONMANAGER;"; @@ -600,6 +599,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS { WebApplication wa = (obj as Menu.ExecutorParameter).Parameters as WebApplication; var numofvd = wa.Xml_VirtualDirectoryList?.Count()??0; + + //var numofwp = 0;if (wa.WorkerProcesses != null) { foreach (var wp in wa.WorkerProcesses) { numofwp++; if (wp.appdomains != null) { foreach (var ad in wp.appdomains) numofwp++; } } } + var numofwp= wa.WorkerProcesses?.Count() ?? 0; if (lineix == 0) { ColorConsole.WriteLine($"{wa.Xml_Description}", ConsoleColor.Black, ConsoleColor.White); @@ -647,22 +649,44 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS ColorConsole.Write($", identity:"); ColorConsole.WriteLine($"{wa.PoolAccount}", ConsoleColor.White); } - else if (5 <= lineix && lineix <= 5+numofvd) + else if (5 <= lineix && lineix < 5+numofvd) { var elementindex = lineix - 5; - if (numofvd==0 || elementindex > numofvd - 1) { ColorConsole.WriteLine(); } + var currentelement = wa.Xml_VirtualDirectoryList.ElementAt(elementindex); + ColorConsole.Write($"Virtual directory:"); + ColorConsole.Write($"{currentelement.VirtualPath}", ConsoleColor.Cyan); + ColorConsole.Write($", ("); + ColorConsole.Write($"{currentelement.PhysicalPath}", ConsoleColor.Cyan); + ColorConsole.WriteLine($")"); + } + else if (5+numofvd <= lineix && lineix < 5 + numofvd + numofwp) + { + var elementindex = lineix - (5 + numofvd); + if (numofwp == 0 || elementindex > numofwp - 1) { ColorConsole.WriteLine(); } else { - var currentelement = wa.Xml_VirtualDirectoryList.ElementAt(elementindex); - ColorConsole.Write($"Virtual directory:"); - ColorConsole.Write($"{currentelement.VirtualPath}", ConsoleColor.Cyan); + var currentelement = wa.WorkerProcesses.ElementAt(elementindex); + var currentelementislocallystored = currentelement.islocallystored ? "Locally stored" : "Not locally stored"; + ColorConsole.Write($"WorkerProcess id:"); + ColorConsole.Write($"{currentelement.pid}", ConsoleColor.Cyan); ColorConsole.Write($", ("); - ColorConsole.Write($"{currentelement.PhysicalPath}", ConsoleColor.Cyan); - ColorConsole.WriteLine($")"); + ColorConsole.Write($"{currentelement.state}", ConsoleColor.Cyan); + ColorConsole.Write($", "); + ColorConsole.Write($"{currentelementislocallystored}", ConsoleColor.Cyan); + ColorConsole.Write($"); "); + foreach (var ad in currentelement.appdomains) + { + ColorConsole.Write($"[ViP:"); + ColorConsole.Write($"{ad.Item1},", ConsoleColor.Cyan); + ColorConsole.Write($"PhP:{ad.Item2}"); + ColorConsole.Write($"]"); + } + ColorConsole.WriteLine(); } } else { + ColorConsole.WriteLine(); return null; } return ""; @@ -742,6 +766,11 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS wa.PoolState = "Unregistered/Unknown"; wa.PoolAccount = ""; } + try + { + wa.WorkerProcesses = GetWorkerProcesses(wa); + } + catch { } return wa; } } @@ -848,6 +877,32 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS #endregion private method:CommitChanges #region private methods: Get information (with no ServerManager parameter) + public static List GetWorkerProcesses(WebApplication wa) + { + using (ServerManager manager = new ServerManager()) + { + return manager.ApplicationPools.Where(p=>p.Name==wa.ApplicationPool.Name).SelectMany(pool => pool.WorkerProcesses).Select(wp=>new MyWorkerProcess(wp)).ToList(); + } + } + public class MyWorkerProcess + { + public string poolname; + public int pid; + public WorkerProcessState state; + public bool islocallystored; + public List> appdomains =new List>(); + public MyWorkerProcess(WorkerProcess wp) + { + poolname = wp.AppPoolName; + pid = wp.ProcessId; + state = wp.State; + islocallystored=wp.IsLocallyStored; + foreach (var ad in wp.ApplicationDomains) + { + appdomains.Add(Tuple.Create(ad.VirtualPath, ad.PhysicalPath)); + } + } + } public static string GetCurrentImpersonateIdentityInfo(WebApplication wa) { var filepath = wa.Xml_ImpersonateIdentityConfigFile; @@ -1154,6 +1209,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS #endregion GetDefinitionList } #endregion WebApplicationManagerXmlProcessor class + #region WebApplication class public class WebApplication : XmlLinqBase { @@ -1193,7 +1249,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS public Application Application; public string ApplicationState; public string ApplicationPath; + public List WorkerProcesses; #endregion properties from environment + public WebApplication() { } public WebApplication(XElement webappXml) { @@ -1420,9 +1478,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS } } #endregion XmlStructure - #endregion WebApplicationManager } #endregion WebApplication class + #region VirtualDirectory class #endregion VirtualDirectory class } diff --git a/Vrh.Log4Pro.MaintenanceConsole/Program.cs b/Vrh.Log4Pro.MaintenanceConsole/Program.cs index cd60efb..fda6f94 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/Program.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/Program.cs @@ -37,6 +37,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole { static void Main(string[] args) { + //TESTS.GetWorkingProcesses(); + //return; var forcedmodulekey = CommandLine.GetCommandLineArgument(args, CLP.CMD_MODULE); var commandmode = !string.IsNullOrEmpty(forcedmodulekey); var silentmode = commandmode && !string.IsNullOrEmpty(CommandLine.GetCommandLineArgument(args, CLP.CMD_SILENT, switchtype: true)); @@ -88,6 +90,28 @@ namespace Vrh.Log4Pro.MaintenanceConsole ColorConsole.PressAnykeyToContinue(); } } + public static class TESTS + { + public static void GetWorkingProcesses() + { + using (ServerManager manager = new ServerManager()) + { + var workerprocesses = manager.ApplicationPools.SelectMany(pool => pool.WorkerProcesses); + var workerprocessesCount = workerprocesses.Count(); + Console.WriteLine($"Number of worker processes: {workerprocessesCount}"); + foreach (var wp in workerprocesses) + { + Console.WriteLine($"process AppPoolName: {wp.AppPoolName}, process ProcessId: {wp.ProcessId}, process State: {wp.State}, process IsLocallyStored: {wp.IsLocallyStored}"); + Console.WriteLine($" ApplicationDomains: {wp.ApplicationDomains.Count()}"); + foreach (var ad in wp.ApplicationDomains) + { + Console.WriteLine($" VirtualPath: {ad.VirtualPath}, PhysicalPath: {ad.PhysicalPath}"); + } + } + } + Console.ReadKey(); + } + } #region MaintenanceConsoleXmlProcessor class public class MaintenanceConsoleXmlProcessor : XmlParser diff --git a/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs b/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs index 501eb97..d68dd5e 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.20.1.0")] -[assembly: AssemblyFileVersion("1.20.1.0")] +[assembly: AssemblyVersion("1.21.0.0")] +[assembly: AssemblyFileVersion("1.21.0.0")] -- libgit2 0.21.2