From c752bb5b442692f00e84a3a0657f0fdc61c753bb Mon Sep 17 00:00:00 2001 From: dev_amdtel Date: Sun, 14 Dec 2014 16:54:02 +0400 Subject: [PATCH 01/32] wsp-10287 WebsitePanel.Server does not run under .net 2.0 --- ...WebsitePanel.Providers.Mail.IceWarp.csproj | 6 +- .../WebsitePanel.Providers.Web.IIs80.csproj | 8 +- .../Sources/WebsitePanel.Server/Web.config | 135 +++++++++--------- .../WebsitePanel.Server.csproj | 3 +- 4 files changed, 81 insertions(+), 71 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.IceWarp/WebsitePanel.Providers.Mail.IceWarp.csproj b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.IceWarp/WebsitePanel.Providers.Mail.IceWarp.csproj index f6df0ed1..3389e9ec 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.IceWarp/WebsitePanel.Providers.Mail.IceWarp.csproj +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.IceWarp/WebsitePanel.Providers.Mail.IceWarp.csproj @@ -17,7 +17,7 @@ true full false - ..\WebsitePanel.Server\bin\ + ..\WebsitePanel.Server\bin\IceWarp\ DEBUG;TRACE prompt 4 @@ -25,7 +25,7 @@ pdbonly true - ..\WebsitePanel.Server\bin\ + ..\WebsitePanel.Server\bin\IceWarp\ TRACE prompt 4 @@ -48,10 +48,12 @@ {684C932A-6C75-46AC-A327-F3689D89EB42} WebsitePanel.Providers.Base + False {E91E52F3-9555-4D00-B577-2B1DBDD87CA7} WebsitePanel.Server.Utils + False diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIs80/WebsitePanel.Providers.Web.IIs80.csproj b/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIs80/WebsitePanel.Providers.Web.IIs80.csproj index dd28ae8c..62f64039 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIs80/WebsitePanel.Providers.Web.IIs80.csproj +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIs80/WebsitePanel.Providers.Web.IIs80.csproj @@ -17,7 +17,7 @@ true full false - ..\WebsitePanel.Server\bin\ + ..\WebsitePanel.Server\bin\IIs80\ DEBUG;TRACE prompt 4 @@ -25,7 +25,7 @@ pdbonly true - ..\WebsitePanel.Server\bin\ + ..\WebsitePanel.Server\bin\IIs80\ TRACE prompt 4 @@ -56,18 +56,22 @@ {684c932a-6c75-46ac-a327-f3689d89eb42} WebsitePanel.Providers.Base + False {9be0317d-e42e-4ff6-9a87-8c801f046ea1} WebsitePanel.Providers.Web.IIs60 + False {1b9dce85-c664-49fc-b6e1-86c63cab88d1} WebsitePanel.Providers.Web.IIs70 + False {e91e52f3-9555-4d00-b577-2b1dbdd87ca7} WebsitePanel.Server.Utils + False diff --git a/WebsitePanel/Sources/WebsitePanel.Server/Web.config b/WebsitePanel/Sources/WebsitePanel.Server/Web.config index f50b8202..d9d1bde5 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/Web.config +++ b/WebsitePanel/Sources/WebsitePanel.Server/Web.config @@ -1,46 +1,51 @@ - + -
-
-
+
+
+
+
+
+
+
+
- - - - - + + + + + - + - + - + - + - + @@ -48,85 +53,85 @@ - + - + - + - + - + - - - + + + - + - - - - + + + + - - + + - - - - + + + + - + - + - - + + - + - + - + - - + + - - + + - - + + - - + + @@ -135,40 +140,40 @@ - - + + - + - - + + - - - - - - - + + + + + + + - - + + - - + + - + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.Server/WebsitePanel.Server.csproj b/WebsitePanel/Sources/WebsitePanel.Server/WebsitePanel.Server.csproj index b21aac2d..8b1d2bb6 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/WebsitePanel.Server.csproj +++ b/WebsitePanel/Sources/WebsitePanel.Server/WebsitePanel.Server.csproj @@ -17,7 +17,7 @@ 4.0 - v4.0 + v3.5 false @@ -79,7 +79,6 @@ - From 08de3dd3380a878dfcc607abc9c3a4e500003a57 Mon Sep 17 00:00:00 2001 From: "a.skorina" Date: Mon, 15 Dec 2014 11:35:56 +0300 Subject: [PATCH 02/32] scheduler installer fix --- .../Setup.SchedulerService/Product.wxs | 29 +++++++++++++++---- .../CustomAction.cs | 29 +++++++++++++++++++ 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/WebsitePanel.Installer/Sources/Setup.SchedulerService/Product.wxs b/WebsitePanel.Installer/Sources/Setup.SchedulerService/Product.wxs index 1fdff4cb..59fc493e 100644 --- a/WebsitePanel.Installer/Sources/Setup.SchedulerService/Product.wxs +++ b/WebsitePanel.Installer/Sources/Setup.SchedulerService/Product.wxs @@ -3,13 +3,23 @@ - + + bannrbmp - + + + + + + + @@ -95,7 +105,9 @@ - + (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL") + + NOT Installed or REINSTALL @@ -103,8 +115,13 @@ - + + + + + + @@ -115,8 +132,8 @@ - - + + diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.SchedulerServiceInstaller/CustomAction.cs b/WebsitePanel.Installer/Sources/WebsitePanel.SchedulerServiceInstaller/CustomAction.cs index eff618a7..dbfaac3c 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.SchedulerServiceInstaller/CustomAction.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.SchedulerServiceInstaller/CustomAction.cs @@ -34,6 +34,7 @@ using System.IO; using System.Linq; using System.ServiceProcess; using System.Text.RegularExpressions; +using System.Threading; using Microsoft.Deployment.WindowsInstaller; using WebsitePanel.Setup; @@ -69,6 +70,14 @@ namespace WebsitePanel.SchedulerServiceInstaller return ActionResult.Success; } + [CustomAction] + public static ActionResult FinalizeUnInstall(Session session) + { + UnInstallService(); + + return ActionResult.Success; + } + private static void InstallService(string installFolder) { try @@ -93,6 +102,26 @@ namespace WebsitePanel.SchedulerServiceInstaller } } + private static void UnInstallService() + { + try + { + var schedulerService = + ServiceController.GetServices().FirstOrDefault( + s => s.DisplayName.Equals("WebsitePanel Scheduler", StringComparison.CurrentCultureIgnoreCase)); + + if (schedulerService != null) + { + StopService(schedulerService.ServiceName); + + SecurityUtils.DeleteService(schedulerService.ServiceName); + } + } + catch (Exception) + { + } + } + private static void ChangeCryptoKey(string installFolder) { string path = Path.Combine(installFolder.Replace("SchedulerService", "Enterprise Server"), "web.config"); From f2db06de56af22457433140356360deb3f8d5ba3 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Mon, 15 Dec 2014 04:41:12 -0800 Subject: [PATCH 03/32] Add/Remove RDS Servers from collection --- .../RemoteDesktopServicesProxy.cs | 91 ++++++++++- .../RemoteDesktopServicesController.cs | 65 +++++++- .../esRemoteDesktopServices.asmx.cs | 10 +- .../IRemoteDesktopServices.cs | 1 + .../Windows2012.cs | 29 ++++ .../RemoteDesktopServicesProxy.cs | 73 +++++++++ .../RemoteDesktopServices.asmx.cs | 17 +++ .../ESModule_ControlsHierarchy.config | 1 + .../App_Data/WebsitePanel_Modules.config | 1 + .../WebsitePanel/Code/Helpers/RDSHelper.cs | 2 +- .../RDSEditCollection.ascx.resx | 144 ++++++++++++++++++ .../WebsitePanel/RDS/RDSCollections.ascx | 4 +- .../WebsitePanel/RDS/RDSCollections.ascx.cs | 5 + .../WebsitePanel/RDS/RDSEditCollection.ascx | 36 +++++ .../RDS/RDSEditCollection.ascx.cs | 42 +++++ .../RDS/RDSEditCollection.ascx.designer.cs | 87 +++++++++++ .../UserControls/RDSCollectionServers.ascx.cs | 34 ++++- .../WebsitePanel.Portal.Modules.csproj | 15 +- 18 files changed, 633 insertions(+), 24 deletions(-) create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/App_LocalResources/RDSEditCollection.ascx.resx create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollection.ascx create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollection.ascx.cs create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollection.ascx.designer.cs diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs index 2bad8a81..acccc914 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs @@ -18,9 +18,8 @@ namespace WebsitePanel.EnterpriseServer { using System.Web.Services.Protocols; using System; using System.Diagnostics; - - using WebsitePanel.Providers.Common; using WebsitePanel.Providers.RemoteDesktopServices; + using WebsitePanel.Providers.Common; using WebsitePanel.Providers.HostedSolution; @@ -37,6 +36,8 @@ namespace WebsitePanel.EnterpriseServer { private System.Threading.SendOrPostCallback AddRdsCollectionOperationCompleted; + private System.Threading.SendOrPostCallback EditRdsCollectionOperationCompleted; + private System.Threading.SendOrPostCallback GetRdsCollectionsPagedOperationCompleted; private System.Threading.SendOrPostCallback RemoveRdsCollectionOperationCompleted; @@ -101,6 +102,9 @@ namespace WebsitePanel.EnterpriseServer { /// public event AddRdsCollectionCompletedEventHandler AddRdsCollectionCompleted; + /// + public event EditRdsCollectionCompletedEventHandler EditRdsCollectionCompleted; + /// public event GetRdsCollectionsPagedCompletedEventHandler GetRdsCollectionsPagedCompleted; @@ -302,6 +306,50 @@ namespace WebsitePanel.EnterpriseServer { } } + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/EditRdsCollection", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public ResultObject EditRdsCollection(int itemId, RdsCollection collection) { + object[] results = this.Invoke("EditRdsCollection", new object[] { + itemId, + collection}); + return ((ResultObject)(results[0])); + } + + /// + public System.IAsyncResult BeginEditRdsCollection(int itemId, RdsCollection collection, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("EditRdsCollection", new object[] { + itemId, + collection}, callback, asyncState); + } + + /// + public ResultObject EndEditRdsCollection(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((ResultObject)(results[0])); + } + + /// + public void EditRdsCollectionAsync(int itemId, RdsCollection collection) { + this.EditRdsCollectionAsync(itemId, collection, null); + } + + /// + public void EditRdsCollectionAsync(int itemId, RdsCollection collection, object userState) { + if ((this.EditRdsCollectionOperationCompleted == null)) { + this.EditRdsCollectionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnEditRdsCollectionOperationCompleted); + } + this.InvokeAsync("EditRdsCollection", new object[] { + itemId, + collection}, this.EditRdsCollectionOperationCompleted, userState); + } + + private void OnEditRdsCollectionOperationCompleted(object arg) { + if ((this.EditRdsCollectionCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.EditRdsCollectionCompleted(this, new EditRdsCollectionCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetRdsCollectionsPaged", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] public RdsCollectionPaged GetRdsCollectionsPaged(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) { @@ -510,9 +558,10 @@ namespace WebsitePanel.EnterpriseServer { /// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetOrganizationRdsServersPaged", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public RdsServersPaged GetOrganizationRdsServersPaged(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) { + public RdsServersPaged GetOrganizationRdsServersPaged(int itemId, [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] System.Nullable collectionId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) { object[] results = this.Invoke("GetOrganizationRdsServersPaged", new object[] { itemId, + collectionId, filterColumn, filterValue, sortColumn, @@ -522,9 +571,10 @@ namespace WebsitePanel.EnterpriseServer { } /// - public System.IAsyncResult BeginGetOrganizationRdsServersPaged(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginGetOrganizationRdsServersPaged(int itemId, System.Nullable collectionId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("GetOrganizationRdsServersPaged", new object[] { itemId, + collectionId, filterColumn, filterValue, sortColumn, @@ -539,17 +589,18 @@ namespace WebsitePanel.EnterpriseServer { } /// - public void GetOrganizationRdsServersPagedAsync(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) { - this.GetOrganizationRdsServersPagedAsync(itemId, filterColumn, filterValue, sortColumn, startRow, maximumRows, null); + public void GetOrganizationRdsServersPagedAsync(int itemId, System.Nullable collectionId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) { + this.GetOrganizationRdsServersPagedAsync(itemId, collectionId, filterColumn, filterValue, sortColumn, startRow, maximumRows, null); } /// - public void GetOrganizationRdsServersPagedAsync(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows, object userState) { + public void GetOrganizationRdsServersPagedAsync(int itemId, System.Nullable collectionId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows, object userState) { if ((this.GetOrganizationRdsServersPagedOperationCompleted == null)) { this.GetOrganizationRdsServersPagedOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetOrganizationRdsServersPagedOperationCompleted); } this.InvokeAsync("GetOrganizationRdsServersPaged", new object[] { itemId, + collectionId, filterColumn, filterValue, sortColumn, @@ -1536,6 +1587,32 @@ namespace WebsitePanel.EnterpriseServer { } } + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void EditRdsCollectionCompletedEventHandler(object sender, EditRdsCollectionCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class EditRdsCollectionCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal EditRdsCollectionCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public ResultObject Result { + get { + this.RaiseExceptionIfNecessary(); + return ((ResultObject)(this.results[0])); + } + } + } + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] public delegate void GetRdsCollectionsPagedCompletedEventHandler(object sender, GetRdsCollectionsPagedCompletedEventArgs e); diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs index c3c154a7..471a6adb 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs @@ -68,6 +68,11 @@ namespace WebsitePanel.EnterpriseServer return AddRdsCollectionInternal(itemId, collection); } + public static ResultObject EditRdsCollection(int itemId, RdsCollection collection) + { + return EditRdsCollectionInternal(itemId, collection); + } + public static RdsCollectionPaged GetRdsCollectionsPaged(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) { return GetRdsCollectionsPagedInternal(itemId, filterColumn, filterValue, sortColumn, startRow, maximumRows); @@ -93,9 +98,9 @@ namespace WebsitePanel.EnterpriseServer return GetFreeRdsServersPagedInternal(filterColumn, filterValue, sortColumn, startRow, maximumRows); } - public static RdsServersPaged GetOrganizationRdsServersPaged(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) + public static RdsServersPaged GetOrganizationRdsServersPaged(int itemId, int? collectionId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) { - return GetOrganizationRdsServersPagedInternal(itemId, filterColumn, filterValue, sortColumn, startRow, maximumRows); + return GetOrganizationRdsServersPagedInternal(itemId, collectionId, filterColumn, filterValue, sortColumn, startRow, maximumRows); } public static RdsServersPaged GetOrganizationFreeRdsServersPaged(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) @@ -285,6 +290,58 @@ namespace WebsitePanel.EnterpriseServer return result; } + private static ResultObject EditRdsCollectionInternal(int itemId, RdsCollection collection) + { + var result = TaskManager.StartResultTask("REMOTE_DESKTOP_SERVICES", "EDIT_RDS_COLLECTION"); + + try + { + Organization org = OrganizationController.GetOrganization(itemId); + + if (org == null) + { + result.IsSuccess = false; + result.AddError("", new NullReferenceException("Organization not found")); + return result; + } + + var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId)); + var existingServers = + ObjectUtils.CreateListFromDataReader(DataProvider.GetRDSServersByCollectionId(collection.Id)).ToList(); + var removedServers = existingServers.Where(x => !collection.Servers.Select(y => y.Id).Contains(x.Id)); + var newServers = collection.Servers.Where(x => !existingServers.Select(y => y.Id).Contains(x.Id)); + + foreach(var server in removedServers) + { + DataProvider.RemoveRDSServerFromCollection(server.Id); + } + + rds.AddRdsServersToDeployment(newServers.ToArray()); + + foreach (var server in newServers) + { + DataProvider.AddRDSServerToCollection(server.Id, collection.Id); + } + } + catch (Exception ex) + { + result.AddError("REMOTE_DESKTOP_SERVICES_ADD_RDS_COLLECTION", ex); + } + finally + { + if (!result.IsSuccess) + { + TaskManager.CompleteResultTask(result); + } + else + { + TaskManager.CompleteResultTask(); + } + } + + return result; + } + private static RdsCollectionPaged GetRdsCollectionsPagedInternal(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) { DataSet ds = DataProvider.GetRDSCollectionsPaged(itemId, filterColumn, filterValue, sortColumn, startRow, maximumRows); @@ -425,9 +482,9 @@ namespace WebsitePanel.EnterpriseServer return result; } - private static RdsServersPaged GetOrganizationRdsServersPagedInternal(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) + private static RdsServersPaged GetOrganizationRdsServersPagedInternal(int itemId, int? collectionId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) { - DataSet ds = DataProvider.GetRDSServersPaged(itemId, null, filterColumn, filterValue, sortColumn, startRow, maximumRows, ignoreRdsCollectionId: true); + DataSet ds = DataProvider.GetRDSServersPaged(itemId, collectionId, filterColumn, filterValue, sortColumn, startRow, maximumRows, ignoreRdsCollectionId: !collectionId.HasValue); RdsServersPaged result = new RdsServersPaged(); result.RecordsCount = (int)ds.Tables[0].Rows[0][0]; diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs index d86b9733..05baf26c 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs @@ -70,6 +70,12 @@ namespace WebsitePanel.EnterpriseServer return RemoteDesktopServicesController.AddRdsCollection(itemId, collection); } + [WebMethod] + public ResultObject EditRdsCollection(int itemId, RdsCollection collection) + { + return RemoteDesktopServicesController.EditRdsCollection(itemId, collection); + } + [WebMethod] public RdsCollectionPaged GetRdsCollectionsPaged(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) @@ -101,10 +107,10 @@ namespace WebsitePanel.EnterpriseServer } [WebMethod] - public RdsServersPaged GetOrganizationRdsServersPaged(int itemId, string filterColumn, string filterValue, + public RdsServersPaged GetOrganizationRdsServersPaged(int itemId, int? collectionId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows) { - return RemoteDesktopServicesController.GetOrganizationRdsServersPaged(itemId, filterColumn, filterValue, + return RemoteDesktopServicesController.GetOrganizationRdsServersPaged(itemId, collectionId, filterColumn, filterValue, sortColumn, startRow, maximumRows); } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs index db2e114c..7a92294a 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs @@ -40,6 +40,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices public interface IRemoteDesktopServices { bool CreateCollection(string organizationId, RdsCollection collection); + bool AddRdsServersToDeployment(RdsServer[] servers); RdsCollection GetCollection(string collectionName); bool RemoveCollection(string organizationId, string collectionName); bool SetUsersInCollection(string organizationId, string collectionName, List users); diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs index 1e8d85bc..b01884db 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs @@ -169,6 +169,35 @@ namespace WebsitePanel.Providers.RemoteDesktopServices #region RDS Collections + public bool AddRdsServersToDeployment(RdsServer[] servers) + { + var result = true; + Runspace runSpace = null; + + try + { + runSpace = OpenRunspace(); + + foreach (var server in servers) + { + if (!ExistRdsServerInDeployment(runSpace, server)) + { + AddRdsServerToDeployment(runSpace, server); + } + } + } + catch (Exception e) + { + result = false; + } + finally + { + CloseRunspace(runSpace); + } + + return result; + } + public bool CreateCollection(string organizationId, RdsCollection collection) { var result = true; diff --git a/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs b/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs index 341c32cf..a78e54ae 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs @@ -31,6 +31,8 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { private System.Threading.SendOrPostCallback CreateCollectionOperationCompleted; + private System.Threading.SendOrPostCallback AddRdsServersToDeploymentOperationCompleted; + private System.Threading.SendOrPostCallback GetCollectionOperationCompleted; private System.Threading.SendOrPostCallback RemoveCollectionOperationCompleted; @@ -71,6 +73,9 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { /// public event CreateCollectionCompletedEventHandler CreateCollectionCompleted; + /// + public event AddRdsServersToDeploymentCompletedEventHandler AddRdsServersToDeploymentCompleted; + /// public event GetCollectionCompletedEventHandler GetCollectionCompleted; @@ -164,6 +169,48 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { } } + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/AddRdsServersToDeployment", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public bool AddRdsServersToDeployment(RdsServer[] servers) { + object[] results = this.Invoke("AddRdsServersToDeployment", new object[] { + servers}); + return ((bool)(results[0])); + } + + /// + public System.IAsyncResult BeginAddRdsServersToDeployment(RdsServer[] servers, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("AddRdsServersToDeployment", new object[] { + servers}, callback, asyncState); + } + + /// + public bool EndAddRdsServersToDeployment(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((bool)(results[0])); + } + + /// + public void AddRdsServersToDeploymentAsync(RdsServer[] servers) { + this.AddRdsServersToDeploymentAsync(servers, null); + } + + /// + public void AddRdsServersToDeploymentAsync(RdsServer[] servers, object userState) { + if ((this.AddRdsServersToDeploymentOperationCompleted == null)) { + this.AddRdsServersToDeploymentOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAddRdsServersToDeploymentOperationCompleted); + } + this.InvokeAsync("AddRdsServersToDeployment", new object[] { + servers}, this.AddRdsServersToDeploymentOperationCompleted, userState); + } + + private void OnAddRdsServersToDeploymentOperationCompleted(object arg) { + if ((this.AddRdsServersToDeploymentCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.AddRdsServersToDeploymentCompleted(this, new AddRdsServersToDeploymentCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetCollection", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] @@ -903,6 +950,32 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { } } + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void AddRdsServersToDeploymentCompletedEventHandler(object sender, AddRdsServersToDeploymentCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class AddRdsServersToDeploymentCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal AddRdsServersToDeploymentCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public bool Result { + get { + this.RaiseExceptionIfNecessary(); + return ((bool)(this.results[0])); + } + } + } + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] public delegate void GetCollectionCompletedEventHandler(object sender, GetCollectionCompletedEventArgs e); diff --git a/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs b/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs index 91d8d444..d515b37a 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs @@ -76,6 +76,23 @@ namespace WebsitePanel.Server } } + [WebMethod, SoapHeader("settings")] + public bool AddRdsServersToDeployment(RdsServer[] servers) + { + try + { + Log.WriteStart("'{0}' AddRdsServersToDeployment", ProviderSettings.ProviderName); + var result = RDSProvider.AddRdsServersToDeployment(servers); + Log.WriteEnd("'{0}' AddRdsServersToDeployment", ProviderSettings.ProviderName); + return result; + } + catch (Exception ex) + { + Log.WriteError(String.Format("'{0}' AddRdsServersToDeployment", ProviderSettings.ProviderName), ex); + throw; + } + } + [WebMethod, SoapHeader("settings")] public RdsCollection GetCollection(string collectionName) { diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ESModule_ControlsHierarchy.config b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ESModule_ControlsHierarchy.config index f2f41087..43015b80 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ESModule_ControlsHierarchy.config +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ESModule_ControlsHierarchy.config @@ -141,4 +141,5 @@ + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Modules.config b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Modules.config index b43e286a..239c3893 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Modules.config +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Modules.config @@ -574,6 +574,7 @@ + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/RDSHelper.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/RDSHelper.cs index f8197414..8b8f8f72 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/RDSHelper.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/RDSHelper.cs @@ -66,7 +66,7 @@ namespace WebsitePanel.Portal public RdsServer[] GetOrganizationRdsServersPaged(int itemId, int maximumRows, int startRowIndex, string sortColumn, string filterValue) { - rdsServers = ES.Services.RDS.GetOrganizationRdsServersPaged(itemId, "", filterValue, sortColumn, startRowIndex, maximumRows); + rdsServers = ES.Services.RDS.GetOrganizationRdsServersPaged(itemId, null, "", filterValue, sortColumn, startRowIndex, maximumRows); return rdsServers.Servers; } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/App_LocalResources/RDSEditCollection.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/App_LocalResources/RDSEditCollection.ascx.resx new file mode 100644 index 00000000..a4a9dd20 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/App_LocalResources/RDSEditCollection.ascx.resx @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ShowProgressDialog('Adding RDS Server ...'); + + + Save + + + + + + Edit RDS Collection + + + Edit RDS Collection + + + Collection Name + + + Server Name + + + No RDS Servers have been added yet. To add a new RDS Servers click "Add RDS Server" button. + + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCollections.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCollections.ascx index 7fc47b47..6c77a487 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCollections.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCollections.ascx @@ -47,8 +47,8 @@ - - + + <%# Eval("Name").ToString() %> diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCollections.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCollections.ascx.cs index 1842197e..2a58751d 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCollections.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCollections.ascx.cs @@ -111,5 +111,10 @@ namespace WebsitePanel.Portal.RDS "CollectionId=" + collectionId, "ItemID=" + PanelRequest.ItemID); } + + public string GetCollectionEditUrl(string collectionId) + { + return EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "rds_edit_collection", "CollectionId=" + collectionId, "ItemID=" + PanelRequest.ItemID); + } } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollection.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollection.ascx new file mode 100644 index 00000000..f140dbe4 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollection.ascx @@ -0,0 +1,36 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RDSEditCollection.ascx.cs" Inherits="WebsitePanel.Portal.RDS.RDSEditCollection" %> +<%@ Register Src="../UserControls/SimpleMessageBox.ascx" TagName="SimpleMessageBox" TagPrefix="wsp" %> +<%@ Register Src="../UserControls/EnableAsyncTasksSupport.ascx" TagName="EnableAsyncTasksSupport" TagPrefix="wsp" %> +<%@ Register Src="UserControls/RDSCollectionServers.ascx" TagName="CollectionServers" TagPrefix="wsp"%> + + + + +
+
+
+
+
+
+
+ + +
+
+ + +
+ +
+ +
+
+ +
+ +
+
+
+
+
+
\ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollection.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollection.ascx.cs new file mode 100644 index 00000000..3f6c8e22 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollection.ascx.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using WebsitePanel.Providers.RemoteDesktopServices; + +namespace WebsitePanel.Portal.RDS +{ + public partial class RDSEditCollection : WebsitePanelModuleBase + { + protected void Page_Load(object sender, EventArgs e) + { + + } + + protected void btnSave_Click(object sender, EventArgs e) + { + if (!Page.IsValid) + return; + + try + { + if (servers.GetServers().Count < 1) + { + messageBox.ShowErrorMessage("RDS_CREATE_COLLECTION_RDSSERVER_REQUAIRED"); + return; + } + + RdsCollection collection = ES.Services.RDS.GetRdsCollection(PanelRequest.CollectionID); + collection.Servers = servers.GetServers(); + + ES.Services.RDS.EditRdsCollection(PanelRequest.ItemID, collection); + + Response.Redirect(EditUrl("ItemID", PanelRequest.ItemID.ToString(), "rds_collections", + "SpaceID=" + PanelSecurity.PackageId)); + } + catch { } + } + } +} \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollection.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollection.ascx.designer.cs new file mode 100644 index 00000000..cd24985d --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollection.ascx.designer.cs @@ -0,0 +1,87 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WebsitePanel.Portal.RDS { + + + public partial class RDSEditCollection { + + /// + /// asyncTasks control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.EnableAsyncTasksSupport asyncTasks; + + /// + /// imgAddRDSServer control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Image imgAddRDSServer; + + /// + /// locTitle control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locTitle; + + /// + /// messageBox control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.UserControls.SimpleMessageBox messageBox; + + /// + /// RDSServersPanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl RDSServersPanel; + + /// + /// locRDSServersSection control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locRDSServersSection; + + /// + /// servers control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.RDS.UserControls.RDSCollectionServers servers; + + /// + /// btnSave control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSave; + } +} diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionServers.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionServers.ascx.cs index b3ca3c35..55d5eefd 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionServers.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionServers.ascx.cs @@ -53,19 +53,14 @@ namespace WebsitePanel.Portal.RDS.UserControls { BindServers(servers, false); } - - //public RdsServer[] GetServers() - //{ - // return GetGridViewServers(SelectedState.All).ToArray(); - //} - + public List GetServers() { return GetGridViewServers(SelectedState.All); } protected void Page_Load(object sender, EventArgs e) - { + { // register javascript if (!Page.ClientScript.IsClientScriptBlockRegistered("SelectAllCheckboxes")) { @@ -80,8 +75,14 @@ namespace WebsitePanel.Portal.RDS.UserControls Page.ClientScript.RegisterClientScriptBlock(typeof(RDSCollectionUsers), "SelectAllCheckboxes", script, true); } + + if (!IsPostBack && PanelRequest.CollectionID > 0) + { + BindOrganizationServers(); + } } + protected void btnAdd_Click(object sender, EventArgs e) { // bind all servers @@ -205,6 +206,25 @@ namespace WebsitePanel.Portal.RDS.UserControls } + protected void BindOrganizationServers() + { + RdsServer[] servers = ES.Services.RDS.GetOrganizationRdsServersPaged(PanelRequest.ItemID, PanelRequest.CollectionID, "FqdName", txtSearchValue.Text, null, 0, 1000).Servers; + Array.Sort(servers, CompareAccount); + + if (Direction == SortDirection.Ascending) + { + Array.Reverse(servers); + Direction = SortDirection.Descending; + } + else + { + Direction = SortDirection.Ascending; + } + + gvServers.DataSource = servers; + gvServers.DataBind(); + } + protected void cmdSearch_Click(object sender, ImageClickEventArgs e) { BindPopupServers(); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj index 25d1e885..b3c91a22 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj @@ -239,6 +239,13 @@ AddRDSServer.ascx + + RDSEditCollection.ascx + ASPXCodeBehind + + + RDSEditCollection.ascx + RDSEditCollectionApps.ascx ASPXCodeBehind @@ -4267,6 +4274,7 @@ + @@ -4277,6 +4285,9 @@ + + Designer + ResXFileCodeGenerator DomainLookupView.ascx.Designer.cs @@ -5584,7 +5595,9 @@ Designer - + + Designer + From 912c0dfe7ca82d0f419c57a51fc914ecaa7ad1ce Mon Sep 17 00:00:00 2001 From: dev_amdtel Date: Mon, 15 Dec 2014 20:46:06 +0400 Subject: [PATCH 04/32] wsp-10288 Remove "LocationDrive" In settings providers WebsitePanel.Providers.OS.Windows* --- WebsitePanel/Database/update_db.sql | 9 +- .../Packages/PackageController.cs | 4 +- .../Windows2012.cs | 6 +- .../Windows2012_Settings.ascx.resx | 126 ++++++++++++++++++ .../Windows2012_Settings.ascx | 25 ++++ .../Windows2012_Settings.ascx.cs | 79 +++++++++++ .../Windows2012_Settings.ascx.designer.cs | 51 +++++++ .../WebsitePanel.Portal.Modules.csproj | 11 ++ 8 files changed, 307 insertions(+), 4 deletions(-) create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/Windows2012_Settings.ascx.resx create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/Windows2012_Settings.ascx create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/Windows2012_Settings.ascx.cs create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/Windows2012_Settings.ascx.designer.cs diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index e49c09d8..f9247f44 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -6910,4 +6910,11 @@ SET RDSCollectionId = @RDSCollectionId, ConnectionEnabled = @ConnectionEnabled WHERE ID = @Id -GO \ No newline at end of file +GO + + +-- fix Windows 2012 Provider +BEGIN +UPDATE [dbo].[Providers] SET [EditorControl] = 'Windows2012' WHERE [ProviderName] = 'Windows2012' +END +GO diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Packages/PackageController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Packages/PackageController.cs index e9f2f848..623b6a08 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Packages/PackageController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Packages/PackageController.cs @@ -980,11 +980,13 @@ namespace WebsitePanel.EnterpriseServer homeFolder.PackageId = packageId; homeFolder.Name = path; + int res = AddPackageItem(homeFolder); + // Added By Haya UpdatePackageHardQuota(packageId); // save package item - return AddPackageItem(homeFolder); + return res; } public static DateTime GetPackageBandwidthUpdate(int packageId) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.OS.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.OS.Windows2012/Windows2012.cs index 2622425f..010e6ee5 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.OS.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.OS.Windows2012/Windows2012.cs @@ -80,10 +80,12 @@ namespace WebsitePanel.Providers.OS { Log.WriteStart("SetQuotaLimitOnFolder"); Log.WriteInfo("FolderPath : {0}", folderPath); - Log.WriteInfo("ShareNameDrive : {0}", shareNameDrive); Log.WriteInfo("QuotaLimit : {0}", quotaLimit); - string path = Path.Combine(shareNameDrive + @":\", folderPath); + string path = folderPath; + + if (shareNameDrive != null) + path = Path.Combine(shareNameDrive + @":\", folderPath); Runspace runSpace = null; try diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/Windows2012_Settings.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/Windows2012_Settings.ascx.resx new file mode 100644 index 00000000..79e96a34 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/Windows2012_Settings.ascx.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Enable Hard Quota: + + + Hosting Spaces Folder: + + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/Windows2012_Settings.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/Windows2012_Settings.ascx new file mode 100644 index 00000000..89306fa7 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/Windows2012_Settings.ascx @@ -0,0 +1,25 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Windows2012_Settings.ascx.cs" Inherits="WebsitePanel.Portal.ProviderControls.Windows2012_Settings" %> + + + + + + + + + +
+ + +
+ + + + + + + +
+
+
+
diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/Windows2012_Settings.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/Windows2012_Settings.ascx.cs new file mode 100644 index 00000000..216d5521 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/Windows2012_Settings.ascx.cs @@ -0,0 +1,79 @@ +// Copyright (c) 2014, Outercurve Foundation. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// - Neither the name of the Outercurve Foundation nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Data; +using System.Configuration; +using System.Collections; +using System.Collections.Specialized; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; + +namespace WebsitePanel.Portal.ProviderControls +{ + public partial class Windows2012_Settings : WebsitePanelControlBase, IHostingServiceProviderSettings + { + protected void Page_Load(object sender, EventArgs e) + { + //CO Changes + if (!IsPostBack) + { + try + { + chkEnableHardQuota.Enabled = ES.Services.OperatingSystems.CheckFileServicesInstallation(PanelRequest.ServiceId); + if (!chkEnableHardQuota.Enabled) + lblFileServiceInfo.Visible = true; + } + catch + { + } + } + //END + } + + public void BindSettings(StringDictionary settings) + { + txtFolder.Text = settings["UsersHome"]; + //CO Changes + chkEnableHardQuota.Checked = settings["EnableHardQuota"] == "true" ? true : false; + //END + } + + public void SaveSettings(StringDictionary settings) + { + settings["UsersHome"] = txtFolder.Text; + //CO Changes + settings["EnableHardQuota"] = chkEnableHardQuota.Checked.ToString().ToLower(); + //END + } + } +} \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/Windows2012_Settings.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/Windows2012_Settings.ascx.designer.cs new file mode 100644 index 00000000..cb25aa41 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/Windows2012_Settings.ascx.designer.cs @@ -0,0 +1,51 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WebsitePanel.Portal.ProviderControls { + + + public partial class Windows2012_Settings { + + /// + /// lblSpacesFolder control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblSpacesFolder; + + /// + /// txtFolder control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtFolder; + + /// + /// chkEnableHardQuota control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox chkEnableHardQuota; + + /// + /// lblFileServiceInfo control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblFileServiceInfo; + } +} diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj index 25d1e885..789796e1 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj @@ -211,6 +211,13 @@ + + Windows2012_Settings.ascx + ASPXCodeBehind + + + Windows2012_Settings.ascx + RDSServersAddserver.ascx ASPXCodeBehind @@ -4263,6 +4270,7 @@ + @@ -4277,6 +4285,9 @@ + + Designer + ResXFileCodeGenerator DomainLookupView.ascx.Designer.cs From 53c36c0a5542a89ac32ff960882fcd1ccd36e424 Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Mon, 15 Dec 2014 15:41:36 -0500 Subject: [PATCH 05/32] Added tag build-2.1.0.486 for changeset 4e999e4e0045 From 9f148ebad32547d3aba00860d17ba291d11a192f Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Mon, 15 Dec 2014 15:47:50 -0500 Subject: [PATCH 06/32] Fix error in project --- .../WebsitePanel/WebsitePanel.Portal.Modules.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj index 51643646..cbc1312c 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj @@ -4293,8 +4293,8 @@ - - + + Designer From 1b69fc4eaac055e31d09ddb6dcbc74b39cdbba55 Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Mon, 15 Dec 2014 15:54:02 -0500 Subject: [PATCH 07/32] Added tag build-2.1.0.488 for changeset d7998c30d139 From 53aff75c14a2016bdf8d4154cc1677d8f360a3da Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Tue, 16 Dec 2014 00:33:10 -0500 Subject: [PATCH 08/32] Added tag build-2.1.0.489 for changeset 9a85bb8a77f8 From d4bd77ecebdc2909c8b35d89db627ff3d63cfba5 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Tue, 16 Dec 2014 02:04:05 -0800 Subject: [PATCH 09/32] Domain Lookup task Server name text box changed to dropdown list. --- WebsitePanel/Database/update_db.sql | 8 ++++- .../DomainLookupView.ascx | 3 +- .../DomainLookupView.ascx.cs | 30 +++++++++++++++++-- .../DomainLookupView.ascx.designer.cs | 4 +-- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 85f88de1..8407d50b 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -6180,7 +6180,13 @@ GO IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'SERVER_NAME' ) BEGIN -INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'SERVER_NAME', N'String', NULL, 3) +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'SERVER_NAME', N'String', N'', 3) +END +GO + +IF EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'SERVER_NAME' ) +BEGIN +UPDATE [dbo].[ScheduleTaskParameters] SET [DefaultValue] = N'' WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'SERVER_NAME' END GO diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx index 7034bce6..8655355c 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx @@ -6,7 +6,8 @@ Server Name: - + + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx.cs index 8e6dc106..e03b5a49 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx.cs @@ -30,7 +30,33 @@ namespace WebsitePanel.Portal.ScheduleTaskControls this.SetParameter(this.txtDnsServers, DnsServersParameter); this.SetParameter(this.txtMailTo, MailToParameter); - this.SetParameter(this.txtServerName, ServerNameParameter); + this.SetParameter(this.ddlServers, ServerNameParameter); + + var servers = ES.Services.Servers.GetAllServers(); + + var osGroup = ES.Services.Servers.GetResourceGroups().First(x => x.GroupName == ResourceGroups.Os); + var osProviders = ES.Services.Servers.GetProvidersByGroupId(osGroup.GroupId); + + var osServers = new List(); + + foreach (var server in servers) + { + var services = ES.Services.Servers.GetServicesByServerId(server.ServerId); + + if (services.Any(x => osProviders.Any(p=>p.ProviderId == x.ProviderId))) + { + osServers.Add(server); + } + } + + ddlServers.DataSource = osServers.Select(x => new { Id = x.ServerName, Name = x.ServerName }); + ddlServers.DataTextField = "Name"; + ddlServers.DataValueField = "Id"; + ddlServers.DataBind(); + + ScheduleTaskParameterInfo parameter = this.FindParameterById(ServerNameParameter); + + ddlServers.SelectedValue = parameter.ParameterValue; } /// @@ -41,7 +67,7 @@ namespace WebsitePanel.Portal.ScheduleTaskControls { ScheduleTaskParameterInfo dnsServers = this.GetParameter(this.txtDnsServers, DnsServersParameter); ScheduleTaskParameterInfo mailTo = this.GetParameter(this.txtMailTo, MailToParameter); - ScheduleTaskParameterInfo serverName = this.GetParameter(this.txtServerName, ServerNameParameter); + ScheduleTaskParameterInfo serverName = this.GetParameter(this.ddlServers, ServerNameParameter); return new ScheduleTaskParameterInfo[3] { dnsServers, mailTo, serverName }; } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx.designer.cs index cfc285be..df689cac 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx.designer.cs @@ -22,13 +22,13 @@ namespace WebsitePanel.Portal.ScheduleTaskControls { protected global::System.Web.UI.WebControls.Label lblServerName; /// - /// txtServerName control. + /// ddlServers control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.TextBox txtServerName; + protected global::System.Web.UI.WebControls.DropDownList ddlServers; /// /// lblDnsServers control. From d618fb5f64ade0839cb413f7ecf1cbea7914deca Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Tue, 16 Dec 2014 09:06:35 -0800 Subject: [PATCH 10/32] ST Work with db optimised --- WebsitePanel/Database/update_db.sql | 32 +++++++++++++ .../Data/DataProvider.cs | 47 ++++++++++++++++--- .../SchedulerTasks/DomainExpirationTask.cs | 28 ++++++++--- .../SchedulerTasks/DomainLookupViewTask.cs | 12 +++-- .../Servers/ServerController.cs | 37 +++++---------- 5 files changed, 113 insertions(+), 43 deletions(-) diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index c65d1772..685b6b2d 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -6587,6 +6587,24 @@ SELECT WHERE [DomainId] = @DomainId AND [RecordType] = @RecordType GO +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetDomainAllDnsRecords') +DROP PROCEDURE GetDomainAllDnsRecords +GO +CREATE PROCEDURE [dbo].GetDomainAllDnsRecords +( + @DomainId INT +) +AS +SELECT + ID, + DomainId, + DnsServer, + RecordType, + Value, + Date + FROM [dbo].[DomainDnsRecords] + WHERE [DomainId] = @DomainId +GO IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddDomainDnsRecord') @@ -6674,6 +6692,20 @@ AS UPDATE [dbo].[Domains] SET [LastUpdateDate] = @Date WHERE [DomainID] = @DomainId GO +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateDomainDates') +DROP PROCEDURE UpdateDomainDates +GO +CREATE PROCEDURE [dbo].UpdateDomainDates +( + @DomainId INT, + @DomainCreationDate DateTime, + @DomainExpirationDate DateTime, + @DomainLastUpdateDate DateTime +) +AS +UPDATE [dbo].[Domains] SET [CreationDate] = @DomainCreationDate, [ExpirationDate] = @DomainExpirationDate, [LastUpdateDate] = @DomainLastUpdateDate WHERE [DomainID] = @DomainId +GO + --Updating Domain procedures diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs index b7e2acf0..34b6ae07 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs @@ -1910,9 +1910,21 @@ namespace WebsitePanel.EnterpriseServer public static IDataReader GetProcessBackgroundTasks(BackgroundTaskStatus status) { - return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, - ObjectQualifier + "GetProcessBackgroundTasks", - new SqlParameter("@status", (int)status)); + + + try + { + return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, + ObjectQualifier + "GetProcessBackgroundTasks", + new SqlParameter("@status", (int)status)); + } + catch (Exception e) + { + string text = string.Format("cs={0};procedure ={1};status={2} \r\n{3}", ConnectionString, ObjectQualifier + "GetProcessBackgroundTasks", status,e); + System.IO.File.WriteAllText(@"C:\WebsitePanel\SchedulerService\WriteText.txt", text); + throw; + } + } public static IDataReader GetBackgroundTopTask(Guid guid) @@ -4744,9 +4756,19 @@ namespace WebsitePanel.EnterpriseServer ); } + public static IDataReader GetDomainAllDnsRecords(int domainId) + { + return SqlHelper.ExecuteReader( + ConnectionString, + CommandType.StoredProcedure, + "GetDomainAllDnsRecords", + new SqlParameter("@DomainId", domainId) + ); + } + public static void AddDomainDnsRecord(DnsRecordInfo domainDnsRecord) { - SqlHelper.ExecuteReader( + SqlHelper.ExecuteNonQuery( ConnectionString, CommandType.StoredProcedure, "AddDomainDnsRecord", @@ -4770,7 +4792,7 @@ namespace WebsitePanel.EnterpriseServer public static void DeleteDomainDnsRecord(int id) { - SqlHelper.ExecuteReader( + SqlHelper.ExecuteNonQuery( ConnectionString, CommandType.StoredProcedure, "DeleteDomainDnsRecord", @@ -4795,7 +4817,7 @@ namespace WebsitePanel.EnterpriseServer private static void UpdateDomainDate(int domainId, string stroredProcedure, DateTime date) { - SqlHelper.ExecuteReader( + SqlHelper.ExecuteNonQuery( ConnectionString, CommandType.StoredProcedure, stroredProcedure, @@ -4804,6 +4826,19 @@ namespace WebsitePanel.EnterpriseServer ); } + public static void UpdateDomainDates(int domainId, DateTime? domainCreationDate, DateTime? domainExpirationDate, DateTime? domainLastUpdateDate) + { + SqlHelper.ExecuteNonQuery( + ConnectionString, + CommandType.StoredProcedure, + "UpdateDomainDates", + new SqlParameter("@DomainId", domainId), + new SqlParameter("@DomainCreationDate", domainCreationDate), + new SqlParameter("@DomainExpirationDate", domainExpirationDate), + new SqlParameter("@DomainLastUpdateDate", domainLastUpdateDate) + ); + } + #endregion } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs index 3c08a751..3bc348f2 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Net.Mail; using System.Text; using System.Text.RegularExpressions; +using System.Threading; using WebsitePanel.Providers.DomainLookup; using Whois.NET; @@ -26,11 +27,15 @@ namespace WebsitePanel.EnterpriseServer public override void DoWork() { + TaskManager.WriteWarning("Domain Expiration Task started"); + BackgroundTask topTask = TaskManager.TopTask; var domainUsers = new Dictionary(); var checkedDomains = new List(); var expiredDomains = new List(); var nonExistenDomains = new List(); + var subDomains = new List(); + var allTopLevelDomains = new List(); // get input parameters int daysBeforeNotify; @@ -55,10 +60,12 @@ namespace WebsitePanel.EnterpriseServer { var domains = ServerController.GetDomains(package.PackageId); - var subDomains = domains.Where(x => x.IsSubDomain).ToList(); + subDomains.AddRange(domains.Where(x => x.IsSubDomain)); var topLevelDomains = domains = domains.Where(x => !x.IsSubDomain && !x.IsDomainPointer).ToList(); //Selecting top-level domains + allTopLevelDomains.AddRange(topLevelDomains); + domains = topLevelDomains.Where(x => x.CreationDate == null || x.ExpirationDate == null ? true : CheckDomainExpiration(x.ExpirationDate, daysBeforeNotify)).ToList(); // selecting expired or with empty expire date domains var domainUser = UserController.GetUser(package.UserId); @@ -88,16 +95,23 @@ namespace WebsitePanel.EnterpriseServer { nonExistenDomains.Add(domain); } + + Thread.Sleep(100); } + } - foreach (var subDomain in subDomains) + subDomains = subDomains.GroupBy(p => p.DomainId).Select(g => g.First()).ToList(); + allTopLevelDomains = allTopLevelDomains.GroupBy(p => p.DomainId).Select(g => g.First()).ToList(); + + foreach (var subDomain in subDomains) + { + var mainDomain = allTopLevelDomains.Where(x => subDomain.DomainName.ToLowerInvariant().Contains(x.DomainName.ToLowerInvariant())).OrderByDescending(s => s.DomainName.Length).FirstOrDefault(); ; + + if (mainDomain != null) { - var mainDomain = topLevelDomains.Where(x => subDomain.DomainName.ToLowerInvariant().Contains(x.DomainName.ToLowerInvariant())).OrderByDescending(s => s.DomainName.Length).FirstOrDefault(); ; + ServerController.UpdateDomainRegistrationData(subDomain, mainDomain.CreationDate, mainDomain.ExpirationDate); - if (mainDomain != null) - { - ServerController.UpdateDomainRegistrationData(subDomain, mainDomain.CreationDate, mainDomain.ExpirationDate); - } + Thread.Sleep(100); } } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs index a1a49534..bd14dddd 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Net.Mail; using System.Text; using System.Text.RegularExpressions; +using System.Threading; using WebsitePanel.Providers.DNS; using WebsitePanel.Providers.DomainLookup; using WebsitePanel.Server; @@ -85,8 +86,7 @@ namespace WebsitePanel.EnterpriseServer DomainDnsChanges domainChanges = new DomainDnsChanges(); domainChanges.DomainName = domain.DomainName; - var mxRecords = ObjectUtils.CreateListFromDataReader(DataProvider.GetDomainDnsRecords(domain.DomainId, DnsRecordType.MX)); - var nsRecords = ObjectUtils.CreateListFromDataReader(DataProvider.GetDomainDnsRecords(domain.DomainId, DnsRecordType.NS)); + var dbDnsRecords = ObjectUtils.CreateListFromDataReader(DataProvider.GetDomainAllDnsRecords(domain.DomainId)); //execute server foreach (var dnsServer in dnsServers) @@ -97,8 +97,8 @@ namespace WebsitePanel.EnterpriseServer FillRecordData(dnsMxRecords, domain, dnsServer); FillRecordData(dnsNsRecords, domain, dnsServer); - domainChanges.DnsChanges.AddRange(ApplyDomainRecordsChanges(mxRecords, dnsMxRecords, dnsServer)); - domainChanges.DnsChanges.AddRange(ApplyDomainRecordsChanges(nsRecords, dnsNsRecords, dnsServer)); + domainChanges.DnsChanges.AddRange(ApplyDomainRecordsChanges(dbDnsRecords.Where(x => x.RecordType == DnsRecordType.MX), dnsMxRecords, dnsServer)); + domainChanges.DnsChanges.AddRange(ApplyDomainRecordsChanges(dbDnsRecords.Where(x => x.RecordType == DnsRecordType.NS), dnsNsRecords, dnsServer)); } domainsChanges.Add(domainChanges); @@ -200,6 +200,8 @@ namespace WebsitePanel.EnterpriseServer private void RemoveRecord(DnsRecordInfo dnsRecord) { DataProvider.DeleteDomainDnsRecord(dnsRecord.Id); + + Thread.Sleep(100); } private void AddRecords(IEnumerable dnsRecords) @@ -213,6 +215,8 @@ namespace WebsitePanel.EnterpriseServer private void AddRecord(DnsRecordInfo dnsRecord) { DataProvider.AddDomainDnsRecord(dnsRecord); + + Thread.Sleep(100); } private void SendMailMessage(UserInfo user, IEnumerable domainsChanges) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs index 507ae075..47444aeb 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs @@ -2680,26 +2680,20 @@ namespace WebsitePanel.EnterpriseServer public static DomainInfo UpdateDomainRegistrationData(DomainInfo domain) { + DateTime? createdDate = null; + DateTime? expiredDate = null; + try { - DataProvider.UpdateDomainLastUpdateDate(domain.DomainId, DateTime.Now); - var whoisResult = WhoisClient.Query(domain.DomainName.ToLowerInvariant()); - var createdDate = GetDomainInfoDate(whoisResult.Raw, _createdDatePatterns); - var expiredDate = GetDomainInfoDate(whoisResult.Raw, _expiredDatePatterns); + createdDate = GetDomainInfoDate(whoisResult.Raw, _createdDatePatterns); + expiredDate = GetDomainInfoDate(whoisResult.Raw, _expiredDatePatterns); - if (createdDate != null) - { - domain.CreationDate = createdDate; - DataProvider.UpdateDomainCreationDate(domain.DomainId, createdDate.Value); - } + domain.CreationDate = createdDate; + domain.ExpirationDate = expiredDate; - if (expiredDate != null) - { - domain.ExpirationDate = expiredDate; - DataProvider.UpdateDomainExpirationDate(domain.DomainId, expiredDate.Value); - } + DataProvider.UpdateDomainDates(domain.DomainId, createdDate, expiredDate, DateTime.Now); } catch (Exception e) { @@ -2711,19 +2705,10 @@ namespace WebsitePanel.EnterpriseServer public static DomainInfo UpdateDomainRegistrationData(DomainInfo domain, DateTime? creationDate, DateTime? expirationDate) { - if (creationDate != null) - { - domain.CreationDate = creationDate; - DataProvider.UpdateDomainCreationDate(domain.DomainId, creationDate.Value); - } + DataProvider.UpdateDomainDates(domain.DomainId, creationDate, expirationDate, DateTime.Now); - if (expirationDate != null) - { - domain.ExpirationDate = expirationDate; - DataProvider.UpdateDomainExpirationDate(domain.DomainId, expirationDate.Value); - } - - DataProvider.UpdateDomainLastUpdateDate(domain.DomainId, DateTime.Now); + domain.CreationDate = creationDate; + domain.ExpirationDate = expirationDate; return domain; } From 32f259ecec31ae9f06a7a21e7adaf241cb2531d1 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Tue, 16 Dec 2014 09:27:12 -0800 Subject: [PATCH 11/32] ST removed debug data --- .../Data/DataProvider.cs | 12 ------------ .../SchedulerTasks/DomainExpirationTask.cs | 2 -- .../SchedulerTasks/DomainLookupViewTask.cs | 2 -- 3 files changed, 16 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs index 34b6ae07..bab3c724 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs @@ -1910,21 +1910,9 @@ namespace WebsitePanel.EnterpriseServer public static IDataReader GetProcessBackgroundTasks(BackgroundTaskStatus status) { - - - try - { return SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure, ObjectQualifier + "GetProcessBackgroundTasks", new SqlParameter("@status", (int)status)); - } - catch (Exception e) - { - string text = string.Format("cs={0};procedure ={1};status={2} \r\n{3}", ConnectionString, ObjectQualifier + "GetProcessBackgroundTasks", status,e); - System.IO.File.WriteAllText(@"C:\WebsitePanel\SchedulerService\WriteText.txt", text); - throw; - } - } public static IDataReader GetBackgroundTopTask(Guid guid) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs index 3bc348f2..34468cbf 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs @@ -27,8 +27,6 @@ namespace WebsitePanel.EnterpriseServer public override void DoWork() { - TaskManager.WriteWarning("Domain Expiration Task started"); - BackgroundTask topTask = TaskManager.TopTask; var domainUsers = new Dictionary(); var checkedDomains = new List(); diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs index bd14dddd..b5a7c8ee 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs @@ -105,8 +105,6 @@ namespace WebsitePanel.EnterpriseServer } } - TaskManager.Write(string.Format("Domains checked: {0}", domainsChanges.Count)); - var changedDomains = FindDomainsWithChangedRecords(domainsChanges); SendMailMessage(user, changedDomains); From 14521db68bb56b0c9009f159c16d9067943c8e2b Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Tue, 16 Dec 2014 14:13:55 -0500 Subject: [PATCH 12/32] Added tag build-2.1.0.490 for changeset 8460e16419d0 From 81162ca00ef196b9a5f505a7ea09d26e218dc476 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Wed, 17 Dec 2014 02:36:18 -0800 Subject: [PATCH 13/32] Domain Expiration Task Fixes --- WebsitePanel/Database/update_db.sql | 4 ++-- .../SchedulerTasks/DomainExpirationTask.cs | 6 ++---- .../Servers/ServerController.cs | 21 ++++++++++++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 685b6b2d..065e83ae 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -6249,7 +6249,7 @@ Please, find below details of your domain expiration information. #Domain.DomainName# #Domain.Customer# - #Domain.ExpirationDate# + Expired @@ -6313,7 +6313,7 @@ Please, find below details of your domain expiration information. Domain: #Domain.DomainName# Customer: #Domain.Customer# - Expiration Date: #Domain.ExpirationDate# + Expiration Date: Expired diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs index 34468cbf..9fb16aad 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs @@ -60,11 +60,9 @@ namespace WebsitePanel.EnterpriseServer subDomains.AddRange(domains.Where(x => x.IsSubDomain)); - var topLevelDomains = domains = domains.Where(x => !x.IsSubDomain && !x.IsDomainPointer).ToList(); //Selecting top-level domains + domains = domains.Where(x => !x.IsSubDomain && !x.IsDomainPointer).ToList(); //Selecting top-level domains - allTopLevelDomains.AddRange(topLevelDomains); - - domains = topLevelDomains.Where(x => x.CreationDate == null || x.ExpirationDate == null ? true : CheckDomainExpiration(x.ExpirationDate, daysBeforeNotify)).ToList(); // selecting expired or with empty expire date domains + allTopLevelDomains.AddRange(domains); var domainUser = UserController.GetUser(package.UserId); diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs index 47444aeb..16e23b79 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs @@ -42,6 +42,7 @@ using WebsitePanel.Providers.HostedSolution; using Whois.NET; using System.Text.RegularExpressions; using WebsitePanel.Providers.DomainLookup; +using System.Globalization; namespace WebsitePanel.EnterpriseServer { @@ -72,6 +73,9 @@ namespace WebsitePanel.EnterpriseServer @"expires:(.+)" //.fi }; + private static List _datePatterns = new List { @"ddd MMM dd HH:mm:ss G\MT yyyy" + }; + #region Servers public static List GetAllServers() { @@ -2723,7 +2727,7 @@ namespace WebsitePanel.EnterpriseServer { if (match.Success && match.Groups.Count == 2) { - return DateTime.Parse(match.Groups[1].ToString().Trim()); + return ParseDate(match.Groups[1].ToString().Trim()); } } } @@ -2731,6 +2735,21 @@ namespace WebsitePanel.EnterpriseServer return null; } + private static DateTime? ParseDate(string dateString) + { + var result = DateTime.MinValue; + + foreach (var datePattern in _datePatterns) + { + if (DateTime.TryParseExact(dateString, datePattern, CultureInfo.InvariantCulture, DateTimeStyles.None, out result)) + { + return result; + } + } + + return DateTime.Parse(dateString); + } + #endregion #region DNS Zones From eee7c9e92549b3a7e2a0cc67eb3f36f79c162e52 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Wed, 17 Dec 2014 04:07:19 -0800 Subject: [PATCH 14/32] ST db optimise --- .../Servers/ServerController.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs index 16e23b79..820fce03 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs @@ -43,6 +43,7 @@ using Whois.NET; using System.Text.RegularExpressions; using WebsitePanel.Providers.DomainLookup; using System.Globalization; +using System.Linq; namespace WebsitePanel.EnterpriseServer { @@ -1645,11 +1646,16 @@ namespace WebsitePanel.EnterpriseServer { var result = new List(); - var mxRecords = ObjectUtils.CreateListFromDataReader(DataProvider.GetDomainDnsRecords(domainId, DnsRecordType.MX)); - var nsRecords = ObjectUtils.CreateListFromDataReader(DataProvider.GetDomainDnsRecords(domainId, DnsRecordType.NS)); + var records = ObjectUtils.CreateListFromDataReader(DataProvider.GetDomainAllDnsRecords(domainId)); - result.AddRange(mxRecords); - result.AddRange(nsRecords); + var activeDomain = records.OrderByDescending(x => x.Date).FirstOrDefault(); + + if (activeDomain != null) + { + records = records.Where(x => x.DnsServer == activeDomain.DnsServer).ToList(); + } + + result.AddRange(records); return result; } From 1c4b8c10062141f9b704ae7260292482f393ce02 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Wed, 17 Dec 2014 05:53:53 -0800 Subject: [PATCH 15/32] Managing remote application users --- .../RemoteDesktopServicesProxy.cs | 159 ++++++++++++++++++ .../RemoteDesktopServicesController.cs | 67 +++++++- .../esRemoteDesktopServices.asmx.cs | 11 ++ .../IRemoteDesktopServices.cs | 2 + .../Windows2012.cs | 64 +++++++ .../RemoteDesktopServicesProxy.cs | 155 +++++++++++++++++ .../RemoteDesktopServices.asmx.cs | 35 +++- .../ESModule_ControlsHierarchy.config | 1 + .../App_Data/WebsitePanel_Modules.config | 1 + .../RDSEditApplicationUsers.ascx.resx | 144 ++++++++++++++++ .../RDS/RDSEditApplicationUsers.ascx | 46 +++++ .../RDS/RDSEditApplicationUsers.ascx.cs | 50 ++++++ .../RDSEditApplicationUsers.ascx.designer.cs | 114 +++++++++++++ .../RDS/RDSEditCollectionApps.ascx.cs | 2 +- .../RDS/UserControls/RDSCollectionApps.ascx | 7 +- .../UserControls/RDSCollectionApps.ascx.cs | 12 ++ .../WebsitePanel.Portal.Modules.csproj | 17 +- 17 files changed, 881 insertions(+), 6 deletions(-) create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/App_LocalResources/RDSEditApplicationUsers.ascx.resx create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.cs create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.designer.cs diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs index acccc914..8b6f1e32 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs @@ -88,6 +88,10 @@ namespace WebsitePanel.EnterpriseServer { private System.Threading.SendOrPostCallback GetOrganizationRdsUsersCountOperationCompleted; + private System.Threading.SendOrPostCallback GetApplicationUsersOperationCompleted; + + private System.Threading.SendOrPostCallback SetApplicationUsersOperationCompleted; + /// public esRemoteDesktopServices() { this.Url = "http://localhost:9002/esRemoteDesktopServices.asmx"; @@ -180,6 +184,12 @@ namespace WebsitePanel.EnterpriseServer { /// public event GetOrganizationRdsUsersCountCompletedEventHandler GetOrganizationRdsUsersCountCompleted; + /// + public event GetApplicationUsersCompletedEventHandler GetApplicationUsersCompleted; + + /// + public event SetApplicationUsersCompletedEventHandler SetApplicationUsersCompleted; + /// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetRdsCollection", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] public RdsCollection GetRdsCollection(int collectionId) { @@ -1503,6 +1513,103 @@ namespace WebsitePanel.EnterpriseServer { } } + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetApplicationUsers", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public string[] GetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp) { + object[] results = this.Invoke("GetApplicationUsers", new object[] { + itemId, + collectionId, + remoteApp}); + return ((string[])(results[0])); + } + + /// + public System.IAsyncResult BeginGetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("GetApplicationUsers", new object[] { + itemId, + collectionId, + remoteApp}, callback, asyncState); + } + + /// + public string[] EndGetApplicationUsers(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((string[])(results[0])); + } + + /// + public void GetApplicationUsersAsync(int itemId, int collectionId, RemoteApplication remoteApp) { + this.GetApplicationUsersAsync(itemId, collectionId, remoteApp, null); + } + + /// + public void GetApplicationUsersAsync(int itemId, int collectionId, RemoteApplication remoteApp, object userState) { + if ((this.GetApplicationUsersOperationCompleted == null)) { + this.GetApplicationUsersOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetApplicationUsersOperationCompleted); + } + this.InvokeAsync("GetApplicationUsers", new object[] { + itemId, + collectionId, + remoteApp}, this.GetApplicationUsersOperationCompleted, userState); + } + + private void OnGetApplicationUsersOperationCompleted(object arg) { + if ((this.GetApplicationUsersCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetApplicationUsersCompleted(this, new GetApplicationUsersCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/SetApplicationUsers", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public ResultObject SetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp, string[] users) { + object[] results = this.Invoke("SetApplicationUsers", new object[] { + itemId, + collectionId, + remoteApp, + users}); + return ((ResultObject)(results[0])); + } + + /// + public System.IAsyncResult BeginSetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp, string[] users, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("SetApplicationUsers", new object[] { + itemId, + collectionId, + remoteApp, + users}, callback, asyncState); + } + + /// + public ResultObject EndSetApplicationUsers(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((ResultObject)(results[0])); + } + + /// + public void SetApplicationUsersAsync(int itemId, int collectionId, RemoteApplication remoteApp, string[] users) { + this.SetApplicationUsersAsync(itemId, collectionId, remoteApp, users, null); + } + + /// + public void SetApplicationUsersAsync(int itemId, int collectionId, RemoteApplication remoteApp, string[] users, object userState) { + if ((this.SetApplicationUsersOperationCompleted == null)) { + this.SetApplicationUsersOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetApplicationUsersOperationCompleted); + } + this.InvokeAsync("SetApplicationUsers", new object[] { + itemId, + collectionId, + remoteApp, + users}, this.SetApplicationUsersOperationCompleted, userState); + } + + private void OnSetApplicationUsersOperationCompleted(object arg) { + if ((this.SetApplicationUsersCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SetApplicationUsersCompleted(this, new SetApplicationUsersCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// public new void CancelAsync(object userState) { base.CancelAsync(userState); @@ -2262,4 +2369,56 @@ namespace WebsitePanel.EnterpriseServer { } } } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void GetApplicationUsersCompletedEventHandler(object sender, GetApplicationUsersCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetApplicationUsersCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal GetApplicationUsersCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public string[] Result { + get { + this.RaiseExceptionIfNecessary(); + return ((string[])(this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void SetApplicationUsersCompletedEventHandler(object sender, SetApplicationUsersCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class SetApplicationUsersCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal SetApplicationUsersCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public ResultObject Result { + get { + this.RaiseExceptionIfNecessary(); + return ((ResultObject)(this.results[0])); + } + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs index 471a6adb..2c21c32f 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs @@ -203,6 +203,16 @@ namespace WebsitePanel.EnterpriseServer return GetOrganizationRdsUsersCountInternal(itemId); } + public static List GetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp) + { + return GetApplicationUsersInternal(itemId, collectionId, remoteApp); + } + + public static ResultObject SetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp, List users) + { + return SetApplicationUsersInternal(itemId, collectionId, remoteApp, users); + } + private static RdsCollection GetRdsCollectionInternal(int collectionId) { var collection = ObjectUtils.FillObjectFromDataReader(DataProvider.GetRDSCollectionById(collectionId)); @@ -832,7 +842,7 @@ namespace WebsitePanel.EnterpriseServer private static List GetRdsCollectionUsersInternal(int collectionId) { return ObjectUtils.CreateListFromDataReader(DataProvider.GetRDSCollectionUsersByRDSCollectionId(collectionId)); - } + } private static ResultObject SetUsersToRdsCollectionInternal(int itemId, int collectionId, List users) { @@ -912,6 +922,61 @@ namespace WebsitePanel.EnterpriseServer return result; } + private static List GetApplicationUsersInternal(int itemId, int collectionId, RemoteApplication remoteApp) + { + var result = new List(); + Organization org = OrganizationController.GetOrganization(itemId); + + if (org == null) + { + return result; + } + + var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId)); + var collection = GetRdsCollection(collectionId); + + result.AddRange(rds.GetApplicationUsers(collection.Name, remoteApp.DisplayName)); + + return result; + } + + private static ResultObject SetApplicationUsersInternal(int itemId, int collectionId, RemoteApplication remoteApp, List users) + { + var result = TaskManager.StartResultTask("REMOTE_DESKTOP_SERVICES", "SET_REMOTE_APP_USERS"); + + try + { + Organization org = OrganizationController.GetOrganization(itemId); + if (org == null) + { + result.IsSuccess = false; + result.AddError("", new NullReferenceException("Organization not found")); + return result; + } + + var collection = GetRdsCollection(collectionId); + var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId)); + rds.SetApplicationUsers(collection.Name, remoteApp, users.ToArray()); + } + catch (Exception ex) + { + result.AddError("REMOTE_DESKTOP_SERVICES_SET_REMOTE_APP_USERS", ex); + } + finally + { + if (!result.IsSuccess) + { + TaskManager.CompleteResultTask(result); + } + else + { + TaskManager.CompleteResultTask(); + } + } + + return result; + } + private static ResultObject AddRemoteApplicationToCollectionInternal(int itemId, RdsCollection collection, RemoteApplication remoteApp) { var result = TaskManager.StartResultTask("REMOTE_DESKTOP_SERVICES", "ADD_REMOTE_APP_TO_COLLECTION"); diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs index 05baf26c..f05d3ca3 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs @@ -236,5 +236,16 @@ namespace WebsitePanel.EnterpriseServer return RemoteDesktopServicesController.GetOrganizationRdsUsersCount(itemId); } + [WebMethod] + public List GetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp) + { + return RemoteDesktopServicesController.GetApplicationUsers(itemId, collectionId, remoteApp); + } + + [WebMethod] + public ResultObject SetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp, List users) + { + return RemoteDesktopServicesController.SetApplicationUsers(itemId, collectionId, remoteApp, users); + } } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs index 7a92294a..6de22e8d 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs @@ -61,5 +61,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices bool CheckSessionHostFeatureInstallation(string hostName); bool CheckServerAvailability(string hostName); + string[] GetApplicationUsers(string collectionName, string applicationName); + bool SetApplicationUsers(string collectionName, RemoteApplication remoteApp, string[] users); } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs index b01884db..16552df1 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs @@ -496,6 +496,70 @@ namespace WebsitePanel.Providers.RemoteDesktopServices #region Remote Applications + public string[] GetApplicationUsers(string collectionName, string applicationName) + { + Runspace runspace = null; + List result = new List(); + + try + { + runspace = OpenRunspace(); + + Command cmd = new Command("Get-RDRemoteApp"); + cmd.Parameters.Add("CollectionName", collectionName); + cmd.Parameters.Add("ConnectionBroker", ConnectionBroker); + cmd.Parameters.Add("DisplayName", applicationName); + + var application = ExecuteShellCommand(runspace, cmd, false).FirstOrDefault(); + + if (application != null) + { + var users = (string[])(GetPSObjectProperty(application, "UserGroups")); + + if (users != null) + { + result.AddRange(users); + } + } + } + finally + { + CloseRunspace(runspace); + } + + return result.ToArray(); + } + + public bool SetApplicationUsers(string collectionName, RemoteApplication remoteApp, string[] users) + { + Runspace runspace = null; + bool result = true; + + try + { + runspace = OpenRunspace(); + + Command cmd = new Command("Set-RDRemoteApp"); + cmd.Parameters.Add("CollectionName", collectionName); + cmd.Parameters.Add("ConnectionBroker", ConnectionBroker); + cmd.Parameters.Add("DisplayName", remoteApp.DisplayName); + cmd.Parameters.Add("UserGroups", users); + cmd.Parameters.Add("Alias", remoteApp.Alias); + + ExecuteShellCommand(runspace, cmd, false).FirstOrDefault(); + } + catch(Exception) + { + result = false; + } + finally + { + CloseRunspace(runspace); + } + + return result; + } + public List GetAvailableRemoteApplications(string collectionName) { var startApps = new List(); diff --git a/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs b/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs index a78e54ae..f3f14bca 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs @@ -65,6 +65,10 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { private System.Threading.SendOrPostCallback CheckServerAvailabilityOperationCompleted; + private System.Threading.SendOrPostCallback GetApplicationUsersOperationCompleted; + + private System.Threading.SendOrPostCallback SetApplicationUsersOperationCompleted; + /// public RemoteDesktopServices() { this.Url = "http://localhost:9003/RemoteDesktopServices.asmx"; @@ -124,6 +128,12 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { /// public event CheckServerAvailabilityCompletedEventHandler CheckServerAvailabilityCompleted; + /// + public event GetApplicationUsersCompletedEventHandler GetApplicationUsersCompleted; + + /// + public event SetApplicationUsersCompletedEventHandler SetApplicationUsersCompleted; + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/CreateCollection", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] @@ -918,6 +928,99 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { } } + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetApplicationUsers", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public string[] GetApplicationUsers(string collectionName, string applicationName) { + object[] results = this.Invoke("GetApplicationUsers", new object[] { + collectionName, + applicationName}); + return ((string[])(results[0])); + } + + /// + public System.IAsyncResult BeginGetApplicationUsers(string collectionName, string applicationName, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("GetApplicationUsers", new object[] { + collectionName, + applicationName}, callback, asyncState); + } + + /// + public string[] EndGetApplicationUsers(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((string[])(results[0])); + } + + /// + public void GetApplicationUsersAsync(string collectionName, string applicationName) { + this.GetApplicationUsersAsync(collectionName, applicationName, null); + } + + /// + public void GetApplicationUsersAsync(string collectionName, string applicationName, object userState) { + if ((this.GetApplicationUsersOperationCompleted == null)) { + this.GetApplicationUsersOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetApplicationUsersOperationCompleted); + } + this.InvokeAsync("GetApplicationUsers", new object[] { + collectionName, + applicationName}, this.GetApplicationUsersOperationCompleted, userState); + } + + private void OnGetApplicationUsersOperationCompleted(object arg) { + if ((this.GetApplicationUsersCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetApplicationUsersCompleted(this, new GetApplicationUsersCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/SetApplicationUsers", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public bool SetApplicationUsers(string collectionName, RemoteApplication remoteApp, string[] users) { + object[] results = this.Invoke("SetApplicationUsers", new object[] { + collectionName, + remoteApp, + users}); + return ((bool)(results[0])); + } + + /// + public System.IAsyncResult BeginSetApplicationUsers(string collectionName, RemoteApplication remoteApp, string[] users, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("SetApplicationUsers", new object[] { + collectionName, + remoteApp, + users}, callback, asyncState); + } + + /// + public bool EndSetApplicationUsers(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((bool)(results[0])); + } + + /// + public void SetApplicationUsersAsync(string collectionName, RemoteApplication remoteApp, string[] users) { + this.SetApplicationUsersAsync(collectionName, remoteApp, users, null); + } + + /// + public void SetApplicationUsersAsync(string collectionName, RemoteApplication remoteApp, string[] users, object userState) { + if ((this.SetApplicationUsersOperationCompleted == null)) { + this.SetApplicationUsersOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetApplicationUsersOperationCompleted); + } + this.InvokeAsync("SetApplicationUsers", new object[] { + collectionName, + remoteApp, + users}, this.SetApplicationUsersOperationCompleted, userState); + } + + private void OnSetApplicationUsersOperationCompleted(object arg) { + if ((this.SetApplicationUsersCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SetApplicationUsersCompleted(this, new SetApplicationUsersCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// public new void CancelAsync(object userState) { base.CancelAsync(userState); @@ -1281,4 +1384,56 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { } } } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void GetApplicationUsersCompletedEventHandler(object sender, GetApplicationUsersCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetApplicationUsersCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal GetApplicationUsersCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public string[] Result { + get { + this.RaiseExceptionIfNecessary(); + return ((string[])(this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void SetApplicationUsersCompletedEventHandler(object sender, SetApplicationUsersCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class SetApplicationUsersCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal SetApplicationUsersCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public bool Result { + get { + this.RaiseExceptionIfNecessary(); + return ((bool)(this.results[0])); + } + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs b/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs index d515b37a..46ebb460 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs @@ -359,6 +359,39 @@ namespace WebsitePanel.Server throw; } } - } + [WebMethod, SoapHeader("settings")] + public string[] GetApplicationUsers(string collectionName, string applicationName) + { + try + { + Log.WriteStart("'{0}' GetApplicationUsers", ProviderSettings.ProviderName); + var result = RDSProvider.GetApplicationUsers(collectionName, applicationName); + Log.WriteEnd("'{0}' GetApplicationUsers", ProviderSettings.ProviderName); + return result; + } + catch (Exception ex) + { + Log.WriteError(String.Format("'{0}' GetApplicationUsers", ProviderSettings.ProviderName), ex); + throw; + } + } + + [WebMethod, SoapHeader("settings")] + public bool SetApplicationUsers(string collectionName, RemoteApplication remoteApp, string[] users) + { + try + { + Log.WriteStart("'{0}' SetApplicationUsers", ProviderSettings.ProviderName); + var result = RDSProvider.SetApplicationUsers(collectionName, remoteApp, users); + Log.WriteEnd("'{0}' SetApplicationUsers", ProviderSettings.ProviderName); + return result; + } + catch (Exception ex) + { + Log.WriteError(String.Format("'{0}' SetApplicationUsers", ProviderSettings.ProviderName), ex); + throw; + } + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ESModule_ControlsHierarchy.config b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ESModule_ControlsHierarchy.config index 43015b80..5e7e4ae7 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ESModule_ControlsHierarchy.config +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ESModule_ControlsHierarchy.config @@ -141,5 +141,6 @@ + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Modules.config b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Modules.config index 239c3893..da90d397 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Modules.config +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Modules.config @@ -574,6 +574,7 @@ + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/App_LocalResources/RDSEditApplicationUsers.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/App_LocalResources/RDSEditApplicationUsers.ascx.resx new file mode 100644 index 00000000..a1ffcecb --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/App_LocalResources/RDSEditApplicationUsers.ascx.resx @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ShowProgressDialog('Adding RDS Server ...'); + + + Save Changes + + + + + + Edit RDS Application + + + Edit RDS Application + + + Application Name: + + + Server Name + + + No RDS Servers have been added yet. To add a new RDS Servers click "Add RDS Server" button. + + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx new file mode 100644 index 00000000..2dc96cb7 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx @@ -0,0 +1,46 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RDSEditApplicationUsers.ascx.cs" Inherits="WebsitePanel.Portal.RDS.RDSEditApplicationUsers" %> +<%@ Register Src="../UserControls/SimpleMessageBox.ascx" TagName="SimpleMessageBox" TagPrefix="wsp" %> +<%@ Register Src="../UserControls/EnableAsyncTasksSupport.ascx" TagName="EnableAsyncTasksSupport" TagPrefix="wsp" %> +<%@ Register Src="UserControls/RDSCollectionUsers.ascx" TagName="CollectionUsers" TagPrefix="wsp"%> + + + + +
+
+
+
+
+
+
+ + +
+
+ + + + + + + +
+ +
+ +
+ +
+ +
+
+ +
+ + +
+
+
+
+
+
\ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.cs new file mode 100644 index 00000000..95b7448f --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using WebsitePanel.Providers.RemoteDesktopServices; + +namespace WebsitePanel.Portal.RDS +{ + public partial class RDSEditApplicationUsers : WebsitePanelModuleBase + { + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + var collection = ES.Services.RDS.GetRdsCollection(PanelRequest.CollectionID); + var applications = ES.Services.RDS.GetCollectionRemoteApplications(PanelRequest.ItemID, collection.Name); + var remoteApp = applications.Where(x => x.DisplayName.Equals(PanelRequest.ApplicationID, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault(); + var collectionUsers = ES.Services.RDS.GetRdsCollectionUsers(PanelRequest.CollectionID); + var applicationUsers = ES.Services.RDS.GetApplicationUsers(PanelRequest.ItemID, PanelRequest.CollectionID, remoteApp); + + locCName.Text = collection.Name; + + users.SetUsers(collectionUsers.Where(x => applicationUsers.Contains(x.SamAccountName)).ToArray()); + } + } + + protected void btnSave_Click(object sender, EventArgs e) + { + if (!Page.IsValid) + { + return; + } + + try + { + var collection = ES.Services.RDS.GetRdsCollection(PanelRequest.CollectionID); + var applications = ES.Services.RDS.GetCollectionRemoteApplications(PanelRequest.ItemID, collection.Name); + var remoteApp = applications.Where(x => x.DisplayName.Equals(PanelRequest.ApplicationID, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault(); + ES.Services.RDS.SetApplicationUsers(PanelRequest.ItemID, PanelRequest.CollectionID, remoteApp, users.GetUsers().Select(x => x.AccountName).ToArray()); + + Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "rds_collection_edit_apps", "CollectionId=" + PanelRequest.CollectionID, "ItemID=" + PanelRequest.ItemID)); + } + catch (Exception) + { + } + } + } +} \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.designer.cs new file mode 100644 index 00000000..8ece837d --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.designer.cs @@ -0,0 +1,114 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WebsitePanel.Portal.RDS { + + + public partial class RDSEditApplicationUsers { + + /// + /// asyncTasks control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.EnableAsyncTasksSupport asyncTasks; + + /// + /// imgEditRDSCollection control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Image imgEditRDSCollection; + + /// + /// locTitle control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locTitle; + + /// + /// messageBox control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.UserControls.SimpleMessageBox messageBox; + + /// + /// locApplicationName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locApplicationName; + + /// + /// locCName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locCName; + + /// + /// UsersPanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl UsersPanel; + + /// + /// locUsersSection control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locUsersSection; + + /// + /// users control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.RDS.UserControls.RDSCollectionUsers users; + + /// + /// btnSave control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSave; + + /// + /// valSummary control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.ValidationSummary valSummary; + } +} diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionApps.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionApps.ascx.cs index 0d647cb3..cfd3e35d 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionApps.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionApps.ascx.cs @@ -48,7 +48,7 @@ namespace WebsitePanel.Portal.RDS locCName.Text = collection.Name; - remoreApps.SetApps(collectionApps); + remoreApps.SetApps(collectionApps, Module); } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx index fc3a8844..147cee05 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx @@ -21,13 +21,18 @@ - + + + + Users + +
diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx.cs index d00a249e..684b9dd7 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx.cs @@ -54,6 +54,12 @@ namespace WebsitePanel.Portal.RDS.UserControls BindApps(apps, false); } + public void SetApps(RemoteApplication[] apps, WebPortal.PageModule module) + { + Module = module; + BindApps(apps, false); + } + public RemoteApplication[] GetApps() { return GetGridViewApps(SelectedState.All).ToArray(); @@ -218,5 +224,11 @@ namespace WebsitePanel.Portal.RDS.UserControls { return string.Compare(app1.DisplayName, app2.DisplayName); } + + public string GetCollectionUsersEditUrl(string appId) + { + return EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "rds_application_edit_users", + "CollectionId=" + PanelRequest.CollectionID, "ItemID=" + PanelRequest.ItemID, "ApplicationID=" + appId); + } } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj index cbc1312c..c98276a8 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj @@ -246,6 +246,13 @@ AddRDSServer.ascx + + RDSEditApplicationUsers.ascx + ASPXCodeBehind + + + RDSEditApplicationUsers.ascx + RDSEditCollection.ascx ASPXCodeBehind @@ -4282,6 +4289,7 @@ + @@ -4294,7 +4302,10 @@ - + + Designer + + Designer @@ -5607,7 +5618,9 @@ Designer - + + Designer + From 11c78bb5ebec5dc14d4f1f943e5b032cb4be77c9 Mon Sep 17 00:00:00 2001 From: dev_amdtel Date: Wed, 17 Dec 2014 19:43:58 +0400 Subject: [PATCH 16/32] wsp-10284 Enterprise solution report --- .../HostedSolution/ReportController.cs | 58 +++++++++++++++++-- .../SchedulerTasks/HostedSolutionReport.cs | 50 ++++++++++++++-- .../Scheduling/Scheduler.cs | 4 +- .../SchedulerService.cs | 19 ++++-- 4 files changed, 112 insertions(+), 19 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/ReportController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/ReportController.cs index fab50dff..ecf6ebdc 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/ReportController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/ReportController.cs @@ -278,11 +278,16 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution } private static void PopulateOrganizationData(Organization org, EnterpriseSolutionStatisticsReport report, string topReseller) - { + { + TaskManager.Write("Stat populate organization data "+org.Name); + if (report.ExchangeReport != null) { + try { + TaskManager.Write("Populate exchange report items"); + PopulateExchangeReportItems(org, report, topReseller); } catch(Exception ex) @@ -295,6 +300,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution { try { + TaskManager.Write("Populate populate CRM report items"); + PopulateCRMReportItems(org, report, topReseller); } catch(Exception ex) @@ -307,6 +314,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution { try { + TaskManager.Write("Populate SharePoint item "); + PopulateSharePointItem(org, report, topReseller); } catch(Exception ex) @@ -319,6 +328,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution { try { + TaskManager.Write("Populate Lync report items"); + PopulateLyncReportItems(org, report, topReseller); } catch (Exception ex) @@ -331,6 +342,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution { try { + TaskManager.Write("Populate Organization statistics report"); + PopulateOrganizationStatisticsReport(org, report, topReseller); } catch(Exception ex) @@ -339,7 +352,7 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution } } - + TaskManager.Write("End populate organization data " + org.Name); } private static int GetExchangeServiceID(int packageId) @@ -408,6 +421,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution private static void PopulateExchangeReportItems(Organization org, EnterpriseSolutionStatisticsReport report, string topReseller) { + TaskManager.Write("Exchange Report Items " + org.Name); + //Check if exchange organization if (string.IsNullOrEmpty(org.GlobalAddressList)) return; @@ -420,10 +435,14 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution } catch (Exception ex) { + TaskManager.WriteError(ex); + throw new ApplicationException( string.Format("Could not get mailboxes for current organization {0}", org.Id), ex); } + TaskManager.WriteParameter("mailboxes.Count", mailboxes.Count); + try { int exchangeServiceId = GetExchangeServiceID(org.PackageId); @@ -431,6 +450,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution } catch(Exception ex) { + TaskManager.WriteError(ex); + throw new ApplicationException( string.Format("Could not get exchange server. PackageId: {0}", org.PackageId), ex); } @@ -440,6 +461,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution { try { + TaskManager.WriteParameter("mailbox", mailbox.UserPrincipalName); + stats = null; try { @@ -448,6 +471,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution } catch (Exception ex) { + TaskManager.WriteError(ex); + TaskManager.WriteError(ex, "Could not get mailbox statistics. AccountName: {0}", mailbox.UserPrincipalName); } @@ -466,6 +491,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution stats.BlackberryEnabled = BlackBerryController.CheckBlackBerryUserExists(mailbox.AccountId); report.ExchangeReport.Items.Add(stats); + + TaskManager.Write("Items.Add"); } } catch(Exception ex) @@ -473,7 +500,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution TaskManager.WriteError(ex); } } - + + TaskManager.Write("End Populate Exchange Report Items " + org.Name); } @@ -547,6 +575,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution private static void PopulateSpaceData(int packageId, EnterpriseSolutionStatisticsReport report, string topReseller) { + TaskManager.Write("Populate SpaceData " + packageId); + List organizations; try @@ -570,10 +600,14 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution TaskManager.WriteError(ex); } } + + TaskManager.Write("End Populate SpaceData " + packageId); } private static void PopulateUserData(UserInfo user, EnterpriseSolutionStatisticsReport report, string topReseller) { + TaskManager.Write("Populate UserData " + user.Username); + DataSet ds; try { @@ -596,11 +630,14 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution TaskManager.WriteError(ex); } } - + + TaskManager.Write("End Populate UserData " + user.Username); } private static void GetUsersData(EnterpriseSolutionStatisticsReport report, int userId, bool generateExchangeReport, bool generateSharePointReport, bool generateCRMReport, bool generateOrganizationReport, bool generateLyncReport, string topReseller) { + TaskManager.Write("Get UsersData " + userId); + List users; try { @@ -611,9 +648,12 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution throw new ApplicationException("Cannot get users for report", ex); } + TaskManager.WriteParameter("users.Count", users.Count); foreach (UserInfo user in users) { + TaskManager.WriteParameter("User", user.Username); + try { PopulateUserData(user, report, topReseller); @@ -631,11 +671,16 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution { TaskManager.WriteError(ex); } - } + } + + TaskManager.Write("End get UsersData " + userId); + } public static EnterpriseSolutionStatisticsReport GetEnterpriseSolutionStatisticsReport(int userId, bool generateExchangeReport, bool generateSharePointReport, bool generateCRMReport, bool generateOrganizationReport, bool generateLyncReport) { + TaskManager.Write("Get enterprise solution statistics report " + userId); + EnterpriseSolutionStatisticsReport report = new EnterpriseSolutionStatisticsReport(); if (generateExchangeReport || generateOrganizationReport) @@ -647,7 +692,6 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution if (generateLyncReport || generateOrganizationReport) report.LyncReport = new LyncStatisticsReport(); - if (generateCRMReport || generateOrganizationReport) report.CRMReport = new CRMStatisticsReport(); @@ -664,6 +708,8 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution TaskManager.WriteError(ex, "Cannot get enterprise solution statistics report"); } + TaskManager.Write("End get enterprise solution statistics report " + userId); + return report; } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/HostedSolutionReport.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/HostedSolutionReport.cs index e0209bc1..e7f82265 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/HostedSolutionReport.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/HostedSolutionReport.cs @@ -32,6 +32,7 @@ using System.IO; using System.Net.Mail; using System.Net.Mime; using System.Text; +using WebsitePanel.EnterpriseServer; using WebsitePanel.EnterpriseServer.Code.HostedSolution; using WebsitePanel.Providers.HostedSolution; @@ -51,6 +52,8 @@ namespace WebsitePanel.EnterpriseServer { try { + TaskManager.Write("Start HostedSolutionReportTask"); + BackgroundTask topTask = TaskManager.TopTask; bool isExchange = Utils.ParseBool(topTask.GetParamValue(EXCHANGE_REPORT), false); @@ -61,23 +64,41 @@ namespace WebsitePanel.EnterpriseServer string email = topTask.GetParamValue(EMAIL).ToString(); + TaskManager.WriteParameter("isExchange",isExchange); + TaskManager.WriteParameter("isSharePoint",isSharePoint); + TaskManager.WriteParameter("isLync", isLync); + TaskManager.WriteParameter("isCRM", isCRM); + TaskManager.WriteParameter("isOrganization", isOrganization); + TaskManager.WriteParameter("email", email); UserInfo user = PackageController.GetPackageOwner(topTask.PackageId); + + TaskManager.WriteParameter("user", user.Username); + EnterpriseSolutionStatisticsReport report = ReportController.GetEnterpriseSolutionStatisticsReport(user.UserId, isExchange, isSharePoint, isCRM, isOrganization, isLync); + TaskManager.WriteParameter("report.ExchangeReport.Items.Count", report.ExchangeReport.Items.Count); + TaskManager.WriteParameter("report.SharePointReport.Items.Count", report.SharePointReport.Items.Count); + TaskManager.WriteParameter("report.CRMReport.Items.Count", report.CRMReport.Items.Count); + TaskManager.WriteParameter("report.OrganizationReport.Items.Count", report.OrganizationReport.Items.Count); + TaskManager.WriteParameter("report.LyncReport.Items.Count", report.LyncReport.Items.Count); SendMessage(user, email, isExchange && report.ExchangeReport != null ? report.ExchangeReport.ToCSV() : string.Empty, isSharePoint && report.SharePointReport != null ? report.SharePointReport.ToCSV() : string.Empty, isCRM && report.CRMReport != null ? report.CRMReport.ToCSV() : string.Empty, isOrganization && report.OrganizationReport != null ? report.OrganizationReport.ToCSV() : string.Empty, isLync && report.LyncReport != null ? report.LyncReport.ToCSV() : string.Empty); + } catch(Exception ex) { TaskManager.WriteError(ex); } + + TaskManager.Write("End HostedSolutionReportTask"); + } @@ -97,6 +118,8 @@ namespace WebsitePanel.EnterpriseServer private void SendMessage(UserInfo user,string email, string exchange_csv, string sharepoint_csv, string crm_csv, string organization_csv, string lync_csv) { + TaskManager.Write("SendMessage"); + List attacments = new List(); PrepareAttament("exchange.csv", exchange_csv, attacments); PrepareAttament("sharepoint.csv", sharepoint_csv, attacments); @@ -104,9 +127,6 @@ namespace WebsitePanel.EnterpriseServer PrepareAttament("crm.csv", crm_csv, attacments); PrepareAttament("organization.csv", organization_csv, attacments); - - - // get letter settings UserSettings settings = UserController.GetUserSettings(user.UserId, UserSettings.HOSTED_SOLUTION_REPORT); @@ -116,9 +136,29 @@ namespace WebsitePanel.EnterpriseServer string body = user.HtmlMail ? settings["HtmlBody"] : settings["TextBody"]; bool isHtml = user.HtmlMail; - MailPriority priority = MailPriority.Normal; + MailPriority priority = MailPriority.Normal; + + TaskManager.WriteParameter("from", from); + TaskManager.WriteParameter("email", email); + TaskManager.WriteParameter("subject", subject); + TaskManager.WriteParameter("body", body); + - MailHelper.SendMessage(from, email, cc, subject, body, priority, isHtml, attacments.ToArray()); + int res = MailHelper.SendMessage(from, email, cc, subject, body, priority, isHtml, attacments.ToArray()); + + if (res==0) + { + TaskManager.Write("SendMessage OK"); + } + else + { + TaskManager.WriteError("SendMessage error ", "error code", res.ToString()); + } + + TaskManager.WriteParameter("", res); + + TaskManager.Write("End SendMessage"); + } } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Scheduling/Scheduler.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Scheduling/Scheduler.cs index 6773f712..d3a65dd4 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Scheduling/Scheduler.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Scheduling/Scheduler.cs @@ -45,7 +45,7 @@ namespace WebsitePanel.EnterpriseServer public static SchedulerJob nextSchedule = null; public static void Start() - { + { ScheduleTasks(); } @@ -73,7 +73,7 @@ namespace WebsitePanel.EnterpriseServer private static void RunManualTasks() { - var tasks = TaskController.GetProcessTasks(BackgroundTaskStatus.Stopping); + var tasks = TaskController.GetProcessTasks(BackgroundTaskStatus.Stopping); foreach (var task in tasks) { diff --git a/WebsitePanel/Sources/WebsitePanel.SchedulerService/SchedulerService.cs b/WebsitePanel/Sources/WebsitePanel.SchedulerService/SchedulerService.cs index 2f017c19..92d0128a 100644 --- a/WebsitePanel/Sources/WebsitePanel.SchedulerService/SchedulerService.cs +++ b/WebsitePanel/Sources/WebsitePanel.SchedulerService/SchedulerService.cs @@ -35,15 +35,16 @@ namespace WebsitePanel.SchedulerService public partial class SchedulerService : ServiceBase { private Timer _Timer; - private static bool _isRuninng; + private static object _isRuninng; #region Construcor public SchedulerService() { + _isRuninng = new object(); + InitializeComponent(); _Timer = new Timer(Process, null, 5000, 5000); - _isRuninng = false; } #endregion @@ -57,12 +58,18 @@ namespace WebsitePanel.SchedulerService protected static void Process(object callback) { //check running service - if (_isRuninng) + if (!Monitor.TryEnter(_isRuninng)) return; - _isRuninng = true; - Scheduler.Start(); - _isRuninng = false; + try + { + Scheduler.Start(); + } + finally + { + Monitor.Exit(_isRuninng); + } + } #endregion From df814794a23b0641671b4712d70e7e3c806a2a7c Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Wed, 17 Dec 2014 08:13:29 -0800 Subject: [PATCH 17/32] Domain lookup mail template changed --- WebsitePanel/Database/update_db.sql | 11 +++-- .../SchedulerTasks/DomainLookupViewTask.cs | 41 +++++++++++++++++-- .../DomainLookup/DnsRecordInfoChange.cs | 3 +- .../DomainLookup/DomainDnsRecordStatuses.cs | 3 +- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 065e83ae..0b4c21ad 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -6393,7 +6393,8 @@ Please, find below details of MX and NS changes. DNS Type Status - Value + Old Value + New Value @@ -6402,7 +6403,8 @@ Please, find below details of MX and NS changes. #DnsChange.DnsServer# #DnsChange.Type# #DnsChange.Status# - #DnsChange.Record.Value# + #DnsChange.OldRecord.Value# + #DnsChange.NewRecord.Value# @@ -6449,8 +6451,9 @@ Please, find below MX and NS Changes Information. DNS: #DnsChange.DnsServer# Type: #DnsChange.Type# - Status: #DnsChange.Status# - Value: #DnsChange.Record.Value# + Status: #DnsChange.Status# + Old Value: #DnsChange.OldRecord.Value# + New Value: #DnsChange.NewRecord.Value# diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs index b5a7c8ee..150c9c25 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs @@ -99,6 +99,8 @@ namespace WebsitePanel.EnterpriseServer domainChanges.DnsChanges.AddRange(ApplyDomainRecordsChanges(dbDnsRecords.Where(x => x.RecordType == DnsRecordType.MX), dnsMxRecords, dnsServer)); domainChanges.DnsChanges.AddRange(ApplyDomainRecordsChanges(dbDnsRecords.Where(x => x.RecordType == DnsRecordType.NS), dnsNsRecords, dnsServer)); + + domainChanges.DnsChanges = CombineDnsRecordChanges(domainChanges.DnsChanges, dnsServer).ToList(); } domainsChanges.Add(domainChanges); @@ -150,13 +152,13 @@ namespace WebsitePanel.EnterpriseServer if (dnsRecord != null) { - dnsRecordChanges.Add(new DnsRecordInfoChange { Record = record, Type = record.RecordType, Status = DomainDnsRecordStatuses.NotChanged, DnsServer = dnsServer }); + dnsRecordChanges.Add(new DnsRecordInfoChange { OldRecord = record, NewRecord = dnsRecord, Type = record.RecordType, Status = DomainDnsRecordStatuses.NotChanged, DnsServer = dnsServer }); dnsRecords.Remove(dnsRecord); } else { - dnsRecordChanges.Add(new DnsRecordInfoChange { Record = record, Type = record.RecordType, Status = DomainDnsRecordStatuses.Removed, DnsServer = dnsServer }); + dnsRecordChanges.Add(new DnsRecordInfoChange { OldRecord = record, NewRecord = new DnsRecordInfo { Value = string.Empty}, Type = record.RecordType, Status = DomainDnsRecordStatuses.Removed, DnsServer = dnsServer }); RemoveRecord(record); } @@ -164,7 +166,7 @@ namespace WebsitePanel.EnterpriseServer foreach (var record in dnsRecords) { - dnsRecordChanges.Add(new DnsRecordInfoChange { Record = record, Type = record.RecordType, Status = DomainDnsRecordStatuses.Added, DnsServer= dnsServer}); + dnsRecordChanges.Add(new DnsRecordInfoChange { OldRecord = new DnsRecordInfo { Value = string.Empty }, NewRecord = record, Type = record.RecordType, Status = DomainDnsRecordStatuses.Added, DnsServer = dnsServer }); AddRecord(record); } @@ -172,6 +174,39 @@ namespace WebsitePanel.EnterpriseServer return dnsRecordChanges; } + private IEnumerable CombineDnsRecordChanges(IEnumerable records, string dnsServer) + { + var resultRecords = records.Where(x => x.DnsServer == dnsServer).ToList(); + + var recordsToRemove = new List(); + + var removedRecords = records.Where(x => x.Status == DomainDnsRecordStatuses.Removed); + var addedRecords = records.Where(x => x.Status == DomainDnsRecordStatuses.Added); + + foreach (DnsRecordType type in (DnsRecordType[])Enum.GetValues(typeof(DnsRecordType))) + { + foreach (var removedRecord in removedRecords.Where(x => x.Type == type)) + { + var addedRecord = addedRecords.FirstOrDefault(x => x.Type == type && !recordsToRemove.Contains(x)); + + if (addedRecord != null) + { + recordsToRemove.Add(addedRecord); + + removedRecord.NewRecord = addedRecord.NewRecord; + removedRecord.Status = DomainDnsRecordStatuses.Updated; + } + } + } + + foreach (var record in recordsToRemove) + { + resultRecords.Remove(record); + } + + return resultRecords; + } + private void FillRecordData(IEnumerable records, DomainInfo domain, string dnsServer) { foreach (var record in records) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DnsRecordInfoChange.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DnsRecordInfoChange.cs index 183c16e0..a5c0306b 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DnsRecordInfoChange.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DnsRecordInfoChange.cs @@ -9,7 +9,8 @@ namespace WebsitePanel.Providers.DomainLookup public class DnsRecordInfoChange { public string DnsServer { get; set; } - public DnsRecordInfo Record { get; set; } + public DnsRecordInfo OldRecord { get; set; } + public DnsRecordInfo NewRecord { get; set; } public DomainDnsRecordStatuses Status { get; set; } public DnsRecordType Type { get; set; } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsRecordStatuses.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsRecordStatuses.cs index 88fa25ed..33bddf37 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsRecordStatuses.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsRecordStatuses.cs @@ -9,6 +9,7 @@ namespace WebsitePanel.Providers.DomainLookup { NotChanged, Removed, - Added + Added, + Updated } } From 9a1231e5d7d96d22baf577ed8a12d7c927982acd Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Wed, 17 Dec 2014 12:06:33 -0500 Subject: [PATCH 18/32] Added tag build-2.1.0.491 for changeset 1415335ff650 From e8a256d64fdf1e21af98be6ba7c5c7823354b3cd Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Wed, 17 Dec 2014 12:27:13 -0500 Subject: [PATCH 19/32] Added tag build-2.1.0.492 for changeset e1f06982c5ca From 37b3098f2e2d092446649f32f088f636fa0458f6 Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Wed, 17 Dec 2014 12:34:18 -0500 Subject: [PATCH 20/32] Added tag build-2.1.0.493 for changeset e1f06982c5ca From f4cf20d0dcb6416e41f381d29fb3abaf01890e8b Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Wed, 17 Dec 2014 22:33:28 -0500 Subject: [PATCH 21/32] Patch for WSP10262 --- .../Servers/ServerController.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs index 820fce03..9d07df37 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs @@ -30,6 +30,7 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Data; +using System.Linq; using System.Net; using System.Xml; using WebsitePanel.Providers; @@ -2188,11 +2189,13 @@ namespace WebsitePanel.EnterpriseServer } } + // Find and delete all zone items for this domain + var zoneItems = PackageController.GetPackageItemsByType(domain.PackageId, ResourceGroups.Dns, typeof (DnsZone)); + zoneItems.AddRange(PackageController.GetPackageItemsByType(domain.PackageId, ResourceGroups.Dns, typeof(SecondaryDnsZone))); - // remove DNS zone meta-item if required - if (domain.ZoneItemId > 0) + foreach (var zoneItem in zoneItems.Where(z => z.Name == domain.ZoneName)) { - PackageController.DeletePackageItem(domain.ZoneItemId); + PackageController.DeletePackageItem(zoneItem.Id); } // delete domain From 1d0ac2dc8368df638993ae3a57979e48b1c2bd48 Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Wed, 17 Dec 2014 22:50:14 -0500 Subject: [PATCH 22/32] Added tag build-2.1.0.494 for changeset 1472573ee366 From a5120e14b27921ea9804fd15bb7c30071a5b668c Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Thu, 18 Dec 2014 03:09:23 -0800 Subject: [PATCH 23/32] ST fixes --- WebsitePanel/Database/update_db.sql | 411 +++++++++--------- .../SchedulerTasks/DomainExpirationTask.cs | 15 +- .../SchedulerTasks/DomainLookupViewTask.cs | 14 +- .../DomainLookup/DomainDnsChanges.cs | 1 + .../App_LocalResources/Domains.ascx.resx | 3 + .../WebsitePanel/Domains.ascx.cs | 11 +- 6 files changed, 242 insertions(+), 213 deletions(-) diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 0b4c21ad..0b4b54b5 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -6200,91 +6200,91 @@ END GO IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainExpirationLetter' AND [PropertyName]= N'HtmlBody' ) BEGIN -INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainExpirationLetter', N'HtmlBody', N' - - Domain Expiration Information - - - -
- - -
- Domain Expiration Information -
- - -

-Hello #user.FirstName#, -

-
- -

-Please, find below details of your domain expiration information. -

- - - - - - - - - - - - - - - - - - -
DomainCustomerExpiration Date
#Domain.DomainName##Domain.Customer#Expired
- - -

- Please, find below details of your non-existen domains. -

- - - - - - - - - - - - - - - - -
DomainCustomer
#Domain.DomainName##Domain.Customer#
-
- - -

-If you have any questions regarding your hosting account, feel free to contact our support department at any time. -

- -

-Best regards +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainExpirationLetter', N'HtmlBody', N' + + Domain Expiration Information + + + +

+ + +
+ Domain Expiration Information +
+ + +

+Hello #user.FirstName#, +

+
+ +

+Please, find below details of your domain expiration information. +

+ + + + + + + + + + + + + + + + + + +
DomainCustomerExpiration Date
#Domain.DomainName##Domain.Customer##Domain.ExpirationDate#
+ + +

+ Please, find below details of your non-existen domains. +

+ + + + + + + + + + + + + + + + +
DomainCustomer
#Domain.DomainName##Domain.Customer#
+
+ + +

+If you have any questions regarding your hosting account, feel free to contact our support department at any time. +

+ +

+Best regards

') END GO @@ -6313,7 +6313,7 @@ Please, find below details of your domain expiration information. Domain: #Domain.DomainName# Customer: #Domain.Customer# - Expiration Date: Expired + Expiration Date: #Domain.ExpirationDate# @@ -6348,76 +6348,76 @@ END GO IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'HtmlBody' ) BEGIN -INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'HtmlBody', N' - - MX and NS Changes Information - - - -
- - -
- MX and NS Changes Information -
- - -

-Hello #user.FirstName#, -

-
- -

-Please, find below details of MX and NS changes. -

- - -

#Domain.DomainName#

- - - - - - - - - - - - - - - - - - - - - - -
DNSTypeStatusOld ValueNew Value
#DnsChange.DnsServer##DnsChange.Type##DnsChange.Status##DnsChange.OldRecord.Value##DnsChange.NewRecord.Value#
- -
- -

-If you have any questions regarding your hosting account, feel free to contact our support department at any time. -

- -

-Best regards +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'HtmlBody', N' + + MX and NS Changes Information + + + +

+ + +
+ MX and NS Changes Information +
+ + +

+Hello #user.FirstName#, +

+
+ +

+Please, find below details of MX and NS changes. +

+ + +

#Domain.DomainName# - #DomainUsers[Domain.PackageId].FirstName# #DomainUsers[Domain.PackageId].LastName#

+ + + + + + + + + + + + + + + + + + + + + + +
DNSTypeStatusOld ValueNew Value
#DnsChange.DnsServer##DnsChange.Type##DnsChange.Status##DnsChange.OldRecord.Value##DnsChange.NewRecord.Value#
+ +
+ +

+If you have any questions regarding your hosting account, feel free to contact our support department at any time. +

+ +

+Best regards

') END GO @@ -6440,20 +6440,19 @@ INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [Property Hello #user.FirstName#, -Please, find below MX and NS Changes Information. - +Please, find below details of MX and NS changes. - #Domain.DomainName# + #Domain.DomainName# - #DomainUsers[Domain.PackageId].FirstName# #DomainUsers[Domain.PackageId].LastName# - DNS: #DnsChange.DnsServer# - Type: #DnsChange.Type# - Status: #DnsChange.Status# - Old Value: #DnsChange.OldRecord.Value# - New Value: #DnsChange.NewRecord.Value# + DNS: #DnsChange.DnsServer# + Type: #DnsChange.Type# + Status: #DnsChange.Status# + Old Value: #DnsChange.OldRecord.Value# + New Value: #DnsChange.NewRecord.Value# @@ -6468,48 +6467,48 @@ END GO IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'NoChangesHtmlBody' ) BEGIN -INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'NoChangesHtmlBody', N' - - MX and NS Changes Information - - - -
- - -
- MX and NS Changes Information -
- - -

-Hello #user.FirstName#, -

-
- -

-No MX and NS changes have been founded. -

- -

-If you have any questions regarding your hosting account, feel free to contact our support department at any time. -

- -

-Best regards +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'NoChangesHtmlBody', N' + + MX and NS Changes Information + + + +

+ + +
+ MX and NS Changes Information +
+ + +

+Hello #user.FirstName#, +

+
+ +

+No MX and NS changes have been found. +

+ +

+If you have any questions regarding your hosting account, feel free to contact our support department at any time. +

+ +

+Best regards

') END GO diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs index 9fb16aad..ef0cce8d 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainExpirationTask.cs @@ -32,7 +32,7 @@ namespace WebsitePanel.EnterpriseServer var checkedDomains = new List(); var expiredDomains = new List(); var nonExistenDomains = new List(); - var subDomains = new List(); + var allDomains = new List(); var allTopLevelDomains = new List(); // get input parameters @@ -58,7 +58,7 @@ namespace WebsitePanel.EnterpriseServer { var domains = ServerController.GetDomains(package.PackageId); - subDomains.AddRange(domains.Where(x => x.IsSubDomain)); + allDomains.AddRange(domains); domains = domains.Where(x => !x.IsSubDomain && !x.IsDomainPointer).ToList(); //Selecting top-level domains @@ -96,17 +96,24 @@ namespace WebsitePanel.EnterpriseServer } } - subDomains = subDomains.GroupBy(p => p.DomainId).Select(g => g.First()).ToList(); + var subDomains = allDomains.Where(x => x.ExpirationDate == null || CheckDomainExpiration(x.ExpirationDate, daysBeforeNotify)).GroupBy(p => p.DomainId).Select(g => g.First()).ToList(); allTopLevelDomains = allTopLevelDomains.GroupBy(p => p.DomainId).Select(g => g.First()).ToList(); foreach (var subDomain in subDomains) { - var mainDomain = allTopLevelDomains.Where(x => subDomain.DomainName.ToLowerInvariant().Contains(x.DomainName.ToLowerInvariant())).OrderByDescending(s => s.DomainName.Length).FirstOrDefault(); ; + var mainDomain = allTopLevelDomains.Where(x => subDomain.DomainId != x.DomainId && subDomain.DomainName.ToLowerInvariant().Contains(x.DomainName.ToLowerInvariant())).OrderByDescending(s => s.DomainName.Length).FirstOrDefault(); ; if (mainDomain != null) { ServerController.UpdateDomainRegistrationData(subDomain, mainDomain.CreationDate, mainDomain.ExpirationDate); + var nonExistenDomain = nonExistenDomains.FirstOrDefault(x => subDomain.DomainId == x.DomainId); + + if (nonExistenDomain != null) + { + nonExistenDomains.Remove(nonExistenDomain); + } + Thread.Sleep(100); } } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs index 150c9c25..d21a92a7 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs @@ -32,6 +32,7 @@ namespace WebsitePanel.EnterpriseServer BackgroundTask topTask = TaskManager.TopTask; List domainsChanges = new List(); + var domainUsers = new Dictionary(); // get input parameters string dnsServersString = (string)topTask.GetParamValue(DnsServersParameter); @@ -83,8 +84,16 @@ namespace WebsitePanel.EnterpriseServer continue; } + if (!domainUsers.ContainsKey(domain.PackageId)) + { + var domainUser = UserController.GetUser(packages.First(x=>x.PackageId == domain.PackageId).UserId); + + domainUsers.Add(domain.PackageId, domainUser); + } + DomainDnsChanges domainChanges = new DomainDnsChanges(); domainChanges.DomainName = domain.DomainName; + domainChanges.PackageId = domain.PackageId; var dbDnsRecords = ObjectUtils.CreateListFromDataReader(DataProvider.GetDomainAllDnsRecords(domain.DomainId)); @@ -109,7 +118,7 @@ namespace WebsitePanel.EnterpriseServer var changedDomains = FindDomainsWithChangedRecords(domainsChanges); - SendMailMessage(user, changedDomains); + SendMailMessage(user, changedDomains, domainUsers); } @@ -252,7 +261,7 @@ namespace WebsitePanel.EnterpriseServer Thread.Sleep(100); } - private void SendMailMessage(UserInfo user, IEnumerable domainsChanges) + private void SendMailMessage(UserInfo user, IEnumerable domainsChanges, Dictionary domainUsers) { BackgroundTask topTask = TaskManager.TopTask; @@ -286,6 +295,7 @@ namespace WebsitePanel.EnterpriseServer Hashtable items = new Hashtable(); items["user"] = user; + items["DomainUsers"] = domainUsers; items["Domains"] = domainsChanges; body = PackageController.EvaluateTemplate(body, items); diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsChanges.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsChanges.cs index ff178e77..3f19ef39 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsChanges.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/DomainLookup/DomainDnsChanges.cs @@ -8,6 +8,7 @@ namespace WebsitePanel.Providers.DomainLookup public class DomainDnsChanges { public string DomainName { get; set; } + public int PackageId { get; set; } public List DnsChanges { get; set; } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/Domains.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/Domains.ascx.resx index 3116414f..8ba7b6a4 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/Domains.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/Domains.ascx.resx @@ -213,4 +213,7 @@ Non-Existent + + Current Real DNS Values + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Domains.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Domains.ascx.cs index da0f5a67..06fb93e2 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Domains.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Domains.ascx.cs @@ -39,6 +39,7 @@ using System.Web.UI.HtmlControls; using System.Linq; using WebsitePanel.EnterpriseServer; +using System.Collections.Generic; namespace WebsitePanel.Portal { @@ -160,7 +161,15 @@ namespace WebsitePanel.Portal return "No Dns Records"; } - return string.Join("\r\n", records.Select(x=>string.Format("{0}: {1}", x.RecordType, x.Value))); + var header = GetLocalizedString("DomainLookup.TooltipHeader"); + + var tooltipLines = new List(); + + tooltipLines.Add(header); + tooltipLines.Add(" "); + tooltipLines.AddRange( records.Select(x=>string.Format("{0}: {1}", x.RecordType, x.Value))); + + return string.Join("\r\n", tooltipLines); } protected void odsDomainsPaged_Selected(object sender, ObjectDataSourceStatusEventArgs e) From a211800357dd427d0cf65b835a14afc2e9e8e50b Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Thu, 18 Dec 2014 06:49:44 -0500 Subject: [PATCH 24/32] Added tag build-2.1.0.495 for changeset 89c02e590ec9 From 75ccdbb916d4505b2155e3ee5ffaee479d5186bd Mon Sep 17 00:00:00 2001 From: "a.skorina" Date: Thu, 18 Dec 2014 17:50:06 +0300 Subject: [PATCH 25/32] scheduler installer fix --- .../Setup.SchedulerService/Product.wxs | 19 ++- .../CustomAction.cs | 119 +++++++++++++----- .../Common/SecurityUtils.cs | 19 +++ 3 files changed, 121 insertions(+), 36 deletions(-) diff --git a/WebsitePanel.Installer/Sources/Setup.SchedulerService/Product.wxs b/WebsitePanel.Installer/Sources/Setup.SchedulerService/Product.wxs index 59fc493e..42e79b27 100644 --- a/WebsitePanel.Installer/Sources/Setup.SchedulerService/Product.wxs +++ b/WebsitePanel.Installer/Sources/Setup.SchedulerService/Product.wxs @@ -82,7 +82,9 @@ - 1 + 1 + SKIPCONNECTIONSTRINGSTEP = "0" + SKIPCONNECTIONSTRINGSTEP = "1" 1 @@ -101,13 +103,15 @@ LicenseAccepted = "1" - 1 + SKIPCONNECTIONSTRINGSTEP = "0" + SKIPCONNECTIONSTRINGSTEP = "1" + (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL") - NOT Installed or REINSTALL + NOT Installed or REINSTALL @@ -115,9 +119,16 @@ - + + + + + + + + diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.SchedulerServiceInstaller/CustomAction.cs b/WebsitePanel.Installer/Sources/WebsitePanel.SchedulerServiceInstaller/CustomAction.cs index dbfaac3c..4fe768ea 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.SchedulerServiceInstaller/CustomAction.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.SchedulerServiceInstaller/CustomAction.cs @@ -27,6 +27,7 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using System; +using System.Collections.Generic; using System.Configuration.Install; using System.Data; using System.Data.SqlClient; @@ -35,6 +36,9 @@ using System.Linq; using System.ServiceProcess; using System.Text.RegularExpressions; using System.Threading; +using System.Windows.Forms; +using System.Windows.Forms.VisualStyles; +using System.Xml; using Microsoft.Deployment.WindowsInstaller; using WebsitePanel.Setup; @@ -42,6 +46,8 @@ namespace WebsitePanel.SchedulerServiceInstaller { public class CustomActions { + public const string CustomDataDelimiter = "-=del=-"; + [CustomAction] public static ActionResult CheckConnection(Session session) { @@ -63,9 +69,23 @@ namespace WebsitePanel.SchedulerServiceInstaller [CustomAction] public static ActionResult FinalizeInstall(Session session) { - ChangeConfigString("installer.connectionstring", session["CONNECTIONSTRING"], session["INSTALLFOLDER"]); - ChangeCryptoKey(session["INSTALLFOLDER"]); - InstallService(session["INSTALLFOLDER"]); + var connectionString = GetCustomActionProperty(session, "ConnectionString").Replace(CustomDataDelimiter, ";"); + var serviceFolder = GetCustomActionProperty(session, "ServiceFolder"); + var previousConnectionString = GetCustomActionProperty(session, "PreviousConnectionString").Replace(CustomDataDelimiter, ";"); + var previousCryptoKey = GetCustomActionProperty(session, "PreviousCryptoKey"); + + if (string.IsNullOrEmpty(serviceFolder)) + { + return ActionResult.Success; + } + + connectionString = string.IsNullOrEmpty(previousConnectionString) + ? connectionString + : previousConnectionString; + + ChangeConfigString("/configuration/connectionStrings/add[@name='EnterpriseServer']", "connectionString", connectionString, serviceFolder); + ChangeConfigString("/configuration/appSettings/add[@key='WebsitePanel.CryptoKey']", "value", previousCryptoKey, serviceFolder); + InstallService(serviceFolder); return ActionResult.Success; } @@ -78,6 +98,46 @@ namespace WebsitePanel.SchedulerServiceInstaller return ActionResult.Success; } + [CustomAction] + public static ActionResult PreInstallationAction(Session session) + { + session["SKIPCONNECTIONSTRINGSTEP"] = "0"; + + session["SERVICEFOLDER"] = session["INSTALLFOLDER"]; + + var servicePath = SecurityUtils.GetServicePath("WebsitePanel Scheduler"); + + if (!string.IsNullOrEmpty(servicePath)) + { + string path = Path.Combine(servicePath, "WebsitePanel.SchedulerService.exe.config"); + + if (File.Exists(path)) + { + using (var reader = new StreamReader(path)) + { + string content = reader.ReadToEnd(); + var pattern = new Regex(@"(?<=)"); + Match match = pattern.Match(content); + session["PREVIOUSCRYPTOKEY"] = match.Value; + + var connectionStringPattern = new Regex(@"(?<=)"); + match = connectionStringPattern.Match(content); + session["PREVIOUSCONNECTIONSTRING"] = match.Value.Replace(";", CustomDataDelimiter); + } + + session["SKIPCONNECTIONSTRINGSTEP"] = "1"; + + if (string.IsNullOrEmpty(session["SERVICEFOLDER"])) + { + session["SERVICEFOLDER"] = servicePath; + } + } + + } + + return ActionResult.Success; + } + private static void InstallService(string installFolder) { try @@ -122,44 +182,29 @@ namespace WebsitePanel.SchedulerServiceInstaller } } - private static void ChangeCryptoKey(string installFolder) + private static void ChangeConfigString(string nodePath, string attrToChange, string value, string installFolder) { - string path = Path.Combine(installFolder.Replace("SchedulerService", "Enterprise Server"), "web.config"); - string cryptoKey = "0123456789"; - - if (File.Exists(path)) - { - using (var reader = new StreamReader(path)) - { - string content = reader.ReadToEnd(); - var pattern = new Regex(@"(?<=)"); - Match match = pattern.Match(content); - cryptoKey = match.Value; - } - } - - ChangeConfigString("installer.cryptokey", cryptoKey, installFolder); - } - - private static void ChangeConfigString(string searchString, string replaceValue, string installFolder) - { - string content; string path = Path.Combine(installFolder, "WebsitePanel.SchedulerService.exe.config"); - using (var reader = new StreamReader(path)) + if (!File.Exists(path)) { - content = reader.ReadToEnd(); + return; } - var re = new Regex("\\$\\{" + searchString + "\\}+", RegexOptions.IgnoreCase); - content = re.Replace(content, replaceValue); + XmlDocument xmldoc = new XmlDocument(); + xmldoc.Load(path); - using (var writer = new StreamWriter(path)) + XmlElement node = xmldoc.SelectSingleNode(nodePath) as XmlElement; + + if (node != null) { - writer.Write(content); + node.SetAttribute(attrToChange, value); + + xmldoc.Save(path); } } + private static void StopService(string serviceName) { var sc = new ServiceController(serviceName); @@ -184,12 +229,12 @@ namespace WebsitePanel.SchedulerServiceInstaller private static string GetConnectionString(string serverName, string databaseName) { - return string.Format("Server={0};database={1};Trusted_Connection=true;", serverName, databaseName); + return string.Format("Server={0};database={1};Trusted_Connection=true;", serverName, databaseName).Replace(";", CustomDataDelimiter); } private static string GetConnectionString(string serverName, string databaseName, string login, string password) { - return string.Format("Server={0};database={1};uid={2};password={3};", serverName, databaseName, login, password); + return string.Format("Server={0};database={1};uid={2};password={3};", serverName, databaseName, login, password).Replace(";", CustomDataDelimiter); } private static bool CheckConnection(string connectionString) @@ -215,5 +260,15 @@ namespace WebsitePanel.SchedulerServiceInstaller return result; } + + private static string GetCustomActionProperty(Session session, string key) + { + if (session.CustomActionData.ContainsKey(key)) + { + return session.CustomActionData[key].Replace("-=-", ";"); + } + + return string.Empty; + } } } \ No newline at end of file diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SecurityUtils.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SecurityUtils.cs index 668e7875..5e71edae 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SecurityUtils.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SecurityUtils.cs @@ -1110,6 +1110,25 @@ namespace WebsitePanel.Setup wmiService.Delete(); } + public static string GetServicePath(string serviceName) + { + var mc = new ManagementClass("Win32_Service"); + + foreach (var mo in mc.GetInstances()) + { + if (mo.GetPropertyValue("Name").ToString() == serviceName) + { + var path = mo.GetPropertyValue("PathName").ToString().Trim('"'); + + var directory = Path.GetDirectoryName(path); + + return directory; + } + } + + return string.Empty; + } + #endregion } From cad9cea1ea2300a0d95315cd4d7d44faee91d44b Mon Sep 17 00:00:00 2001 From: dev_amdtel Date: Thu, 18 Dec 2014 21:49:32 +0400 Subject: [PATCH 26/32] fix Web App Gallery for WordPress --- .../WebApplicationGalleryParamControl.ascx.cs | 191 +++++++++--------- 1 file changed, 99 insertions(+), 92 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebApplicationGalleryParamControl.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebApplicationGalleryParamControl.ascx.cs index 54d93bcf..d3c216b5 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebApplicationGalleryParamControl.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebApplicationGalleryParamControl.ascx.cs @@ -185,104 +185,111 @@ namespace WebsitePanel.Portal private void BindControls() { - // hide database server parameters - DeploymentParameterWellKnownTag hiddenTags = - DeploymentParameterWellKnownTag.IisApp | - DeploymentParameterWellKnownTag.Hidden | - DeploymentParameterWellKnownTag.DBServer | - DeploymentParameterWellKnownTag.DBAdminUserName | - DeploymentParameterWellKnownTag.DBAdminPassword; - - if ((WellKnownTags & hiddenTags) > 0) + try { - this.Visible = false; - return; - } - // disable all editor controls - BooleanControl.Visible = false; - EnumControl.Visible = false; - PasswordControl.Visible = false; - TextControl.Visible = false; + // hide database server parameters + DeploymentParameterWellKnownTag hiddenTags = + DeploymentParameterWellKnownTag.IisApp | + DeploymentParameterWellKnownTag.Hidden | + DeploymentParameterWellKnownTag.DBServer | + DeploymentParameterWellKnownTag.DBAdminUserName | + DeploymentParameterWellKnownTag.DBAdminPassword; - // enable specific control - if ((ValidationKind & DeploymentParameterValidationKind.Boolean) == DeploymentParameterValidationKind.Boolean) - { - // Boolean value - BooleanControl.Visible = true; - bool val = false; - Boolean.TryParse(DefaultValue, out val); - boolValue.Checked = val; - } - else if ((ValidationKind & DeploymentParameterValidationKind.Enumeration) == DeploymentParameterValidationKind.Enumeration) - { - // Enumeration value - EnumControl.Visible = true; - - // fill dropdown - enumValue.Items.Clear(); - string[] items = (ValidationString ?? "").Trim().Split(','); - foreach (string item in items) - enumValue.Items.Add(item.Trim()); - - // select default value - enumValue.SelectedValue = DefaultValue; - } - else if ((WellKnownTags & DeploymentParameterWellKnownTag.Password) == DeploymentParameterWellKnownTag.Password) - { - // Password value - PasswordControl.Visible = true; - confirmPasswordControls.Visible = ((WellKnownTags & DeploymentParameterWellKnownTag.New) == DeploymentParameterWellKnownTag.New); - } - else - { - // Text value - TextControl.Visible = true; - textValue.Text = DefaultValue; - valPrefix.Text = ValuePrefix; - valSuffix.Text = ValueSuffix; - - if ( - (WellKnownTags & DeploymentParameterWellKnownTag.MySql) == DeploymentParameterWellKnownTag.MySql - && - (WellKnownTags & DeploymentParameterWellKnownTag.DBUserName) == DeploymentParameterWellKnownTag.DBUserName - ) + if ((WellKnownTags & hiddenTags) > 0) { - MysqlUsernameLengthValidator.Enabled = true; + this.Visible = false; + return; } + + // disable all editor controls + BooleanControl.Visible = false; + EnumControl.Visible = false; + PasswordControl.Visible = false; + TextControl.Visible = false; + + // enable specific control + if ((ValidationKind & DeploymentParameterValidationKind.Boolean) == DeploymentParameterValidationKind.Boolean) + { + // Boolean value + BooleanControl.Visible = true; + bool val = false; + Boolean.TryParse(DefaultValue, out val); + boolValue.Checked = val; + } + else if ((ValidationKind & DeploymentParameterValidationKind.Enumeration) == DeploymentParameterValidationKind.Enumeration) + { + // Enumeration value + EnumControl.Visible = true; + + // fill dropdown + enumValue.Items.Clear(); + string[] items = (ValidationString ?? "").Trim().Split(','); + foreach (string item in items) + enumValue.Items.Add(item.Trim()); + + // select default value + enumValue.SelectedValue = DefaultValue; + } + else if ((WellKnownTags & DeploymentParameterWellKnownTag.Password) == DeploymentParameterWellKnownTag.Password) + { + // Password value + PasswordControl.Visible = true; + confirmPasswordControls.Visible = ((WellKnownTags & DeploymentParameterWellKnownTag.New) == DeploymentParameterWellKnownTag.New); + } + else + { + // Text value + TextControl.Visible = true; + textValue.Text = DefaultValue == null ? "" : DefaultValue; + valPrefix.Text = ValuePrefix == null ? "" : ValuePrefix; + valSuffix.Text = ValueSuffix == null ? "" : ValueSuffix; + + if ( + (ValuePrefix != null) && (ValueSuffix != null) + && + ((WellKnownTags & DeploymentParameterWellKnownTag.MySql) == DeploymentParameterWellKnownTag.MySql) + && + ((WellKnownTags & DeploymentParameterWellKnownTag.DBUserName) == DeploymentParameterWellKnownTag.DBUserName) + ) + { + MysqlUsernameLengthValidator.Enabled = true; + } + } + + // enforce validation for database parameters if they are allowed empty by app pack developers + bool isDatabaseParameter = (WellKnownTags & ( + DeploymentParameterWellKnownTag.DBName | + DeploymentParameterWellKnownTag.DBUserName | + DeploymentParameterWellKnownTag.DBUserPassword)) > 0; + + // enforce validation for database name and username + if ((WellKnownTags & (DeploymentParameterWellKnownTag.DBName | DeploymentParameterWellKnownTag.DBUserName)) > 0 + && String.IsNullOrEmpty(ValidationString)) + { + validationKind |= DeploymentParameterValidationKind.RegularExpression; + validationString = DatabaseIdentifierRegexp; + } + + // validation common for all editors + requireTextValue.Enabled = requirePassword.Enabled = requireConfirmPassword.Enabled = requireEnumValue.Enabled = + ((ValidationKind & DeploymentParameterValidationKind.AllowEmpty) != DeploymentParameterValidationKind.AllowEmpty) || isDatabaseParameter; + + requireTextValue.Text = requirePassword.Text = requireEnumValue.Text = + String.Format(GetLocalizedString("RequiredValidator.Text"), FriendlyName); + + regexpTextValue.Enabled = regexpPassword.Enabled = regexpEnumValue.Enabled = + (ValidationKind & DeploymentParameterValidationKind.RegularExpression) == DeploymentParameterValidationKind.RegularExpression; + + regexpTextValue.ValidationExpression = regexpPassword.ValidationExpression = regexpEnumValue.ValidationExpression = + ValidationString ?? ""; + + regexpTextValue.Text = regexpPassword.Text = regexpEnumValue.Text = + String.Format(GetLocalizedString("RegexpValidator.Text"), FriendlyName, ValidationString); + + } - - - // enforce validation for database parameters if they are allowed empty by app pack developers - bool isDatabaseParameter = (WellKnownTags & ( - DeploymentParameterWellKnownTag.DBName | - DeploymentParameterWellKnownTag.DBUserName | - DeploymentParameterWellKnownTag.DBUserPassword)) > 0; - - // enforce validation for database name and username - if ((WellKnownTags & (DeploymentParameterWellKnownTag.DBName | DeploymentParameterWellKnownTag.DBUserName)) > 0 - && String.IsNullOrEmpty(ValidationString)) - { - validationKind |= DeploymentParameterValidationKind.RegularExpression; - validationString = DatabaseIdentifierRegexp; - } - - // validation common for all editors - requireTextValue.Enabled = requirePassword.Enabled = requireConfirmPassword.Enabled = requireEnumValue.Enabled = - ((ValidationKind & DeploymentParameterValidationKind.AllowEmpty) != DeploymentParameterValidationKind.AllowEmpty) || isDatabaseParameter; - - requireTextValue.Text = requirePassword.Text = requireEnumValue.Text = - String.Format(GetLocalizedString("RequiredValidator.Text"), FriendlyName); - - regexpTextValue.Enabled = regexpPassword.Enabled = regexpEnumValue.Enabled = - (ValidationKind & DeploymentParameterValidationKind.RegularExpression) == DeploymentParameterValidationKind.RegularExpression; - - regexpTextValue.ValidationExpression = regexpPassword.ValidationExpression = regexpEnumValue.ValidationExpression = - ValidationString ?? ""; - - regexpTextValue.Text = regexpPassword.Text = regexpEnumValue.Text = - String.Format(GetLocalizedString("RegexpValidator.Text"), FriendlyName, ValidationString); - + catch { } // just skip } From 26561dcd4d2816c07fdf95e44ada84a7a4dc47ac Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Thu, 18 Dec 2014 13:04:01 -0500 Subject: [PATCH 27/32] Added tag build-2.1.0.496 for changeset 80dce0a3c828 From 79e176e3805f1a35ef3f2e36ffe35d68b91731c6 Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Thu, 18 Dec 2014 15:13:48 -0500 Subject: [PATCH 28/32] Added tag build-2.1.0.497 for changeset 98866ecf6577 From 8a45147d44817f751b6f73cbd496bf862322f5ea Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Fri, 19 Dec 2014 02:46:23 -0800 Subject: [PATCH 29/32] MX and NS - DNS timeout fix --- .../SchedulerTasks/DomainLookupViewTask.cs | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs index d21a92a7..d5e042c1 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SchedulerTasks/DomainLookupViewTask.cs @@ -26,7 +26,9 @@ namespace WebsitePanel.EnterpriseServer private const string MxRecordPattern = @"mail exchanger = (.+)"; private const string NsRecordPattern = @"nameserver = (.+)"; - + private const string DnsTimeOutMessage = @"dns request timed out"; + private const int DnsTimeOutRetryCount = 3; + public override void DoWork() { BackgroundTask topTask = TaskManager.TopTask; @@ -100,8 +102,8 @@ namespace WebsitePanel.EnterpriseServer //execute server foreach (var dnsServer in dnsServers) { - var dnsMxRecords = GetDomainDnsRecords(winServer, domain.DomainName, dnsServer, DnsRecordType.MX); - var dnsNsRecords = GetDomainDnsRecords(winServer, domain.DomainName, dnsServer, DnsRecordType.NS); + var dnsMxRecords = GetDomainDnsRecords(winServer, domain.DomainName, dnsServer, DnsRecordType.MX) ?? dbDnsRecords.Where(x => x.RecordType == DnsRecordType.MX).ToList(); + var dnsNsRecords = GetDomainDnsRecords(winServer, domain.DomainName, dnsServer, DnsRecordType.NS) ?? dbDnsRecords.Where(x => x.RecordType == DnsRecordType.NS).ToList(); FillRecordData(dnsMxRecords, domain, dnsServer); FillRecordData(dnsNsRecords, domain, dnsServer); @@ -311,7 +313,20 @@ namespace WebsitePanel.EnterpriseServer var args = string.Format("-type={0} {1} {2}", recordType, domain, dnsServer); // execute system command - var raw = winServer.ExecuteSystemCommand(command, args); + var raw = string.Empty; + int triesCount = 0; + + do + { + raw = winServer.ExecuteSystemCommand(command, args); + } + while (raw.ToLowerInvariant().Contains(DnsTimeOutMessage) && ++triesCount < DnsTimeOutRetryCount); + + //timeout check + if (raw.ToLowerInvariant().Contains(DnsTimeOutMessage)) + { + return null; + } var records = ParseNsLookupResult(raw, dnsServer, recordType); From f217cf6246115698c2c2742aa803b9253c5877ce Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Fri, 19 Dec 2014 17:22:03 -0500 Subject: [PATCH 30/32] Added tag build-2.1.0.498 for changeset 64a9f8d465de From 2d96231e35d58e2a33ef762c6bb23abb2d8d47cb Mon Sep 17 00:00:00 2001 From: Olov Karlsson Date: Fri, 19 Dec 2014 23:27:15 +0100 Subject: [PATCH 31/32] IDN support: new validation of domain names, make DNS providers use ascii and iis unicode. Block use of IDN domain names in organizations and mail --- WebsitePanel/Database/install_db.sql | 1 + WebsitePanel/Database/update_db.sql | 106 ++++++++++++++ .../DnsServers/DnsServerController.cs | 22 ++- .../Servers/ServerController.cs | 2 +- .../WebsitePanel.Server/DNSServer.asmx.cs | 27 ++-- .../DomainsAddDomain.ascx.resx | 24 --- .../WebsitePanel/Code/Framework/Utils.cs | 43 ++++-- .../WebsitePanel/DnsZoneRecords.ascx.cs | 5 + .../WebsitePanel/DomainsAddDomain.ascx | 28 +--- .../WebsitePanel/DomainsAddDomain.ascx.cs | 25 ++-- .../DomainsAddDomain.ascx.designer.cs | 93 +----------- .../DomainsSelectDomainControl.ascx.cs | 12 ++ .../ExchangeAddDomainName.ascx.cs | 3 +- .../OrganizationAddDomainName.ascx.cs | 3 +- .../OrganizationCreateOrganization.ascx.cs | 3 +- .../WebsitePanel/MailDomainsAddPointer.ascx | 2 +- .../WebsitePanel/MailEditAddress.ascx | 2 +- .../DomainControl.ascx.resx | 138 ++++++++++++++++++ .../UserControls/DomainControl.ascx | 10 ++ .../UserControls/DomainControl.ascx.cs | 134 +++++++++++++++++ .../DomainControl.ascx.designer.cs | 60 ++++++++ .../WebsitePanel/UserCreateSpace.ascx | 12 +- .../UserCreateSpace.ascx.designer.cs | 20 +-- .../WebsitePanel.Portal.Modules.csproj | 9 ++ 24 files changed, 581 insertions(+), 203 deletions(-) create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/App_LocalResources/DomainControl.ascx.resx create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/DomainControl.ascx create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/DomainControl.ascx.cs create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/DomainControl.ascx.designer.cs diff --git a/WebsitePanel/Database/install_db.sql b/WebsitePanel/Database/install_db.sql index 47bb884f..c28f6f0b 100644 --- a/WebsitePanel/Database/install_db.sql +++ b/WebsitePanel/Database/install_db.sql @@ -21064,6 +21064,7 @@ SET @sql = @sql + ' SELECT COUNT(DomainID) FROM @Domains;SELECT WS.ItemName AS WebSiteName, ISNULL(MD.ItemID, 0) AS MailDomainID, MD.ItemName AS MailDomainName, + Z.ItemName AS ZoneName, D.IsSubDomain, D.IsInstantAlias, D.IsDomainPointer, diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 0b4b54b5..a6bbcc6c 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -6057,6 +6057,112 @@ END RETURN GO +-- wsp-10053: IDN, return ZoneName also from GetDomainsPaged (already exists in other GetDomain-sps) +ALTER PROCEDURE [dbo].[GetDomainsPaged] +( + @ActorID int, + @PackageID int, + @ServerID int, + @Recursive bit, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS +SET NOCOUNT ON + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- build query and run it to the temporary table +DECLARE @sql nvarchar(4000) + +IF @SortColumn = '' OR @SortColumn IS NULL +SET @SortColumn = 'DomainName' + +SET @sql = ' +DECLARE @Domains TABLE +( + ItemPosition int IDENTITY(1,1), + DomainID int +) +INSERT INTO @Domains (DomainID) +SELECT + D.DomainID +FROM Domains AS D +INNER JOIN Packages AS P ON D.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +LEFT OUTER JOIN Services AS S ON Z.ServiceID = S.ServiceID +LEFT OUTER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +WHERE (D.IsInstantAlias = 0 AND D.IsDomainPointer = 0) AND + ((@Recursive = 0 AND D.PackageID = @PackageID) + OR (@Recursive = 1 AND dbo.CheckPackageParent(@PackageID, D.PackageID) = 1)) +AND (@ServerID = 0 OR (@ServerID > 0 AND S.ServerID = @ServerID)) +' + +IF @FilterColumn <> '' AND @FilterValue <> '' +SET @sql = @sql + ' AND ' + @FilterColumn + ' LIKE @FilterValue ' + +IF @SortColumn <> '' AND @SortColumn IS NOT NULL +SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + +SET @sql = @sql + ' SELECT COUNT(DomainID) FROM @Domains;SELECT + D.DomainID, + D.PackageID, + D.ZoneItemID, + D.DomainItemID, + D.DomainName, + D.HostingAllowed, + ISNULL(WS.ItemID, 0) AS WebSiteID, + WS.ItemName AS WebSiteName, + ISNULL(MD.ItemID, 0) AS MailDomainID, + MD.ItemName AS MailDomainName, + Z.ItemName AS ZoneName, + D.IsSubDomain, + D.IsInstantAlias, + D.IsDomainPointer, + + -- packages + P.PackageName, + + -- server + ISNULL(SRV.ServerID, 0) AS ServerID, + ISNULL(SRV.ServerName, '''') AS ServerName, + ISNULL(SRV.Comments, '''') AS ServerComments, + ISNULL(SRV.VirtualServer, 0) AS VirtualServer, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM @Domains AS SD +INNER JOIN Domains AS D ON SD.DomainID = D.DomainID +INNER JOIN Packages AS P ON D.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID +LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +LEFT OUTER JOIN Services AS S ON Z.ServiceID = S.ServiceID +LEFT OUTER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +WHERE SD.ItemPosition BETWEEN @StartRow + 1 AND @StartRow + @MaximumRows' + +exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @PackageID int, @FilterValue nvarchar(50), @ServerID int, @Recursive bit', +@StartRow, @MaximumRows, @PackageID, @FilterValue, @ServerID, @Recursive + + +RETURN + +GO + + -- Domain lookup tasks IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTasks] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP') diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/DnsServers/DnsServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/DnsServers/DnsServerController.cs index 8a5d68e3..44ec6c81 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/DnsServers/DnsServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/DnsServers/DnsServerController.cs @@ -29,6 +29,8 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; +using System.Globalization; +using System.Linq; using System.Xml; using System.Xml.Serialization; using WebsitePanel.Providers; @@ -38,6 +40,12 @@ namespace WebsitePanel.EnterpriseServer { public class DnsServerController : IImportController, IBackupController { + private static string GetAsciiZoneName(string zoneName) + { + var idn = new IdnMapping(); + return idn.GetAscii(zoneName); + } + private static DNSServer GetDNSServer(int serviceId) { DNSServer dns = new DNSServer(); @@ -55,6 +63,9 @@ namespace WebsitePanel.EnterpriseServer // get DNS provider DNSServer dns = GetDNSServer(serviceId); + // Ensure zoneName is in ascii before saving to database + zoneName = GetAsciiZoneName(zoneName); + // check if zone already exists if (dns.ZoneExists(zoneName)) return BusinessErrorCodes.ERROR_DNS_ZONE_EXISTS; @@ -199,7 +210,7 @@ namespace WebsitePanel.EnterpriseServer { // zone item DnsZone zone = primaryZone ? new DnsZone() : new SecondaryDnsZone(); - zone.Name = zoneName; + zone.Name = GetAsciiZoneName(zoneName); zone.PackageId = spaceId; zone.ServiceId = serviceId; int zoneItemId = PackageController.AddPackageItem(zone); @@ -280,6 +291,8 @@ namespace WebsitePanel.EnterpriseServer foreach (GlobalDnsRecord record in records) { + domainName = GetAsciiZoneName(domainName); + DnsRecord rr = new DnsRecord(); rr.RecordType = (DnsRecordType)Enum.Parse(typeof(DnsRecordType), record.RecordType, true); rr.RecordName = Utils.ReplaceStringVariable(record.RecordName, "host_name", hostName, true); @@ -359,8 +372,11 @@ namespace WebsitePanel.EnterpriseServer DNSServer dns = new DNSServer(); ServiceProviderProxy.Init(dns, serviceId); + // IDN: The list of importable names is populated with unicode names, to make it easier for the user + var idn = new IdnMapping(); + if (itemType == typeof(DnsZone)) - items.AddRange(dns.GetZones()); + items.AddRange(dns.GetZones().Select(z => idn.GetUnicode(z))); return items; } @@ -377,7 +393,7 @@ namespace WebsitePanel.EnterpriseServer { // add DNS zone DnsZone zone = new DnsZone(); - zone.Name = itemName; + zone.Name = GetAsciiZoneName(itemName); zone.ServiceId = serviceId; zone.PackageId = packageId; int zoneId = PackageController.AddPackageItem(zone); diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs index 9d07df37..220ee79d 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Servers/ServerController.cs @@ -2776,7 +2776,7 @@ namespace WebsitePanel.EnterpriseServer DNSServer dns = new DNSServer(); ServiceProviderProxy.Init(dns, zoneItem.ServiceId); - return dns.GetZoneRecords(domain.DomainName); + return dns.GetZoneRecords(zoneItem.Name); } return new DnsRecord[] { }; diff --git a/WebsitePanel/Sources/WebsitePanel.Server/DNSServer.asmx.cs b/WebsitePanel/Sources/WebsitePanel.Server/DNSServer.asmx.cs index 89c6574a..a4f26d8a 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/DNSServer.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server/DNSServer.asmx.cs @@ -28,6 +28,7 @@ using System; using System.ComponentModel; +using System.Globalization; using System.Web.Services; using System.Web.Services.Protocols; using WebsitePanel.Providers; @@ -51,6 +52,12 @@ namespace WebsitePanel.Server get { return (IDnsServer)Provider; } } + private string GetAsciiZoneName(string zoneName) + { + var idn = new IdnMapping(); + return idn.GetAscii(zoneName); + } + #region Zones [WebMethod, SoapHeader("settings")] public bool ZoneExists(string zoneName) @@ -58,7 +65,7 @@ namespace WebsitePanel.Server try { Log.WriteStart("'{0}' ZoneExists", ProviderSettings.ProviderName); - bool result = DnsProvider.ZoneExists(zoneName); + bool result = DnsProvider.ZoneExists(GetAsciiZoneName(zoneName)); Log.WriteEnd("'{0}' ZoneExists", ProviderSettings.ProviderName); return result; } @@ -92,7 +99,7 @@ namespace WebsitePanel.Server try { Log.WriteStart("'{0}' AddPrimaryZone", ProviderSettings.ProviderName); - DnsProvider.AddPrimaryZone(zoneName, secondaryServers); + DnsProvider.AddPrimaryZone(GetAsciiZoneName(zoneName), secondaryServers); Log.WriteEnd("'{0}' AddPrimaryZone", ProviderSettings.ProviderName); } catch (Exception ex) @@ -108,7 +115,7 @@ namespace WebsitePanel.Server try { Log.WriteStart("'{0}' AddSecondaryZone", ProviderSettings.ProviderName); - DnsProvider.AddSecondaryZone(zoneName, masterServers); + DnsProvider.AddSecondaryZone(GetAsciiZoneName(zoneName), masterServers); Log.WriteEnd("'{0}' AddSecondaryZone", ProviderSettings.ProviderName); } catch (Exception ex) @@ -124,7 +131,7 @@ namespace WebsitePanel.Server try { Log.WriteStart("'{0}' DeleteZone", ProviderSettings.ProviderName); - DnsProvider.DeleteZone(zoneName); + DnsProvider.DeleteZone(GetAsciiZoneName(zoneName)); Log.WriteEnd("'{0}' DeleteZone", ProviderSettings.ProviderName); } catch (Exception ex) @@ -140,7 +147,7 @@ namespace WebsitePanel.Server try { Log.WriteStart("'{0}' UpdateSoaRecord", ProviderSettings.ProviderName); - DnsProvider.UpdateSoaRecord(zoneName, host, primaryNsServer, primaryPerson); + DnsProvider.UpdateSoaRecord(GetAsciiZoneName(zoneName), host, primaryNsServer, primaryPerson); Log.WriteEnd("'{0}' UpdateSoaRecord", ProviderSettings.ProviderName); } catch (Exception ex) @@ -158,7 +165,7 @@ namespace WebsitePanel.Server try { Log.WriteStart("'{0}' GetZoneRecords", ProviderSettings.ProviderName); - DnsRecord[] result = DnsProvider.GetZoneRecords(zoneName); + DnsRecord[] result = DnsProvider.GetZoneRecords(GetAsciiZoneName(zoneName)); Log.WriteEnd("'{0}' GetZoneRecords", ProviderSettings.ProviderName); return result; } @@ -175,7 +182,7 @@ namespace WebsitePanel.Server try { Log.WriteStart("'{0}' AddZoneRecord", ProviderSettings.ProviderName); - DnsProvider.AddZoneRecord(zoneName, record); + DnsProvider.AddZoneRecord(GetAsciiZoneName(zoneName), record); Log.WriteEnd("'{0}' AddZoneRecord", ProviderSettings.ProviderName); } catch (Exception ex) @@ -191,7 +198,7 @@ namespace WebsitePanel.Server try { Log.WriteStart("'{0}' DeleteZoneRecord", ProviderSettings.ProviderName); - DnsProvider.DeleteZoneRecord(zoneName, record); + DnsProvider.DeleteZoneRecord(GetAsciiZoneName(zoneName), record); Log.WriteEnd("'{0}' DeleteZoneRecord", ProviderSettings.ProviderName); } catch (Exception ex) @@ -207,7 +214,7 @@ namespace WebsitePanel.Server try { Log.WriteStart("'{0}' AddZoneRecords", ProviderSettings.ProviderName); - DnsProvider.AddZoneRecords(zoneName, records); + DnsProvider.AddZoneRecords(GetAsciiZoneName(zoneName), records); Log.WriteEnd("'{0}' AddZoneRecords", ProviderSettings.ProviderName); } catch (Exception ex) @@ -223,7 +230,7 @@ namespace WebsitePanel.Server try { Log.WriteStart("'{0}' DeleteZoneRecords", ProviderSettings.ProviderName); - DnsProvider.DeleteZoneRecords(zoneName, records); + DnsProvider.DeleteZoneRecords(GetAsciiZoneName(zoneName), records); Log.WriteEnd("'{0}' DeleteZoneRecords", ProviderSettings.ProviderName); } catch (Exception ex) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/DomainsAddDomain.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/DomainsAddDomain.ascx.resx index 2389512c..c05e907e 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/DomainsAddDomain.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/DomainsAddDomain.ascx.resx @@ -144,18 +144,6 @@ Tick this checkbox if DNS zone for this domain will be located on name servers of your hosting provider. Make sure you changed name servers in the domain registrar control panel. - - Please, enter correct domain name, for example "mydomain.com" or "sub.mydomain.com". - - - * - - - Please enter domain name - - - * - Enable DNS @@ -168,18 +156,6 @@ Assign to existing Web Site - - Please, enter correct sub-domain name, for example "subdomain" or "sub.subdomain". - - - * - - - Please enter sub-domain name - - - * - Hostname: diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Framework/Utils.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Framework/Utils.cs index 0a33b5a7..186614a1 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Framework/Utils.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Framework/Utils.cs @@ -159,7 +159,7 @@ namespace WebsitePanel.Portal foreach (string part in parts) if (part.Trim() != "" && !list.Contains(part.Trim())) list.Add(part); - return (string[])list.ToArray(typeof(string)); + return (string[]) list.ToArray(typeof (string)); } public static string ReplaceStringVariable(string str, string variable, string value) @@ -172,7 +172,7 @@ namespace WebsitePanel.Portal { long length = stream.Length; byte[] content = new byte[length]; - stream.Read(content, 0, (int)length); + stream.Read(content, 0, (int) length); stream.Close(); return content; } @@ -231,7 +231,7 @@ namespace WebsitePanel.Portal selValues.Add(item.Value); } - string cookieVal = String.Join(",", (string[])selValues.ToArray(typeof(string))); + string cookieVal = String.Join(",", (string[]) selValues.ToArray(typeof (string))); // create cookie HttpCookie cookie = new HttpCookie(ctrl.UniqueID, cookieVal); @@ -251,7 +251,7 @@ namespace WebsitePanel.Portal foreach (ListItem item in ctrl.Items) item.Selected = false; - string[] vals = cookie.Value.Split(new char[] { ',' }); + string[] vals = cookie.Value.Split(new char[] {','}); foreach (string val in vals) { ListItem item = ctrl.Items.FindByValue(val); @@ -278,9 +278,9 @@ namespace WebsitePanel.Portal // Convert 4 bytes into a 32-bit integer value. int seed = (randomBytes[0] & 0x7f) << 24 | - randomBytes[1] << 16 | - randomBytes[2] << 8 | - randomBytes[3]; + randomBytes[1] << 16 | + randomBytes[2] << 8 | + randomBytes[3]; Random rnd = new Random(seed); @@ -294,17 +294,38 @@ namespace WebsitePanel.Portal public static bool CheckQouta(string key, PackageContext cntx) { return cntx.Quotas.ContainsKey(key) && - ((cntx.Quotas[key].QuotaAllocatedValue == 1 && cntx.Quotas[key].QuotaTypeId == 1) || - (cntx.Quotas[key].QuotaTypeId != 1 && (cntx.Quotas[key].QuotaAllocatedValue > 0 || cntx.Quotas[key].QuotaAllocatedValue == -1))); + ((cntx.Quotas[key].QuotaAllocatedValue == 1 && cntx.Quotas[key].QuotaTypeId == 1) || + (cntx.Quotas[key].QuotaTypeId != 1 && (cntx.Quotas[key].QuotaAllocatedValue > 0 || cntx.Quotas[key].QuotaAllocatedValue == -1))); } public static bool CheckQouta(string key, HostingPlanContext cntx) { return cntx.Quotas.ContainsKey(key) && - ((cntx.Quotas[key].QuotaAllocatedValue == 1 && cntx.Quotas[key].QuotaTypeId == 1) || - (cntx.Quotas[key].QuotaTypeId != 1 && (cntx.Quotas[key].QuotaAllocatedValue > 0 || cntx.Quotas[key].QuotaAllocatedValue == -1))); + ((cntx.Quotas[key].QuotaAllocatedValue == 1 && cntx.Quotas[key].QuotaTypeId == 1) || + (cntx.Quotas[key].QuotaTypeId != 1 && (cntx.Quotas[key].QuotaAllocatedValue > 0 || cntx.Quotas[key].QuotaAllocatedValue == -1))); } + public static bool IsIdnDomain(string domainName) + { + if (string.IsNullOrEmpty(domainName)) + { + return false; + } + + var idn = new IdnMapping(); + return idn.GetAscii(domainName) != domainName; + } + + public static string UnicodeToAscii(string domainName) + { + if (string.IsNullOrEmpty(domainName)) + { + return string.Empty; + } + + var idn = new IdnMapping(); + return idn.GetAscii(domainName); + } } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DnsZoneRecords.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DnsZoneRecords.ascx.cs index 1f323332..d9b78d01 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DnsZoneRecords.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DnsZoneRecords.ascx.cs @@ -30,6 +30,7 @@ using System; using System.Data; using System.Configuration; using System.Collections; +using System.Globalization; using System.Web; using System.Web.Security; using System.Web.UI; @@ -57,6 +58,10 @@ namespace WebsitePanel.Portal // domain name DomainInfo domain = ES.Services.Servers.GetDomain(PanelRequest.DomainID); litDomainName.Text = domain.DomainName; + if (Utils.IsIdnDomain(domain.DomainName)) + { + litDomainName.Text = string.Format("{0} ({1})", Utils.UnicodeToAscii(domain.DomainName), domain.DomainName); + } } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomain.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomain.ascx index a7b93c8b..e1f91b1b 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomain.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomain.ascx @@ -1,33 +1,21 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DomainsAddDomain.ascx.cs" Inherits="WebsitePanel.Portal.DomainsAddDomain" %> <%@ Register Src="UserControls/EnableAsyncTasksSupport.ascx" TagName="EnableAsyncTasksSupport" TagPrefix="wsp" %> -<%@ Register Src="DomainsSelectDomainControl.ascx" TagName="DomainsSelectDomainControl" TagPrefix="uc1" %> +<%@ Register Src="UserControls/DomainControl.ascx" TagName="DomainControl" TagPrefix="wsp" %> <%@ Register Src="UserControls/CollapsiblePanel.ascx" TagPrefix="wsp" TagName="CollapsiblePanel" %> - +
- -

- - - -

-

- - . - - - +

+

+<%-- +

+ +

--%> diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomain.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomain.ascx.cs index 0de467dc..017e6797 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomain.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomain.ascx.cs @@ -30,6 +30,7 @@ using System; using System.Web; using WebsitePanel.EnterpriseServer; using System.Collections.Generic; +using WebsitePanel.Portal.UserControls; namespace WebsitePanel.Portal { @@ -82,12 +83,12 @@ namespace WebsitePanel.Portal if (type == DomainType.Domain || type == DomainType.DomainPointer) { // domains - DomainPanel.Visible = true; + DomainName.IsSubDomain = false; } else { // sub-domains - SubDomainPanel.Visible = true; + DomainName.IsSubDomain = true; // fill sub-domains if (!IsPostBack) @@ -178,14 +179,14 @@ namespace WebsitePanel.Portal if (!domain.IsDomainPointer && !domain.IsSubDomain && !domain.IsInstantAlias) domains.Add(domain); - DomainsList.DataSource = domains; - DomainsList.DataBind(); + DomainName.DataSource = domains; + DomainName.DataBind(); } private void BindResellerDomains() { - DomainsList.DataSource = ES.Services.Servers.GetResellerDomains(PanelSecurity.PackageId); - DomainsList.DataBind(); + DomainName.DataSource = ES.Services.Servers.GetResellerDomains(PanelSecurity.PackageId); + DomainName.DataBind(); } private void AddDomain() @@ -197,9 +198,7 @@ namespace WebsitePanel.Portal DomainType type = GetDomainType(Request["DomainType"]); // get domain name - string domainName = DomainName.Text.Trim(); - if (type == DomainType.SubDomain || type == DomainType.ProviderSubDomain) - domainName = SubDomainName.Text.Trim() + "." + DomainsList.SelectedValue; + var domainName = DomainName.Text; int pointWebSiteId = 0; int pointMailDomainId = 0; @@ -263,5 +262,13 @@ namespace WebsitePanel.Portal { AddDomain(); } + + protected void DomainName_TextChanged(object sender, DomainControl.DomainNameEventArgs e) + { + // If the choosen domain is a idn domain, don't allow to create mail + var isIdn = Utils.IsIdnDomain(e.DomainName); + PointMailDomainPanel.Enabled = !isIdn; + PointMailDomain.Checked = !isIdn; + } } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomain.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomain.ascx.designer.cs index 6b22fdcc..27f9ad97 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomain.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsAddDomain.ascx.designer.cs @@ -1,31 +1,3 @@ -// Copyright (c) 2014, Outercurve Foundation. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// - Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// - Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// - Neither the name of the Outercurve Foundation nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - //------------------------------------------------------------------------------ // // This code was generated by a tool. @@ -74,70 +46,7 @@ namespace WebsitePanel.Portal { /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.TextBox DomainName; - - /// - /// DomainRequiredValidator control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.RequiredFieldValidator DomainRequiredValidator; - - /// - /// DomainFormatValidator control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.RegularExpressionValidator DomainFormatValidator; - - /// - /// SubDomainPanel control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.HtmlControls.HtmlGenericControl SubDomainPanel; - - /// - /// SubDomainName control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox SubDomainName; - - /// - /// DomainsList control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.DropDownList DomainsList; - - /// - /// SubDomainRequiredValidator control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.RequiredFieldValidator SubDomainRequiredValidator; - - /// - /// SubDomainFormatValidator control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.RegularExpressionValidator SubDomainFormatValidator; + protected global::WebsitePanel.Portal.UserControls.DomainControl DomainName; /// /// OptionsPanelHeader control. diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsSelectDomainControl.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsSelectDomainControl.ascx.cs index 5bedfeba..97264617 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsSelectDomainControl.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/DomainsSelectDomainControl.ascx.cs @@ -30,6 +30,7 @@ using System; using System.Data; using System.Configuration; using System.Collections; +using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; @@ -44,6 +45,12 @@ namespace WebsitePanel.Portal { public partial class DomainsSelectDomainControl : WebsitePanelControlBase { + public bool HideIdnDomains + { + get { return (ViewState["HideIdnDomains"] != null) && (bool)ViewState["HideIdnDomains"]; } + set { ViewState["HideIdnDomains"] = value; } + } + public bool HideWebSites { get { return (ViewState["HideWebSites"] != null) ? (bool)ViewState["HideWebSites"] : false; } @@ -116,6 +123,11 @@ namespace WebsitePanel.Portal { DomainInfo[] domains = ES.Services.Servers.GetMyDomains(PackageId); + if (HideIdnDomains) + { + domains = domains.Where(d => !Utils.IsIdnDomain(d.DomainName)).ToArray(); + } + WebSite[] sites = null; Hashtable htSites = new Hashtable(); Hashtable htMailDomainPointers = new Hashtable(); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddDomainName.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddDomainName.ascx.cs index 69739f33..e3ef0c4f 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddDomainName.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeAddDomainName.ascx.cs @@ -28,6 +28,7 @@ using System; using System.Data; +using System.Linq; using System.Text; using System.Collections.Generic; @@ -40,7 +41,7 @@ namespace WebsitePanel.Portal.ExchangeServer { protected void Page_Load(object sender, EventArgs e) { - DomainInfo[] domains = ES.Services.Servers.GetMyDomains(PanelSecurity.PackageId); + DomainInfo[] domains = ES.Services.Servers.GetMyDomains(PanelSecurity.PackageId).Where(d => !Utils.IsIdnDomain(d.DomainName)).ToArray(); Organization[] orgs = ES.Services.Organizations.GetOrganizations(PanelSecurity.PackageId, false); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationAddDomainName.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationAddDomainName.ascx.cs index abcd110c..0bef0f9b 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationAddDomainName.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationAddDomainName.ascx.cs @@ -28,6 +28,7 @@ using System; using System.Data; +using System.Linq; using System.Text; using System.Collections.Generic; @@ -40,7 +41,7 @@ namespace WebsitePanel.Portal.ExchangeServer { protected void Page_Load(object sender, EventArgs e) { - DomainInfo[] domains = ES.Services.Servers.GetMyDomains(PanelSecurity.PackageId); + DomainInfo[] domains = ES.Services.Servers.GetMyDomains(PanelSecurity.PackageId).Where(d => !Utils.IsIdnDomain(d.DomainName)).ToArray(); Organization[] orgs = ES.Services.Organizations.GetOrganizations(PanelSecurity.PackageId, false); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationCreateOrganization.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationCreateOrganization.ascx.cs index 073033fa..12ebbdf2 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationCreateOrganization.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationCreateOrganization.ascx.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; +using System.Linq; using WebsitePanel.EnterpriseServer; using WebsitePanel.Providers.HostedSolution; @@ -37,7 +38,7 @@ namespace WebsitePanel.Portal.ExchangeServer { protected void Page_Load(object sender, EventArgs e) { - DomainInfo[] domains = ES.Services.Servers.GetMyDomains(PanelSecurity.PackageId); + DomainInfo[] domains = ES.Services.Servers.GetMyDomains(PanelSecurity.PackageId).Where(d => !Utils.IsIdnDomain(d.DomainName)).ToArray(); Organization[] orgs = ES.Services.Organizations.GetOrganizations(PanelSecurity.PackageId, false); var list = new List(); SetPolicy(PanelSecurity.PackageId, UserSettings.EXCHANGE_POLICY, "OrgIdPolicy"); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/MailDomainsAddPointer.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/MailDomainsAddPointer.ascx index 1f57cb0f..9f7f5428 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/MailDomainsAddPointer.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/MailDomainsAddPointer.ascx @@ -6,7 +6,7 @@ + HideMailDomains="true" HideDomainsSubDomains="false" HideInstantAlias="false" HideDomainPointers="true" HideIdnDomains="True"/> diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/MailEditAddress.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/MailEditAddress.ascx index 6037cbc1..48c26731 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/MailEditAddress.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/MailEditAddress.ascx @@ -9,7 +9,7 @@  @  - + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/App_LocalResources/DomainControl.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/App_LocalResources/DomainControl.ascx.resx new file mode 100644 index 00000000..7eef1acc --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/App_LocalResources/DomainControl.ascx.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Please, enter correct domain name, for example "mydomain.com" or "sub.mydomain.com". + + + * + + + Please enter domain name + + + * + + + Please enter sub-domain name + + + * + + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/DomainControl.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/DomainControl.ascx new file mode 100644 index 00000000..871eb72d --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/DomainControl.ascx @@ -0,0 +1,10 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DomainControl.ascx.cs" Inherits="WebsitePanel.Portal.UserControls.DomainControl" %> + + +. + + + + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/DomainControl.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/DomainControl.ascx.cs new file mode 100644 index 00000000..ddcb7541 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/DomainControl.ascx.cs @@ -0,0 +1,134 @@ +// Copyright (c) 2014, Outercurve Foundation. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// - Neither the name of the Outercurve Foundation nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Text.RegularExpressions; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Globalization; + +namespace WebsitePanel.Portal.UserControls +{ + public partial class DomainControl : WebsitePanelControlBase + { + public class DomainNameEventArgs : EventArgs + { + public string DomainName { get; set; } + } + + public event EventHandler TextChanged; + + public virtual void OnTextChanged() + { + var handler = TextChanged; + if (handler != null) handler(this, new DomainNameEventArgs {DomainName = Text}); + } + + public object DataSource + { + set { DomainsList.DataSource = value; } + } + + public bool AutoPostBack + { + get { return txtDomainName.AutoPostBack; } + set { txtDomainName.AutoPostBack = value; } + } + + public Unit Width + { + get { return txtDomainName.Width; } + set { txtDomainName.Width = value; } + } + + public bool RequiredEnabled + { + get { return DomainRequiredValidator.Enabled; } + set { DomainRequiredValidator.Enabled = value; } + } + + public string Text + { + get + { + var domainName = txtDomainName.Text.Trim(); + if (IsSubDomain) + { + domainName += "." + DomainsList.SelectedValue; + } + return domainName; + } + set { txtDomainName.Text = value; } + } + + public string ValidationGroup + { + get { return DomainRequiredValidator.ValidationGroup; } + set { DomainRequiredValidator.ValidationGroup = value; DomainFormatValidator.ValidationGroup = value; } + } + + public bool IsSubDomain { + get { return SubDomainSeparator.Visible; } + set + { + SubDomainSeparator.Visible = value; + DomainsList.Visible = value; + DomainRequiredValidator.Enabled = !value; + } + } + + protected void Page_Load(object sender, EventArgs e) + { + } + + protected new void DataBind() + { + DomainsList.DataBind(); + } + + protected void DomainFormatValidator_ServerValidate(object source, ServerValidateEventArgs args) + { + var idn = new IdnMapping(); + try + { + var ascii = idn.GetAscii(Text); + var regex = new Regex(@"^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.){1,10}[a-zA-Z]{2,15}$"); + args.IsValid = regex.IsMatch(ascii); + } + catch (Exception) + { + args.IsValid = false; + } + } + + protected void txtDomainName_TextChanged(object sender, EventArgs e) + { + OnTextChanged(); + } + } +} \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/DomainControl.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/DomainControl.ascx.designer.cs new file mode 100644 index 00000000..07cd0861 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserControls/DomainControl.ascx.designer.cs @@ -0,0 +1,60 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WebsitePanel.Portal.UserControls { + + + public partial class DomainControl { + + /// + /// txtDomainName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtDomainName; + + /// + /// SubDomainSeparator control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal SubDomainSeparator; + + /// + /// DomainsList control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList DomainsList; + + /// + /// DomainRequiredValidator control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator DomainRequiredValidator; + + /// + /// DomainFormatValidator control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CustomValidator DomainFormatValidator; + } +} diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateSpace.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateSpace.ascx index 12ccdeeb..8c821a95 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateSpace.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateSpace.ascx @@ -1,12 +1,11 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UserCreateSpace.ascx.cs" Inherits="WebsitePanel.Portal.UserCreateSpace" %> -<%@ Register TagPrefix="wsp" TagName="CollapsiblePanel" Src="UserControls/CollapsiblePanel.ascx" %> <%@ Register Src="UserControls/UsernameControl.ascx" TagName="UsernameControl" TagPrefix="uc4" %> -<%@ Register Src="DomainsSelectDomainControl.ascx" TagName="DomainsSelectDomainControl" TagPrefix="uc1" %> +<%@ Register Src="UserControls/DomainControl.ascx" TagName="DomainControl" TagPrefix="wsp" %> <%@ Register Src="UserControls/EnableAsyncTasksSupport.ascx" TagName="EnableAsyncTasksSupport" TagPrefix="wsp" %> - + @@ -74,12 +73,7 @@ - - - + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateSpace.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateSpace.ascx.designer.cs index 1429ed53..be8bf255 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateSpace.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateSpace.ascx.designer.cs @@ -163,25 +163,7 @@ namespace WebsitePanel.Portal { /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.TextBox txtDomainName; - - /// - /// DomainRequiredValidator control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.RequiredFieldValidator DomainRequiredValidator; - - /// - /// DomainFormatValidator control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.RegularExpressionValidator DomainFormatValidator; + protected global::WebsitePanel.Portal.UserControls.DomainControl txtDomainName; /// /// fsWeb control. diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj index c98276a8..6bc95c06 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj @@ -773,6 +773,13 @@ SpaceOrganizationsSelector.ascx + + DomainControl.ascx + ASPXCodeBehind + + + DomainControl.ascx + ASPXCodeBehind @@ -4379,6 +4386,7 @@ + @@ -5626,6 +5634,7 @@ + Designer From 87577100a36be6fdfdf7a3c7d852a2d84238601d Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Fri, 19 Dec 2014 17:43:02 -0500 Subject: [PATCH 32/32] Added tag build-2.1.0.499 for changeset b2dcef10100b