This commit is contained in:
vfedosevich 2015-04-16 05:00:56 -07:00
commit 097378bc50
352 changed files with 45244 additions and 2550 deletions

View file

@ -100,6 +100,19 @@ namespace WebsitePanel.EnterpriseServer
svals[i] = ivals[i].ToString();
s = String.Join(";", svals);
}
// when property is custom class with Persistent attribute
else if (prop.PropertyType.GetCustomAttributes(typeof(PersistentAttribute), false).Length > 0)
{
// add sub-class properties to hash
var childHash = GetObjectProperties(val, persistentOnly);
foreach (var hashKey in childHash.Keys)
{
var value = childHash[hashKey];
hash.Add(prop.Name + "." + hashKey, value);
}
// exit
continue;
}
else
s = val.ToString();
}
@ -478,6 +491,41 @@ namespace WebsitePanel.EnterpriseServer
}
}
private static Hashtable GetPropertiesForCache(Type type, bool persistentOnly)
{
// create properties cache
var props = new Hashtable();
PropertyInfo[] objProps = type.GetProperties(BindingFlags.Instance
//| BindingFlags.DeclaredOnly
| BindingFlags.Public);
foreach (PropertyInfo prop in objProps)
{
// check for persistent attribute
object[] attrs = prop.GetCustomAttributes(typeof(PersistentAttribute), false);
if (!persistentOnly || (persistentOnly && attrs.Length > 0) && !props.ContainsKey(prop.Name))
{
// when property is custom class with Persistent attribute
if (prop.PropertyType.GetCustomAttributes(typeof (PersistentAttribute), false).Length > 0)
{
// add sub-class properties to hash
var childHash = GetPropertiesForCache(prop.PropertyType, persistentOnly);
foreach (var hashKey in childHash.Keys)
{
var value = childHash[hashKey];
props.Add(prop.Name + "." + hashKey, value);
}
// exit
continue;
}
// add property to hash
props.Add(prop.Name, prop);
}
}
return props;
}
public static void CreateObjectFromHash(object obj, Hashtable propValues, bool persistentOnly)
{
Type type = obj.GetType();
@ -491,21 +539,7 @@ namespace WebsitePanel.EnterpriseServer
}
else
{
// create properties cache
props = new Hashtable();
PropertyInfo[] objProps = type.GetProperties(BindingFlags.Instance
//| BindingFlags.DeclaredOnly
| BindingFlags.Public);
foreach (PropertyInfo prop in objProps)
{
// check for persistent attribute
object[] attrs = prop.GetCustomAttributes(typeof(PersistentAttribute), false);
if (!persistentOnly || (persistentOnly && attrs.Length > 0) && !props.ContainsKey(prop.Name))
{
// add property to hash
props.Add(prop.Name, prop);
}
}
props = GetPropertiesForCache(type, persistentOnly);
if (!propertiesCache.ContainsKey(type.Name))
{
@ -520,38 +554,63 @@ namespace WebsitePanel.EnterpriseServer
// try to locate specified property
if (props[propName] != null)
{
PropertyInfo prop = (PropertyInfo)props[propName];
string val = propValues[propName].ToString();
var currentObj = obj;
// when property is custom class with Persistent attribute
if (propName.Contains("."))
{
var mainPropertyName = propName.Split('.')[0];
var childPropertyName = propName.Split('.')[1];
var mainProperty = type.GetProperty(mainPropertyName);
if (mainProperty == null) continue;
var mainVal = mainProperty.GetValue(obj, null);
if (mainVal == null)
{
mainVal = Activator.CreateInstance(mainProperty.PropertyType);
mainProperty.SetValue(obj, mainVal, null);
}
currentObj = mainVal;
var childProperty = mainProperty.PropertyType.GetProperty(childPropertyName);
if (childProperty == null) continue;
prop = childProperty;
}
// set property
// we support:
// String
// Int32
// Boolean
// Float
PropertyInfo prop = (PropertyInfo)props[propName];
string val = propValues[propName].ToString();
if (prop.PropertyType == typeof(String))
prop.SetValue(obj, val, null);
prop.SetValue(currentObj, val, null);
else if (prop.PropertyType == typeof(Int32))
prop.SetValue(obj, Int32.Parse(val), null);
prop.SetValue(currentObj, Int32.Parse(val), null);
else
if (prop.PropertyType == typeof(long))
prop.SetValue(obj, long.Parse(val), null);
prop.SetValue(currentObj, long.Parse(val), null);
else
if (prop.PropertyType == typeof(Boolean))
prop.SetValue(obj, Boolean.Parse(val), null);
prop.SetValue(currentObj, Boolean.Parse(val), null);
else if (prop.PropertyType == typeof(Single))
prop.SetValue(obj, Single.Parse(val), null);
prop.SetValue(currentObj, Single.Parse(val), null);
else if (prop.PropertyType.IsEnum)
prop.SetValue(obj, Enum.Parse(prop.PropertyType, val, true), null);
prop.SetValue(currentObj, Enum.Parse(prop.PropertyType, val, true), null);
else
if (prop.PropertyType == typeof(Guid))
prop.SetValue(obj, new Guid(val), null);
prop.SetValue(currentObj, new Guid(val), null);
else
if (prop.PropertyType == typeof(string[]))
{
if (val == "")
prop.SetValue(obj, new string[0], null);
prop.SetValue(currentObj, new string[0], null);
else
prop.SetValue(obj, val.Split(';'), null);
prop.SetValue(currentObj, val.Split(';'), null);
}
else if (prop.PropertyType == typeof(int[]))
{
@ -564,7 +623,7 @@ namespace WebsitePanel.EnterpriseServer
if (val == "")
ivals = new int[0];
prop.SetValue(obj, ivals, null);
prop.SetValue(currentObj, ivals, null);
}
}
}

View file

@ -3540,6 +3540,21 @@ namespace WebsitePanel.EnterpriseServer
new SqlParameter("@Recursive", recursive));
return reader;
}
public static IDataReader GetVirtualMachinesPaged2012(int actorId, int packageId, string filterColumn, string filterValue,
string sortColumn, int startRow, int maximumRows, bool recursive)
{
IDataReader reader = SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure,
"GetVirtualMachinesPaged2012",
new SqlParameter("@ActorID", actorId),
new SqlParameter("@PackageID", packageId),
new SqlParameter("@FilterColumn", VerifyColumnName(filterColumn)),
new SqlParameter("@FilterValue", VerifyColumnValue(filterValue)),
new SqlParameter("@SortColumn", VerifyColumnName(sortColumn)),
new SqlParameter("@StartRow", startRow),
new SqlParameter("@MaximumRows", maximumRows),
new SqlParameter("@Recursive", recursive));
return reader;
}
#endregion
public static IDataReader GetVirtualMachinesForPCPaged(int actorId, int packageId, string filterColumn, string filterValue,

View file

@ -76,6 +76,11 @@ namespace WebsitePanel.EnterpriseServer
return GetFoldersInternal(itemId);
}
public static SystemFile[] GetUserRootFolders(int itemId, int accountId, string userName, string displayName)
{
return GetUserRootFoldersInternal(itemId, accountId, userName, displayName);
}
public static SystemFile GetFolder(int itemId, string folderName)
{
return GetFolderInternal(itemId, folderName);
@ -554,6 +559,57 @@ namespace WebsitePanel.EnterpriseServer
}
}
protected static SystemFile[] GetUserRootFoldersInternal(int itemId, int accountId, string userName, string displayName)
{
try
{
var rootFolders = new List<SystemFile>();
// load organization
Organization org = OrganizationController.GetOrganization(itemId);
if (org == null)
{
return new SystemFile[0];
}
int serviceId = GetEnterpriseStorageServiceID(org.PackageId);
if (serviceId == 0)
{
return new SystemFile[0];
}
EnterpriseStorage es = GetEnterpriseStorage(serviceId);
var webDavSettings = ObjectUtils.CreateListFromDataReader<WebDavSetting>(
DataProvider.GetEnterpriseFolders(itemId)).ToArray();
var userGroups = OrganizationController.GetSecurityGroupsByMember(itemId, accountId);
foreach (var folder in es.GetFoldersWithoutFrsm(org.OrganizationId, webDavSettings))
{
var permissions = ConvertToESPermission(itemId,folder.Rules);
foreach (var permission in permissions)
{
if ((!permission.IsGroup
&& (permission.DisplayName == userName || permission.DisplayName == displayName))
|| (permission.IsGroup && userGroups.Any(x => x.DisplayName == permission.DisplayName)))
{
rootFolders.Add(folder);
break;
}
}
}
return rootFolders.ToArray();
}
catch (Exception ex)
{
throw ex;
}
}
protected static SystemFile GetFolderInternal(int itemId, string folderName)
{
try

View file

@ -383,6 +383,13 @@ namespace WebsitePanel.EnterpriseServer
if (cntx.Quotas[Quotas.HOSTED_SHAREPOINT_STORAGE_SIZE] != null)
org.WarningSharePointStorage = cntx.Quotas[Quotas.HOSTED_SHAREPOINT_STORAGE_SIZE].QuotaAllocatedValue;
if (cntx.Quotas[Quotas.HOSTED_SHAREPOINT_ENTERPRISE_STORAGE_SIZE] != null)
org.MaxSharePointEnterpriseStorage = cntx.Quotas[Quotas.HOSTED_SHAREPOINT_ENTERPRISE_STORAGE_SIZE].QuotaAllocatedValue;
if (cntx.Quotas[Quotas.HOSTED_SHAREPOINT_ENTERPRISE_STORAGE_SIZE] != null)
org.WarningSharePointEnterpriseStorage = cntx.Quotas[Quotas.HOSTED_SHAREPOINT_ENTERPRISE_STORAGE_SIZE].QuotaAllocatedValue;
//add organization to package items
itemId = AddOrganizationToPackageItems(org, serviceId, packageId, organizationName, organizationId, domainName);
@ -670,6 +677,16 @@ namespace WebsitePanel.EnterpriseServer
TaskManager.WriteError(ex);
}
try
{
HostedSharePointServerEntController.DeleteSiteCollections(itemId);
}
catch (Exception ex)
{
successful = false;
TaskManager.WriteError(ex);
}
if (org.IsOCSOrganization)
{
DeleteOCSUsers(itemId, ref successful);
@ -939,7 +956,9 @@ namespace WebsitePanel.EnterpriseServer
stats.CreatedUsers = 5;
stats.AllocatedUsers = 10;
stats.CreatedSharePointSiteCollections = 1;
stats.CreatedSharePointEnterpriseSiteCollections = 1;
stats.AllocatedSharePointSiteCollections = 5;
stats.AllocatedSharePointEnterpriseSiteCollections = 5;
return stats;
}
#endregion
@ -971,6 +990,13 @@ namespace WebsitePanel.EnterpriseServer
stats.CreatedSharePointSiteCollections = sharePointStats.TotalRowCount;
}
if (cntxTmp.Groups.ContainsKey(ResourceGroups.SharepointEnterpriseServer))
{
SharePointEnterpriseSiteCollectionListPaged sharePointStats = HostedSharePointServerEntController.GetSiteCollectionsPaged(org.PackageId, org.Id, string.Empty, string.Empty, string.Empty, 0, 0);
stats.CreatedSharePointEnterpriseSiteCollections = sharePointStats.TotalRowCount;
}
if (cntxTmp.Groups.ContainsKey(ResourceGroups.HostedCRM))
{
stats.CreatedCRMUsers = CRMController.GetCRMUsersCount(org.Id, string.Empty, string.Empty, CRMUserLycenseTypes.FULL).Value;
@ -1050,8 +1076,15 @@ namespace WebsitePanel.EnterpriseServer
{
SharePointSiteCollectionListPaged sharePointStats = HostedSharePointServerController.GetSiteCollectionsPaged(org.PackageId, o.Id, string.Empty, string.Empty, string.Empty, 0, 0);
stats.CreatedSharePointSiteCollections += sharePointStats.TotalRowCount;
}
if (cntxTmp.Groups.ContainsKey(ResourceGroups.SharepointEnterpriseServer))
{
SharePointEnterpriseSiteCollectionListPaged sharePointStats = HostedSharePointServerEntController.GetSiteCollectionsPaged(org.PackageId, o.Id, string.Empty, string.Empty, string.Empty, 0, 0);
stats.CreatedSharePointEnterpriseSiteCollections += sharePointStats.TotalRowCount;
}
if (cntxTmp.Groups.ContainsKey(ResourceGroups.HostedCRM))
{
stats.CreatedCRMUsers += CRMController.GetCRMUsersCount(o.Id, string.Empty, string.Empty, CRMUserLycenseTypes.FULL ).Value;
@ -1119,6 +1152,11 @@ namespace WebsitePanel.EnterpriseServer
stats.AllocatedSharePointSiteCollections = cntx.Quotas[Quotas.HOSTED_SHAREPOINT_SITES].QuotaAllocatedValue;
}
if (cntx.Groups.ContainsKey(ResourceGroups.SharepointEnterpriseServer))
{
stats.AllocatedSharePointEnterpriseSiteCollections = cntx.Quotas[Quotas.HOSTED_SHAREPOINT_ENTERPRISE_SITES].QuotaAllocatedValue;
}
if (cntx.Groups.ContainsKey(ResourceGroups.HostedCRM))
{
stats.AllocatedCRMUsers = cntx.Quotas[Quotas.CRM_USERS].QuotaAllocatedValue;

View file

@ -116,6 +116,21 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
}
if (report.SharePointEnterpriseReport != null)
{
List<SharePointEnterpriseStatistics> sharePoints =
report.SharePointEnterpriseReport.Items.FindAll(
delegate(SharePointEnterpriseStatistics stats) { return stats.OrganizationID == org.OrganizationId; });
item.TotalSharePointEnterpriseSiteCollections = sharePoints.Count;
foreach (SharePointEnterpriseStatistics current in sharePoints)
{
item.TotalSharePointEnterpriseSiteCollectionsSize += current.SiteCollectionSize;
}
}
if (report.CRMReport != null)
{
List<CRMOrganizationStatistics> crmOrganizationStatistics =
@ -158,6 +173,18 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
return PackageController.GetPackageServiceId(packageId, ResourceGroups.SharepointFoundationServer);
}
private static HostedSharePointServerEnt GetHostedSharePointServerEnt(int serviceId)
{
HostedSharePointServerEnt sps = new HostedSharePointServerEnt();
ServiceProviderProxy.Init(sps, serviceId);
return sps;
}
private static int GetHostedSharePointEntServiceId(int packageId)
{
return PackageController.GetPackageServiceId(packageId, ResourceGroups.SharepointEnterpriseServer);
}
private static void PopulateBaseItem(BaseStatistics stats, Organization org, string topReseller)
{
@ -324,6 +351,21 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
}
if (report.SharePointEnterpriseReport != null)
{
try
{
TaskManager.Write("Populate SharePoint Enterprise item ");
PopulateSharePointEnterpriseItem(org, report, topReseller);
}
catch (Exception ex)
{
TaskManager.WriteError(ex);
}
}
if (report.LyncReport != null)
{
try
@ -394,6 +436,7 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
string.Format("Could not get sharepoint server. PackageId: {0}", org.PackageId), ex);
}
foreach (SharePointSiteCollection siteCollection in siteCollections)
{
try
@ -419,6 +462,59 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
private static void PopulateSharePointEnterpriseItem(Organization org, EnterpriseSolutionStatisticsReport report, string topReseller)
{
List<SharePointEnterpriseSiteCollection> siteCollections;
try
{
siteCollections = HostedSharePointServerEntController.GetSiteCollections(org.Id);
}
catch (Exception ex)
{
throw new ApplicationException(string.Format("Could not get site collections. OrgId: {0}", org.Id), ex);
}
if (siteCollections == null || siteCollections.Count == 0)
return;
HostedSharePointServerEnt srvEnt;
try
{
int serviceId = GetHostedSharePointEntServiceId(org.PackageId);
srvEnt = GetHostedSharePointServerEnt(serviceId);
}
catch (Exception ex)
{
throw new ApplicationException(
string.Format("Could not get sharepoint enterprise server. PackageId: {0}", org.PackageId), ex);
}
foreach (SharePointEnterpriseSiteCollection siteCollection in siteCollections)
{
try
{
SharePointEnterpriseStatistics stats = new SharePointEnterpriseStatistics();
PopulateBaseItem(stats, org, topReseller);
stats.SiteCollectionUrl = siteCollection.PhysicalAddress;
stats.SiteCollectionOwner = siteCollection.OwnerName;
stats.SiteCollectionQuota = siteCollection.MaxSiteStorage;
stats.SiteCollectionCreated = siteCollection.CreatedDate;
stats.SiteCollectionSize = srvEnt.Enterprise_GetSiteCollectionSize(siteCollection.PhysicalAddress);
report.SharePointEnterpriseReport.Items.Add(stats);
}
catch (Exception ex)
{
TaskManager.WriteError(ex);
}
}
}
private static void PopulateExchangeReportItems(Organization org, EnterpriseSolutionStatisticsReport report, string topReseller)
{
TaskManager.Write("Exchange Report Items " + org.Name);

View file

@ -488,6 +488,7 @@ namespace WebsitePanel.EnterpriseServer
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.MySql5, domain, "");
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.Statistics, domain, "");
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPS, domain, "");
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPS2012, domain, "");
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPSForPC, domain, "");
}
}
@ -711,6 +712,11 @@ namespace WebsitePanel.EnterpriseServer
if (Utils.ParseBool(vpsSettings["AutoAssignExternalIP"], true))
ServerController.AllocateMaximumPackageIPAddresses(packageId, ResourceGroups.VPS, IPAddressPool.VpsExternalNetwork);
// allocate "VPS" IP addresses
int vps2012ServiceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.VPS2012);
StringDictionary vps2012Settings = ServerController.GetServiceSettings(vps2012ServiceId);
if (Utils.ParseBool(vps2012Settings["AutoAssignExternalIP"], true))
ServerController.AllocateMaximumPackageIPAddresses(packageId, ResourceGroups.VPS2012, IPAddressPool.VpsExternalNetwork);
// allocate "VPSForPC" IP addresses
int vpsfcpServiceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.VPSForPC);
@ -1681,6 +1687,18 @@ namespace WebsitePanel.EnterpriseServer
}
}
// VPS2012
else if (String.Compare(PackageSettings.VIRTUAL_PRIVATE_SERVERS_2012, settingsName, true) == 0)
{
// load Exchange service settings
int vpsServiceId = GetPackageServiceId(packageId, ResourceGroups.VPS2012);
if (vpsServiceId > 0)
{
StringDictionary vpsSettings = ServerController.GetServiceSettings(vpsServiceId);
settings["HostnamePattern"] = vpsSettings["HostnamePattern"];
}
}
//vpforCP
else if (String.Compare(PackageSettings.VIRTUAL_PRIVATE_SERVERS_FOR_PRIVATE_CLOUD, settingsName, true) == 0)
{

View file

@ -331,6 +331,49 @@ namespace WebsitePanel.EnterpriseServer
return UpdateRdsServerSettingsInternal(serverId, settingsName, settings);
}
public static ResultObject ShadowSession(int itemId, string sessionId, bool control)
{
return ShadowSessionInternal(itemId, sessionId, control);
}
private static ResultObject ShadowSessionInternal(int itemId, string sessionId, bool control)
{
var result = TaskManager.StartResultTask<ResultObject>("REMOTE_DESKTOP_SERVICES", "SHADOW_RDS_SESSION");
try
{
Organization org = OrganizationController.GetOrganization(itemId);
if (org == null)
{
result.IsSuccess = false;
result.AddError("SHADOW_RDS_SESSION", new NullReferenceException("Organization not found"));
return result;
}
var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId));
rds.ShadowSession(sessionId, control);
}
catch (Exception ex)
{
result.AddError("REMOTE_DESKTOP_SERVICES_SHADOW_RDS_SESSION", ex);
}
finally
{
if (!result.IsSuccess)
{
TaskManager.CompleteResultTask(result);
}
else
{
TaskManager.CompleteResultTask();
}
}
return result;
}
private static RdsServerSettings GetRdsServerSettingsInternal(int serverId, string settingsName)
{
IDataReader reader = DataProvider.GetRdsServerSettings(serverId, settingsName);
@ -363,25 +406,9 @@ namespace WebsitePanel.EnterpriseServer
{
var collection = ObjectUtils.FillObjectFromDataReader<RdsCollection>(DataProvider.GetRDSCollectionById(serverId));
var rds = GetRemoteDesktopServices(GetRdsServiceId(collection.ItemId));
rds.ApplyGPO(collection.Name, settings);
XmlDocument doc = new XmlDocument();
XmlElement nodeProps = doc.CreateElement("properties");
if (settings != null)
{
foreach (var setting in settings.Settings)
{
XmlElement nodeProp = doc.CreateElement("property");
nodeProp.SetAttribute("name", setting.PropertyName);
nodeProp.SetAttribute("value", setting.PropertyValue);
nodeProp.SetAttribute("applyUsers", setting.ApplyUsers ? "1" : "0");
nodeProp.SetAttribute("applyAdministrators", setting.ApplyAdministrators ? "1" : "0");
nodeProps.AppendChild(nodeProp);
}
}
string xml = nodeProps.OuterXml;
Organization org = OrganizationController.GetOrganization(collection.ItemId);
rds.ApplyGPO(org.OrganizationId, collection.Name, settings);
string xml = GetSettingsXml(settings);
DataProvider.UpdateRdsServerSettings(serverId, settingsName, xml);
@ -748,8 +775,11 @@ namespace WebsitePanel.EnterpriseServer
};
rds.CreateCollection(org.OrganizationId, collection);
rds.ApplyGPO(collection.Name, GetDefaultGpoSettings());
collection.Id = DataProvider.AddRDSCollection(itemId, collection.Name, collection.Description, collection.DisplayName);
var defaultGpoSettings = GetDefaultGpoSettings();
rds.ApplyGPO(org.OrganizationId, collection.Name, defaultGpoSettings);
collection.Id = DataProvider.AddRDSCollection(itemId, collection.Name, collection.Description, collection.DisplayName);
string xml = GetSettingsXml(defaultGpoSettings);
DataProvider.UpdateRdsServerSettings(collection.Id, string.Format("Collection-{0}-Settings", collection.Id), xml);
collection.Settings.RdsCollectionId = collection.Id;
int settingsId = DataProvider.AddRdsCollectionSettings(collection.Settings);
@ -806,6 +836,7 @@ namespace WebsitePanel.EnterpriseServer
}
rds.AddSessionHostServersToCollection(org.OrganizationId, collection.Name, newServers.ToArray());
rds.MoveSessionHostsToCollectionOU(collection.Servers.ToArray(), collection.Name, org.OrganizationId);
foreach (var server in newServers)
{
@ -2098,7 +2129,52 @@ namespace WebsitePanel.EnterpriseServer
ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.SCREEN_SAVER_DISABLED_USERS])
});
settings.Settings.Add(new RdsServerSetting
{
PropertyName = RdsServerSettings.RDS_VIEW_WITHOUT_PERMISSION,
PropertyValue = "",
ApplyAdministrators = Convert.ToBoolean(defaultSettings[RdsServerSettings.RDS_VIEW_WITHOUT_PERMISSION_ADMINISTRATORS]),
ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.RDS_VIEW_WITHOUT_PERMISSION_Users])
});
settings.Settings.Add(new RdsServerSetting
{
PropertyName = RdsServerSettings.RDS_CONTROL_WITHOUT_PERMISSION,
PropertyValue = "",
ApplyAdministrators = Convert.ToBoolean(defaultSettings[RdsServerSettings.RDS_CONTROL_WITHOUT_PERMISSION_ADMINISTRATORS]),
ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.RDS_CONTROL_WITHOUT_PERMISSION_Users])
});
settings.Settings.Add(new RdsServerSetting
{
PropertyName = RdsServerSettings.DISABLE_CMD,
PropertyValue = "",
ApplyAdministrators = Convert.ToBoolean(defaultSettings[RdsServerSettings.DISABLE_CMD_ADMINISTRATORS]),
ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.DISABLE_CMD_USERS])
});
return settings;
}
private static string GetSettingsXml(RdsServerSettings settings)
{
XmlDocument doc = new XmlDocument();
XmlElement nodeProps = doc.CreateElement("properties");
if (settings != null)
{
foreach (var setting in settings.Settings)
{
XmlElement nodeProp = doc.CreateElement("property");
nodeProp.SetAttribute("name", setting.PropertyName);
nodeProp.SetAttribute("value", setting.PropertyValue);
nodeProp.SetAttribute("applyUsers", setting.ApplyUsers ? "1" : "0");
nodeProp.SetAttribute("applyAdministrators", setting.ApplyAdministrators ? "1" : "0");
nodeProps.AppendChild(nodeProp);
}
}
return nodeProps.OuterXml;
}
}
}

View file

@ -179,6 +179,20 @@ namespace WebsitePanel.EnterpriseServer
}
}
}
if (cntx.Groups.ContainsKey(ResourceGroups.SharepointEnterpriseServer))
{
SharePointSiteDiskSpace[] sharePointSiteDiskSpaces =
HostedSharePointServerEntController.CalculateSharePointSitesDiskSpace(org.Id, out res);
if (res == 0)
{
foreach (SharePointSiteDiskSpace currecnt in sharePointSiteDiskSpaces)
{
size += currecnt.DiskSpace;
}
}
}
ServiceProviderItemDiskSpace tmp = new ServiceProviderItemDiskSpace();
tmp.ItemId = item.Id;
tmp.DiskSpace = size;

View file

@ -1481,6 +1481,10 @@ namespace WebsitePanel.EnterpriseServer
{
return Quotas.VPS_EXTERNAL_IP_ADDRESSES_NUMBER;
}
else if (String.Compare(groupName, ResourceGroups.VPS2012, true) == 0)
{
return Quotas.VPS2012_EXTERNAL_IP_ADDRESSES_NUMBER;
}
else if (String.Compare(groupName, ResourceGroups.VPSForPC, true) == 0)
{
return Quotas.VPSForPC_EXTERNAL_IP_ADDRESSES_NUMBER;
@ -1840,6 +1844,7 @@ namespace WebsitePanel.EnterpriseServer
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.MySql5, domain, "");
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.Statistics, domain, "");
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPS, domain, "");
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPS2012, domain, "");
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPSForPC, domain, "");
}
@ -2403,6 +2408,7 @@ namespace WebsitePanel.EnterpriseServer
ServerController.AddServiceDNSRecords(domain.PackageId, ResourceGroups.MySql5, domain, "");
ServerController.AddServiceDNSRecords(domain.PackageId, ResourceGroups.Statistics, domain, "");
ServerController.AddServiceDNSRecords(domain.PackageId, ResourceGroups.VPS, domain, "");
ServerController.AddServiceDNSRecords(domain.PackageId, ResourceGroups.VPS2012, domain, "");
ServerController.AddServiceDNSRecords(domain.PackageId, ResourceGroups.VPSForPC, domain, "");
ServerController.AddServiceDNSRecords(domain.PackageId, ResourceGroups.Dns, domain, "");
break;

View file

@ -58,18 +58,18 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
/// <param name="startRow">Row index to start from.</param>
/// <param name="maximumRows">Maximum number of rows to retrieve.</param>
/// <returns>Site collections that match.</returns>
public static SharePointSiteCollectionListPaged GetSiteCollectionsPaged(int packageId, int organizationId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows, string groupName = null)
public static SharePointSiteCollectionListPaged GetSiteCollectionsPaged(int packageId, int organizationId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
{
if (IsDemoMode)
{
SharePointSiteCollectionListPaged demoResult = new SharePointSiteCollectionListPaged();
demoResult.SiteCollections = GetSiteCollections(1, false, null);
demoResult.SiteCollections = GetSiteCollections(1, false);
demoResult.TotalRowCount = demoResult.SiteCollections.Count;
return demoResult;
}
SharePointSiteCollectionListPaged paged = new SharePointSiteCollectionListPaged();
DataSet result = PackageController.GetRawPackageItemsPaged(packageId, groupName, typeof(SharePointSiteCollection),
DataSet result = PackageController.GetRawPackageItemsPaged(packageId, ResourceGroups.SharepointFoundationServer, typeof(SharePointSiteCollection),
true, filterColumn, filterValue, sortColumn, startRow, Int32.MaxValue);
List<SharePointSiteCollection> items = PackageController.CreateServiceItemsList(result, 1).ConvertAll<SharePointSiteCollection>(delegate(ServiceProviderItem item) { return (SharePointSiteCollection)item; });
@ -149,9 +149,8 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
/// </summary>
/// <param name="packageId">Package that owns site collections.</param>
/// <param name="recursive">A value which shows whether nested spaces must be searched as well.</param>
/// <param name="groupName">Resource group name.</param>
/// <returns>List of found site collections.</returns>
public static List<SharePointSiteCollection> GetSiteCollections(int packageId, bool recursive, string groupName)
public static List<SharePointSiteCollection> GetSiteCollections(int packageId, bool recursive)
{
if (IsDemoMode)
{
@ -184,7 +183,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
}
List<ServiceProviderItem> items = PackageController.GetPackageItemsByType(packageId, groupName, typeof(SharePointSiteCollection), recursive);
List<ServiceProviderItem> items = PackageController.GetPackageItemsByType(packageId, typeof(SharePointSiteCollection), recursive);
return items.ConvertAll<SharePointSiteCollection>(delegate(ServiceProviderItem item) { return (SharePointSiteCollection)item; });
}
@ -197,7 +196,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
{
if (IsDemoMode)
{
return GetSiteCollections(1, false, null)[itemId - 1];
return GetSiteCollections(1, false)[itemId - 1];
}
SharePointSiteCollection item = PackageController.GetPackageItem(itemId) as SharePointSiteCollection;
@ -208,9 +207,8 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
/// Adds SharePoint site collection.
/// </summary>
/// <param name="item">Site collection description.</param>
/// <param name="groupName">Resource group name.</param>
/// <returns>Created site collection id within metabase.</returns>
public static int AddSiteCollection(SharePointSiteCollection item, string groupName)
public static int AddSiteCollection(SharePointSiteCollection item)
{
// Check account.
@ -238,7 +236,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
}
// Check if stats resource is available
int serviceId = PackageController.GetPackageServiceId(item.PackageId, groupName);
int serviceId = PackageController.GetPackageServiceId(item.PackageId, ResourceGroups.SharepointFoundationServer);
if (serviceId == 0)
{
@ -276,7 +274,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
item.Name = String.Format("{0}://{1}", rootWebApplicationUri.Scheme, hostNameBase + "-" + counter.ToString() + "." + sslRoot);
siteName = String.Format("{0}", hostNameBase + "-" + counter.ToString() + "." + sslRoot);
while (CheckServiceItemExists(item.Name, item.PackageId))
while ( DataProvider. CheckServiceItemExists( serviceId, item. Name, "WebsitePanel.Providers.SharePoint.SharePointSiteCollection, WebsitePanel.Providers.Base"))
{
counter++;
item.Name = String.Format("{0}://{1}", rootWebApplicationUri.Scheme, hostNameBase + "-" + counter.ToString() + "." + sslRoot);
@ -306,7 +304,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
// Check package item with given name already exists.
if (PackageController.GetPackageItemByName(item.PackageId, groupName, item.Name, typeof(SharePointSiteCollection)) != null)
if (PackageController.GetPackageItemByName(item.PackageId, item.Name, typeof(SharePointSiteCollection)) != null)
{
return BusinessErrorCodes.ERROR_SHAREPOINT_PACKAGE_ITEM_EXISTS;
}
@ -1016,16 +1014,5 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
}
}
private static bool CheckServiceItemExists(string name, int packageId)
{
bool exists = PackageController.GetPackageItemByName(packageId, ResourceGroups.SharepointFoundationServer, name, typeof(SharePointSiteCollection)) != null;
if (!exists)
{
exists = PackageController.GetPackageItemByName(packageId, ResourceGroups.SharepointServer, name, typeof(SharePointSiteCollection)) != null;
}
return exists;
}
}
}
}

View file

@ -612,6 +612,7 @@ namespace WebsitePanel.EnterpriseServer
#region Setup External network
TaskManager.Write("VPS_CREATE_SETUP_EXTERNAL_NETWORK");
TaskManager.IndicatorCurrent = -1; // Some providers (for example HyperV2012R2) could not provide progress
try
{
@ -644,6 +645,7 @@ namespace WebsitePanel.EnterpriseServer
#region Setup Management network
TaskManager.Write("VPS_CREATE_SETUP_MANAGEMENT_NETWORK");
TaskManager.IndicatorCurrent = -1; // Some providers (for example HyperV2012R2) could not provide progress
try
{
@ -704,6 +706,7 @@ namespace WebsitePanel.EnterpriseServer
#region Setup Private network
TaskManager.Write("VPS_CREATE_SETUP_PRIVATE_NETWORK");
TaskManager.IndicatorCurrent = -1; // Some providers (for example HyperV2012R2) could not provide progress
try
{
@ -759,6 +762,7 @@ namespace WebsitePanel.EnterpriseServer
TaskManager.Write("VPS_CREATE_CONVERT_VHD");
TaskManager.Write("VPS_CREATE_CONVERT_SOURCE_VHD", vm.OperatingSystemTemplatePath);
TaskManager.Write("VPS_CREATE_CONVERT_DEST_VHD", vm.VirtualHardDrivePath);
TaskManager.IndicatorCurrent = -1; // Some providers (for example HyperV2012R2) could not provide progress
try
{
// convert VHD
@ -817,6 +821,7 @@ namespace WebsitePanel.EnterpriseServer
if (vm.HddSize > hddSizeGB)
{
TaskManager.Write("VPS_CREATE_EXPAND_VHD");
TaskManager.IndicatorCurrent = -1; // Some providers (for example HyperV2012R2) could not provide progress
// expand VHD
try
@ -958,6 +963,7 @@ namespace WebsitePanel.EnterpriseServer
TaskManager.Write("VPS_CREATE_CPU_CORES", vm.CpuCores.ToString());
TaskManager.Write("VPS_CREATE_RAM_SIZE", vm.RamSize.ToString());
TaskManager.Write("VPS_CREATE_CREATE_VM");
TaskManager.IndicatorCurrent = -1; // Some providers (for example HyperV2012R2) could not provide progress
// create virtual machine
try
{
@ -1031,6 +1037,7 @@ namespace WebsitePanel.EnterpriseServer
#region Start VPS
TaskManager.Write("VPS_CREATE_START_VPS");
TaskManager.IndicatorCurrent = -1; // Some providers (for example HyperV2012R2) could not provide progress
try
{

View file

@ -0,0 +1,85 @@
// 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.
using System;
using System.Collections.Generic;
using System.Web;
using System.Threading;
using WebsitePanel.Providers.Virtualization;
namespace WebsitePanel.EnterpriseServer
{
public class CreateServerAsyncWorker2012
{
#region Properties
public int ThreadUserId { get; set; }
public string TaskId { get; set; }
public VirtualMachine Item { get; set; }
public LibraryItem OsTemplate { get; set; }
public int ExternalAddressesNumber { get; set; }
public bool RandomExternalAddresses { get; set; }
public int[] ExternalAddresses { get; set; }
public int PrivateAddressesNumber { get; set; }
public bool RandomPrivateAddresses { get; set; }
public string[] PrivateAddresses { get; set; }
public string SummaryLetterEmail { get; set; }
#endregion
public CreateServerAsyncWorker2012()
{
ThreadUserId = -1; // admin
}
#region Create
public void CreateAsync()
{
// start asynchronously
Thread t = new Thread(new ThreadStart(Create));
t.Start();
}
private void Create()
{
// impersonate thread
if (ThreadUserId != -1)
SecurityContext.SetThreadPrincipal(ThreadUserId);
// perform backup
VirtualizationServerController2012.CreateVirtualMachineInternal(TaskId, Item, OsTemplate,
ExternalAddressesNumber, RandomExternalAddresses, ExternalAddresses,
PrivateAddressesNumber, RandomPrivateAddresses, PrivateAddresses,
SummaryLetterEmail);
}
#endregion
}
}

View file

@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Bin\</OutputPath>
<OutputPath>..\WebsitePanel.EnterpriseServer\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@ -26,7 +26,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Bin\</OutputPath>
<OutputPath>..\WebsitePanel.EnterpriseServer\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@ -165,6 +165,7 @@
<Compile Include="Scheduling\SchedulerController.cs" />
<Compile Include="Scheduling\SchedulerJob.cs" />
<Compile Include="Servers\ServerController.cs" />
<Compile Include="SharePoint\HostedSharePointServerEntController.cs" />
<Compile Include="SharePoint\HostedSharePointServerController.cs" />
<Compile Include="SharePoint\SharePointServerController.cs" />
<Compile Include="StatisticsServers\StatisticsServerController.cs" />
@ -175,6 +176,8 @@
<Compile Include="Tasks\TaskManager.cs" />
<Compile Include="Users\UserAsyncWorker.cs" />
<Compile Include="Users\UserController.cs" />
<Compile Include="Virtualization2012\CreateServerAsyncWorker2012.cs" />
<Compile Include="Virtualization2012\VirtualizationServerController2012.cs" />
<Compile Include="VirtualizationForPrivateCloud\CreateAsyncVMfromVM.cs" />
<Compile Include="VirtualizationForPrivateCloud\CreateServerAsyncWorkerForPrivateCloud.cs" />
<Compile Include="VirtualizationForPrivateCloud\VirtualizationServerControllerForPrivateCloud.cs" />