diff --git a/Vrh.Log4Pro.MaintenanceConsole/Manager - WebApplicationManager.cs b/Vrh.Log4Pro.MaintenanceConsole/Manager - WebApplicationManager.cs index 063fa4d..cac9a35 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/Manager - WebApplicationManager.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/Manager - WebApplicationManager.cs @@ -331,7 +331,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS foreach (var p in sr.SelectedParameterList) { WebApplication wa=p.Parameters as WebApplication; - WebApplicationManagerCore.RegisterWebApplication(wa.Xml_SiteName, wa.Xml_PoolName, wa.Xml_AppName, wa.Xml_AppPhysicalPath, wa.Xml_SitePhysicalPath, 8080, wa.Xml_RecreatePool, wa.Xml_RecreateSite, wa.Xml_RecreateApp, wa.Xml_PoolPipeLineMode); + WebApplicationManagerCore.RegisterWebApplication(wa.Xml_SiteName, wa.Xml_PoolName, wa.Xml_AppName, wa.Xml_AppPhysicalPath, wa.Xml_SitePhysicalPath, 8080, wa.Xml_RecreatePool, wa.Xml_RecreateSite, wa.Xml_RecreateApp, wa.Xml_PoolPipeLineMode,wa.Xml_VirtualDirectoryList); ColorConsole.WriteLine($"{wa.Xml_AppName} is registered in site {wa.Xml_SiteName} using pool {wa.Xml_PoolName}."); } return o; @@ -505,6 +505,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS private static object DisplayWebAppInfo(object obj, int lineix) { WebApplication wa = (obj as Menu.ExecutorParameter).Parameters as WebApplication; + var numofvd = wa.Xml_VirtualDirectoryList?.Count()??0; if (lineix == 0) { ColorConsole.WriteLine($"{wa.Xml_Description}", ConsoleColor.Black, ConsoleColor.White); @@ -552,9 +553,19 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS ColorConsole.Write($", identity:"); ColorConsole.WriteLine($"{wa.PoolAccount}", ConsoleColor.White); } - else if (lineix == 5) + else if (5 <= lineix && lineix <= 5+numofvd) { - ColorConsole.WriteLine(); + var elementindex = lineix - 5; + if (numofvd==0 || elementindex > numofvd - 1) { ColorConsole.WriteLine(); } + else + { + 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 { @@ -655,7 +666,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS } #region private method:RegisterWebApplication - public static void RegisterWebApplication(string sitename, string poolname, string appname, string poolphypath, string sitephypath, int siteport, bool recreatepool, bool recreatesite, bool recreateapp,ManagedPipelineMode plmode) + public static void RegisterWebApplication(string sitename, string poolname, string appname, string poolphypath, string sitephypath, int siteport, bool recreatepool, bool recreatesite, bool recreateapp,ManagedPipelineMode plmode,List vdlist) { using (ServerManager serverManager = new ServerManager()) { @@ -668,8 +679,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS SetItemProperty(serverManager, poolname, "managedRuntimeVersion", "v4.0"); SetItemProperty(serverManager, poolname, "enable32BitAppOnWin64", "true"); - if (!isExistWebApp(serverManager, sitename, appname)) { CreateWebApp(serverManager, appname, poolname, sitename, poolphypath); } - else if (recreateapp) { RemoveWebApp(serverManager, appname, sitename); CreateWebApp(serverManager, appname, poolname, sitename, poolphypath); } + if (!isExistWebApp(serverManager, sitename, appname)) { CreateWebApp(serverManager, appname, poolname, sitename, poolphypath, vdlist); } + else if (recreateapp) { RemoveWebApp(serverManager, appname, sitename); CreateWebApp(serverManager, appname, poolname, sitename, poolphypath, vdlist); } CommitChanges(serverManager, poolname); } @@ -926,13 +937,20 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS ApplicationPool pool = serverManager.ApplicationPools[poolname]; pool.ManagedPipelineMode = plmode; } - private static void CreateWebApp(ServerManager serverManager, string appname, string poolname, string sitename, string poolphypath) + private static void CreateWebApp(ServerManager serverManager, string appname, string poolname, string sitename, string poolphypath,List vdlist) { + appname = Path.Combine("/", appname); Site site = serverManager.Sites[sitename]; - Application application = site.Applications[Path.Combine("/",appname)]; + Application application = site.Applications[appname]; if (application != null) { site.Applications.Remove(application); } - application = site.Applications.Add(Path.Combine("/",appname), poolphypath); + application = site.Applications.Add(appname, poolphypath); application.ApplicationPoolName = poolname; + + foreach (var vd in vdlist) + { + application.VirtualDirectories.Add(vd.VirtualPath, vd.PhysicalPath); + } + serverManager.CommitChanges(); } private static void CreateWebSite(ServerManager serverManager, string sitename, string poolname, string hostheader, string sitephypath, int siteport = 8000) { @@ -979,11 +997,11 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS CommitChanges(serverManager, poolname); } } - private static void CreateWebApp(string appname, string poolname, string sitename, string poolphypath) + private static void CreateWebApp(string appname, string poolname, string sitename, string poolphypath, List vdlist) { using (ServerManager serverManager = new ServerManager()) { - CreateWebApp(serverManager, appname, poolname, sitename, poolphypath); + CreateWebApp(serverManager, appname, poolname, sitename, poolphypath,vdlist); CommitChanges(serverManager, poolname); } } @@ -1065,6 +1083,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS public bool Xml_RecreateApp; public bool Xml_ForceRemovePool; public bool Xml_ForceRemoveSite; + public List Xml_VirtualDirectoryList; #endregion properties from Xml definition #region properties from environment @@ -1120,6 +1139,20 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS Xml_ForceRemovePool = GetValue(nameof(XmlStructure.WebApplication.Attributes.ForceRemovePool), webappXml, false); Xml_ForceRemoveSite = GetValue(nameof(XmlStructure.WebApplication.Attributes.ForceRemoveSite), webappXml, false); + + Xml_VirtualDirectoryList = new List(); + try + { + var vddefinitionXmlList = GetAllXElements(webappXml, nameof(XmlStructure.WebApplication.VirtualDirectory)); + if (vddefinitionXmlList != null && vddefinitionXmlList.Any()) + { + foreach (var vddefinitionXml in vddefinitionXmlList) + { + Xml_VirtualDirectoryList.Add(new VirtualDirectory(vddefinitionXml)); + } + } + } + catch { } } public WebApplication(WebApplication wadef) { @@ -1139,12 +1172,27 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS Xml_RecreateApp = wadef.Xml_RecreateApp; Xml_ForceRemovePool = wadef.Xml_ForceRemovePool; Xml_ForceRemoveSite = wadef.Xml_ForceRemoveSite; + Xml_VirtualDirectoryList = wadef.Xml_VirtualDirectoryList.Select(x => new VirtualDirectory(x)).ToList(); Xml_ImpersonateIdentityConfigFile = wadef.Xml_ImpersonateIdentityConfigFile; Xml_ImpersonateIdentity = wadef.Xml_ImpersonateIdentity; Xml_ImpersonateIdentityUsername = wadef.Xml_ImpersonateIdentityUsername; Xml_ImpersonateIdentityPassword = wadef.Xml_ImpersonateIdentityPassword; } + + public class VirtualDirectory : XmlLinqBase + { + public string VirtualPath; + public string PhysicalPath; + public VirtualDirectory(string vpath, string ppath) { VirtualPath = vpath; PhysicalPath = ppath; } + public VirtualDirectory(VirtualDirectory vd) { VirtualPath = vd.VirtualPath; PhysicalPath = vd.PhysicalPath; } + public VirtualDirectory(XElement vdxml) + { + VirtualPath = GetValue(nameof(XmlStructure.WebApplication.VirtualDirectory.Attributes.VirtualPath), vdxml, ""); + PhysicalPath = GetValue(nameof(XmlStructure.WebApplication.VirtualDirectory.Attributes.PhysicalPath), vdxml, ""); + } + } + #region XmlStructure public static class XmlStructure { @@ -1172,10 +1220,20 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS public static class ForceRemovePool { } public static class ForceRemoveSite { } } + public static class VirtualDirectory + { + public static class Attributes + { + public static class VirtualPath {} + public static class PhysicalPath {} + } + } } } #endregion XmlStructure + #endregion WebApplicationManager } #endregion WebApplication class - #endregion WebApplicationManager + #region VirtualDirectory class + #endregion VirtualDirectory class } diff --git a/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs b/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs index aea8aaa..900209d 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.6.3.0")] -[assembly: AssemblyFileVersion("1.6.3.0")] +[assembly: AssemblyVersion("1.7.0.0")] +[assembly: AssemblyFileVersion("1.7.0.0")] -- libgit2 0.21.2