From c4734e105f7906ed30ca83b8750bf17b83e33849 Mon Sep 17 00:00:00 2001 From: me Date: Thu, 5 Feb 2015 22:02:12 +0400 Subject: [PATCH] wsp-10302 Enable/disable multiple accounts at once --- .../WebsitePanel_SharedResources.ascx.resx | 9 +++ .../App_Themes/Default/Styles/Skin.css | 4 + .../WebsitePanel/Code/Framework/Utils.cs | 26 +++---- .../WebsitePanel/Code/Helpers/Extensions.cs | 18 +++++ .../ExchangeServer/ExchangeMailboxes.ascx | 77 +++++++++++++------ .../ExchangeServer/ExchangeMailboxes.ascx.cs | 38 +++++++++ .../ExchangeMailboxes.ascx.designer.cs | 9 +++ .../ExchangeServer/OrganizationUsers.ascx | 64 ++++++++++----- .../ExchangeServer/OrganizationUsers.ascx.cs | 41 ++++++++++ .../OrganizationUsers.ascx.designer.cs | 9 +++ .../WebsitePanel/IPAddresses.ascx.cs | 1 + .../ServerIPAddressesControl.ascx.cs | 1 + .../WebsitePanel.Portal.Modules.csproj | 11 +++ 13 files changed, 251 insertions(+), 57 deletions(-) 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 049d2b3d..d93a9f1c 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx @@ -3136,6 +3136,15 @@ User general settings have been successfully updated. + + Action has been successfully performed. + + + Failed to perform action. + + + Please select the users for which you want to perform actions. + User password has been successfully updated. diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Themes/Default/Styles/Skin.css b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Themes/Default/Styles/Skin.css index 08834b23..d4b25131 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Themes/Default/Styles/Skin.css +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Themes/Default/Styles/Skin.css @@ -93,6 +93,7 @@ select:disabled {border:1px solid #ccc; background:#f5f5f5; color:#ccc; cursor:n textarea {font-family:inherit; font-size:inherit; color:inherit; background:#fff; border: 1px solid #ccc; padding:3px 0 3px 3px; margin:0; resize:none;} /* checkbox */ input[type=checkbox], input[type=radio] {margin:8px 4px 8px; vertical-align:-1px;} +.HeaderCheckbox {margin-left:5px;} input[type=image] {margin-right:4px;} .LoginLabel {display:block; line-height:34px; width:auto !important; padding-right:8px;} .LoginContainer .SubHead {padding-right:8px; color:#333;} @@ -180,6 +181,9 @@ h2.ProductTitle.Huge {margin:0;} .FormButtonsBarClean {clear: both; padding-bottom: 4px;} .FormButtonsBarCleanLeft {float: left;} .FormButtonsBarCleanRight {text-align: right;} +.FormButtonsBarCleanMiddle {float: right;} +.FormButtonsBarCleanSeparator {padding-right: 30px;} +.FormButtonsBarCleanSeparatorSmall {padding-right: 15px;} .GridFooter .Left {float: left;} .GridFooter .Right {text-align: right;} .FormRow {padding-top: 4px; padding-bottom: 4px;} 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 428ab43f..9e8827ac 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Framework/Utils.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Framework/Utils.cs @@ -328,21 +328,21 @@ namespace WebsitePanel.Portal return idn.GetAscii(domainName); } - /// - /// Adds the specified parameter to the Query String. - /// - /// - /// Name of the parameter to add. - /// Value for the parameter to add. - /// Url with added parameter. - public static Uri AddParameter(this Uri url, string paramName, string paramValue) + public static List GetCheckboxValuesFromGrid(GridView gridView, string checkboxName) { - var uriBuilder = new UriBuilder(url); - var query = HttpUtility.ParseQueryString(uriBuilder.Query); - query[paramName] = paramValue; - uriBuilder.Query = query.ToString(); + // Get checked users + var userIds = new List(); - return new Uri(uriBuilder.ToString()); + foreach (GridViewRow gvr in gridView.Rows) + { + if (((CheckBox)gvr.FindControl(checkboxName)).Checked) + { + string userId = gridView.DataKeys[gvr.DataItemIndex].Value.ToString(); + userIds.Add((T)Convert.ChangeType(userId, typeof(T))); + } + } + + return userIds; } } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/Extensions.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/Extensions.cs index 767435ca..b38fc2ea 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/Extensions.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/Extensions.cs @@ -66,6 +66,24 @@ namespace WebsitePanel.Portal.Code.Helpers || PackagesHelper.CheckGroupQuotaEnabled(packageId, t.ResourceGroup, t.Quota) select t; } + + + /// + /// Adds the specified parameter to the Query String. + /// + /// + /// Name of the parameter to add. + /// Value for the parameter to add. + /// Url with added parameter. + public static Uri AddParameter(this Uri url, string paramName, string paramValue) + { + var uriBuilder = new UriBuilder(url); + var query = HttpUtility.ParseQueryString(uriBuilder.Query); + query[paramName] = paramValue; + uriBuilder.Query = query.ToString(); + + return new Uri(uriBuilder.ToString()); + } } public class Tab diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx index aba30904..b967aa40 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx @@ -2,6 +2,15 @@ <%@ Register Src="../UserControls/SimpleMessageBox.ascx" TagName="SimpleMessageBox" TagPrefix="wsp" %> <%@ Register Src="../UserControls/QuotaViewer.ascx" TagName="QuotaViewer" TagPrefix="wsp" %> <%@ Register Src="../UserControls/EnableAsyncTasksSupport.ascx" TagName="EnableAsyncTasksSupport" TagPrefix="wsp" %> +<%@ Register Src="../UserControls/UserActions.ascx" TagName="UserActions" TagPrefix="wsp" %> + + + + @@ -23,35 +32,45 @@ -
- - - - - - 10 - 20 - 50 - - 100 - - +
+ + + + + + +
+ + + + + + + + 10 + 20 + 50 - - DisplayName - Email - AccountName - Account Number - Login - - + 100 + + + + + DisplayName + Email + AccountName + Account Number + Login + + +
@@ -60,6 +79,14 @@ + + + + + + + + @@ -80,7 +107,7 @@ - + <%# GetServiceLevel((int)Eval("LevelId")).LevelName%> diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.cs index 734314f2..d88a3ea6 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.cs @@ -69,6 +69,7 @@ namespace WebsitePanel.Portal.ExchangeServer BindServiceLevels(); + DoUserActions(); if (cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_ISCONSUMER)) { @@ -273,5 +274,42 @@ namespace WebsitePanel.Portal.ExchangeServer odsAccountsPaged.SelectParameters["accountTypes"].DefaultValue = string.Join(",", accountTypes); } + protected void DoUserActions() + { + // Get checked users + var userIds = Utils.GetCheckboxValuesFromGrid(gvMailboxes, "chkSelectedUsersIds"); + + if (userActions.SelectedAction != UserActionTypes.None) + { + if (userIds.Count > 0) + { + try + { + var result = userActions.DoUserActions(userIds); + + if (result < 0) + { + messageBox.ShowResultMessage(result); + return; + } + + messageBox.ShowSuccessMessage("ORGANIZATION_USERS_ACTIONS"); + } + catch (Exception ex) + { + messageBox.ShowErrorMessage("ORGANIZATION_USERS_ACTIONS", ex); + } + + // Refresh users grid + gvMailboxes.DataBind(); + } + else + { + messageBox.ShowWarningMessage("ORGANIZATION_USERS_ACTIONS"); + } + } + + userActions.ResetSelection(); + } } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.designer.cs index 94c5736e..121ed1c5 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxes.ascx.designer.cs @@ -85,6 +85,15 @@ namespace WebsitePanel.Portal.ExchangeServer { /// protected global::System.Web.UI.WebControls.Button btnCreateMailbox; + /// + /// userActions control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.UserActions userActions; + /// /// SearchPanel control. /// diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx index 5f70a82f..8a98736b 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx @@ -3,6 +3,15 @@ <%@ Register Src="../UserControls/SimpleMessageBox.ascx" TagName="SimpleMessageBox" TagPrefix="wsp" %> <%@ Register Src="../UserControls/QuotaViewer.ascx" TagName="QuotaViewer" TagPrefix="wsp" %> <%@ Register Src="../UserControls/EnableAsyncTasksSupport.ascx" TagName="EnableAsyncTasksSupport" TagPrefix="wsp" %> +<%@ Register Src="../UserControls/UserActions.ascx" TagName="UserActions" TagPrefix="wsp" %> + + + + @@ -25,25 +34,35 @@ -
- - - 10 - 20 - 50 - 100 - +
+ + + + + + +
+ + + + + 10 + 20 + 50 + 100 + - - DisplayName - Email - AccountName - Account Number - Login - - + + DisplayName + Email + AccountName + Account Number + Login + + +
@@ -59,7 +78,14 @@
- + + + + + + + + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.cs index 2854f39c..73f6f616 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.cs @@ -52,6 +52,8 @@ namespace WebsitePanel.Portal.HostedSolution BindServiceLevels(); + DoUserActions(); + if (cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_ISCONSUMER)) { if (cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue != 1) @@ -388,5 +390,44 @@ namespace WebsitePanel.Portal.HostedSolution messageBox.ShowErrorMessage("ORGANIZATIONS_DELETE_USERS", ex); } } + + + protected void DoUserActions() + { + // Get checked users + var userIds = Utils.GetCheckboxValuesFromGrid(gvUsers, "chkSelectedUsersIds"); + + if (userActions.SelectedAction != UserActionTypes.None) + { + if (userIds.Count > 0) + { + try + { + var result = userActions.DoUserActions(userIds); + + if (result < 0) + { + messageBox.ShowResultMessage(result); + return; + } + + messageBox.ShowSuccessMessage("ORGANIZATION_USERS_ACTIONS"); + } + catch (Exception ex) + { + messageBox.ShowErrorMessage("ORGANIZATION_USERS_ACTIONS", ex); + } + + // Refresh users grid + gvUsers.DataBind(); + } + else + { + messageBox.ShowWarningMessage("ORGANIZATION_USERS_ACTIONS"); + } + } + + userActions.ResetSelection(); + } } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.designer.cs index 22dab4cf..17643c1b 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUsers.ascx.designer.cs @@ -85,6 +85,15 @@ namespace WebsitePanel.Portal.HostedSolution { /// protected global::System.Web.UI.WebControls.Button btnCreateUser; + /// + /// userActions control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.UserActions userActions; + /// /// SearchPanel control. /// diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/IPAddresses.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/IPAddresses.ascx.cs index 950cd86d..10757751 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/IPAddresses.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/IPAddresses.ascx.cs @@ -31,6 +31,7 @@ using System.Web.UI.WebControls; using System.Collections.Generic; using WebsitePanel.Providers.Common; using System.Text; +using WebsitePanel.Portal.Code.Helpers; namespace WebsitePanel.Portal { diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ServerIPAddressesControl.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ServerIPAddressesControl.ascx.cs index fc805eee..b3d8849c 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ServerIPAddressesControl.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ServerIPAddressesControl.ascx.cs @@ -36,6 +36,7 @@ using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; +using WebsitePanel.Portal.Code.Helpers; namespace WebsitePanel.Portal { 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 046875ad..dc3a4358 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj @@ -891,6 +891,13 @@ ItemButtonPanel.ascx + + UserActions.ascx + ASPXCodeBehind + + + UserActions.ascx + UserOrganization.ascx ASPXCodeBehind @@ -4473,6 +4480,7 @@ + @@ -4541,6 +4549,9 @@ + + Designer +