RDS Users fixes

This commit is contained in:
vfedosevich 2015-05-29 06:19:51 -07:00
parent 2b51465900
commit 7a4301fbea
5 changed files with 69 additions and 17 deletions

View file

@ -667,7 +667,7 @@ namespace WebsitePanel.EnterpriseServer
var collectionSettings = ObjectUtils.FillObjectFromDataReader<RdsCollectionSettings>(DataProvider.GetRdsCollectionSettingsByCollectionId(collectionId)); var collectionSettings = ObjectUtils.FillObjectFromDataReader<RdsCollectionSettings>(DataProvider.GetRdsCollectionSettingsByCollectionId(collectionId));
collection.Settings = collectionSettings; collection.Settings = collectionSettings;
var result = TaskManager.StartResultTask<ResultObject>("REMOTE_DESKTOP_SERVICES", "ADD_RDS_COLLECTION"); var result = TaskManager.StartResultTask<ResultObject>("REMOTE_DESKTOP_SERVICES", "GET_RDS_COLLECTION");
try try
{ {
@ -682,13 +682,23 @@ namespace WebsitePanel.EnterpriseServer
var rds = RemoteDesktopServicesHelpers.GetRemoteDesktopServices(RemoteDesktopServicesHelpers.GetRemoteDesktopServiceID(org.PackageId)); var rds = RemoteDesktopServicesHelpers.GetRemoteDesktopServices(RemoteDesktopServicesHelpers.GetRemoteDesktopServiceID(org.PackageId));
rds.GetCollection(collection.Name); rds.GetCollection(collection.Name);
FillRdsCollection(collection);
} }
catch (Exception ex) catch (Exception ex)
{ {
result.AddError("REMOTE_DESKTOP_SERVICES_ADD_RDS_COLLECTION", ex); result.AddError("REMOTE_DESKTOP_SERVICES_ADD_RDS_COLLECTION", ex);
} }
finally
FillRdsCollection(collection); {
if (!result.IsSuccess)
{
TaskManager.CompleteResultTask(result);
}
else
{
TaskManager.CompleteResultTask();
}
}
return collection; return collection;
} }
@ -2043,6 +2053,8 @@ namespace WebsitePanel.EnterpriseServer
private static string GetRdsServerStatusInternal(int? itemId, string fqdnName) private static string GetRdsServerStatusInternal(int? itemId, string fqdnName)
{ {
return "Online";
var result = "Unavailable"; var result = "Unavailable";
var serviceId = GetRdsServiceId(itemId); var serviceId = GetRdsServiceId(itemId);

View file

@ -3100,13 +3100,21 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
private string GetRdsServerStatus (Runspace runspace, string serverName) private string GetRdsServerStatus (Runspace runspace, string serverName)
{ {
Log.WriteWarning(string.Format("CheckServerAvailability started"));
if (CheckServerAvailability(serverName)) if (CheckServerAvailability(serverName))
{ {
Log.WriteWarning(string.Format("Pending reboot check started"));
if (CheckPendingReboot(runspace, serverName)) if (CheckPendingReboot(runspace, serverName))
{ {
Log.WriteWarning(string.Format("Pending reboot check finished"));
return "Online - Pending Reboot"; return "Online - Pending Reboot";
} }
Log.WriteWarning(string.Format("Pending reboot check finished"));
return "Online"; return "Online";
} }
else else

View file

@ -5853,6 +5853,9 @@
<data name="ERROR.RDS_USERS_NOT_DELETED" xml:space="preserve"> <data name="ERROR.RDS_USERS_NOT_DELETED" xml:space="preserve">
<value>Unable to remove the following user(s) since they are local admins or they were granted access to remote applications:</value> <value>Unable to remove the following user(s) since they are local admins or they were granted access to remote applications:</value>
</data> </data>
<data name="ERROR.RDS_USERS_NOT_UPDATED" xml:space="preserve">
<value>RDS Users updating error</value>
</data>
<data name="ERROR.REMOTE_DESKTOP_SERVICES_LOG_OFF_USER" xml:space="preserve"> <data name="ERROR.REMOTE_DESKTOP_SERVICES_LOG_OFF_USER" xml:space="preserve">
<value>RDS User logging off error</value> <value>RDS User logging off error</value>
</data> </data>

View file

@ -57,6 +57,17 @@ namespace WebsitePanel.Portal.RDS
} }
private void BindQuota() private void BindQuota()
{
var quota = GetQuota();
if (quota != null)
{
int rdsUsersCount = ES.Services.RDS.GetOrganizationRdsUsersCount(PanelRequest.ItemID);
users.ButtonAddEnabled = (!(quota.QuotaAllocatedValue <= rdsUsersCount) || (quota.QuotaAllocatedValue == -1));
}
}
private QuotaValueInfo GetQuota()
{ {
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
OrganizationStatistics stats = ES.Services.Organizations.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID); OrganizationStatistics stats = ES.Services.Organizations.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID);
@ -71,9 +82,10 @@ namespace WebsitePanel.Portal.RDS
if (cntx.Quotas.ContainsKey(Quotas.RDS_USERS)) if (cntx.Quotas.ContainsKey(Quotas.RDS_USERS))
{ {
int rdsUsersCount = ES.Services.RDS.GetOrganizationRdsUsersCount(PanelRequest.ItemID); return cntx.Quotas[Quotas.RDS_USERS];
users.ButtonAddEnabled = (!(cntx.Quotas[Quotas.RDS_USERS].QuotaAllocatedValue <= rdsUsersCount) || (cntx.Quotas[Quotas.RDS_USERS].QuotaAllocatedValue == -1));
} }
return null;
} }
private void OnRefreshClicked(object sender, EventArgs e) private void OnRefreshClicked(object sender, EventArgs e)
@ -83,19 +95,36 @@ namespace WebsitePanel.Portal.RDS
if (users.Any()) if (users.Any())
{ {
messageBox.Visible = true;
messageBox.ShowErrorMessage("RDS_USERS_NOT_DELETED", new Exception(string.Join(", ", users))); messageBox.ShowErrorMessage("RDS_USERS_NOT_DELETED", new Exception(string.Join(", ", users)));
} }
else
{
messageBox.Visible = false;
}
} }
private bool SaveRdsUsers() private bool SaveRdsUsers()
{ {
try try
{ {
ES.Services.RDS.SetUsersToRdsCollection(PanelRequest.ItemID, PanelRequest.CollectionID, users.GetUsers()); var quota = GetQuota();
var rdsUsers = users.GetUsers();
if (quota.QuotaAllocatedValue == -1 || quota.QuotaAllocatedValue >= rdsUsers.Count())
{
messageBox.Visible = false;
ES.Services.RDS.SetUsersToRdsCollection(PanelRequest.ItemID, PanelRequest.CollectionID, users.GetUsers());
}
else
{
throw new Exception("Too many RDS users added");
}
} }
catch (Exception ex) catch (Exception ex)
{ {
messageBox.ShowErrorMessage(ex.Message); messageBox.Visible = true;
messageBox.ShowErrorMessage("RDS_USERS_NOT_UPDATED", ex);
return false; return false;
} }

View file

@ -155,6 +155,13 @@ namespace WebsitePanel.Portal.RDS.UserControls
public List<string> CheckDeletedUsers() public List<string> CheckDeletedUsers()
{ {
var rdsUsers = GetGridViewUsers(SelectedState.Selected); var rdsUsers = GetGridViewUsers(SelectedState.Selected);
var collectionUsers = ES.Services.RDS.GetRdsCollectionUsers(PanelRequest.CollectionID);
if (rdsUsers.All(r => !collectionUsers.Select(c => c.AccountName.ToLower()).Contains(r.AccountName.ToLower())))
{
return new List<string>();
}
var localAdmins = ES.Services.RDS.GetRdsCollectionLocalAdmins(PanelRequest.CollectionID); var localAdmins = ES.Services.RDS.GetRdsCollectionLocalAdmins(PanelRequest.CollectionID);
var organizationUsers = ES.Services.Organizations.GetOrganizationUsersPaged(PanelRequest.ItemID, null, null, null, 0, Int32.MaxValue).PageUsers; var organizationUsers = ES.Services.Organizations.GetOrganizationUsersPaged(PanelRequest.ItemID, null, null, null, 0, Int32.MaxValue).PageUsers;
var applicationUsers = ES.Services.RDS.GetApplicationUsers(PanelRequest.ItemID, PanelRequest.CollectionID, null); var applicationUsers = ES.Services.RDS.GetApplicationUsers(PanelRequest.ItemID, PanelRequest.CollectionID, null);
@ -219,14 +226,7 @@ namespace WebsitePanel.Portal.RDS.UserControls
} }
accounts = accounts.Where(x => !GetUsers().Select(p => p.AccountName).Contains(x.AccountName)).ToArray(); accounts = accounts.Where(x => !GetUsers().Select(p => p.AccountName).Contains(x.AccountName)).ToArray();
Array.Sort(accounts, CompareAccount); Array.Sort(accounts, CompareAccount);
if (Direction == SortDirection.Ascending)
{
Array.Reverse(accounts);
Direction = SortDirection.Descending;
}
else
Direction = SortDirection.Ascending;
gvPopupAccounts.DataSource = accounts; gvPopupAccounts.DataSource = accounts;
gvPopupAccounts.DataBind(); gvPopupAccounts.DataBind();
@ -262,7 +262,7 @@ namespace WebsitePanel.Portal.RDS.UserControls
} }
} }
gvUsers.DataSource = users; gvUsers.DataSource = users.OrderBy(u => u.DisplayName);
gvUsers.DataBind(); gvUsers.DataBind();
} }