diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs index 84ae3fbd..a351f386 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs @@ -158,7 +158,6 @@ order by rg.groupOrder public const string ORGANIZATION_USERS = "HostedSolution.Users"; public const string ORGANIZATION_DOMAINS = "HostedSolution.Domains"; public const string ORGANIZATION_ALLOWCHANGEUPN = "HostedSolution.AllowChangeUPN"; - //public const string ORGANIZATION_SECURITYGROUPMANAGEMENT = "HostedSolution.SecurityGroupManagement"; public const string ORGANIZATION_SECURITYGROUPS = "HostedSolution.SecurityGroups"; public const string CRM_USERS = "HostedCRM.Users"; diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/OrganizationProxy.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/OrganizationProxy.cs index 4daaabf4..1d9d15f0 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/OrganizationProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/OrganizationProxy.cs @@ -144,6 +144,8 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution private System.Threading.SendOrPostCallback AddAdditionalGroupOperationCompleted; + private System.Threading.SendOrPostCallback SetDefaultOrganizationOperationCompleted; + /// public esOrganizations() { @@ -267,6 +269,9 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution /// public event AddAdditionalGroupCompletedEventHandler AddAdditionalGroupCompleted; + /// + public event SetDefaultOrganizationCompletedEventHandler SetDefaultOrganizationCompleted; + /// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/CheckOrgIdExists", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] @@ -2608,6 +2613,56 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution } } + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/SetDefaultOrganization", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public void SetDefaultOrganization(int newDefaultOrganizationId, int currentDefaultOrganizationId) + { + this.Invoke("SetDefaultOrganization", new object[] { + newDefaultOrganizationId, + currentDefaultOrganizationId}); + } + + /// + public System.IAsyncResult BeginSetDefaultOrganization(int newDefaultOrganizationId, int currentDefaultOrganizationId, System.AsyncCallback callback, object asyncState) + { + return this.BeginInvoke("SetDefaultOrganization", new object[] { + newDefaultOrganizationId, + currentDefaultOrganizationId}, callback, asyncState); + } + + /// + public void EndSetDefaultOrganization(System.IAsyncResult asyncResult) + { + this.EndInvoke(asyncResult); + } + + /// + public void SetDefaultOrganizationAsync(int newDefaultOrganizationId, int currentDefaultOrganizationId) + { + this.SetDefaultOrganizationAsync(newDefaultOrganizationId, currentDefaultOrganizationId, null); + } + + /// + public void SetDefaultOrganizationAsync(int newDefaultOrganizationId, int currentDefaultOrganizationId, object userState) + { + if ((this.SetDefaultOrganizationOperationCompleted == null)) + { + this.SetDefaultOrganizationOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetDefaultOrganizationOperationCompleted); + } + this.InvokeAsync("SetDefaultOrganization", new object[] { + newDefaultOrganizationId, + currentDefaultOrganizationId}, this.SetDefaultOrganizationOperationCompleted, userState); + } + + private void OnSetDefaultOrganizationOperationCompleted(object arg) + { + if ((this.SetDefaultOrganizationCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SetDefaultOrganizationCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// public new void CancelAsync(object userState) { @@ -3732,4 +3787,8 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution } } } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void SetDefaultOrganizationCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs index 5b7e0f8e..c1c58d8f 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs @@ -286,6 +286,7 @@ namespace WebsitePanel.EnterpriseServer TaskManager.WriteError(ex); } } + public static int CreateOrganization(int packageId, string organizationId, string organizationName, string domainName) { int itemId; @@ -1276,6 +1277,44 @@ namespace WebsitePanel.EnterpriseServer return 0; } + public static void SetDefaultOrganization(int newDefaultOrganizationId, int currentDefaultOrganizationId) + { + // place log record + List parameters = new List(); + parameters.Add(new BackgroundTaskParameter("ItemID", newDefaultOrganizationId)); + + TaskManager.StartTask("ORGANIZATION", "SET_DEFAULT_ORG", parameters); + + try + { + if (currentDefaultOrganizationId > 0) + { + // load current default organization + Organization currentDefaultOrg = (Organization)PackageController.GetPackageItem(currentDefaultOrganizationId); + + currentDefaultOrg.IsDefault = false; + + // save changes + PackageController.UpdatePackageItem(currentDefaultOrg); + } + + // load organization + Organization newDefaultOrg = (Organization)PackageController.GetPackageItem(newDefaultOrganizationId); + + newDefaultOrg.IsDefault = true; + // save changes + PackageController.UpdatePackageItem(newDefaultOrg); + } + catch (Exception ex) + { + throw TaskManager.WriteError(ex); + } + finally + { + TaskManager.CompleteTask(); + } + } + #region Users diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esOrganizations.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esOrganizations.asmx.cs index e44669eb..74098095 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esOrganizations.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esOrganizations.asmx.cs @@ -117,6 +117,11 @@ namespace WebsitePanel.EnterpriseServer return OrganizationController.GetAccountIdByUserPrincipalName(itemId, userPrincipalName); } + [WebMethod] + public void SetDefaultOrganization(int newDefaultOrganizationId, int currentDefaultOrganizationId) + { + OrganizationController.SetDefaultOrganization(newDefaultOrganizationId, currentDefaultOrganizationId); + } #endregion diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/Organization.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/Organization.cs index 534ea87d..7bd07942 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/Organization.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/Organization.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2014, Outercurve Foundation. +// Copyright (c) 2012, Outercurve Foundation. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -62,6 +62,9 @@ namespace WebsitePanel.Providers.HostedSolution private int warningSharePointStorage; #endregion + + [Persistent] + public bool IsDefault { get; set; } [Persistent] public int MaxSharePointStorage diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/Organizations.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/Organizations.ascx.resx index 9a44ec38..90ff8dde 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/Organizations.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/Organizations.ascx.resx @@ -168,4 +168,10 @@ Home + + Default + + + Set Default Organization + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx index aaa3031e..ee284508 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx @@ -74,6 +74,13 @@ + + +
+ /> +
+
+

+     -
-
+ +
+ +
diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.cs index 15770b50..a7079111 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2014, Outercurve Foundation. +// Copyright (c) 2012, Outercurve Foundation. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, @@ -27,14 +27,18 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using System; +using System.Data; using System.Text; using System.Web.UI.WebControls; using WebsitePanel.EnterpriseServer; +using WebsitePanel.Providers.HostedSolution; namespace WebsitePanel.Portal.ExchangeServer { public partial class Organizations : WebsitePanelModuleBase { + private int CurrentDefaultOrgId { get; set; } + protected void Page_Load(object sender, EventArgs e) { // set display preferences @@ -50,16 +54,17 @@ namespace WebsitePanel.Portal.ExchangeServer btnCreate.Enabled = false; } - PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); if (cntx.Quotas.ContainsKey(Quotas.ORGANIZATIONS)) { btnCreate.Enabled = (!(cntx.Quotas[Quotas.ORGANIZATIONS].QuotaAllocatedValue <= gvOrgs.Rows.Count)||(cntx.Quotas[Quotas.ORGANIZATIONS].QuotaAllocatedValue==-1)); } - + //else //if (gvOrgs.Rows.Count > 0) btnCreate.Enabled = false; + btnSetDefaultOrganization.Enabled = !(gvOrgs.Rows.Count < 2); + if (!Page.IsPostBack) { if (Request.UrlReferrer != null && PanelSecurity.SelectedUser.Role == UserRole.User) @@ -69,6 +74,8 @@ namespace WebsitePanel.Portal.ExchangeServer if (Request.UrlReferrer.Query.Equals(queryBuilder.ToString(), StringComparison.InvariantCultureIgnoreCase) && gvOrgs.Rows.Count > 0) { + if (CurrentDefaultOrgId > 0) Response.Redirect(GetOrganizationEditUrl(CurrentDefaultOrgId.ToString())); + Response.Redirect(((HyperLink)gvOrgs.Rows[0].Cells[1].Controls[1]).NavigateUrl); } } @@ -139,5 +146,33 @@ namespace WebsitePanel.Portal.ExchangeServer } } } + + protected void btnSetDefaultOrganization_Click(object sender, EventArgs e) + { + // get org + int newDefaultOrgId = Utils.ParseInt(Request.Form["DefaultOrganization"], CurrentDefaultOrgId); + + try + { + ES.Services.Organizations.SetDefaultOrganization(newDefaultOrgId, CurrentDefaultOrgId); + + ShowSuccessMessage("REQUEST_COMPLETED_SUCCESFULLY"); + } + catch (Exception ex) + { + ShowErrorMessage("ORGANIZATION_SET_DEFAULT_ORG", ex); + } + } + + public string IsChecked(string val, string itemId) + { + if (!string.IsNullOrEmpty(val) && val.ToLowerInvariant() == "true") + { + CurrentDefaultOrgId = Utils.ParseInt(itemId, 0); + return "checked"; + } + + return ""; + } } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.designer.cs index d918a0c8..892e33d5 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.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. @@ -165,5 +137,14 @@ namespace WebsitePanel.Portal.ExchangeServer { /// To modify move field declaration from designer file to code-behind file. ///
protected global::WebsitePanel.Portal.Quota orgsQuota; + + /// + /// btnSetDefaultOrganization control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSetDefaultOrganization; } }