RDS Collection settings added

This commit is contained in:
vfedosevich 2015-01-27 04:48:25 -08:00
parent b13ad8cc41
commit 636b3e22ca
28 changed files with 1610 additions and 61 deletions

View file

@ -4556,6 +4556,95 @@ namespace WebsitePanel.EnterpriseServer
#region RDS
public static IDataReader GetRdsCollectionSettingsByCollectionId(int collectionId)
{
return SqlHelper.ExecuteReader(
ConnectionString,
CommandType.StoredProcedure,
"GetRDSCollectionSettingsByCollectionId",
new SqlParameter("@RDSCollectionID", collectionId)
);
}
public static int AddRdsCollectionSettings(RdsCollectionSettings settings)
{
return AddRdsCollectionSettings(settings.RdsCollectionId, settings.DisconnectedSessionLimitMin, settings.ActiveSessionLimitMin, settings.IdleSessionLimitMin, settings.BrokenConnectionAction,
settings.AutomaticReconnectionEnabled, settings.TemporaryFoldersDeletedOnExit, settings.TemporaryFoldersPerSession, settings.ClientDeviceRedirectionOptions, settings.ClientPrinterRedirected,
settings.ClientPrinterAsDefault, settings.RDEasyPrintDriverEnabled, settings.MaxRedirectedMonitors);
}
private static int AddRdsCollectionSettings(int rdsCollectionId, int disconnectedSessionLimitMin, int activeSessionLimitMin, int idleSessionLimitMin, string brokenConnectionAction,
bool automaticReconnectionEnabled, bool temporaryFoldersDeletedOnExit, bool temporaryFoldersPerSession, string clientDeviceRedirectionOptions, bool ClientPrinterRedirected,
bool clientPrinterAsDefault, bool rdEasyPrintDriverEnabled, int maxRedirectedMonitors)
{
SqlParameter rdsCollectionSettingsId = new SqlParameter("@RDSCollectionSettingsID", SqlDbType.Int);
rdsCollectionSettingsId.Direction = ParameterDirection.Output;
SqlHelper.ExecuteNonQuery(
ConnectionString,
CommandType.StoredProcedure,
"AddRDSCollectionSettings",
rdsCollectionSettingsId,
new SqlParameter("@RdsCollectionId", rdsCollectionId),
new SqlParameter("@DisconnectedSessionLimitMin", disconnectedSessionLimitMin),
new SqlParameter("@ActiveSessionLimitMin", activeSessionLimitMin),
new SqlParameter("@IdleSessionLimitMin", idleSessionLimitMin),
new SqlParameter("@BrokenConnectionAction", brokenConnectionAction),
new SqlParameter("@AutomaticReconnectionEnabled", automaticReconnectionEnabled),
new SqlParameter("@TemporaryFoldersDeletedOnExit", temporaryFoldersDeletedOnExit),
new SqlParameter("@TemporaryFoldersPerSession", temporaryFoldersPerSession),
new SqlParameter("@ClientDeviceRedirectionOptions", clientDeviceRedirectionOptions),
new SqlParameter("@ClientPrinterRedirected", ClientPrinterRedirected),
new SqlParameter("@ClientPrinterAsDefault", clientPrinterAsDefault),
new SqlParameter("@RDEasyPrintDriverEnabled", rdEasyPrintDriverEnabled),
new SqlParameter("@MaxRedirectedMonitors", maxRedirectedMonitors)
);
return Convert.ToInt32(rdsCollectionSettingsId.Value);
}
public static void UpdateRDSCollectionSettings(RdsCollectionSettings settings)
{
UpdateRDSCollectionSettings(settings.Id, settings.RdsCollectionId, settings.DisconnectedSessionLimitMin, settings.ActiveSessionLimitMin, settings.IdleSessionLimitMin, settings.BrokenConnectionAction,
settings.AutomaticReconnectionEnabled, settings.TemporaryFoldersDeletedOnExit, settings.TemporaryFoldersPerSession, settings.ClientDeviceRedirectionOptions, settings.ClientPrinterRedirected,
settings.ClientPrinterAsDefault, settings.RDEasyPrintDriverEnabled, settings.MaxRedirectedMonitors);
}
public static void UpdateRDSCollectionSettings(int id, int rdsCollectionId, int disconnectedSessionLimitMin, int activeSessionLimitMin, int idleSessionLimitMin, string brokenConnectionAction,
bool automaticReconnectionEnabled, bool temporaryFoldersDeletedOnExit, bool temporaryFoldersPerSession, string clientDeviceRedirectionOptions, bool ClientPrinterRedirected,
bool clientPrinterAsDefault, bool rdEasyPrintDriverEnabled, int maxRedirectedMonitors)
{
SqlHelper.ExecuteNonQuery(
ConnectionString,
CommandType.StoredProcedure,
"UpdateRDSCollectionSettings",
new SqlParameter("@Id", id),
new SqlParameter("@RdsCollectionId", rdsCollectionId),
new SqlParameter("@DisconnectedSessionLimitMin", disconnectedSessionLimitMin),
new SqlParameter("@ActiveSessionLimitMin", activeSessionLimitMin),
new SqlParameter("@IdleSessionLimitMin", idleSessionLimitMin),
new SqlParameter("@BrokenConnectionAction", brokenConnectionAction),
new SqlParameter("@AutomaticReconnectionEnabled", automaticReconnectionEnabled),
new SqlParameter("@TemporaryFoldersDeletedOnExit", temporaryFoldersDeletedOnExit),
new SqlParameter("@TemporaryFoldersPerSession", temporaryFoldersPerSession),
new SqlParameter("@ClientDeviceRedirectionOptions", clientDeviceRedirectionOptions),
new SqlParameter("@ClientPrinterRedirected", ClientPrinterRedirected),
new SqlParameter("@ClientPrinterAsDefault", clientPrinterAsDefault),
new SqlParameter("@RDEasyPrintDriverEnabled", rdEasyPrintDriverEnabled),
new SqlParameter("@MaxRedirectedMonitors", maxRedirectedMonitors)
);
}
public static void DeleteRDSCollectionSettings(int id)
{
SqlHelper.ExecuteNonQuery(
ConnectionString,
CommandType.StoredProcedure,
"DeleteRDSCollectionSettings",
new SqlParameter("@Id", id)
);
}
public static IDataReader GetRDSCollectionsByItemId(int itemId)
{
return SqlHelper.ExecuteReader(
@ -4614,7 +4703,7 @@ namespace WebsitePanel.EnterpriseServer
new SqlParameter("@ItemID", itemId),
new SqlParameter("@Name", name),
new SqlParameter("@Description", description),
new SqlParameter("DisplayName", displayName)
new SqlParameter("@DisplayName", displayName)
);
// read identity

View file

@ -58,6 +58,11 @@ namespace WebsitePanel.EnterpriseServer
return GetRdsCollectionInternal(collectionId);
}
public static RdsCollectionSettings GetRdsCollectionSettings(int collectionId)
{
return GetRdsCollectionSettingsInternal(collectionId);
}
public static List<RdsCollection> GetOrganizationRdsCollections(int itemId)
{
return GetOrganizationRdsCollectionsInternal(itemId);
@ -73,6 +78,11 @@ namespace WebsitePanel.EnterpriseServer
return EditRdsCollectionInternal(itemId, collection);
}
public static ResultObject EditRdsCollectionSettings(int itemId, RdsCollection collection)
{
return EditRdsCollectionSettingsInternal(itemId, collection);
}
public static RdsCollectionPaged GetRdsCollectionsPaged(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
{
return GetRdsCollectionsPagedInternal(itemId, filterColumn, filterValue, sortColumn, startRow, maximumRows);
@ -226,13 +236,15 @@ namespace WebsitePanel.EnterpriseServer
private static RdsCollection GetRdsCollectionInternal(int collectionId)
{
var collection = ObjectUtils.FillObjectFromDataReader<RdsCollection>(DataProvider.GetRDSCollectionById(collectionId));
var collectionSettings = ObjectUtils.FillObjectFromDataReader<RdsCollectionSettings>(DataProvider.GetRdsCollectionSettingsByCollectionId(collectionId));
collection.Settings = collectionSettings;
var result = TaskManager.StartResultTask<ResultObject>("REMOTE_DESKTOP_SERVICES", "ADD_RDS_COLLECTION");
try
{
// load organization
Organization org = OrganizationController.GetOrganization(4115);
Organization org = OrganizationController.GetOrganization(collection.ItemId);
if (org == null)
{
result.IsSuccess = false;
@ -253,6 +265,13 @@ namespace WebsitePanel.EnterpriseServer
return collection;
}
private static RdsCollectionSettings GetRdsCollectionSettingsInternal(int collectionId)
{
var collection = ObjectUtils.FillObjectFromDataReader<RdsCollection>(DataProvider.GetRDSCollectionById(collectionId));
return ObjectUtils.FillObjectFromDataReader<RdsCollectionSettings>(DataProvider.GetRdsCollectionSettingsByCollectionId(collectionId));
}
private static List<RdsCollection> GetOrganizationRdsCollectionsInternal(int itemId)
{
var collections = ObjectUtils.CreateListFromDataReader<RdsCollection>(DataProvider.GetRDSCollectionsByItemId(itemId));
@ -280,8 +299,37 @@ namespace WebsitePanel.EnterpriseServer
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId));
collection.Name = GetFormattedCollectionName(collection.DisplayName, org.OrganizationId);
collection.Settings = new RdsCollectionSettings
{
DisconnectedSessionLimitMin = 0,
ActiveSessionLimitMin = 0,
IdleSessionLimitMin = 0,
BrokenConnectionAction = BrokenConnectionActionValues.Disconnect.ToString(),
AutomaticReconnectionEnabled = true,
TemporaryFoldersDeletedOnExit = true,
TemporaryFoldersPerSession = true,
ClientDeviceRedirectionOptions = string.Join(",", new List<string>
{
ClientDeviceRedirectionOptionValues.AudioVideoPlayBack.ToString(),
ClientDeviceRedirectionOptionValues.AudioRecording.ToString(),
ClientDeviceRedirectionOptionValues.SmartCard.ToString(),
ClientDeviceRedirectionOptionValues.Clipboard.ToString(),
ClientDeviceRedirectionOptionValues.Drive.ToString(),
ClientDeviceRedirectionOptionValues.PlugAndPlayDevice.ToString()
}.ToArray()),
ClientPrinterRedirected = true,
ClientPrinterAsDefault = true,
RDEasyPrintDriverEnabled = true,
MaxRedirectedMonitors = 16
};
rds.CreateCollection(org.OrganizationId, collection);
collection.Id = DataProvider.AddRDSCollection(itemId, collection.Name, collection.Description, collection.DisplayName);
collection.Id = DataProvider.AddRDSCollection(itemId, collection.Name, collection.Description, collection.DisplayName);
collection.Settings.RdsCollectionId = collection.Id;
int settingsId = DataProvider.AddRdsCollectionSettings(collection.Settings);
collection.Settings.Id = settingsId;
foreach (var server in collection.Servers)
{
@ -359,6 +407,54 @@ namespace WebsitePanel.EnterpriseServer
return result;
}
private static ResultObject EditRdsCollectionSettingsInternal(int itemId, RdsCollection collection)
{
var result = TaskManager.StartResultTask<ResultObject>("REMOTE_DESKTOP_SERVICES", "EDIT_RDS_COLLECTION_SETTINGS");
try
{
Organization org = OrganizationController.GetOrganization(itemId);
if (org == null)
{
result.IsSuccess = false;
result.AddError("", new NullReferenceException("Organization not found"));
return result;
}
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId));
rds.EditRdsCollectionSettings(collection);
var collectionSettings = ObjectUtils.FillObjectFromDataReader<RdsCollectionSettings>(DataProvider.GetRdsCollectionSettingsByCollectionId(collection.Id));
if (collectionSettings == null)
{
DataProvider.AddRdsCollectionSettings(collection.Settings);
}
else
{
DataProvider.UpdateRDSCollectionSettings(collection.Settings);
}
}
catch (Exception ex)
{
result.AddError("REMOTE_DESKTOP_SERVICES_ADD_RDS_COLLECTION", ex);
throw TaskManager.WriteError(ex);
}
finally
{
if (!result.IsSuccess)
{
TaskManager.CompleteResultTask(result);
}
else
{
TaskManager.CompleteResultTask();
}
}
return result;
}
private static RdsCollectionPaged GetRdsCollectionsPagedInternal(int itemId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
{
DataSet ds = DataProvider.GetRDSCollectionsPaged(itemId, filterColumn, filterValue, sortColumn, startRow, maximumRows);