Commit bfb6894de0a2016ce6cef887114a4734a2b8841a
1 parent
7eaab142
v1.7.0
- WebApplicationMnagaerben virtuális directory-k definiálási lehetősége
Showing
2 changed files
with
72 additions
and
14 deletions
Show diff stats
Vrh.Log4Pro.MaintenanceConsole/Manager - WebApplicationManager.cs
| ... | ... | @@ -331,7 +331,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS |
| 331 | 331 | foreach (var p in sr.SelectedParameterList) |
| 332 | 332 | { |
| 333 | 333 | WebApplication wa=p.Parameters as WebApplication; |
| 334 | - 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); | |
| 334 | + 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); | |
| 335 | 335 | ColorConsole.WriteLine($"{wa.Xml_AppName} is registered in site {wa.Xml_SiteName} using pool {wa.Xml_PoolName}."); |
| 336 | 336 | } |
| 337 | 337 | return o; |
| ... | ... | @@ -505,6 +505,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS |
| 505 | 505 | private static object DisplayWebAppInfo(object obj, int lineix) |
| 506 | 506 | { |
| 507 | 507 | WebApplication wa = (obj as Menu.ExecutorParameter).Parameters as WebApplication; |
| 508 | + var numofvd = wa.Xml_VirtualDirectoryList?.Count()??0; | |
| 508 | 509 | if (lineix == 0) |
| 509 | 510 | { |
| 510 | 511 | ColorConsole.WriteLine($"{wa.Xml_Description}", ConsoleColor.Black, ConsoleColor.White); |
| ... | ... | @@ -552,9 +553,19 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS |
| 552 | 553 | ColorConsole.Write($", identity:"); |
| 553 | 554 | ColorConsole.WriteLine($"{wa.PoolAccount}", ConsoleColor.White); |
| 554 | 555 | } |
| 555 | - else if (lineix == 5) | |
| 556 | + else if (5 <= lineix && lineix <= 5+numofvd) | |
| 556 | 557 | { |
| 557 | - ColorConsole.WriteLine(); | |
| 558 | + var elementindex = lineix - 5; | |
| 559 | + if (numofvd==0 || elementindex > numofvd - 1) { ColorConsole.WriteLine(); } | |
| 560 | + else | |
| 561 | + { | |
| 562 | + var currentelement = wa.Xml_VirtualDirectoryList.ElementAt(elementindex); | |
| 563 | + ColorConsole.Write($"Virtual directory:"); | |
| 564 | + ColorConsole.Write($"{currentelement.VirtualPath}", ConsoleColor.Cyan); | |
| 565 | + ColorConsole.Write($", ("); | |
| 566 | + ColorConsole.Write($"{currentelement.PhysicalPath}", ConsoleColor.Cyan); | |
| 567 | + ColorConsole.WriteLine($")"); | |
| 568 | + } | |
| 558 | 569 | } |
| 559 | 570 | else |
| 560 | 571 | { |
| ... | ... | @@ -655,7 +666,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS |
| 655 | 666 | } |
| 656 | 667 | |
| 657 | 668 | #region private method:RegisterWebApplication |
| 658 | - public static void RegisterWebApplication(string sitename, string poolname, string appname, string poolphypath, string sitephypath, int siteport, bool recreatepool, bool recreatesite, bool recreateapp,ManagedPipelineMode plmode) | |
| 669 | + 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<WebApplication.VirtualDirectory> vdlist) | |
| 659 | 670 | { |
| 660 | 671 | using (ServerManager serverManager = new ServerManager()) |
| 661 | 672 | { |
| ... | ... | @@ -668,8 +679,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS |
| 668 | 679 | SetItemProperty(serverManager, poolname, "managedRuntimeVersion", "v4.0"); |
| 669 | 680 | SetItemProperty(serverManager, poolname, "enable32BitAppOnWin64", "true"); |
| 670 | 681 | |
| 671 | - if (!isExistWebApp(serverManager, sitename, appname)) { CreateWebApp(serverManager, appname, poolname, sitename, poolphypath); } | |
| 672 | - else if (recreateapp) { RemoveWebApp(serverManager, appname, sitename); CreateWebApp(serverManager, appname, poolname, sitename, poolphypath); } | |
| 682 | + if (!isExistWebApp(serverManager, sitename, appname)) { CreateWebApp(serverManager, appname, poolname, sitename, poolphypath, vdlist); } | |
| 683 | + else if (recreateapp) { RemoveWebApp(serverManager, appname, sitename); CreateWebApp(serverManager, appname, poolname, sitename, poolphypath, vdlist); } | |
| 673 | 684 | |
| 674 | 685 | CommitChanges(serverManager, poolname); |
| 675 | 686 | } |
| ... | ... | @@ -926,13 +937,20 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS |
| 926 | 937 | ApplicationPool pool = serverManager.ApplicationPools[poolname]; |
| 927 | 938 | pool.ManagedPipelineMode = plmode; |
| 928 | 939 | } |
| 929 | - private static void CreateWebApp(ServerManager serverManager, string appname, string poolname, string sitename, string poolphypath) | |
| 940 | + private static void CreateWebApp(ServerManager serverManager, string appname, string poolname, string sitename, string poolphypath,List<WebApplication.VirtualDirectory> vdlist) | |
| 930 | 941 | { |
| 942 | + appname = Path.Combine("/", appname); | |
| 931 | 943 | Site site = serverManager.Sites[sitename]; |
| 932 | - Application application = site.Applications[Path.Combine("/",appname)]; | |
| 944 | + Application application = site.Applications[appname]; | |
| 933 | 945 | if (application != null) { site.Applications.Remove(application); } |
| 934 | - application = site.Applications.Add(Path.Combine("/",appname), poolphypath); | |
| 946 | + application = site.Applications.Add(appname, poolphypath); | |
| 935 | 947 | application.ApplicationPoolName = poolname; |
| 948 | + | |
| 949 | + foreach (var vd in vdlist) | |
| 950 | + { | |
| 951 | + application.VirtualDirectories.Add(vd.VirtualPath, vd.PhysicalPath); | |
| 952 | + } | |
| 953 | + serverManager.CommitChanges(); | |
| 936 | 954 | } |
| 937 | 955 | private static void CreateWebSite(ServerManager serverManager, string sitename, string poolname, string hostheader, string sitephypath, int siteport = 8000) |
| 938 | 956 | { |
| ... | ... | @@ -979,11 +997,11 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS |
| 979 | 997 | CommitChanges(serverManager, poolname); |
| 980 | 998 | } |
| 981 | 999 | } |
| 982 | - private static void CreateWebApp(string appname, string poolname, string sitename, string poolphypath) | |
| 1000 | + private static void CreateWebApp(string appname, string poolname, string sitename, string poolphypath, List<WebApplication.VirtualDirectory> vdlist) | |
| 983 | 1001 | { |
| 984 | 1002 | using (ServerManager serverManager = new ServerManager()) |
| 985 | 1003 | { |
| 986 | - CreateWebApp(serverManager, appname, poolname, sitename, poolphypath); | |
| 1004 | + CreateWebApp(serverManager, appname, poolname, sitename, poolphypath,vdlist); | |
| 987 | 1005 | CommitChanges(serverManager, poolname); |
| 988 | 1006 | } |
| 989 | 1007 | } |
| ... | ... | @@ -1065,6 +1083,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS |
| 1065 | 1083 | public bool Xml_RecreateApp; |
| 1066 | 1084 | public bool Xml_ForceRemovePool; |
| 1067 | 1085 | public bool Xml_ForceRemoveSite; |
| 1086 | + public List<VirtualDirectory> Xml_VirtualDirectoryList; | |
| 1068 | 1087 | #endregion properties from Xml definition |
| 1069 | 1088 | |
| 1070 | 1089 | #region properties from environment |
| ... | ... | @@ -1120,6 +1139,20 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS |
| 1120 | 1139 | |
| 1121 | 1140 | Xml_ForceRemovePool = GetValue(nameof(XmlStructure.WebApplication.Attributes.ForceRemovePool), webappXml, false); |
| 1122 | 1141 | Xml_ForceRemoveSite = GetValue(nameof(XmlStructure.WebApplication.Attributes.ForceRemoveSite), webappXml, false); |
| 1142 | + | |
| 1143 | + Xml_VirtualDirectoryList = new List<VirtualDirectory>(); | |
| 1144 | + try | |
| 1145 | + { | |
| 1146 | + var vddefinitionXmlList = GetAllXElements(webappXml, nameof(XmlStructure.WebApplication.VirtualDirectory)); | |
| 1147 | + if (vddefinitionXmlList != null && vddefinitionXmlList.Any()) | |
| 1148 | + { | |
| 1149 | + foreach (var vddefinitionXml in vddefinitionXmlList) | |
| 1150 | + { | |
| 1151 | + Xml_VirtualDirectoryList.Add(new VirtualDirectory(vddefinitionXml)); | |
| 1152 | + } | |
| 1153 | + } | |
| 1154 | + } | |
| 1155 | + catch { } | |
| 1123 | 1156 | } |
| 1124 | 1157 | public WebApplication(WebApplication wadef) |
| 1125 | 1158 | { |
| ... | ... | @@ -1139,12 +1172,27 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS |
| 1139 | 1172 | Xml_RecreateApp = wadef.Xml_RecreateApp; |
| 1140 | 1173 | Xml_ForceRemovePool = wadef.Xml_ForceRemovePool; |
| 1141 | 1174 | Xml_ForceRemoveSite = wadef.Xml_ForceRemoveSite; |
| 1175 | + Xml_VirtualDirectoryList = wadef.Xml_VirtualDirectoryList.Select(x => new VirtualDirectory(x)).ToList(); | |
| 1142 | 1176 | |
| 1143 | 1177 | Xml_ImpersonateIdentityConfigFile = wadef.Xml_ImpersonateIdentityConfigFile; |
| 1144 | 1178 | Xml_ImpersonateIdentity = wadef.Xml_ImpersonateIdentity; |
| 1145 | 1179 | Xml_ImpersonateIdentityUsername = wadef.Xml_ImpersonateIdentityUsername; |
| 1146 | 1180 | Xml_ImpersonateIdentityPassword = wadef.Xml_ImpersonateIdentityPassword; |
| 1147 | 1181 | } |
| 1182 | + | |
| 1183 | + public class VirtualDirectory : XmlLinqBase | |
| 1184 | + { | |
| 1185 | + public string VirtualPath; | |
| 1186 | + public string PhysicalPath; | |
| 1187 | + public VirtualDirectory(string vpath, string ppath) { VirtualPath = vpath; PhysicalPath = ppath; } | |
| 1188 | + public VirtualDirectory(VirtualDirectory vd) { VirtualPath = vd.VirtualPath; PhysicalPath = vd.PhysicalPath; } | |
| 1189 | + public VirtualDirectory(XElement vdxml) | |
| 1190 | + { | |
| 1191 | + VirtualPath = GetValue(nameof(XmlStructure.WebApplication.VirtualDirectory.Attributes.VirtualPath), vdxml, ""); | |
| 1192 | + PhysicalPath = GetValue(nameof(XmlStructure.WebApplication.VirtualDirectory.Attributes.PhysicalPath), vdxml, ""); | |
| 1193 | + } | |
| 1194 | + } | |
| 1195 | + | |
| 1148 | 1196 | #region XmlStructure |
| 1149 | 1197 | public static class XmlStructure |
| 1150 | 1198 | { |
| ... | ... | @@ -1172,10 +1220,20 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS |
| 1172 | 1220 | public static class ForceRemovePool { } |
| 1173 | 1221 | public static class ForceRemoveSite { } |
| 1174 | 1222 | } |
| 1223 | + public static class VirtualDirectory | |
| 1224 | + { | |
| 1225 | + public static class Attributes | |
| 1226 | + { | |
| 1227 | + public static class VirtualPath {} | |
| 1228 | + public static class PhysicalPath {} | |
| 1229 | + } | |
| 1230 | + } | |
| 1175 | 1231 | } |
| 1176 | 1232 | } |
| 1177 | 1233 | #endregion XmlStructure |
| 1234 | + #endregion WebApplicationManager | |
| 1178 | 1235 | } |
| 1179 | 1236 | #endregion WebApplication class |
| 1180 | - #endregion WebApplicationManager | |
| 1237 | + #region VirtualDirectory class | |
| 1238 | + #endregion VirtualDirectory class | |
| 1181 | 1239 | } | ... | ... |
Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
| ... | ... | @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; |
| 32 | 32 | // You can specify all the values or you can default the Build and Revision Numbers |
| 33 | 33 | // by using the '*' as shown below: |
| 34 | 34 | // [assembly: AssemblyVersion("1.0.*")] |
| 35 | -[assembly: AssemblyVersion("1.6.3.0")] | |
| 36 | -[assembly: AssemblyFileVersion("1.6.3.0")] | |
| 35 | +[assembly: AssemblyVersion("1.7.0.0")] | |
| 36 | +[assembly: AssemblyFileVersion("1.7.0.0")] | ... | ... |