This commit is contained in:
Alexander Trofimov 2015-04-07 22:03:47 +03:00
commit 9e67b26822
134 changed files with 10745 additions and 598 deletions

View file

@ -381,6 +381,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);
@ -668,6 +675,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);
@ -937,7 +954,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
@ -969,6 +988,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;
@ -1048,8 +1074,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))
{
SharePointSiteCollectionListPaged sharePointStats = HostedSharePointServerController.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;
@ -1117,6 +1150,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

@ -408,24 +408,7 @@ namespace WebsitePanel.EnterpriseServer
var rds = GetRemoteDesktopServices(GetRdsServiceId(collection.ItemId));
Organization org = OrganizationController.GetOrganization(collection.ItemId);
rds.ApplyGPO(org.OrganizationId, 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;
string xml = GetSettingsXml(settings);
DataProvider.UpdateRdsServerSettings(serverId, settingsName, xml);
@ -792,8 +775,11 @@ namespace WebsitePanel.EnterpriseServer
};
rds.CreateCollection(org.OrganizationId, collection);
rds.ApplyGPO(org.OrganizationId, 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);
@ -850,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)
{
@ -2142,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

@ -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, "Sharepoint Foundation Server", 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

@ -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>
@ -163,6 +163,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" />