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

@ -6042,7 +6042,7 @@ CREATE PROCEDURE [dbo].GetOrganizationRdsUsersCount
)
AS
SELECT
@TotalNumber = Count([RDSCollectionId])
@TotalNumber = Count(DISTINCT([AccountId]))
FROM [dbo].[RDSCollectionUsers]
WHERE [RDSCollectionId] in (SELECT [ID] FROM [RDSCollections] where [ItemId] = @ItemId )
RETURN
@ -8192,6 +8192,22 @@ AS
INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID
INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID
WHERE pt.ParentPackageID = @PackageID AND ea.AccountType = 11)
ELSE IF @QuotaID = 450
SET @Result = (SELECT COUNT(DISTINCT(RCU.[AccountId])) FROM [dbo].[RDSCollectionUsers] RCU
INNER JOIN ExchangeAccounts EA ON EA.AccountId = RCU.AccountId
INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID
INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID
WHERE PT.ParentPackageID = @PackageID)
ELSE IF @QuotaID = 451
SET @Result = (SELECT COUNT(RS.[ID]) FROM [dbo].[RDSServers] RS
INNER JOIN ServiceItems si ON RS.ItemID = si.ItemID
INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID
WHERE PT.ParentPackageID = @PackageID)
ELSE IF @QuotaID = 491
SET @Result = (SELECT COUNT(RC.[ID]) FROM [dbo].[RDSCollections] RC
INNER JOIN ServiceItems si ON RC.ItemID = si.ItemID
INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID
WHERE PT.ParentPackageID = @PackageID)
ELSE IF @QuotaName like 'ServiceLevel.%' -- Support Service Level Quota
BEGIN
DECLARE @LevelID int

View file

@ -760,8 +760,21 @@ namespace WebsitePanel.EnterpriseServer
}
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(organization.PackageId));
var userSessions = rds.GetRdsUserSessions(collection.Name).ToList();
var organizationUsers = OrganizationController.GetOrganizationUsersPaged(collection.ItemId, null, null, null, 0, Int32.MaxValue).PageUsers;
return rds.GetRdsUserSessions(collection.Name).ToList();
foreach(var userSession in userSessions)
{
var organizationUser = organizationUsers.FirstOrDefault(o => o.SamAccountName.Equals(userSession.SamAccountName, StringComparison.CurrentCultureIgnoreCase));
if (organizationUser != null)
{
userSession.IsVip = organizationUser.IsVIP;
result.Add(userSession);
}
}
return result;
}
private static RdsServersPaged GetFreeRdsServersPagedInternal(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)

View file

@ -13,5 +13,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
public string SessionState { get; set; }
public string HostServer { get; set; }
public string DomainName { get; set; }
public bool IsVip { get; set; }
public string SamAccountName { get; set; }
}
}

View file

@ -2294,14 +2294,18 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
foreach(var userSession in userSessions)
{
var session = new RdsUserSession();
foreach(var prop in properties)
var session = new RdsUserSession
{
prop.SetValue(session, GetPSObjectProperty(userSession, prop.Name).ToString(), null);
}
CollectionName = GetPSObjectProperty(userSession, "CollectionName").ToString(),
DomainName = GetPSObjectProperty(userSession, "DomainName").ToString(),
HostServer = GetPSObjectProperty(userSession, "HostServer").ToString(),
SessionState = GetPSObjectProperty(userSession, "SessionState").ToString(),
UnifiedSessionId = GetPSObjectProperty(userSession, "UnifiedSessionId").ToString(),
SamAccountName = GetPSObjectProperty(userSession, "UserName").ToString(),
};
session.UserName = GetUserFullName(session.DomainName, session.UserName, runSpace);
session.IsVip = false;
session.UserName = GetUserFullName(session.DomainName, session.SamAccountName, runSpace);
result.Add(session);
}

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

@ -42,6 +42,7 @@ namespace WebsitePanel.Portal.RDS
{
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

@ -42,6 +42,7 @@
<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");
}
}
}