From 2a239006a45868b67b7c72700a9e3305ed431584 Mon Sep 17 00:00:00 2001 From: feodor_fitsner Date: Tue, 11 Sep 2012 18:13:45 -0700 Subject: [PATCH] Prototype added: Switching website shared IP to dedicated and vice versa. --- .../WebServersProxy.cs | 204 +++++++++++++----- .../Code/WebServers/WebServerController.cs | 101 +++++++++ .../WebsitePanel.EnterpriseServer/Web.config | 4 +- .../esWebServers.asmx.cs | 12 ++ .../WebsitePanel_SharedResources.ascx.resx | 20 +- .../WebSitesEditSite.ascx.resx | 67 ++++-- .../WebsitePanel/WebSitesEditSite.ascx | 26 ++- .../WebsitePanel/WebSitesEditSite.ascx.cs | 94 +++++++- .../WebSitesEditSite.ascx.designer.cs | 99 +++++++++ 9 files changed, 535 insertions(+), 92 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/WebServersProxy.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/WebServersProxy.cs index f70325be..ca9b7876 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/WebServersProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/WebServersProxy.cs @@ -1,59 +1,3 @@ -// Copyright (c) 2012, 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. - -// Copyright (c) 2012, 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. @@ -80,7 +24,6 @@ namespace WebsitePanel.EnterpriseServer { using WebsitePanel.Providers.Common; using WebsitePanel.Providers.Web; using WebsitePanel.Providers.ResultObjects; - /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] @@ -124,6 +67,10 @@ namespace WebsitePanel.EnterpriseServer { private System.Threading.SendOrPostCallback DeleteWebSiteOperationCompleted; + private System.Threading.SendOrPostCallback SwitchWebSiteToDedicatedIPOperationCompleted; + + private System.Threading.SendOrPostCallback SwitchWebSiteToSharedIPOperationCompleted; + private System.Threading.SendOrPostCallback DeleteVirtualDirectoryOperationCompleted; private System.Threading.SendOrPostCallback ChangeSiteStateOperationCompleted; @@ -306,6 +253,12 @@ namespace WebsitePanel.EnterpriseServer { /// public event DeleteWebSiteCompletedEventHandler DeleteWebSiteCompleted; + /// + public event SwitchWebSiteToDedicatedIPCompletedEventHandler SwitchWebSiteToDedicatedIPCompleted; + + /// + public event SwitchWebSiteToSharedIPCompletedEventHandler SwitchWebSiteToSharedIPCompleted; + /// public event DeleteVirtualDirectoryCompletedEventHandler DeleteVirtualDirectoryCompleted; @@ -1252,6 +1205,91 @@ namespace WebsitePanel.EnterpriseServer { } } + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/SwitchWebSiteToDedicatedIP", 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 int SwitchWebSiteToDedicatedIP(int siteItemId, int ipAddressId) { + object[] results = this.Invoke("SwitchWebSiteToDedicatedIP", new object[] { + siteItemId, + ipAddressId}); + return ((int)(results[0])); + } + + /// + public System.IAsyncResult BeginSwitchWebSiteToDedicatedIP(int siteItemId, int ipAddressId, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("SwitchWebSiteToDedicatedIP", new object[] { + siteItemId, + ipAddressId}, callback, asyncState); + } + + /// + public int EndSwitchWebSiteToDedicatedIP(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((int)(results[0])); + } + + /// + public void SwitchWebSiteToDedicatedIPAsync(int siteItemId, int ipAddressId) { + this.SwitchWebSiteToDedicatedIPAsync(siteItemId, ipAddressId, null); + } + + /// + public void SwitchWebSiteToDedicatedIPAsync(int siteItemId, int ipAddressId, object userState) { + if ((this.SwitchWebSiteToDedicatedIPOperationCompleted == null)) { + this.SwitchWebSiteToDedicatedIPOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSwitchWebSiteToDedicatedIPOperationCompleted); + } + this.InvokeAsync("SwitchWebSiteToDedicatedIP", new object[] { + siteItemId, + ipAddressId}, this.SwitchWebSiteToDedicatedIPOperationCompleted, userState); + } + + private void OnSwitchWebSiteToDedicatedIPOperationCompleted(object arg) { + if ((this.SwitchWebSiteToDedicatedIPCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SwitchWebSiteToDedicatedIPCompleted(this, new SwitchWebSiteToDedicatedIPCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/SwitchWebSiteToSharedIP", 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 int SwitchWebSiteToSharedIP(int siteItemId) { + object[] results = this.Invoke("SwitchWebSiteToSharedIP", new object[] { + siteItemId}); + return ((int)(results[0])); + } + + /// + public System.IAsyncResult BeginSwitchWebSiteToSharedIP(int siteItemId, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("SwitchWebSiteToSharedIP", new object[] { + siteItemId}, callback, asyncState); + } + + /// + public int EndSwitchWebSiteToSharedIP(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((int)(results[0])); + } + + /// + public void SwitchWebSiteToSharedIPAsync(int siteItemId) { + this.SwitchWebSiteToSharedIPAsync(siteItemId, null); + } + + /// + public void SwitchWebSiteToSharedIPAsync(int siteItemId, object userState) { + if ((this.SwitchWebSiteToSharedIPOperationCompleted == null)) { + this.SwitchWebSiteToSharedIPOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSwitchWebSiteToSharedIPOperationCompleted); + } + this.InvokeAsync("SwitchWebSiteToSharedIP", new object[] { + siteItemId}, this.SwitchWebSiteToSharedIPOperationCompleted, userState); + } + + private void OnSwitchWebSiteToSharedIPOperationCompleted(object arg) { + if ((this.SwitchWebSiteToSharedIPCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SwitchWebSiteToSharedIPCompleted(this, new SwitchWebSiteToSharedIPCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/DeleteVirtualDirectory", 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 int DeleteVirtualDirectory(int siteItemId, string vdirName) { @@ -4422,6 +4460,58 @@ namespace WebsitePanel.EnterpriseServer { } } + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void SwitchWebSiteToDedicatedIPCompletedEventHandler(object sender, SwitchWebSiteToDedicatedIPCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class SwitchWebSiteToDedicatedIPCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal SwitchWebSiteToDedicatedIPCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public int Result { + get { + this.RaiseExceptionIfNecessary(); + return ((int)(this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void SwitchWebSiteToSharedIPCompletedEventHandler(object sender, SwitchWebSiteToSharedIPCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class SwitchWebSiteToSharedIPCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal SwitchWebSiteToSharedIPCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public int Result { + get { + this.RaiseExceptionIfNecessary(); + return ((int)(this.results[0])); + } + } + } + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] public delegate void DeleteVirtualDirectoryCompletedEventHandler(object sender, DeleteVirtualDirectoryCompletedEventArgs e); diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/WebServers/WebServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/WebServers/WebServerController.cs index 5ea67ab0..939c0567 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/WebServers/WebServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/WebServers/WebServerController.cs @@ -611,6 +611,107 @@ namespace WebsitePanel.EnterpriseServer } } + public static int SwitchWebSiteToDedicatedIP(int siteItemId, int ipAddressId) + { + // check account + int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); + if (accountCheck < 0) return accountCheck; + + // load web site item + WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId); + if (siteItem == null) + return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND; + + // load assigned IP address + IPAddressInfo ip = ServerController.GetIPAddress(ipAddressId); + if (ip == null) + return BusinessErrorCodes.ERROR_WEB_SITE_IP_ADDRESS_NOT_SPECIFIED; + + string ipAddr = !String.IsNullOrEmpty(ip.InternalIP) ? ip.InternalIP : ip.ExternalIP; + + // place log record + TaskManager.StartTask("WEB_SITE", "SWITCH_TO_DEDICATED_IP", siteItem.Name); + TaskManager.ItemId = siteItemId; + + try + { + // get web site pointers + var sitePointers = GetWebSitePointers(siteItemId); + + // get existing web site bindings + WebServer web = new WebServer(); + ServiceProviderProxy.Init(web, siteItem.ServiceId); + var bindings = web.GetSiteBindings(siteItem.SiteId); + + // update site bindings + web.UpdateSiteBindings(siteItem.SiteId, new ServerBinding[] { new ServerBinding(ipAddr, "80", "") }); + + // update site item + siteItem.SiteIPAddressId = ipAddressId; + PackageController.UpdatePackageItem(siteItem); + + // associate IP with web site + if (ipAddressId != 0) + ServerController.AddItemIPAddress(siteItemId, ipAddressId); + + // re-create pointers + foreach (var pointer in sitePointers) + DeleteWebSitePointer(siteItemId, pointer.DomainId, false); + + foreach (var pointer in sitePointers) + AddWebSitePointer(siteItemId, null, pointer.DomainId, false); + + return 0; + } + catch (Exception ex) + { + throw TaskManager.WriteError(ex); + } + finally + { + TaskManager.CompleteTask(); + } + } + + public static int SwitchWebSiteToSharedIP(int siteItemId) + { + // check account + int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); + if (accountCheck < 0) return accountCheck; + + // load web site item + WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId); + if (siteItem == null) + return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND; + + // place log record + TaskManager.StartTask("WEB_SITE", "SWITCH_TO_SHARED_IP", siteItem.Name); + TaskManager.ItemId = siteItemId; + + try + { + // get web site pointers + var sitePointers = GetWebSitePointers(siteItemId); + + // get existing web site bindings + WebServer web = new WebServer(); + ServiceProviderProxy.Init(web, siteItem.ServiceId); + var bindings = web.GetSiteBindings(siteItem.SiteId); + + // TODO + + return 0; + } + catch (Exception ex) + { + throw TaskManager.WriteError(ex); + } + finally + { + TaskManager.CompleteTask(); + } + } + private static void FillWebServerBindings(List bindings, List dnsRecords, string ipAddr, string hostName, string domainName) // TODO test if IPv6 works diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Web.config b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Web.config index b78330c8..ba1ad41e 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Web.config +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Web.config @@ -5,11 +5,11 @@ - + - + diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esWebServers.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esWebServers.asmx.cs index a5f3882f..997303e9 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esWebServers.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esWebServers.asmx.cs @@ -157,6 +157,18 @@ namespace WebsitePanel.EnterpriseServer return WebServerController.DeleteWebSite(siteItemId); } + [WebMethod] + public int SwitchWebSiteToDedicatedIP(int siteItemId, int ipAddressId) + { + return WebServerController.SwitchWebSiteToDedicatedIP(siteItemId, ipAddressId); + } + + [WebMethod] + public int SwitchWebSiteToSharedIP(int siteItemId) + { + return WebServerController.SwitchWebSiteToSharedIP(siteItemId); + } + [WebMethod] public int DeleteVirtualDirectory(int siteItemId, string vdirName) { diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx index 3dbe097a..5f8b0d3a 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx @@ -5125,9 +5125,6 @@ Lync Server - - General Lync User settings have been successfully updated. - Lync User has been successfully created but the following errors have been occured: @@ -5191,14 +5188,12 @@ Succesfully stamp mailboxes - Mailbox plan update failed Mailbox plan updated - Failed to apply plans template @@ -5208,7 +5203,16 @@ Request Completed Succesfully - - - + + Error updating web site to dedicated IP + + + Error updating web site to shared IP + + + Web site has been updated to dedicated IP + + + Web site has been updated to shared IP + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/WebSitesEditSite.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/WebSitesEditSite.ascx.resx index 9ee024bb..f82d2d99 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/WebSitesEditSite.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/WebSitesEditSite.ascx.resx @@ -112,10 +112,10 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Add Folder @@ -243,7 +243,7 @@ .htaccess Groups - + Custom MIME types are not defined @@ -408,55 +408,82 @@ To connect to web site management service please use username and password provi SSL - + Web Publishing - + Web Deploy Publishing is Disabled. - + Web Deploy Publishing is Enabled. - + To enable Web Publishing for this web site specify account user name and password and then click "Enable" button. - + Please choose a Microsoft SQL database: - + Build Publising Profile Wizard - + Please use the link below to build a publishing profile that makes it easy to configure publishing settings for your convenience. - + Change Password - + Disable - + Enable - + Username: - + Confim password: - + Password: - + Now you can publish content to this site easily via either Web Matrix or Visual Studio .NET 2010. Please use the link below to download publishing profile that makes it easy to publish the content online for your convenience. You also have an option to re-build publishing profile if you decide to change or update your publishing settings. - + Choose database... - + Choose database user... - + Choose FTP account... + + ShowProgressDialog('Applying changes...'); + + + Apply + + + Cancel + + + Switch to dedicated IP + + + if(!confirm('Do you really want to switch this web site to shared IP?')) return false;ShowProgressDialog('Applying changes...'); + + + Switch to shared IP + + + IP address: + + + Select IP address: + + + IP address: Shared + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx index e9fe4244..50177473 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx @@ -115,18 +115,38 @@ BackgroundCssClass="modalBackground" DropShadow="false" CancelControlID="PubProfileWizardCancelButton" />
- +
+ -
domain.com - + + +     + + + + + +     + + + + + +   + +   + + +
+
diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.cs index 5c7d807a..af5f5e12 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.cs @@ -163,8 +163,29 @@ namespace WebsitePanel.Portal lnkSiteName.Text = site.Name; lnkSiteName.NavigateUrl = "http://" + site.Name; - if (!String.IsNullOrEmpty(site.SiteIPAddress)) - litIPAddress.Text = String.Format("({0})", site.SiteIPAddress); + // bind unassigned IP addresses + PackageIPAddress[] ips = ES.Services.Servers.GetPackageUnassignedIPAddresses(site.PackageId, IPAddressPool.WebSites); + foreach (PackageIPAddress ip in ips) + { + string fullIP = ip.ExternalIP; + if (ip.InternalIP != null && + ip.InternalIP != "" && + ip.InternalIP != ip.ExternalIP) + fullIP += " (" + ip.InternalIP + ")"; + + ddlIpAddresses.Items.Add(new ListItem(fullIP, ip.PackageAddressID.ToString())); + } + + bool isDedicatedIP = false; + if (!String.IsNullOrEmpty(site.SiteIPAddress)) + { + litIPAddress.Text = site.SiteIPAddress; + isDedicatedIP = true; + } + + dedicatedIP.Visible = isDedicatedIP; + sharedIP.Visible = !isDedicatedIP; + cmdSwitchToDedicatedIP.Visible = (ddlIpAddresses.Items.Count > 0); litFrontPageUnavailable.Visible = false; @@ -981,5 +1002,74 @@ namespace WebsitePanel.Portal PortalUtils.SPACE_ID_PARAM + "=" + PanelSecurity.PackageId.ToString())); } #endregion + + protected void cmdSwitchToDedicatedIP_Click(object sender, EventArgs e) + { + sharedIP.Visible = false; + switchToDedicatedIP.Visible = true; + } + + protected void cmdSwitchToSharedIP_Click(object sender, EventArgs e) + { + // call web service + try + { + int result = ES.Services.WebServers.SwitchWebSiteToSharedIP(PanelRequest.ItemID); + + if (result < 0) + { + ShowResultMessage(result); + return; + } + + ShowSuccessMessage("WEB_SWITCH_TO_SHARED_IP"); + } + catch (Exception ex) + { + ShowErrorMessage("WEB_SWITCH_TO_SHARED_IP", ex); + return; + } + + // rebind + BindWebSite(); + } + + protected void cmdApplyDedicatedIP_Click(object sender, EventArgs e) + { + // call web service + try + { + int addressId = Int32.Parse(ddlIpAddresses.SelectedValue); + int result = ES.Services.WebServers.SwitchWebSiteToDedicatedIP(PanelRequest.ItemID, addressId); + + if (result < 0) + { + ShowResultMessage(result); + return; + } + + ShowSuccessMessage("WEB_SWITCH_TO_DEDICATED_IP"); + } + catch (Exception ex) + { + ShowErrorMessage("WEB_SWITCH_TO_DEDICATED_IP", ex); + return; + } + + // rebind + HideDedicatedIPPanel(); + BindWebSite(); + } + + protected void cmdCancelDedicatedIP_Click(object sender, EventArgs e) + { + HideDedicatedIPPanel(); + } + + private void HideDedicatedIPPanel() + { + switchToDedicatedIP.Visible = false; + sharedIP.Visible = true; + } } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.designer.cs index 822f1c72..299d66d1 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.designer.cs @@ -192,6 +192,51 @@ namespace WebsitePanel.Portal { /// protected global::System.Web.UI.WebControls.HyperLink lnkSiteName; + /// + /// sharedIP control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel sharedIP; + + /// + /// locSharedIPAddress control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locSharedIPAddress; + + /// + /// cmdSwitchToDedicatedIP control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton cmdSwitchToDedicatedIP; + + /// + /// dedicatedIP control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel dedicatedIP; + + /// + /// locDedicatedIPAddress control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locDedicatedIPAddress; + /// /// litIPAddress control. /// @@ -201,6 +246,60 @@ namespace WebsitePanel.Portal { /// protected global::System.Web.UI.WebControls.Literal litIPAddress; + /// + /// cmdSwitchToSharedIP control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton cmdSwitchToSharedIP; + + /// + /// switchToDedicatedIP control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel switchToDedicatedIP; + + /// + /// locSelectIPAddress control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locSelectIPAddress; + + /// + /// ddlIpAddresses control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList ddlIpAddresses; + + /// + /// cmdApplyDedicatedIP control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton cmdApplyDedicatedIP; + + /// + /// cmdCancelDedicatedIP control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton cmdCancelDedicatedIP; + /// /// btnAddPointer control. ///