RDS Qoutas fixes
This commit is contained in:
parent
789cd6ca11
commit
a1c0b62490
18 changed files with 187 additions and 46 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2290,18 +2290,22 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
|
|||
cmd.Parameters.Add("CollectionName", collectionName);
|
||||
cmd.Parameters.Add("ConnectionBroker", ConnectionBroker);
|
||||
var userSessions = ExecuteShellCommand(runSpace, cmd, false, out errors);
|
||||
var properties = typeof(RdsUserSession).GetProperties();
|
||||
var properties = typeof(RdsUserSession).GetProperties();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
session.UserName = GetUserFullName(session.DomainName, session.UserName, runSpace);
|
||||
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.IsVip = false;
|
||||
session.UserName = GetUserFullName(session.DomainName, session.SamAccountName, runSpace);
|
||||
result.Add(session);
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
|
@ -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>
|
|
@ -72,6 +72,11 @@
|
|||
</asp:TemplateField>
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
<div>
|
||||
<asp:Localize ID="locQuota" runat="server" meta:resourcekey="locQuota" Text="RDS Servers:"></asp:Localize>
|
||||
|
||||
<wsp:QuotaViewer ID="rdsServersQuota" runat="server" QuotaTypeId="2" DisplayGauge="true"/>
|
||||
</div>
|
||||
<asp:ObjectDataSource ID="odsRDSAssignedServersPaged" runat="server" EnablePaging="True"
|
||||
SelectCountMethod="GetOrganizationRdsServersPagedCount"
|
||||
SelectMethod="GetOrganizationRdsServersPaged"
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -66,6 +66,11 @@
|
|||
</asp:TemplateField>
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
<div>
|
||||
<asp:Localize ID="locQuota" runat="server" meta:resourcekey="locQuota" Text="Collections Created:"></asp:Localize>
|
||||
|
||||
<wsp:QuotaViewer ID="collectionsQuota" runat="server" QuotaTypeId="2" DisplayGauge="true" />
|
||||
</div>
|
||||
<asp:ObjectDataSource ID="odsRDSCollectionsPaged" runat="server" EnablePaging="True"
|
||||
SelectCountMethod="GetRDSCollectonsPagedCount"
|
||||
SelectMethod="GetRDSCollectonsPaged"
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
||||
<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" />
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue