RDS Qoutas fixes

This commit is contained in:
vfedosevich 2015-02-27 06:47:53 -08:00
parent 789cd6ca11
commit a1c0b62490
18 changed files with 187 additions and 46 deletions

View file

@ -145,7 +145,7 @@
<value>Assigned RDS Servers</value>
</data>
<data name="locQuota.Text" xml:space="preserve">
<value>Total RDS Servers Allocated:</value>
<value>Total Remote Desktop Servers Allocated:</value>
</data>
<data name="cmdDisable.Text" xml:space="preserve">
<value>Disable</value>

View file

@ -147,4 +147,7 @@
<data name="gvServer.Header" xml:space="preserve">
<value>RDS Server</value>
</data>
<data name="locQuota.Text" xml:space="preserve">
<value>Total Remote Desktop Collections Created:</value>
</data>
</root>

View file

@ -144,4 +144,7 @@
<data name="secRdsUsers.Text" xml:space="preserve">
<value>RDS Users</value>
</data>
<data name="locQuota.Text" xml:space="preserve">
<value>Total RDS Users Assigned:</value>
</data>
</root>

View file

@ -72,6 +72,11 @@
</asp:TemplateField>
</Columns>
</asp:GridView>
<div>
<asp:Localize ID="locQuota" runat="server" meta:resourcekey="locQuota" Text="RDS Servers:"></asp:Localize>
&nbsp;&nbsp;&nbsp;
<wsp:QuotaViewer ID="rdsServersQuota" runat="server" QuotaTypeId="2" DisplayGauge="true"/>
</div>
<asp:ObjectDataSource ID="odsRDSAssignedServersPaged" runat="server" EnablePaging="True"
SelectCountMethod="GetOrganizationRdsServersPagedCount"
SelectMethod="GetOrganizationRdsServersPaged"

View file

@ -41,18 +41,32 @@ namespace WebsitePanel.Portal.RDS
{
protected void Page_Load(object sender, EventArgs e)
{
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
if (!IsPostBack)
{
BindQuota(cntx);
}
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
if (cntx.Quotas.ContainsKey(Quotas.RDS_SERVERS))
{
btnAddServerToOrg.Enabled = (!(cntx.Quotas[Quotas.RDS_SERVERS].QuotaAllocatedValue <= gvRDSAssignedServers.Rows.Count) || (cntx.Quotas[Quotas.RDS_SERVERS].QuotaAllocatedValue == -1));
}
}
private void BindQuota(PackageContext cntx)
{
OrganizationStatistics stats = ES.Services.Organizations.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID);
OrganizationStatistics tenantStats = ES.Services.Organizations.GetOrganizationStatistics(PanelRequest.ItemID);
rdsServersQuota.QuotaUsedValue = stats.CreatedRdsServers;
rdsServersQuota.QuotaValue = stats.AllocatedRdsServers;
if (stats.AllocatedUsers != -1)
{
rdsServersQuota.QuotaAvailable = tenantStats.AllocatedRdsServers - tenantStats.CreatedRdsServers;
}
}
protected void btnAddServerToOrg_Click(object sender, EventArgs e)
{
Response.Redirect(EditUrl("ItemID", PanelRequest.ItemID.ToString(), "rds_add_server",

View file

@ -1,31 +1,3 @@
// Copyright (c) 2015, 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.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@ -139,6 +111,24 @@ namespace WebsitePanel.Portal.RDS {
/// </remarks>
protected global::System.Web.UI.WebControls.GridView gvRDSAssignedServers;
/// <summary>
/// locQuota control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Localize locQuota;
/// <summary>
/// rdsServersQuota control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.QuotaViewer rdsServersQuota;
/// <summary>
/// odsRDSAssignedServersPaged control.
/// </summary>

View file

@ -66,6 +66,11 @@
</asp:TemplateField>
</Columns>
</asp:GridView>
<div>
<asp:Localize ID="locQuota" runat="server" meta:resourcekey="locQuota" Text="Collections Created:"></asp:Localize>
&nbsp;&nbsp;&nbsp;
<wsp:QuotaViewer ID="collectionsQuota" runat="server" QuotaTypeId="2" DisplayGauge="true" />
</div>
<asp:ObjectDataSource ID="odsRDSCollectionsPaged" runat="server" EnablePaging="True"
SelectCountMethod="GetRDSCollectonsPagedCount"
SelectMethod="GetRDSCollectonsPaged"

View file

@ -42,17 +42,32 @@ namespace WebsitePanel.Portal.RDS
{
protected void Page_Load(object sender, EventArgs e)
{
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
if (!IsPostBack)
{
BindQuota(cntx);
}
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
if (cntx.Quotas.ContainsKey(Quotas.RDS_COLLECTIONS))
{
btnAddCollection.Enabled = (!(cntx.Quotas[Quotas.RDS_COLLECTIONS].QuotaAllocatedValue <= gvRDSCollections.Rows.Count) || (cntx.Quotas[Quotas.RDS_COLLECTIONS].QuotaAllocatedValue == -1));
}
}
private void BindQuota(PackageContext cntx)
{
OrganizationStatistics stats = ES.Services.Organizations.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID);
OrganizationStatistics tenantStats = ES.Services.Organizations.GetOrganizationStatistics(PanelRequest.ItemID);
collectionsQuota.QuotaUsedValue = stats.CreatedRdsCollections;
collectionsQuota.QuotaValue = stats.AllocatedRdsCollections;
if (stats.AllocatedUsers != -1)
{
collectionsQuota.QuotaAvailable = tenantStats.AllocatedRdsCollections - tenantStats.CreatedRdsCollections;
}
}
public string GetServerName(string collectionId)
{
int id = int.Parse(collectionId);

View file

@ -111,6 +111,24 @@ namespace WebsitePanel.Portal.RDS {
/// </remarks>
protected global::System.Web.UI.WebControls.GridView gvRDSCollections;
/// <summary>
/// locQuota control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Localize locQuota;
/// <summary>
/// collectionsQuota control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.QuotaViewer collectionsQuota;
/// <summary>
/// odsRDSCollectionsPaged control.
/// </summary>

View file

@ -1,6 +1,7 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RDSEditCollectionUsers.ascx.cs" Inherits="WebsitePanel.Portal.RDS.RDSEditCollectionUsers" %>
<%@ Register Src="../UserControls/SimpleMessageBox.ascx" TagName="SimpleMessageBox" TagPrefix="wsp" %>
<%@ Register Src="../UserControls/EnableAsyncTasksSupport.ascx" TagName="EnableAsyncTasksSupport" TagPrefix="wsp" %>
<%@ Register Src="../UserControls/QuotaViewer.ascx" TagName="QuotaViewer" TagPrefix="wsp" %>
<%@ Register Src="UserControls/RDSCollectionUsers.ascx" TagName="CollectionUsers" TagPrefix="wsp"%>
<%@ Register Src="UserControls/RDSCollectionTabs.ascx" TagName="CollectionTabs" TagPrefix="wsp" %>
<%@ Register TagPrefix="wsp" TagName="CollapsiblePanel" Src="../UserControls/CollapsiblePanel.ascx" %>
@ -34,6 +35,11 @@
<wsp:CollectionUsers id="users" runat="server" />
</div>
</asp:Panel>
<div>
<asp:Localize ID="locQuota" runat="server" meta:resourcekey="locQuota" Text="Users Created:"></asp:Localize>
&nbsp;&nbsp;&nbsp;
<wsp:QuotaViewer ID="usersQuota" runat="server" QuotaTypeId="2" DisplayGauge="true" />
</div>
<div class="FormFooterClean">
<wsp:ItemButtonPanel id="buttonPanel" runat="server" ValidationGroup="SaveRDSCollection"
OnSaveClick="btnSave_Click" OnSaveExitClick="btnSaveExit_Click" />

View file

@ -39,9 +39,10 @@ namespace WebsitePanel.Portal.RDS
{
protected void Page_Load(object sender, EventArgs e)
{
{
if (!IsPostBack)
{
BindQuota();
var collectionUsers = ES.Services.RDS.GetRdsCollectionUsers(PanelRequest.CollectionID);
var collection = ES.Services.RDS.GetRdsCollection(PanelRequest.CollectionID);
@ -50,6 +51,20 @@ namespace WebsitePanel.Portal.RDS
}
}
private void BindQuota()
{
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
OrganizationStatistics stats = ES.Services.Organizations.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID);
OrganizationStatistics tenantStats = ES.Services.Organizations.GetOrganizationStatistics(PanelRequest.ItemID);
usersQuota.QuotaUsedValue = stats.CreatedRdsUsers;
usersQuota.QuotaValue = stats.AllocatedRdsUsers;
if (stats.AllocatedUsers != -1)
{
usersQuota.QuotaAvailable = tenantStats.AllocatedRdsUsers - tenantStats.CreatedRdsUsers;
}
}
private bool SaveRdsUsers()
{
try
@ -73,6 +88,7 @@ namespace WebsitePanel.Portal.RDS
}
SaveRdsUsers();
BindQuota();
}
protected void btnSaveExit_Click(object sender, EventArgs e)

View file

@ -93,6 +93,24 @@ namespace WebsitePanel.Portal.RDS {
/// </remarks>
protected global::WebsitePanel.Portal.RDS.UserControls.RDSCollectionUsers users;
/// <summary>
/// locQuota control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Localize locQuota;
/// <summary>
/// usersQuota control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.QuotaViewer usersQuota;
/// <summary>
/// buttonPanel control.
/// </summary>

View file

@ -38,10 +38,11 @@
<asp:GridView ID="gvRDSUserSessions" runat="server" AutoGenerateColumns="False" EnableViewState="true"
Width="100%" EmptyDataText="gvRDSUserSessions" CssSelectorClass="NormalGridView"
OnRowCommand="gvRDSCollections_RowCommand" AllowPaging="True" AllowSorting="True">
<Columns>
<Columns>
<asp:TemplateField meta:resourcekey="gvUserName" HeaderText="gvUserName">
<ItemStyle Width="30%" Wrap="false"/>
<ItemTemplate>
<asp:Image ID="vipImage" runat="server" ImageUrl='<%# GetAccountImage(Convert.ToBoolean(Eval("IsVip"))) %>' ImageAlign="AbsMiddle"/>
<asp:Literal ID="litUserName" runat="server" Text='<%# Eval("UserName") %>'/>
<asp:HiddenField ID="hfUnifiedSessionId" runat="server" Value='<%# Eval("UnifiedSessionId") %>'/>
</ItemTemplate>

View file

@ -5,6 +5,8 @@ using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebsitePanel.EnterpriseServer;
using WebsitePanel.Providers.HostedSolution;
using WebsitePanel.Providers.RemoteDesktopServices;
namespace WebsitePanel.Portal.RDS
@ -101,5 +103,15 @@ namespace WebsitePanel.Portal.RDS
gvRDSUserSessions.DataSource = userSessions;
gvRDSUserSessions.DataBind();
}
public string GetAccountImage(bool vip)
{
if (vip)
{
return GetThemedImage("Exchange/vip_user_16.png");
}
return GetThemedImage("Exchange/accounting_mail_16.png");
}
}
}