wsp-10302 Enable/disable multiple accounts at once

This commit is contained in:
me 2015-02-05 22:02:12 +04:00
parent be944131f9
commit c4734e105f
13 changed files with 251 additions and 57 deletions

View file

@ -3136,6 +3136,15 @@
<data name="Success.ORGANIZATION_UPDATE_USER_SETTINGS" xml:space="preserve">
<value>User general settings have been successfully updated.</value>
</data>
<data name="Success.ORGANIZATION_USERS_ACTIONS" xml:space="preserve">
<value>Action has been successfully performed.</value>
</data>
<data name="Error.ORGANIZATION_USERS_ACTIONS" xml:space="preserve">
<value>Failed to perform action.</value>
</data>
<data name="Warning.ORGANIZATION_USERS_ACTIONS" xml:space="preserve">
<value>Please select the users for which you want to perform actions.</value>
</data>
<data name="Success.ORGANIZATION_SET_USER_PASSWORD" xml:space="preserve">
<value>User password has been successfully updated.</value>
</data>

View file

@ -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;}

View file

@ -328,21 +328,21 @@ namespace WebsitePanel.Portal
return idn.GetAscii(domainName);
}
/// <summary>
/// Adds the specified parameter to the Query String.
/// </summary>
/// <param name="url"></param>
/// <param name="paramName">Name of the parameter to add.</param>
/// <param name="paramValue">Value for the parameter to add.</param>
/// <returns>Url with added parameter.</returns>
public static Uri AddParameter(this Uri url, string paramName, string paramValue)
public static List<T> GetCheckboxValuesFromGrid<T>(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<T>();
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;
}
}
}

View file

@ -66,6 +66,24 @@ namespace WebsitePanel.Portal.Code.Helpers
|| PackagesHelper.CheckGroupQuotaEnabled(packageId, t.ResourceGroup, t.Quota)
select t;
}
/// <summary>
/// Adds the specified parameter to the Query String.
/// </summary>
/// <param name="url"></param>
/// <param name="paramName">Name of the parameter to add.</param>
/// <param name="paramValue">Value for the parameter to add.</param>
/// <returns>Url with added parameter.</returns>
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

View file

@ -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" %>
<script src="JavaScript/jquery-1.4.4.min.js" type="text/javascript"></script>
<script language="javascript">
function SelectAllCheckboxes(box) {
$(".NormalGridView tbody :checkbox").attr("checked", $(box).attr("checked"));
}
</script>
<wsp:EnableAsyncTasksSupport id="asyncTasks" runat="server"/>
@ -23,35 +32,45 @@
<asp:Button ID="btnCreateMailbox" runat="server" meta:resourcekey="btnCreateMailbox"
Text="Create New Mailbox" CssClass="Button1" OnClick="btnCreateMailbox_Click" />
</div>
<div class="FormButtonsBarCleanRight">
<asp:Panel ID="SearchPanel" runat="server" DefaultButton="cmdSearch">
<asp:CheckBox ID="chkMailboxes" runat="server" meta:resourcekey="chkMailboxes" Text="Mailboxes" AutoPostBack="true" OnCheckedChanged="chkMailboxes_CheckedChanged"/>
<asp:CheckBox ID="chkResourceMailboxes" runat="server" meta:resourcekey="chkResourceMailboxes" Text="Resource Mailboxes" AutoPostBack="true" OnCheckedChanged="chkMailboxes_CheckedChanged"/>
<asp:CheckBox ID="chkSharedMailboxes" runat="server" meta:resourcekey="chkSharedMailboxes" Text="Shared Mailboxes" AutoPostBack="true" OnCheckedChanged="chkMailboxes_CheckedChanged"/>
<asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlPageSize_SelectedIndexChanged">
<asp:ListItem>10</asp:ListItem>
<asp:ListItem Selected="True">20</asp:ListItem>
<asp:ListItem>50</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
</asp:DropDownList>
<div class="FormButtonsBarCleanMiddle">
<table>
<tr>
<td>
<wsp:UserActions ID="userActions" runat="server" />
</td>
<td class="FormButtonsBarCleanSeparatorSmall"></td>
<td>
<asp:Panel ID="SearchPanel" runat="server" DefaultButton="cmdSearch">
<asp:CheckBox ID="chkMailboxes" runat="server" meta:resourcekey="chkMailboxes" Text="Mailboxes" AutoPostBack="true" OnCheckedChanged="chkMailboxes_CheckedChanged" />
<asp:CheckBox ID="chkResourceMailboxes" runat="server" meta:resourcekey="chkResourceMailboxes" Text="Resource Mailboxes" AutoPostBack="true" OnCheckedChanged="chkMailboxes_CheckedChanged" />
<asp:CheckBox ID="chkSharedMailboxes" runat="server" meta:resourcekey="chkSharedMailboxes" Text="Shared Mailboxes" AutoPostBack="true" OnCheckedChanged="chkMailboxes_CheckedChanged" />
<asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="ddlPageSize_SelectedIndexChanged">
<asp:ListItem>10</asp:ListItem>
<asp:ListItem Selected="True">20</asp:ListItem>
<asp:ListItem>50</asp:ListItem>
<asp:DropDownList ID="ddlSearchColumn" runat="server" CssClass="NormalTextBox">
<asp:ListItem Value="DisplayName" meta:resourcekey="ddlSearchColumnDisplayName">DisplayName</asp:ListItem>
<asp:ListItem Value="PrimaryEmailAddress" meta:resourcekey="ddlSearchColumnEmail">Email</asp:ListItem>
<asp:ListItem Value="AccountName" meta:resourcekey="ddlSearchColumnAccountName">AccountName</asp:ListItem>
<asp:ListItem Value="SubscriberNumber" meta:resourcekey="ddlSearchColumnSubscriberNumber">Account Number</asp:ListItem>
<asp:ListItem Value="UserPrincipalName" meta:resourcekey="ddlSearchColumnUserPrincipalName">Login</asp:ListItem>
</asp:DropDownList><asp:TextBox ID="txtSearchValue" runat="server" CssClass="NormalTextBox" Width="100"></asp:TextBox><asp:ImageButton ID="cmdSearch" Runat="server" meta:resourcekey="cmdSearch" SkinID="SearchButton"
CausesValidation="false"/>
</asp:Panel>
<asp:ListItem>100</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddlSearchColumn" runat="server" CssClass="NormalTextBox">
<asp:ListItem Value="DisplayName" meta:resourcekey="ddlSearchColumnDisplayName">DisplayName</asp:ListItem>
<asp:ListItem Value="PrimaryEmailAddress" meta:resourcekey="ddlSearchColumnEmail">Email</asp:ListItem>
<asp:ListItem Value="AccountName" meta:resourcekey="ddlSearchColumnAccountName">AccountName</asp:ListItem>
<asp:ListItem Value="SubscriberNumber" meta:resourcekey="ddlSearchColumnSubscriberNumber">Account Number</asp:ListItem>
<asp:ListItem Value="UserPrincipalName" meta:resourcekey="ddlSearchColumnUserPrincipalName">Login</asp:ListItem>
</asp:DropDownList><asp:TextBox ID="txtSearchValue" runat="server" CssClass="NormalTextBox" Width="100"></asp:TextBox><asp:ImageButton ID="cmdSearch" runat="server" meta:resourcekey="cmdSearch" SkinID="SearchButton"
CausesValidation="false" />
</asp:Panel>
</td>
</tr>
</table>
</div>
</div>
<asp:GridView ID="gvMailboxes" runat="server" AutoGenerateColumns="False" EnableViewState="true"
Width="100%" EmptyDataText="gvMailboxes" CssSelectorClass="NormalGridView"
Width="100%" EmptyDataText="gvMailboxes" CssSelectorClass="NormalGridView" DataKeyNames="AccountId"
OnRowCommand="gvMailboxes_RowCommand" AllowPaging="True" AllowSorting="True"
DataSourceID="odsAccountsPaged" PageSize="20">
<Columns>
@ -60,6 +79,14 @@
<asp:Image ID="img2" runat="server" Width="16px" Height="16px" ImageUrl='<%# GetStateImage((bool)Eval("Locked"),(bool)Eval("Disabled")) %>' ImageAlign="AbsMiddle" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="selectAll" Runat="server" onclick="javascript:SelectAllCheckboxes(this);" CssClass="HeaderCheckbox"></asp:CheckBox>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox runat="server" ID="chkSelectedUsersIds"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="gvMailboxesDisplayName" SortExpression="DisplayName">
<ItemStyle Width="20%"></ItemStyle>
<ItemTemplate>
@ -80,7 +107,7 @@
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="gvServiceLevel">
<ItemStyle Width="20%"></ItemStyle>
<ItemStyle Width="15%"></ItemStyle>
<ItemTemplate>
<asp:Label id="lbServLevel" runat="server" ToolTip = '<%# GetServiceLevel((int)Eval("LevelId")).LevelDescription%>'>
<%# GetServiceLevel((int)Eval("LevelId")).LevelName%>

View file

@ -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<int>(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();
}
}
}

View file

@ -85,6 +85,15 @@ namespace WebsitePanel.Portal.ExchangeServer {
/// </remarks>
protected global::System.Web.UI.WebControls.Button btnCreateMailbox;
/// <summary>
/// userActions control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.UserActions userActions;
/// <summary>
/// SearchPanel control.
/// </summary>

View file

@ -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" %>
<script src="JavaScript/jquery-1.4.4.min.js" type="text/javascript"></script>
<script language="javascript">
function SelectAllCheckboxes(box) {
$(".NormalGridView tbody :checkbox").attr("checked", $(box).attr("checked"));
}
</script>
<wsp:EnableAsyncTasksSupport id="asyncTasks" runat="server"/>
@ -25,25 +34,35 @@
<asp:Button ID="btnCreateUser" runat="server" meta:resourcekey="btnCreateUser"
Text="Create New User" CssClass="Button1" OnClick="btnCreateUser_Click" />
</div>
<div class="FormButtonsBarCleanRight">
<asp:Panel ID="SearchPanel" runat="server" DefaultButton="cmdSearch">
<asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlPageSize_SelectedIndexChanged">
<asp:ListItem>10</asp:ListItem>
<asp:ListItem Selected="True">20</asp:ListItem>
<asp:ListItem>50</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
</asp:DropDownList>
<div class="FormButtonsBarCleanMiddle">
<table>
<tr>
<td>
<wsp:UserActions ID="userActions" runat="server" />
</td>
<td class="FormButtonsBarCleanSeparator"></td>
<td>
<asp:Panel ID="SearchPanel" runat="server" DefaultButton="cmdSearch">
<asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="ddlPageSize_SelectedIndexChanged">
<asp:ListItem>10</asp:ListItem>
<asp:ListItem Selected="True">20</asp:ListItem>
<asp:ListItem>50</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddlSearchColumn" runat="server" CssClass="NormalTextBox">
<asp:ListItem Value="DisplayName" meta:resourcekey="ddlSearchColumnDisplayName">DisplayName</asp:ListItem>
<asp:ListItem Value="PrimaryEmailAddress" meta:resourcekey="ddlSearchColumnEmail">Email</asp:ListItem>
<asp:ListItem Value="AccountName" meta:resourcekey="ddlSearchColumnAccountName">AccountName</asp:ListItem>
<asp:ListItem Value="SubscriberNumber" meta:resourcekey="ddlSearchColumnSubscriberNumber">Account Number</asp:ListItem>
<asp:ListItem Value="UserPrincipalName" meta:resourcekey="ddlSearchColumnUserPrincipalName">Login</asp:ListItem>
</asp:DropDownList><asp:TextBox ID="txtSearchValue" runat="server" CssClass="NormalTextBox" Width="100"></asp:TextBox><asp:ImageButton ID="cmdSearch" Runat="server" meta:resourcekey="cmdSearch" SkinID="SearchButton"
CausesValidation="false"/>
</asp:Panel>
<asp:DropDownList ID="ddlSearchColumn" runat="server" CssClass="NormalTextBox">
<asp:ListItem Value="DisplayName" meta:resourcekey="ddlSearchColumnDisplayName">DisplayName</asp:ListItem>
<asp:ListItem Value="PrimaryEmailAddress" meta:resourcekey="ddlSearchColumnEmail">Email</asp:ListItem>
<asp:ListItem Value="AccountName" meta:resourcekey="ddlSearchColumnAccountName">AccountName</asp:ListItem>
<asp:ListItem Value="SubscriberNumber" meta:resourcekey="ddlSearchColumnSubscriberNumber">Account Number</asp:ListItem>
<asp:ListItem Value="UserPrincipalName" meta:resourcekey="ddlSearchColumnUserPrincipalName">Login</asp:ListItem>
</asp:DropDownList><asp:TextBox ID="txtSearchValue" runat="server" CssClass="NormalTextBox" Width="100"></asp:TextBox><asp:ImageButton ID="cmdSearch" runat="server" meta:resourcekey="cmdSearch" SkinID="SearchButton"
CausesValidation="false" />
</asp:Panel>
</td>
</tr>
</table>
</div>
</div>
<asp:Panel ID="UsersPanel" runat="server">
@ -59,7 +78,14 @@
<asp:Image ID="img2" runat="server" Width="16px" Height="16px" ImageUrl='<%# GetStateImage((bool)Eval("Locked"),(bool)Eval("Disabled")) %>' ImageAlign="AbsMiddle" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="selectAll" Runat="server" onclick="javascript:SelectAllCheckboxes(this);" CssClass="HeaderCheckbox"></asp:CheckBox>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox runat="server" ID="chkSelectedUsersIds"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="gvUsersDisplayName" SortExpression="DisplayName">
<ItemStyle Width="25%"></ItemStyle>
<ItemTemplate>

View file

@ -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<int>(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();
}
}
}

View file

@ -85,6 +85,15 @@ namespace WebsitePanel.Portal.HostedSolution {
/// </remarks>
protected global::System.Web.UI.WebControls.Button btnCreateUser;
/// <summary>
/// userActions control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.UserActions userActions;
/// <summary>
/// SearchPanel control.
/// </summary>

View file

@ -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
{

View file

@ -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
{

View file

@ -891,6 +891,13 @@
<Compile Include="UserControls\ItemButtonPanel.ascx.designer.cs">
<DependentUpon>ItemButtonPanel.ascx</DependentUpon>
</Compile>
<Compile Include="UserControls\UserActions.ascx.cs">
<DependentUpon>UserActions.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="UserControls\UserActions.ascx.designer.cs">
<DependentUpon>UserActions.ascx</DependentUpon>
</Compile>
<Compile Include="UserOrganization.ascx.cs">
<DependentUpon>UserOrganization.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@ -4473,6 +4480,7 @@
<Content Include="UserControls\PackagePhoneNumbers.ascx" />
<Content Include="Lync\UserControls\AllocatePackagePhoneNumbers.ascx" />
<Content Include="UserControls\ItemButtonPanel.ascx" />
<Content Include="UserControls\UserActions.ascx" />
<Content Include="UserOrganization.ascx" />
<Content Include="VPSForPC\MonitoringPage.aspx" />
<Content Include="VPSForPC\VdcAccountVLanAdd.ascx" />
@ -4541,6 +4549,9 @@
<Content Include="PhoneNumbers.ascx" />
<Content Include="PhoneNumbersAddPhoneNumber.ascx" />
<Content Include="PhoneNumbersEditPhoneNumber.ascx" />
<Content Include="UserControls\App_LocalResources\UserActions.ascx.resx">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="App_LocalResources\BandwidthReport.ascx.resx">