Commit 735c2a0810cb0d6b75e0f3d0609356c26d05c69c

Authored by Schwirg László
1 parent 734d70bb

v1.21.0.0

- WebApp info kiegészítésre került a w3wp.exe információkkal
Vrh.Log4Pro.MaintenanceConsole/Manager - WebApplicationManager.cs
@@ -21,7 +21,6 @@ using System.Xml.Linq; @@ -21,7 +21,6 @@ using System.Xml.Linq;
21 21
22 namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS 22 namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS
23 { 23 {
24 - #region WebApplicationManager  
25 public static class WebApplicationManager 24 public static class WebApplicationManager
26 { 25 {
27 internal const string XMLCONNECTIONSTRING = "config=MAINTENANCECONSOLE_WEBAPPLICATIONMANAGER;"; 26 internal const string XMLCONNECTIONSTRING = "config=MAINTENANCECONSOLE_WEBAPPLICATIONMANAGER;";
@@ -600,6 +599,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS @@ -600,6 +599,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS
600 { 599 {
601 WebApplication wa = (obj as Menu.ExecutorParameter).Parameters as WebApplication; 600 WebApplication wa = (obj as Menu.ExecutorParameter).Parameters as WebApplication;
602 var numofvd = wa.Xml_VirtualDirectoryList?.Count()??0; 601 var numofvd = wa.Xml_VirtualDirectoryList?.Count()??0;
  602 +
  603 + //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++; } } }
  604 + var numofwp= wa.WorkerProcesses?.Count() ?? 0;
603 if (lineix == 0) 605 if (lineix == 0)
604 { 606 {
605 ColorConsole.WriteLine($"{wa.Xml_Description}", ConsoleColor.Black, ConsoleColor.White); 607 ColorConsole.WriteLine($"{wa.Xml_Description}", ConsoleColor.Black, ConsoleColor.White);
@@ -647,22 +649,44 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS @@ -647,22 +649,44 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS
647 ColorConsole.Write($", identity:"); 649 ColorConsole.Write($", identity:");
648 ColorConsole.WriteLine($"{wa.PoolAccount}", ConsoleColor.White); 650 ColorConsole.WriteLine($"{wa.PoolAccount}", ConsoleColor.White);
649 } 651 }
650 - else if (5 <= lineix && lineix <= 5+numofvd) 652 + else if (5 <= lineix && lineix < 5+numofvd)
651 { 653 {
652 var elementindex = lineix - 5; 654 var elementindex = lineix - 5;
653 - if (numofvd==0 || elementindex > numofvd - 1) { ColorConsole.WriteLine(); } 655 + var currentelement = wa.Xml_VirtualDirectoryList.ElementAt(elementindex);
  656 + ColorConsole.Write($"Virtual directory:");
  657 + ColorConsole.Write($"{currentelement.VirtualPath}", ConsoleColor.Cyan);
  658 + ColorConsole.Write($", (");
  659 + ColorConsole.Write($"{currentelement.PhysicalPath}", ConsoleColor.Cyan);
  660 + ColorConsole.WriteLine($")");
  661 + }
  662 + else if (5+numofvd <= lineix && lineix < 5 + numofvd + numofwp)
  663 + {
  664 + var elementindex = lineix - (5 + numofvd);
  665 + if (numofwp == 0 || elementindex > numofwp - 1) { ColorConsole.WriteLine(); }
654 else 666 else
655 { 667 {
656 - var currentelement = wa.Xml_VirtualDirectoryList.ElementAt(elementindex);  
657 - ColorConsole.Write($"Virtual directory:");  
658 - ColorConsole.Write($"{currentelement.VirtualPath}", ConsoleColor.Cyan); 668 + var currentelement = wa.WorkerProcesses.ElementAt(elementindex);
  669 + var currentelementislocallystored = currentelement.islocallystored ? "Locally stored" : "Not locally stored";
  670 + ColorConsole.Write($"WorkerProcess id:");
  671 + ColorConsole.Write($"{currentelement.pid}", ConsoleColor.Cyan);
659 ColorConsole.Write($", ("); 672 ColorConsole.Write($", (");
660 - ColorConsole.Write($"{currentelement.PhysicalPath}", ConsoleColor.Cyan);  
661 - ColorConsole.WriteLine($")"); 673 + ColorConsole.Write($"{currentelement.state}", ConsoleColor.Cyan);
  674 + ColorConsole.Write($", ");
  675 + ColorConsole.Write($"{currentelementislocallystored}", ConsoleColor.Cyan);
  676 + ColorConsole.Write($"); ");
  677 + foreach (var ad in currentelement.appdomains)
  678 + {
  679 + ColorConsole.Write($"[ViP:");
  680 + ColorConsole.Write($"{ad.Item1},", ConsoleColor.Cyan);
  681 + ColorConsole.Write($"PhP:{ad.Item2}");
  682 + ColorConsole.Write($"]");
  683 + }
  684 + ColorConsole.WriteLine();
662 } 685 }
663 } 686 }
664 else 687 else
665 { 688 {
  689 + ColorConsole.WriteLine();
666 return null; 690 return null;
667 } 691 }
668 return ""; 692 return "";
@@ -742,6 +766,11 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS @@ -742,6 +766,11 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS
742 wa.PoolState = "Unregistered/Unknown"; 766 wa.PoolState = "Unregistered/Unknown";
743 wa.PoolAccount = ""; 767 wa.PoolAccount = "";
744 } 768 }
  769 + try
  770 + {
  771 + wa.WorkerProcesses = GetWorkerProcesses(wa);
  772 + }
  773 + catch { }
745 return wa; 774 return wa;
746 } 775 }
747 } 776 }
@@ -848,6 +877,32 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS @@ -848,6 +877,32 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS
848 #endregion private method:CommitChanges 877 #endregion private method:CommitChanges
849 878
850 #region private methods: Get information (with no ServerManager parameter) 879 #region private methods: Get information (with no ServerManager parameter)
  880 + public static List<MyWorkerProcess> GetWorkerProcesses(WebApplication wa)
  881 + {
  882 + using (ServerManager manager = new ServerManager())
  883 + {
  884 + return manager.ApplicationPools.Where(p=>p.Name==wa.ApplicationPool.Name).SelectMany(pool => pool.WorkerProcesses).Select(wp=>new MyWorkerProcess(wp)).ToList();
  885 + }
  886 + }
  887 + public class MyWorkerProcess
  888 + {
  889 + public string poolname;
  890 + public int pid;
  891 + public WorkerProcessState state;
  892 + public bool islocallystored;
  893 + public List<Tuple<string, string>> appdomains =new List<Tuple<string, string>>();
  894 + public MyWorkerProcess(WorkerProcess wp)
  895 + {
  896 + poolname = wp.AppPoolName;
  897 + pid = wp.ProcessId;
  898 + state = wp.State;
  899 + islocallystored=wp.IsLocallyStored;
  900 + foreach (var ad in wp.ApplicationDomains)
  901 + {
  902 + appdomains.Add(Tuple.Create(ad.VirtualPath, ad.PhysicalPath));
  903 + }
  904 + }
  905 + }
851 public static string GetCurrentImpersonateIdentityInfo(WebApplication wa) 906 public static string GetCurrentImpersonateIdentityInfo(WebApplication wa)
852 { 907 {
853 var filepath = wa.Xml_ImpersonateIdentityConfigFile; 908 var filepath = wa.Xml_ImpersonateIdentityConfigFile;
@@ -1154,6 +1209,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS @@ -1154,6 +1209,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS
1154 #endregion GetDefinitionList 1209 #endregion GetDefinitionList
1155 } 1210 }
1156 #endregion WebApplicationManagerXmlProcessor class 1211 #endregion WebApplicationManagerXmlProcessor class
  1212 +
1157 #region WebApplication class 1213 #region WebApplication class
1158 public class WebApplication : XmlLinqBase 1214 public class WebApplication : XmlLinqBase
1159 { 1215 {
@@ -1193,7 +1249,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS @@ -1193,7 +1249,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS
1193 public Application Application; 1249 public Application Application;
1194 public string ApplicationState; 1250 public string ApplicationState;
1195 public string ApplicationPath; 1251 public string ApplicationPath;
  1252 + public List<WebApplicationManagerCore.MyWorkerProcess> WorkerProcesses;
1196 #endregion properties from environment 1253 #endregion properties from environment
  1254 +
1197 public WebApplication() { } 1255 public WebApplication() { }
1198 public WebApplication(XElement webappXml) 1256 public WebApplication(XElement webappXml)
1199 { 1257 {
@@ -1420,9 +1478,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS @@ -1420,9 +1478,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS
1420 } 1478 }
1421 } 1479 }
1422 #endregion XmlStructure 1480 #endregion XmlStructure
1423 - #endregion WebApplicationManager  
1424 } 1481 }
1425 #endregion WebApplication class 1482 #endregion WebApplication class
  1483 +
1426 #region VirtualDirectory class 1484 #region VirtualDirectory class
1427 #endregion VirtualDirectory class 1485 #endregion VirtualDirectory class
1428 } 1486 }
Vrh.Log4Pro.MaintenanceConsole/Program.cs
@@ -37,6 +37,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole @@ -37,6 +37,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole
37 { 37 {
38 static void Main(string[] args) 38 static void Main(string[] args)
39 { 39 {
  40 + //TESTS.GetWorkingProcesses();
  41 + //return;
40 var forcedmodulekey = CommandLine.GetCommandLineArgument(args, CLP.CMD_MODULE); 42 var forcedmodulekey = CommandLine.GetCommandLineArgument(args, CLP.CMD_MODULE);
41 var commandmode = !string.IsNullOrEmpty(forcedmodulekey); 43 var commandmode = !string.IsNullOrEmpty(forcedmodulekey);
42 var silentmode = commandmode && !string.IsNullOrEmpty(CommandLine.GetCommandLineArgument(args, CLP.CMD_SILENT, switchtype: true)); 44 var silentmode = commandmode && !string.IsNullOrEmpty(CommandLine.GetCommandLineArgument(args, CLP.CMD_SILENT, switchtype: true));
@@ -88,6 +90,28 @@ namespace Vrh.Log4Pro.MaintenanceConsole @@ -88,6 +90,28 @@ namespace Vrh.Log4Pro.MaintenanceConsole
88 ColorConsole.PressAnykeyToContinue(); 90 ColorConsole.PressAnykeyToContinue();
89 } 91 }
90 } 92 }
  93 + public static class TESTS
  94 + {
  95 + public static void GetWorkingProcesses()
  96 + {
  97 + using (ServerManager manager = new ServerManager())
  98 + {
  99 + var workerprocesses = manager.ApplicationPools.SelectMany(pool => pool.WorkerProcesses);
  100 + var workerprocessesCount = workerprocesses.Count();
  101 + Console.WriteLine($"Number of worker processes: {workerprocessesCount}");
  102 + foreach (var wp in workerprocesses)
  103 + {
  104 + Console.WriteLine($"process AppPoolName: {wp.AppPoolName}, process ProcessId: {wp.ProcessId}, process State: {wp.State}, process IsLocallyStored: {wp.IsLocallyStored}");
  105 + Console.WriteLine($" ApplicationDomains: {wp.ApplicationDomains.Count()}");
  106 + foreach (var ad in wp.ApplicationDomains)
  107 + {
  108 + Console.WriteLine($" VirtualPath: {ad.VirtualPath}, PhysicalPath: {ad.PhysicalPath}");
  109 + }
  110 + }
  111 + }
  112 + Console.ReadKey();
  113 + }
  114 + }
91 115
92 #region MaintenanceConsoleXmlProcessor class 116 #region MaintenanceConsoleXmlProcessor class
93 public class MaintenanceConsoleXmlProcessor : XmlParser 117 public class MaintenanceConsoleXmlProcessor : XmlParser
Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; @@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
32 // You can specify all the values or you can default the Build and Revision Numbers 32 // You can specify all the values or you can default the Build and Revision Numbers
33 // by using the '*' as shown below: 33 // by using the '*' as shown below:
34 // [assembly: AssemblyVersion("1.0.*")] 34 // [assembly: AssemblyVersion("1.0.*")]
35 -[assembly: AssemblyVersion("1.20.1.0")]  
36 -[assembly: AssemblyFileVersion("1.20.1.0")] 35 +[assembly: AssemblyVersion("1.21.0.0")]
  36 +[assembly: AssemblyFileVersion("1.21.0.0")]