diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql
index 228701b7..9470c435 100644
--- a/WebsitePanel/Database/update_db.sql
+++ b/WebsitePanel/Database/update_db.sql
@@ -9461,4 +9461,34 @@ END
GO
-UPDATE [dbo].[Quotas] SET GroupID = 45 WHERE QuotaName = 'EnterpriseStorage.DriveMaps'
\ No newline at end of file
+UPDATE [dbo].[Quotas] SET GroupID = 45 WHERE QuotaName = 'EnterpriseStorage.DriveMaps'
+
+
+UPDATE [dbo].[ResourceGroups] SET GroupName = 'Sharepoint Enterprise Server' WHERE GroupName = 'Sharepoint Server'
+GO
+
+IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'Hosted SharePoint Enterprise 2013')
+BEGIN
+DECLARE @provider_id AS INT
+DECLARE @group_id AS INT
+SELECT @group_id = GroupId FROM [dbo].[ResourceGroups] WHERE GroupName = 'Sharepoint Enterprise Server'
+SELECT TOP 1 @provider_id = ProviderId + 1 From [dbo].[Providers] ORDER BY ProviderID DESC
+INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery])
+VALUES (@provider_id, @group_id, N'HostedSharePoint2013Ent', N'Hosted SharePoint Enterprise 2013', N'WebsitePanel.Providers.HostedSolution.HostedSharePointServer2013Ent, WebsitePanel.Providers.HostedSolution.SharePoint2013Ent', N'HostedSharePoint30', NULL)
+END
+GO
+
+UPDATE Providers SET ProviderType = N'WebsitePanel.Providers.HostedSolution.HostedSharePointServer2013Ent, WebsitePanel.Providers.HostedSolution.SharePoint2013Ent' WHERE ProviderID = 1301
+GO
+
+UPDATE [dbo].[Quotas] SET QuotaName = 'HostedSharePointEnterprise.Sites' WHERE QuotaId = 550
+GO
+
+UPDATE [dbo].[Quotas] SET QuotaName = 'HostedSharePointEnterprise.MaxStorage' WHERE QuotaId = 551
+GO
+
+UPDATE [dbo].[Quotas] SET QuotaName = 'HostedSharePointEnterprise.UseSharedSSL' WHERE QuotaId = 552
+GO
+
+UPDATE [dbo].[ServiceItemTypes] SET DisplayName = 'SharePointEnterpriseSiteCollection' WHERE DisplayName = 'SharePointSiteCollection'
+GO
\ No newline at end of file
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs
index 47155cb1..ed021ce8 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs
@@ -154,6 +154,9 @@ order by rg.groupOrder
public const string HOSTED_SHAREPOINT_SITES = "HostedSharePoint.Sites"; // Hosted SharePoint Sites
public const string HOSTED_SHAREPOINT_STORAGE_SIZE = "HostedSharePoint.MaxStorage"; // Hosted SharePoint storage size;
public const string HOSTED_SHAREPOINT_USESHAREDSSL = "HostedSharePoint.UseSharedSSL"; // Hosted SharePoint Use Shared SSL Root
+ public const string HOSTED_SHAREPOINT_ENTERPRISE_SITES = "HostedSharePointEnterprise.Sites"; // Hosted SharePoint Sites
+ public const string HOSTED_SHAREPOINT_ENTERPRISE_STORAGE_SIZE = "HostedSharePointEnterprise.MaxStorage"; // Hosted SharePoint storage size;
+ public const string HOSTED_SHAREPOINT_ENTERPRISE_USESHAREDSSL = "HostedSharePointEnterprise.UseSharedSSL"; // Hosted SharePoint Use Shared SSL Root
public const string DNS_EDITOR = "DNS.Editor"; // DNS Editor
public const string DNS_ZONES = "DNS.Zones"; // DNS Editor
public const string DNS_PRIMARY_ZONES = "DNS.PrimaryZones"; // DNS Editor
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Servers/ResourceGroups.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Servers/ResourceGroups.cs
index 0e412bfb..f610eec3 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Servers/ResourceGroups.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Servers/ResourceGroups.cs
@@ -45,6 +45,7 @@ namespace WebsitePanel.EnterpriseServer
public const string Statistics = "Statistics";
public const string SharePoint = "SharePoint";
public const string SharepointFoundationServer = "Sharepoint Foundation Server";
+ public const string SharepointEnterpriseServer = "Sharepoint Enterprise Server";
public const string SharepointServer = "Sharepoint Server";
public const string Exchange = "Exchange";
public const string HostedOrganizations = "Hosted Organizations";
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/WebsitePanel.EnterpriseServer.Base.csproj b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/WebsitePanel.EnterpriseServer.Base.csproj
index 9f9c3763..ba6f30a1 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/WebsitePanel.EnterpriseServer.Base.csproj
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/WebsitePanel.EnterpriseServer.Base.csproj
@@ -39,7 +39,7 @@
true
full
false
- ..\..\Bin\
+ ..\WebsitePanel.EnterpriseServer\bin\
DEBUG;TRACE
prompt
4
@@ -49,7 +49,7 @@
none
true
- ..\..\Bin\
+ ..\WebsitePanel.EnterpriseServer\bin\
TRACE
prompt
4
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs
index 57d9ea5f..c56aa486 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs
@@ -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))
+ {
+ SharePointSiteCollectionListPaged 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;
@@ -1117,6 +1143,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;
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SharePoint/HostedSharePointServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SharePoint/HostedSharePointServerController.cs
index 3915a855..a03a95ca 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SharePoint/HostedSharePointServerController.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SharePoint/HostedSharePointServerController.cs
@@ -58,18 +58,18 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
/// Row index to start from.
/// Maximum number of rows to retrieve.
/// Site collections that match.
- 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, typeof(SharePointSiteCollection),
true, filterColumn, filterValue, sortColumn, startRow, Int32.MaxValue);
List items = PackageController.CreateServiceItemsList(result, 1).ConvertAll(delegate(ServiceProviderItem item) { return (SharePointSiteCollection)item; });
@@ -149,9 +149,8 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
///
/// Package that owns site collections.
/// A value which shows whether nested spaces must be searched as well.
- /// Resource group name.
/// List of found site collections.
- public static List GetSiteCollections(int packageId, bool recursive, string groupName)
+ public static List GetSiteCollections(int packageId, bool recursive)
{
if (IsDemoMode)
{
@@ -184,7 +183,7 @@ namespace WebsitePanel.EnterpriseServer.Code.SharePoint
}
- List items = PackageController.GetPackageItemsByType(packageId, groupName, typeof(SharePointSiteCollection), recursive);
+ List items = PackageController.GetPackageItemsByType(packageId, typeof(SharePointSiteCollection), recursive);
return items.ConvertAll(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.
///
/// Site collection description.
- /// Resource group name.
/// Created site collection id within metabase.
- 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;
- }
- }
+ }
}
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SharePoint/HostedSharePointServerEntController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SharePoint/HostedSharePointServerEntController.cs
new file mode 100644
index 00000000..87c147e1
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/SharePoint/HostedSharePointServerEntController.cs
@@ -0,0 +1,1020 @@
+// 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.Collections.Specialized;
+using System.Data;
+using System.IO;
+using System.Xml;
+using System.Xml.Serialization;
+using WebsitePanel.Providers;
+using WebsitePanel.Providers.DNS;
+using WebsitePanel.Providers.HostedSolution;
+using WebsitePanel.Providers.SharePoint;
+
+namespace WebsitePanel.EnterpriseServer.Code.SharePoint
+{
+ ///
+ /// Exposes handful API on hosted SharePoint site collections management.
+ ///
+ public class HostedSharePointServerEntController : IImportController, IBackupController
+ {
+ private const int FILE_BUFFER_LENGTH = 5000000; // ~5MB
+
+ ///
+ /// Gets site collections in raw form.
+ ///
+ /// Package to which desired site collections belong.
+ /// Organization to which desired site collections belong.
+ /// Filter column name.
+ /// Filter value.
+ /// Sort column name.
+ /// Row index to start from.
+ /// Maximum number of rows to retrieve.
+ /// Site collections that match.
+ public static SharePointSiteCollectionListPaged GetSiteCollectionsPaged(int packageId, int organizationId, string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows, string groupName = null)
+ {
+ if (IsDemoMode)
+ {
+ SharePointSiteCollectionListPaged demoResult = new SharePointSiteCollectionListPaged();
+ demoResult.SiteCollections = GetSiteCollections(1, false);
+ demoResult.TotalRowCount = demoResult.SiteCollections.Count;
+ return demoResult;
+ }
+
+ SharePointSiteCollectionListPaged paged = new SharePointSiteCollectionListPaged();
+ DataSet result = PackageController.GetRawPackageItemsPaged(packageId, typeof(SharePointSiteCollection),
+ true, filterColumn, filterValue, sortColumn, startRow, Int32.MaxValue);
+ List items = PackageController.CreateServiceItemsList(result, 1).ConvertAll(delegate(ServiceProviderItem item) { return (SharePointSiteCollection)item; });
+
+ if (organizationId > 0)
+ {
+ items = items.FindAll(delegate(SharePointSiteCollection siteCollection) { return siteCollection.OrganizationId == organizationId; });
+ }
+ paged.TotalRowCount = items.Count;
+
+ if (items.Count > maximumRows)
+ {
+ items.RemoveRange(maximumRows, items.Count - maximumRows);
+ }
+
+ paged.SiteCollections = items;
+
+ return paged;
+ }
+
+ public static List GetSiteCollections(int organizationId)
+ {
+ Organization org = OrganizationController.GetOrganization(organizationId);
+
+ List items = PackageController.GetPackageItemsByType(org.PackageId, typeof(SharePointSiteCollection), false);
+ items.ConvertAll(delegate(ServiceProviderItem item) { return (SharePointSiteCollection)item; });
+ List ret = new List();
+ foreach (ServiceProviderItem item in items)
+ {
+ SharePointSiteCollection siteCollection = item as SharePointSiteCollection;
+ if (siteCollection != null && siteCollection.OrganizationId == organizationId)
+ {
+ ret.Add(siteCollection);
+ }
+ }
+
+ return ret;
+ }
+
+ ///
+ /// Gets list of supported languages by this installation of SharePoint.
+ ///
+ /// List of supported languages
+ public static int[] GetSupportedLanguages(int packageId)
+ {
+ if (IsDemoMode)
+ {
+ return new int[] { 1033 };
+ }
+
+ // Log operation.
+ TaskManager.StartTask("HOSTED_SHAREPOINT_ENTERPRISE", "GET_LANGUAGES");
+
+ int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.SharepointFoundationServer);
+ if (serviceId == 0)
+ {
+ return new int[] { };
+ }
+
+ try
+ {
+ // Create site collection on server.
+ HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(serviceId);
+ return hostedSharePointServer.Enterprise_GetSupportedLanguages();
+ }
+ catch (Exception ex)
+ {
+ throw TaskManager.WriteError(ex);
+ }
+ finally
+ {
+ TaskManager.CompleteTask();
+ }
+ }
+
+ ///
+ /// Gets list of SharePoint site collections that belong to the package.
+ ///
+ /// Package that owns site collections.
+ /// A value which shows whether nested spaces must be searched as well.
+ /// Resource group name.
+ /// List of found site collections.
+ public static List GetSiteCollections(int packageId, bool recursive)
+ {
+ if (IsDemoMode)
+ {
+ List demoResult = new List();
+ SharePointSiteCollection siteCollection1 = new SharePointSiteCollection();
+ siteCollection1.Id = 1;
+ siteCollection1.OrganizationId = 1;
+ siteCollection1.LocaleId = 1033;
+ siteCollection1.Name = "http://john.fabrikam.com";
+ siteCollection1.OwnerEmail = "john@fabrikam.com";
+ siteCollection1.OwnerLogin = "john@fabrikam.com";
+ siteCollection1.OwnerName = "John Smith";
+ siteCollection1.PhysicalAddress = "http://john.fabrikam.com";
+ siteCollection1.Title = "John Smith's Team Site";
+ siteCollection1.Url = "http://john.fabrikam.com";
+ demoResult.Add(siteCollection1);
+ SharePointSiteCollection siteCollection2 = new SharePointSiteCollection();
+ siteCollection2.Id = 2;
+ siteCollection1.OrganizationId = 1;
+ siteCollection2.LocaleId = 1033;
+ siteCollection2.Name = "http://mark.contoso.com";
+ siteCollection2.OwnerEmail = "mark@contoso.com";
+ siteCollection2.OwnerLogin = "mark@contoso.com";
+ siteCollection2.OwnerName = "Mark Jonsons";
+ siteCollection2.PhysicalAddress = "http://mark.contoso.com";
+ siteCollection2.Title = "Mark Jonsons' Blog";
+ siteCollection2.Url = "http://mark.contoso.com";
+ demoResult.Add(siteCollection2);
+ return demoResult;
+ }
+
+
+ List items = PackageController.GetPackageItemsByType(packageId, typeof(SharePointSiteCollection), recursive);
+ return items.ConvertAll(delegate(ServiceProviderItem item) { return (SharePointSiteCollection)item; });
+ }
+
+ ///
+ /// Gets SharePoint site collection with given id.
+ ///
+ /// Site collection id within metabase.
+ /// Site collection or null in case no such item exist.
+ public static SharePointSiteCollection GetSiteCollection(int itemId)
+ {
+ if (IsDemoMode)
+ {
+ return GetSiteCollections(1, false)[itemId - 1];
+ }
+
+ SharePointSiteCollection item = PackageController.GetPackageItem(itemId) as SharePointSiteCollection;
+ return item;
+ }
+
+ ///
+ /// Adds SharePoint site collection.
+ ///
+ /// Site collection description.
+ /// Resource group name.
+ /// Created site collection id within metabase.
+ public static int AddSiteCollection(SharePointSiteCollection item)
+ {
+
+ // Check account.
+ int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
+ if (accountCheck < 0)
+ {
+ return accountCheck;
+ }
+
+ // Check package.
+ int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
+ if (packageCheck < 0)
+ {
+ return packageCheck;
+ }
+
+ // Check quota.
+ OrganizationStatistics orgStats = OrganizationController.GetOrganizationStatistics(item.OrganizationId);
+ //QuotaValueInfo quota = PackageController.GetPackageQuota(item.PackageId, Quotas.HOSTED_SHAREPOINT_SITES);
+
+ if (orgStats.AllocatedSharePointEnterpriseSiteCollections > -1
+ && orgStats.CreatedSharePointEnterpriseSiteCollections >= orgStats.AllocatedSharePointEnterpriseSiteCollections)
+ {
+ return BusinessErrorCodes.ERROR_SHAREPOINT_RESOURCE_QUOTA_LIMIT;
+ }
+
+ // Check if stats resource is available
+ int serviceId = PackageController.GetPackageServiceId(item.PackageId, ResourceGroups.SharepointEnterpriseServer);
+
+ if (serviceId == 0)
+ {
+ return BusinessErrorCodes.ERROR_SHAREPOINT_RESOURCE_UNAVAILABLE;
+ }
+
+ StringDictionary hostedSharePointSettings = ServerController.GetServiceSettings(serviceId);
+ QuotaValueInfo quota = PackageController.GetPackageQuota(item.PackageId, Quotas.HOSTED_SHAREPOINT_ENTERPRISE_USESHAREDSSL);
+ Uri rootWebApplicationUri = new Uri(hostedSharePointSettings["RootWebApplicationUri"]);
+ Organization org = OrganizationController.GetOrganization(item.OrganizationId);
+ string siteName = item.Name;
+
+ if (quota.QuotaAllocatedValue == 1)
+ {
+ string sslRoot = hostedSharePointSettings["SharedSSLRoot"];
+
+
+ string defaultDomain = org.DefaultDomain;
+ string hostNameBase = string.Empty;
+
+ string[] tmp = defaultDomain.Split('.');
+ if (tmp.Length == 2)
+ {
+ hostNameBase = tmp[0];
+ }
+ else
+ {
+ if (tmp.Length > 2)
+ {
+ hostNameBase = tmp[0] + tmp[1];
+ }
+ }
+
+ int counter = 0;
+ item.Name = String.Format("{0}://{1}", rootWebApplicationUri.Scheme, hostNameBase + "-" + counter.ToString() + "." + sslRoot);
+ siteName = String.Format("{0}", hostNameBase + "-" + counter.ToString() + "." + sslRoot);
+
+ 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);
+ siteName = String.Format("{0}", hostNameBase + "-" + counter.ToString() + "." + sslRoot);
+ }
+ }
+ else
+ item.Name = String.Format("{0}://{1}", rootWebApplicationUri.Scheme, item.Name);
+
+ if (rootWebApplicationUri.Port > 0 && rootWebApplicationUri.Port != 80 && rootWebApplicationUri.Port != 443)
+ {
+ item.PhysicalAddress = String.Format("{0}:{1}", item.Name, rootWebApplicationUri.Port);
+ }
+ else
+ {
+ item.PhysicalAddress = item.Name;
+ }
+
+ if (Utils.ParseBool(hostedSharePointSettings["LocalHostFile"], false))
+ {
+ item.RootWebApplicationInteralIpAddress = hostedSharePointSettings["RootWebApplicationInteralIpAddress"];
+ item.RootWebApplicationFQDN = item.Name.Replace(rootWebApplicationUri.Scheme + "://", "");
+ }
+
+ item.MaxSiteStorage = RecalculateMaxSize(org.MaxSharePointEnterpriseStorage, (int)item.MaxSiteStorage);
+ item.WarningStorage = item.MaxSiteStorage == -1 ? -1 : Math.Min((int)item.WarningStorage, item.MaxSiteStorage);
+
+
+ // Check package item with given name already exists.
+ if (PackageController.GetPackageItemByName(item.PackageId, item.Name, typeof(SharePointSiteCollection)) != null)
+ {
+ return BusinessErrorCodes.ERROR_SHAREPOINT_PACKAGE_ITEM_EXISTS;
+ }
+
+ // Log operation.
+ TaskManager.StartTask("HOSTED_SHAREPOINT_ENTERPRISE", "ADD_SITE_COLLECTION", item.Name);
+
+ try
+ {
+ // Create site collection on server.
+ HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(serviceId);
+
+ hostedSharePointServer.Enterprise_CreateSiteCollection(item);
+
+ // Make record in metabase.
+ item.ServiceId = serviceId;
+ int itemId = PackageController.AddPackageItem(item);
+
+ hostedSharePointServer.Enterprise_SetPeoplePickerOu(item.Name, org.DistinguishedName);
+
+ int dnsServiceId = PackageController.GetPackageServiceId(item.PackageId, ResourceGroups.Dns);
+ if (dnsServiceId > 0)
+ {
+ string[] tmpStr = siteName.Split('.');
+ string hostName = tmpStr[0];
+ string domainName = siteName.Substring(hostName.Length + 1, siteName.Length - (hostName.Length + 1));
+
+ List dnsRecords = ServerController.GetDnsRecordsByService(serviceId);
+ List resourceRecords = DnsServerController.BuildDnsResourceRecords(dnsRecords, hostName, domainName, "");
+ DNSServer dns = new DNSServer();
+
+ ServiceProviderProxy.Init(dns, dnsServiceId);
+ // add new resource records
+ dns.AddZoneRecords(domainName, resourceRecords.ToArray());
+ }
+
+ TaskManager.ItemId = itemId;
+
+ return itemId;
+ }
+ catch (Exception ex)
+ {
+ throw TaskManager.WriteError(ex);
+ }
+ finally
+ {
+ TaskManager.CompleteTask();
+ }
+ }
+
+ ///
+ /// Deletes SharePoint site collection with given id.
+ ///
+ /// Site collection id within metabase.
+ /// ?
+ public static int DeleteSiteCollection(int itemId)
+ {
+ // Check account.
+ int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
+ if (accountCheck < 0)
+ {
+ return accountCheck;
+ }
+
+ // Load original meta item
+ SharePointSiteCollection origItem = (SharePointSiteCollection)PackageController.GetPackageItem(itemId);
+ if (origItem == null)
+ {
+ return BusinessErrorCodes.ERROR_SHAREPOINT_PACKAGE_ITEM_NOT_FOUND;
+ }
+
+ // Get service settings.
+ StringDictionary hostedSharePointSettings = ServerController.GetServiceSettings(origItem.ServiceId);
+ Uri rootWebApplicationUri = new Uri(hostedSharePointSettings["RootWebApplicationUri"]);
+ string siteName = origItem.Name.Replace(String.Format("{0}://", rootWebApplicationUri.Scheme), String.Empty);
+
+ // Log operation.
+ TaskManager.StartTask("HOSTED_SHAREPOINT_ENTERPRISE", "DELETE_SITE", origItem.Name, itemId);
+
+ try
+ {
+ // Delete site collection on server.
+ HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(origItem.ServiceId);
+ hostedSharePointServer.Enterprise_DeleteSiteCollection(origItem);
+ // Delete record in metabase.
+ PackageController.DeletePackageItem(origItem.Id);
+
+ int dnsServiceId = PackageController.GetPackageServiceId(origItem.PackageId, ResourceGroups.Dns);
+ if (dnsServiceId > 0)
+ {
+ string[] tmpStr = siteName.Split('.');
+ string hostName = tmpStr[0];
+ string domainName = siteName.Substring(hostName.Length + 1, siteName.Length - (hostName.Length + 1));
+
+ List dnsRecords = ServerController.GetDnsRecordsByService(origItem.ServiceId);
+ List resourceRecords = DnsServerController.BuildDnsResourceRecords(dnsRecords, hostName, domainName, "");
+ DNSServer dns = new DNSServer();
+
+ ServiceProviderProxy.Init(dns, dnsServiceId);
+ // add new resource records
+ dns.DeleteZoneRecords(domainName, resourceRecords.ToArray());
+ }
+
+ return 0;
+ }
+ catch (Exception ex)
+ {
+ throw TaskManager.WriteError(ex);
+ }
+ finally
+ {
+ TaskManager.CompleteTask();
+ }
+ }
+
+ ///
+ /// Deletes SharePoint site collections which belong to organization.
+ ///
+ /// Site collection id within metabase.
+ public static void DeleteSiteCollections(int organizationId)
+ {
+ Organization org = OrganizationController.GetOrganization(organizationId);
+ SharePointSiteCollectionListPaged existentSiteCollections = GetSiteCollectionsPaged(org.PackageId, org.Id, String.Empty, String.Empty, String.Empty, 0, Int32.MaxValue);
+ foreach (SharePointSiteCollection existentSiteCollection in existentSiteCollections.SiteCollections)
+ {
+ DeleteSiteCollection(existentSiteCollection.Id);
+ }
+ }
+
+ ///
+ /// Backups SharePoint site collection.
+ ///
+ /// Site collection id within metabase.
+ /// Backed up site collection file name.
+ /// A value which shows whether back up must be archived.
+ /// A value which shows whether created back up must be downloaded.
+ /// Local folder to store downloaded backup.
+ /// Created backup file name.
+ public static string BackupSiteCollection(int itemId, string fileName, bool zipBackup, bool download, string folderName)
+ {
+ // Check account.
+ int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
+ if (accountCheck < 0)
+ {
+ return null;
+ }
+
+ // Load original meta item
+ SharePointSiteCollection origItem = (SharePointSiteCollection)PackageController.GetPackageItem(itemId);
+ if (origItem == null)
+ {
+ return null;
+ }
+
+ // Log operation.
+ TaskManager.StartTask("HOSTED_SHAREPOINT_ENTERPRISE", "BACKUP_SITE_COLLECTION", origItem.Name, itemId);
+
+ try
+ {
+ // Create site collection on server.
+ HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(origItem.ServiceId);
+ string backFile = hostedSharePointServer.Enterprise_BackupSiteCollection(origItem.Name, fileName, zipBackup);
+
+ if (!download)
+ {
+ // Copy backup files to space folder.
+ string relFolderName = FilesController.CorrectRelativePath(folderName);
+ if (!relFolderName.EndsWith("\\"))
+ {
+ relFolderName = relFolderName + "\\";
+ }
+
+ // Create backup folder if not exists
+ if (!FilesController.DirectoryExists(origItem.PackageId, relFolderName))
+ {
+ FilesController.CreateFolder(origItem.PackageId, relFolderName);
+ }
+
+ string packageFile = relFolderName + Path.GetFileName(backFile);
+
+ // Delete destination file if exists
+ if (FilesController.FileExists(origItem.PackageId, packageFile))
+ {
+ FilesController.DeleteFiles(origItem.PackageId, new string[] { packageFile });
+ }
+
+ byte[] buffer = null;
+
+ int offset = 0;
+ do
+ {
+ // Read remote content.
+ buffer = hostedSharePointServer.Enterprise_GetTempFileBinaryChunk(backFile, offset, FILE_BUFFER_LENGTH);
+
+ // Write remote content.
+ FilesController.AppendFileBinaryChunk(origItem.PackageId, packageFile, buffer);
+
+ offset += FILE_BUFFER_LENGTH;
+ }
+ while (buffer.Length == FILE_BUFFER_LENGTH);
+ }
+
+ return backFile;
+ }
+ catch (Exception ex)
+ {
+ throw TaskManager.WriteError(ex);
+ }
+ finally
+ {
+ TaskManager.CompleteTask();
+ }
+ }
+
+ ///
+ /// Restores SharePoint site collection.
+ ///
+ /// Site collection id within metabase.
+ ///
+ ///
+ ///
+ public static int RestoreSiteCollection(int itemId, string uploadedFile, string packageFile)
+ {
+ // Check account.
+ int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
+ if (accountCheck < 0)
+ {
+ return accountCheck;
+ }
+
+ // Load original meta item.
+ SharePointSiteCollection origItem = (SharePointSiteCollection)PackageController.GetPackageItem(itemId);
+ if (origItem == null)
+ {
+ return BusinessErrorCodes.ERROR_SHAREPOINT_PACKAGE_ITEM_NOT_FOUND;
+ }
+
+ // Check package.
+ int packageCheck = SecurityContext.CheckPackage(origItem.PackageId, DemandPackage.IsActive);
+ if (packageCheck < 0)
+ {
+ return packageCheck;
+ }
+
+ // Log operation.
+ TaskManager.StartTask("HOSTED_SHAREPOINT_ENTERPRISE", "BACKUP_SITE_COLLECTION", origItem.Name, itemId);
+
+ try
+ {
+ // Create site collection on server.
+ HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(origItem.ServiceId);
+
+ string backupFile = null;
+ if (!String.IsNullOrEmpty(packageFile))
+ {
+ // Copy package files to the remote SharePoint Server.
+ string path = null;
+ byte[] buffer = null;
+
+ int offset = 0;
+ do
+ {
+ // Read package file.
+ buffer = FilesController.GetFileBinaryChunk(origItem.PackageId, packageFile, offset, FILE_BUFFER_LENGTH);
+
+ // Write remote backup file
+ string tempPath = hostedSharePointServer.Enterprise_AppendTempFileBinaryChunk(Path.GetFileName(packageFile), path, buffer);
+ if (path == null)
+ {
+ path = tempPath;
+ backupFile = path;
+ }
+
+ offset += FILE_BUFFER_LENGTH;
+ }
+ while (buffer.Length == FILE_BUFFER_LENGTH);
+ }
+ else if (!String.IsNullOrEmpty(uploadedFile))
+ {
+ // Upladed files.
+ backupFile = uploadedFile;
+ }
+
+ // Restore.
+ if (!String.IsNullOrEmpty(backupFile))
+ {
+ hostedSharePointServer.Enterprise_RestoreSiteCollection(origItem, backupFile);
+ }
+
+ return 0;
+ }
+ catch (Exception ex)
+ {
+ throw TaskManager.WriteError(ex);
+ }
+ finally
+ {
+ TaskManager.CompleteTask();
+ }
+ }
+
+ ///
+ /// Gets binary data chunk of specified size from specified offset.
+ ///
+ /// Item id to obtain realted service id.
+ /// Path to file to get bunary data chunk from.
+ /// Offset from which to start data reading.
+ /// Binary data chunk length.
+ /// Binary data chunk read from file.
+ public static byte[] GetBackupBinaryChunk(int itemId, string path, int offset, int length)
+ {
+ // Load original meta item.
+ SharePointSiteCollection item = (SharePointSiteCollection)PackageController.GetPackageItem(itemId);
+ if (item == null)
+ {
+ return null;
+ }
+
+ HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(item.ServiceId);
+ return hostedSharePointServer.Enterprise_GetTempFileBinaryChunk(path, offset, length);
+ }
+
+ ///
+ /// Appends supplied binary data chunk to file.
+ ///
+ /// Item id to obtain realted service id.
+ /// Non existent file name to append to.
+ /// Full path to existent file to append to.
+ /// Binary data chunk to append to.
+ /// Path to file that was appended with chunk.
+ public static string AppendBackupBinaryChunk(int itemId, string fileName, string path, byte[] chunk)
+ {
+ // Load original meta item.
+ SharePointSiteCollection item = (SharePointSiteCollection)PackageController.GetPackageItem(itemId);
+ if (item == null)
+ {
+ return null;
+ }
+
+ HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(item.ServiceId);
+ return hostedSharePointServer.Enterprise_AppendTempFileBinaryChunk(fileName, path, chunk);
+ }
+
+ ///
+ /// Initializes a new hosted SharePoint server proxy.
+ ///
+ /// Hosted SharePoint service id.
+ /// Hosted SharePoint server proxy.
+ private static HostedSharePointServerEnt GetHostedSharePointServer(int serviceId)
+ {
+
+ HostedSharePointServerEnt sps = new HostedSharePointServerEnt();
+ ServiceProviderProxy.Init(sps, serviceId);
+ return sps;
+ }
+
+ ///
+ /// Gets list of importable items.
+ ///
+ /// Package that owns importable items.
+ /// Item type id.
+ /// Item type.
+ /// Item resource group.
+ /// List of importable item names.
+ public List GetImportableItems(int packageId, int itemTypeId, Type itemType, ResourceGroupInfo group)
+ {
+ List items = new List();
+
+ // Get service id
+ int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName);
+ if (serviceId == 0)
+ {
+ return items;
+ }
+
+ HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(serviceId);
+ if (itemType == typeof(SharePointSiteCollection))
+ {
+ foreach (SharePointSiteCollection siteCollection in hostedSharePointServer.Enterprise_GetSiteCollections())
+ {
+ items.Add(siteCollection.Url);
+ }
+ }
+
+ return items;
+ }
+
+ ///
+ /// Imports selected item into metabase.
+ ///
+ /// Package to which items must be imported.
+ /// Item type id.
+ /// Item type.
+ /// Item resource group.
+ /// Item name to import.
+ public void ImportItem(int packageId, int itemTypeId, Type itemType, ResourceGroupInfo group, string itemName)
+ {
+ // Get service id
+ int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName);
+ if (serviceId == 0)
+ {
+ return;
+ }
+
+ HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(serviceId);
+ if (itemType == typeof(SharePointSiteCollection))
+ {
+ SharePointSiteCollection siteCollection = hostedSharePointServer.Enterprise_GetSiteCollection(itemName);
+ PackageController.AddPackageItem(siteCollection);
+ }
+ }
+
+ ///
+ /// Backups service item by serializing it into supplied writer.
+ ///
+ /// Temporary directory path.
+ /// Xml wirter used to store backuped service provider items.
+ /// Service provider item to be backed up..
+ /// Service provider resource group.
+ /// Resulting code.
+ public int BackupItem(string tempFolder, XmlWriter writer, ServiceProviderItem item, ResourceGroupInfo group)
+ {
+ SharePointSiteCollection siteCollection = item as SharePointSiteCollection;
+ if (siteCollection != null)
+ {
+ HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(siteCollection.ServiceId);
+ SharePointSiteCollection loadedSiteCollection = hostedSharePointServer.Enterprise_GetSiteCollection(siteCollection.Url);
+ // Update item
+ siteCollection.Url = loadedSiteCollection.Url;
+ siteCollection.OwnerLogin = loadedSiteCollection.OwnerLogin;
+ siteCollection.OwnerName = loadedSiteCollection.OwnerName;
+ siteCollection.OwnerEmail = loadedSiteCollection.OwnerEmail;
+ siteCollection.LocaleId = loadedSiteCollection.LocaleId;
+ siteCollection.Title = loadedSiteCollection.Title;
+ siteCollection.Description = loadedSiteCollection.Description;
+ // Serialize it.
+ XmlSerializer serializer = new XmlSerializer(typeof(SharePointSiteCollection));
+ serializer.Serialize(writer, siteCollection);
+
+ }
+ return 0;
+ }
+
+ ///
+ /// Restore backed up previously service provider item.
+ ///
+ /// Temporary directory path.
+ /// Serialized service provider item.
+ /// Service provider item id.
+ /// Service provider item type.
+ /// Service provider item name.
+ /// Service provider item package.
+ /// Service provider item service id.
+ /// Service provider item resource group.
+ /// Resulting code.
+ public int RestoreItem(string tempFolder, XmlNode itemNode, int itemId, Type itemType, string itemName, int packageId, int serviceId, ResourceGroupInfo group)
+ {
+ if (itemType == typeof(SharePointSiteCollection))
+ {
+ HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(serviceId);
+ // Deserialize item.
+ XmlSerializer serializer = new XmlSerializer(typeof(SharePointSiteCollection));
+ SharePointSiteCollection siteCollection = (SharePointSiteCollection)serializer.Deserialize(new XmlNodeReader(itemNode.SelectSingleNode("SharePointSiteCollection")));
+ siteCollection.PackageId = packageId;
+ siteCollection.ServiceId = serviceId;
+
+ // Create site collection if needed.
+ if (hostedSharePointServer.Enterprise_GetSiteCollection(siteCollection.Url) == null)
+ {
+ hostedSharePointServer.Enterprise_CreateSiteCollection(siteCollection);
+ }
+
+ // Add metabase record if needed.
+ SharePointSiteCollection metaSiteCollection = (SharePointSiteCollection)PackageController.GetPackageItemByName(packageId, itemName, typeof(SharePointSiteCollection));
+ if (metaSiteCollection == null)
+ {
+ PackageController.AddPackageItem(siteCollection);
+ }
+ }
+
+ return 0;
+ }
+
+
+ private static int GetHostedSharePointServiceId(int packageId)
+ {
+ return PackageController.GetPackageServiceId(packageId, ResourceGroups.SharepointFoundationServer);
+ }
+
+ private static List GetOrganizationSharePointSiteCollections(int orgId)
+ {
+ Organization org = OrganizationController.GetOrganization(orgId);
+
+ SharePointSiteCollectionListPaged siteCollections = GetSiteCollectionsPaged(org.PackageId, org.Id, String.Empty, String.Empty, String.Empty, 0, Int32.MaxValue);
+ return siteCollections.SiteCollections;
+ }
+
+ private static int RecalculateStorageMaxSize(int size, int packageId)
+ {
+ PackageContext cntx = PackageController.GetPackageContext(packageId);
+ QuotaValueInfo quota = cntx.Quotas[Quotas.HOSTED_SHAREPOINT_ENTERPRISE_STORAGE_SIZE];
+
+ if (quota.QuotaAllocatedValue == -1)
+ {
+ if (size == -1)//Unlimited
+ return -1;
+ else
+ return size;
+ }
+ else
+ {
+ if (size == -1)
+ return quota.QuotaAllocatedValue;
+
+ return Math.Min(size, quota.QuotaAllocatedValue);
+ }
+ }
+
+ private static int RecalculateMaxSize(int parentSize, int realSize)
+ {
+ if (parentSize == -1)
+ {
+ if (realSize == -1 || realSize == 0)
+ return -1;
+ else
+ return realSize;
+ }
+
+
+ if (realSize == -1 || realSize == 0)
+ return parentSize;
+
+ return Math.Min(parentSize, realSize);
+
+ }
+
+
+ public static int SetStorageSettings(int itemId, int maxStorage, int warningStorage, bool applyToSiteCollections)
+ {
+ // check account
+ int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
+ if (accountCheck < 0) return accountCheck;
+
+ // place log record
+ TaskManager.StartTask("HOSTED_SHAREPOINT_ENTERPRISE", "SET_ORG_LIMITS", itemId);
+
+ try
+ {
+ Organization org = (Organization)PackageController.GetPackageItem(itemId);
+ if (org == null)
+ return 0;
+
+ // set limits
+ int realMaxSizeValue = RecalculateStorageMaxSize(maxStorage, org.PackageId);
+
+ org.MaxSharePointEnterpriseStorage = realMaxSizeValue;
+
+ org.WarningSharePointEnterpriseStorage = realMaxSizeValue == -1 ? -1 : Math.Min(warningStorage, realMaxSizeValue);
+
+ // save organization
+ UpdateOrganization(org);
+
+ if (applyToSiteCollections)
+ {
+ int serviceId = GetHostedSharePointServiceId(org.PackageId);
+
+ HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(serviceId);
+
+ List currentOrgSiteCollection =
+ GetOrganizationSharePointSiteCollections(org.Id);
+
+
+ foreach (SharePointSiteCollection siteCollection in currentOrgSiteCollection)
+ {
+ try
+ {
+ SharePointSiteCollection sc = GetSiteCollection(siteCollection.Id);
+ sc.MaxSiteStorage = realMaxSizeValue;
+ sc.WarningStorage = realMaxSizeValue == -1 ? -1 : warningStorage;
+ PackageController.UpdatePackageItem(sc);
+
+ hostedSharePointServer.Enterprise_UpdateQuotas(siteCollection.PhysicalAddress, realMaxSizeValue,
+ warningStorage);
+ }
+ catch (Exception ex)
+ {
+ TaskManager.WriteError(ex);
+ }
+ }
+ }
+
+ return 0;
+ }
+ catch (Exception ex)
+ {
+ throw TaskManager.WriteError(ex);
+ }
+ finally
+ {
+ TaskManager.CompleteTask();
+ }
+ }
+
+ public static SharePointSiteDiskSpace[] CalculateSharePointSitesDiskSpace(int itemId, out int errorCode)
+ {
+ SharePointSiteDiskSpace[] retDiskSpace = null;
+ errorCode = 0;
+ // check account
+ int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
+ if (accountCheck < 0)
+ {
+ errorCode = accountCheck;
+ return null;
+ }
+
+ // place log record
+ TaskManager.StartTask("HOSTED_SHAREPOINT_ENTERPRISE", "CALCULATE_DISK_SPACE", itemId);
+
+ try
+ {
+ Organization org = (Organization)PackageController.GetPackageItem(itemId);
+ if (org == null)
+ return null;
+
+ int serviceId = GetHostedSharePointServiceId(org.PackageId);
+
+ HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(serviceId);
+
+ List currentOrgSiteCollection =
+ GetOrganizationSharePointSiteCollections(org.Id);
+
+ List urls = new List();
+ foreach (SharePointSiteCollection siteCollection in currentOrgSiteCollection)
+ {
+ urls.Add(siteCollection.PhysicalAddress);
+ }
+ if (urls.Count > 0)
+ retDiskSpace = hostedSharePointServer.Enterprise_CalculateSiteCollectionsDiskSpace(urls.ToArray());
+ else
+ {
+ retDiskSpace = new SharePointSiteDiskSpace[1];
+ retDiskSpace[0] = new SharePointSiteDiskSpace();
+ retDiskSpace[0].DiskSpace = 0;
+ retDiskSpace[0].Url = string.Empty;
+ }
+ }
+ catch (Exception ex)
+ {
+ throw TaskManager.WriteError(ex);
+ }
+ finally
+ {
+ TaskManager.CompleteTask();
+ }
+ return retDiskSpace;
+ }
+
+ private static void UpdateOrganization(Organization organization)
+ {
+ PackageController.UpdatePackageItem(organization);
+ }
+
+
+ public static void UpdateQuota(int itemId, int siteCollectionId, int maxStorage, int warningStorage)
+ {
+ TaskManager.StartTask("HOSTED_SHAREPOINT_ENTERPRISE", "UPDATE_QUOTA");
+ try
+ {
+ Organization org = (Organization)PackageController.GetPackageItem(itemId);
+ if (org == null)
+ return;
+
+ int serviceId = GetHostedSharePointServiceId(org.PackageId);
+
+ HostedSharePointServerEnt hostedSharePointServer = GetHostedSharePointServer(serviceId);
+
+ SharePointSiteCollection sc = GetSiteCollection(siteCollectionId);
+
+ int maxSize = RecalculateMaxSize(org.MaxSharePointEnterpriseStorage, maxStorage);
+ int warningSize = warningStorage;
+
+
+ sc.MaxSiteStorage = maxSize;
+ sc.WarningStorage = maxSize == -1 ? -1 : Math.Min(warningSize, maxSize);
+ PackageController.UpdatePackageItem(sc);
+
+ hostedSharePointServer.Enterprise_UpdateQuotas(sc.PhysicalAddress, maxSize,
+ warningStorage);
+ }
+ catch (Exception ex)
+ {
+ throw TaskManager.WriteError(ex);
+ }
+ finally
+ {
+ TaskManager.CompleteTask();
+ }
+ }
+ ///
+ /// Gets a value if caller is in demo mode.
+ ///
+ private static bool IsDemoMode
+ {
+ get
+ {
+ return (SecurityContext.CheckAccount(DemandAccount.NotDemo) < 0);
+ }
+ }
+
+ }
+}
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/WebsitePanel.EnterpriseServer.Code.csproj b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/WebsitePanel.EnterpriseServer.Code.csproj
index 58c17bbf..19107f3d 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/WebsitePanel.EnterpriseServer.Code.csproj
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/WebsitePanel.EnterpriseServer.Code.csproj
@@ -17,7 +17,7 @@
true
full
false
- ..\..\Bin\
+ ..\WebsitePanel.EnterpriseServer\bin\
DEBUG;TRACE
prompt
4
@@ -26,7 +26,7 @@
pdbonly
true
- ..\..\Bin\
+ ..\WebsitePanel.EnterpriseServer\bin\
TRACE
prompt
4
@@ -163,6 +163,7 @@
+
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/WebsitePanel.EnterpriseServer.csproj b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/WebsitePanel.EnterpriseServer.csproj
index c18d5220..6e3e5f97 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/WebsitePanel.EnterpriseServer.csproj
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/WebsitePanel.EnterpriseServer.csproj
@@ -68,16 +68,19 @@
-
+
+ False
..\..\Bin\WebsitePanel.EnterpriseServer.Base.dll
-
+
+ False
..\..\Bin\WebsitePanel.EnterpriseServer.Code.dll
-
+
+ False
..\..\Bin\WebsitePanel.Providers.Base.dll
-
+
False
..\..\Bin\WebsitePanel.Server.Client.dll
@@ -120,6 +123,7 @@
+
@@ -164,6 +168,10 @@
esEnterpriseStorage.asmx
Component
+
+ esHostedSharePointServersEnt.asmx
+ Component
+
esRemoteDesktopServices.asmx
Component
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esHostedSharePointServers.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esHostedSharePointServers.asmx.cs
index c99bee6a..2468333c 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esHostedSharePointServers.asmx.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esHostedSharePointServers.asmx.cs
@@ -59,10 +59,10 @@ namespace WebsitePanel.EnterpriseServer
/// Site collections in raw format.
[WebMethod]
public SharePointSiteCollectionListPaged GetSiteCollectionsPaged(int packageId, int organizationId,
- string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows, string groupName)
+ string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
{
return HostedSharePointServerController.GetSiteCollectionsPaged(packageId, organizationId, filterColumn, filterValue,
- sortColumn, startRow, maximumRows, groupName);
+ sortColumn, startRow, maximumRows);
}
///
@@ -83,9 +83,9 @@ namespace WebsitePanel.EnterpriseServer
/// Resource group name.
/// List of found site collections.
[WebMethod]
- public List GetSiteCollections(int packageId, bool recursive, string groupName)
+ public List GetSiteCollections(int packageId, bool recursive)
{
- return HostedSharePointServerController.GetSiteCollections(packageId, recursive, groupName);
+ return HostedSharePointServerController.GetSiteCollections(packageId, recursive);
}
[WebMethod]
@@ -116,7 +116,7 @@ namespace WebsitePanel.EnterpriseServer
public SharePointSiteCollection GetSiteCollectionByDomain(int organizationId, string domain)
{
DomainInfo domainInfo = ServerController.GetDomain(domain);
- SharePointSiteCollectionListPaged existentSiteCollections = this.GetSiteCollectionsPaged(domainInfo.PackageId, organizationId, "ItemName", String.Format("%{0}", domain), String.Empty, 0, Int32.MaxValue, null);
+ SharePointSiteCollectionListPaged existentSiteCollections = this.GetSiteCollectionsPaged(domainInfo.PackageId, organizationId, "ItemName", String.Format("%{0}", domain), String.Empty, 0, Int32.MaxValue);
foreach (SharePointSiteCollection existentSiteCollection in existentSiteCollections.SiteCollections)
{
Uri existentSiteCollectionUri = new Uri(existentSiteCollection.Name);
@@ -136,9 +136,9 @@ namespace WebsitePanel.EnterpriseServer
/// Resource group name.
/// Created site collection id within metabase.
[WebMethod]
- public int AddSiteCollection(SharePointSiteCollection item, string groupName)
+ public int AddSiteCollection(SharePointSiteCollection item)
{
- return HostedSharePointServerController.AddSiteCollection(item, groupName);
+ return HostedSharePointServerController.AddSiteCollection(item);
}
///
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esHostedSharePointServersEnt.asmx b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esHostedSharePointServersEnt.asmx
new file mode 100644
index 00000000..394c337c
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esHostedSharePointServersEnt.asmx
@@ -0,0 +1 @@
+<%@ WebService Language="C#" CodeBehind="esHostedSharePointServersEnt.asmx.cs" Class="WebsitePanel.EnterpriseServer.esHostedSharePointServers" %>
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esHostedSharePointServersEnt.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esHostedSharePointServersEnt.asmx.cs
new file mode 100644
index 00000000..e5b51f35
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esHostedSharePointServersEnt.asmx.cs
@@ -0,0 +1,237 @@
+// 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.ComponentModel;
+using System.Web.Services;
+using WebsitePanel.EnterpriseServer.Code.SharePoint;
+using WebsitePanel.Providers.SharePoint;
+using Microsoft.Web.Services3;
+
+namespace WebsitePanel.EnterpriseServer
+{
+ ///
+ /// Summary description for esHostedSharePointServers
+ ///
+ [WebService(Namespace = "http://smbsaas/websitepanel/enterpriseserver")]
+ [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
+ [Policy("ServerPolicy")]
+ [ToolboxItem(false)]
+ public class esHostedSharePointServersEnt : WebService
+ {
+ ///
+ /// Gets site collections in raw form.
+ ///
+ /// Package to which desired site collections belong.
+ /// Organization to which desired site collections belong.
+ /// Filter column name.
+ /// Filter value.
+ /// Sort column name.
+ /// Row index to start from.
+ /// Maximum number of rows to retrieve.
+ /// Resource group name.
+ /// Site collections in raw format.
+ [WebMethod]
+ public SharePointSiteCollectionListPaged GetSiteCollectionsPaged(int packageId, int organizationId,
+ string filterColumn, string filterValue, string sortColumn, int startRow, int maximumRows)
+ {
+ return HostedSharePointServerEntController.GetSiteCollectionsPaged(packageId, organizationId, filterColumn, filterValue,
+ sortColumn, startRow, maximumRows);
+ }
+
+ ///
+ /// Gets list of supported languages by this installation of SharePoint.
+ ///
+ /// List of supported languages
+ [WebMethod]
+ public int[] GetSupportedLanguages(int packageId)
+ {
+ return HostedSharePointServerEntController.GetSupportedLanguages(packageId);
+ }
+
+ ///
+ /// Gets list of SharePoint site collections that belong to the package.
+ ///
+ /// Package that owns site collections.
+ /// A value which shows whether nested spaces must be searched as well.
+ /// Resource group name.
+ /// List of found site collections.
+ [WebMethod]
+ public List GetSiteCollections(int packageId, bool recursive)
+ {
+ return HostedSharePointServerEntController.GetSiteCollections(packageId, recursive);
+ }
+
+ [WebMethod]
+ public int SetStorageSettings(int itemId, int maxStorage, int warningStorage, bool applyToSiteCollections)
+ {
+ return HostedSharePointServerEntController.SetStorageSettings(itemId, maxStorage, warningStorage, applyToSiteCollections );
+ }
+
+ ///
+ /// Gets SharePoint site collection with given id.
+ ///
+ /// Site collection id within metabase.
+ /// Site collection.
+ [WebMethod]
+ public SharePointSiteCollection GetSiteCollection(int itemId)
+ {
+ return HostedSharePointServerEntController.GetSiteCollection(itemId);
+ }
+
+ ///
+ /// Gets SharePoint site collection from package under organization with given domain.
+ ///
+ /// Package id.
+ /// Organization id.
+ /// Domain name.
+ /// SharePoint site collection or null.
+ [WebMethod]
+ public SharePointSiteCollection GetSiteCollectionByDomain(int organizationId, string domain)
+ {
+ DomainInfo domainInfo = ServerController.GetDomain(domain);
+ SharePointSiteCollectionListPaged existentSiteCollections = this.GetSiteCollectionsPaged(domainInfo.PackageId, organizationId, "ItemName", String.Format("%{0}", domain), String.Empty, 0, Int32.MaxValue);
+ foreach (SharePointSiteCollection existentSiteCollection in existentSiteCollections.SiteCollections)
+ {
+ Uri existentSiteCollectionUri = new Uri(existentSiteCollection.Name);
+ if (existentSiteCollection.Name == String.Format("{0}://{1}", existentSiteCollectionUri.Scheme, domain))
+ {
+ return existentSiteCollection;
+ }
+ }
+
+ return null;
+ }
+
+ ///
+ /// Adds SharePoint site collection.
+ ///
+ /// Site collection description.
+ /// Resource group name.
+ /// Created site collection id within metabase.
+ [WebMethod]
+ public int AddSiteCollection(SharePointSiteCollection item)
+ {
+ return HostedSharePointServerEntController.AddSiteCollection(item);
+ }
+
+ ///
+ /// Deletes SharePoint site collection with given id.
+ ///
+ /// Site collection id within metabase.
+ /// ?
+ [WebMethod]
+ public int DeleteSiteCollection(int itemId)
+ {
+ return HostedSharePointServerEntController.DeleteSiteCollection(itemId);
+ }
+
+ ///
+ /// Deletes SharePoint site collections which belong to organization.
+ ///
+ /// Site collection id within metabase.
+ /// ?
+ [WebMethod]
+ public int DeleteSiteCollections(int organizationId)
+ {
+ HostedSharePointServerEntController.DeleteSiteCollections(organizationId);
+ return 0;
+ }
+
+
+ ///
+ /// Backups SharePoint site collection.
+ ///
+ /// Site collection id within metabase.
+ /// Backed up site collection file name.
+ /// A value which shows whether back up must be archived.
+ /// A value which shows whether created back up must be downloaded.
+ /// Local folder to store downloaded backup.
+ /// Created backup file name.
+ [WebMethod]
+ public string BackupSiteCollection(int itemId, string fileName, bool zipBackup, bool download, string folderName)
+ {
+ return HostedSharePointServerEntController.BackupSiteCollection(itemId, fileName, zipBackup, download, folderName);
+ }
+
+ ///
+ /// Restores SharePoint site collection.
+ ///
+ /// Site collection id within metabase.
+ ///
+ ///
+ ///
+ [WebMethod]
+ public int RestoreSiteCollection(int itemId, string uploadedFile, string packageFile)
+ {
+ return HostedSharePointServerEntController.RestoreSiteCollection(itemId, uploadedFile, packageFile);
+ }
+
+ ///
+ /// Gets binary data chunk of specified size from specified offset.
+ ///
+ /// Item id to obtain realted service id.
+ /// Path to file to get bunary data chunk from.
+ /// Offset from which to start data reading.
+ /// Binary data chunk length.
+ /// Binary data chunk read from file.
+ [WebMethod]
+ public byte[] GetBackupBinaryChunk(int itemId, string path, int offset, int length)
+ {
+ return HostedSharePointServerEntController.GetBackupBinaryChunk(itemId, path, offset, length);
+ }
+
+ ///
+ /// Appends supplied binary data chunk to file.
+ ///
+ /// Item id to obtain realted service id.
+ /// Non existent file name to append to.
+ /// Full path to existent file to append to.
+ /// Binary data chunk to append to.
+ /// Path to file that was appended with chunk.
+ [WebMethod]
+ public string AppendBackupBinaryChunk(int itemId, string fileName, string path, byte[] chunk)
+ {
+ return HostedSharePointServerEntController.AppendBackupBinaryChunk(itemId, fileName, path, chunk);
+ }
+
+ [WebMethod]
+ public SharePointSiteDiskSpace[] CalculateSharePointSitesDiskSpace(int itemId, out int errorCode)
+ {
+ return HostedSharePointServerEntController.CalculateSharePointSitesDiskSpace(itemId, out errorCode);
+ }
+
+
+ [WebMethod]
+ public void UpdateQuota(int itemId, int siteCollectionId, int maxSize, int warningSize)
+ {
+ HostedSharePointServerEntController.UpdateQuota(itemId, siteCollectionId, maxSize, warningSize);
+ }
+ }
+}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/Organization.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/Organization.cs
index 69b3f2c7..f88314b1 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/Organization.cs
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/Organization.cs
@@ -61,6 +61,9 @@ namespace WebsitePanel.Providers.HostedSolution
private int maxSharePointStorage;
private int warningSharePointStorage;
+ private int maxSharePointEnterpriseStorage;
+ private int warningSharePointEnterpriseStorage;
+
#endregion
[Persistent]
@@ -80,6 +83,19 @@ namespace WebsitePanel.Providers.HostedSolution
set { warningSharePointStorage = value; }
}
+ public int MaxSharePointEnterpriseStorage
+ {
+ get { return maxSharePointEnterpriseStorage; }
+ set { maxSharePointEnterpriseStorage = value; }
+ }
+
+ [Persistent]
+ public int WarningSharePointEnterpriseStorage
+ {
+ get { return warningSharePointEnterpriseStorage; }
+ set { warningSharePointEnterpriseStorage = value; }
+ }
+
[Persistent]
public string CrmUrl
{
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/OrganizationStatistics.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/OrganizationStatistics.cs
index 56923206..eddf97ed 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/OrganizationStatistics.cs
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/OrganizationStatistics.cs
@@ -61,6 +61,9 @@ namespace WebsitePanel.Providers.HostedSolution
private int allocatedSharePointSiteCollections;
private int createdSharePointSiteCollections;
+ private int allocatedSharePointEnterpriseSiteCollections;
+ private int createdSharePointEnterpriseSiteCollections;
+
private int createdCRMUsers;
private int allocatedCRMUsers;
@@ -288,6 +291,18 @@ namespace WebsitePanel.Providers.HostedSolution
set { createdSharePointSiteCollections = value; }
}
+ public int AllocatedSharePointEnterpriseSiteCollections
+ {
+ get { return allocatedSharePointEnterpriseSiteCollections; }
+ set { allocatedSharePointEnterpriseSiteCollections = value; }
+ }
+
+ public int CreatedSharePointEnterpriseSiteCollections
+ {
+ get { return createdSharePointEnterpriseSiteCollections; }
+ set { createdSharePointEnterpriseSiteCollections = value; }
+ }
+
public int CreatedBlackBerryUsers { get; set; }
public int AllocatedBlackBerryUsers { get; set; }
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/SharePoint/IHostedSharePointServerEnt.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/SharePoint/IHostedSharePointServerEnt.cs
new file mode 100644
index 00000000..4bc6f8ee
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/SharePoint/IHostedSharePointServerEnt.cs
@@ -0,0 +1,120 @@
+// 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;
+
+namespace WebsitePanel.Providers.SharePoint
+{
+ ///
+ /// Exposes functionality for share point server provider hosted in conjunction with organization management provider and
+ /// exchange server.
+ ///
+ public interface IHostedSharePointServerEnt
+ {
+ ///
+ /// When implemented gets root web application uri.
+ ///
+ Uri Enterprise_RootWebApplicationUri
+ {
+ get;
+ }
+
+ ///
+ /// When implemented gets list of supported languages by this installation of SharePoint.
+ ///
+ /// List of supported languages
+ int[] Enterprise_GetSupportedLanguages();
+
+ ///
+ /// When implemented gets list of SharePoint collections within root web application.
+ ///
+ /// List of SharePoint collections within root web application.
+ SharePointSiteCollection[] Enterprise_GetSiteCollections();
+
+ ///
+ /// When implemented gets SharePoint collection within root web application with given name.
+ ///
+ /// Url that uniquely identifies site collection to be loaded.
+ /// SharePoint collection within root web application with given name.
+ SharePointSiteCollection Enterprise_GetSiteCollection(string url);
+
+ ///
+ /// When implemented creates site collection within predefined root web application.
+ ///
+ /// Information about site coolection to be created.
+ void Enterprise_CreateSiteCollection(SharePointSiteCollection siteCollection);
+
+ ///
+ /// When implemented deletes site collection under given url.
+ ///
+ /// Url that uniquely identifies site collection to be deleted.
+ void Enterprise_DeleteSiteCollection(SharePointSiteCollection siteCollection);
+
+ ///
+ /// When implemeneted backups site collection under give url.
+ ///
+ /// Url that uniquely identifies site collection to be deleted.
+ /// Resulting backup file name.
+ /// A value which shows whether created backup must be archived.
+ /// Created backup full path.
+ string Enterprise_BackupSiteCollection(string url, string filename, bool zip);
+
+ ///
+ /// When implemented restores site collection under given url from backup.
+ ///
+ /// Site collection to be restored.
+ /// Backup file name to restore from.
+ void Enterprise_RestoreSiteCollection(SharePointSiteCollection siteCollection, string filename);
+
+ ///
+ /// When implemented gets binary data chunk of specified size from specified offset.
+ ///
+ /// Path to file to get bunary data chunk from.
+ /// Offset from which to start data reading.
+ /// Binary data chunk length.
+ /// Binary data chunk read from file.
+ byte[] Enterprise_GetTempFileBinaryChunk(string path, int offset, int length);
+
+ ///
+ /// When implemented appends supplied binary data chunk to file.
+ ///
+ /// Non existent file name to append to.
+ /// Full path to existent file to append to.
+ /// Binary data chunk to append to.
+ /// Path to file that was appended with chunk.
+ string Enterprise_AppendTempFileBinaryChunk(string fileName, string path, byte[] chunk);
+
+ void Enterprise_UpdateQuotas(string url, long maxStorage, long warningStorage);
+
+ SharePointSiteDiskSpace[] Enterprise_CalculateSiteCollectionsDiskSpace(string[] urls);
+
+ long Enterprise_GetSiteCollectionSize(string url);
+
+ void Enterprise_SetPeoplePickerOu(string site, string ou);
+ }
+}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj b/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj
index e72359e6..2dec0c17 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj
@@ -280,6 +280,7 @@
+
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.SharePoint2013Ent/HostedSharePointServer2013Ent.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.SharePoint2013Ent/HostedSharePointServer2013Ent.cs
new file mode 100644
index 00000000..d9e93497
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.SharePoint2013Ent/HostedSharePointServer2013Ent.cs
@@ -0,0 +1,352 @@
+// 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.IO;
+using System.Text.RegularExpressions;
+using System.Xml;
+using Microsoft.Win32;
+using WebsitePanel.Providers.SharePoint;
+using WebsitePanel.Providers.Utils;
+using WebsitePanel.Server.Utils;
+
+namespace WebsitePanel.Providers.HostedSolution
+{
+ ///
+ /// Provides hosted SharePoint server functionality implementation.
+ ///
+ public class HostedSharePointServer2013Ent : HostingServiceProviderBase, IHostedSharePointServerEnt
+ {
+ #region Delegate
+
+ private delegate TReturn SharePointAction(HostedSharePointServer2013EntImpl impl);
+
+ #endregion
+
+ #region Fields
+
+ protected string LanguagePacksPath;
+ protected string Wss3Registry32Key;
+ protected string Wss3RegistryKey;
+
+ #endregion
+
+ #region Properties
+
+ public string BackupTemporaryFolder
+ {
+ get { return ProviderSettings["BackupTemporaryFolder"]; }
+ }
+
+ public Uri Enterprise_RootWebApplicationUri
+ {
+ get { return new Uri(ProviderSettings["RootWebApplicationUri"]); }
+ }
+
+ #endregion
+
+ #region Constructor
+
+ public HostedSharePointServer2013Ent()
+ {
+ Wss3RegistryKey = @"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0";
+ Wss3Registry32Key = @"SOFTWARE\Wow6432Node\Microsoft\Shared Tools\Web Server Extensions\15.0";
+ LanguagePacksPath = @"%commonprogramfiles%\microsoft shared\Web Server Extensions\15\HCCab\";
+ }
+
+ #endregion
+
+ #region Methods
+
+ /// Gets list of supported languages by this installation of SharePoint.
+ /// List of supported languages
+ public int[] Enterprise_GetSupportedLanguages()
+ {
+ var impl = new HostedSharePointServer2013EntImpl();
+ return impl.GetSupportedLanguages(Enterprise_RootWebApplicationUri);
+ }
+
+ /// Gets list of SharePoint collections within root web application.
+ /// List of SharePoint collections within root web application.
+ public SharePointSiteCollection[] Enterprise_GetSiteCollections()
+ {
+ return ExecuteSharePointAction(impl => impl.GetSiteCollections(Enterprise_RootWebApplicationUri));
+ }
+
+ /// Gets SharePoint collection within root web application with given name.
+ /// Url that uniquely identifies site collection to be loaded.
+ /// SharePoint collection within root web application with given name.
+ public SharePointSiteCollection Enterprise_GetSiteCollection(string url)
+ {
+ return ExecuteSharePointAction(impl => impl.GetSiteCollection(Enterprise_RootWebApplicationUri, url));
+ }
+
+ /// Creates site collection within predefined root web application.
+ /// Information about site coolection to be created.
+ public void Enterprise_CreateSiteCollection(SharePointSiteCollection siteCollection)
+ {
+ ExecuteSharePointAction
+
+ HostedSharePointServerEnt.asmx
+ Component
+
RemoteDesktopServices.asmx
Component
diff --git a/WebsitePanel/Sources/generate_server_proxies.bat b/WebsitePanel/Sources/generate_server_proxies.bat
index 1ed0de0e..cd4f2b8a 100644
--- a/WebsitePanel/Sources/generate_server_proxies.bat
+++ b/WebsitePanel/Sources/generate_server_proxies.bat
@@ -17,8 +17,8 @@ REM %WSE_CLEAN% .\WebsitePanel.Server.Client\DatabaseServerProxy.cs
REM %WSDL% %SERVER_URL%/DNSServer.asmx /out:.\WebsitePanel.Server.Client\DnsServerProxy.cs /namespace:WebsitePanel.Providers.DNS /type:webClient /fields
REM %WSE_CLEAN% .\WebsitePanel.Server.Client\DnsServerProxy.cs
-%WSDL% %SERVER_URL%/ExchangeServer.asmx /out:.\WebsitePanel.Server.Client\ExchangeServerProxy.cs /namespace:WebsitePanel.Providers.Exchange /type:webClient /fields
-%WSE_CLEAN% .\WebsitePanel.Server.Client\ExchangeServerProxy.cs
+REM %WSDL% %SERVER_URL%/ExchangeServer.asmx /out:.\WebsitePanel.Server.Client\ExchangeServerProxy.cs /namespace:WebsitePanel.Providers.Exchange /type:webClient /fields
+REM %WSE_CLEAN% .\WebsitePanel.Server.Client\ExchangeServerProxy.cs
REM %WSDL% %SERVER_URL%/ExchangeServerHostedEdition.asmx /out:.\WebsitePanel.Server.Client\ExchangeServerHostedEditionProxy.cs /namespace:WebsitePanel.Providers.ExchangeHostedEdition /type:webClient /fields
REM %WSE_CLEAN% .\WebsitePanel.Server.Client\ExchangeServerHostedEditionProxy.cs
@@ -26,6 +26,9 @@ REM %WSE_CLEAN% .\WebsitePanel.Server.Client\ExchangeServerHostedEditionProxy.cs
REM %WSDL% %SERVER_URL%/HostedSharePointServer.asmx /out:.\WebsitePanel.Server.Client\HostedSharePointServerProxy.cs /namespace:WebsitePanel.Providers.HostedSolution /type:webClient /fields
REM %WSE_CLEAN% .\WebsitePanel.Server.Client\HostedSharePointServerProxy.cs
+%WSDL% %SERVER_URL%/HostedSharePointServerEnt.asmx /out:.\WebsitePanel.Server.Client\HostedSharePointServerEntProxy.cs /namespace:WebsitePanel.Providers.HostedSolution /type:webClient /fields
+%WSE_CLEAN% .\WebsitePanel.Server.Client\HostedSharePointServerEntProxy.cs
+
REM %WSDL% %SERVER_URL%/OCSEdgeServer.asmx /out:.\WebsitePanel.Server.Client\OCSEdgeServerProxy.cs /namespace:WebsitePanel.Providers.OCS /type:webClient /fields
REM %WSE_CLEAN% .\WebsitePanel.Server.Client\OCSEdgeServerProxy.cs
@@ -35,8 +38,8 @@ REM %WSE_CLEAN% .\WebsitePanel.Server.Client\OCSServerProxy.cs
REM %WSDL% %SERVER_URL%/OperatingSystem.asmx /out:.\WebsitePanel.Server.Client\OperatingSystemProxy.cs /namespace:WebsitePanel.Providers.OS /type:webClient /fields
REM %WSE_CLEAN% .\WebsitePanel.Server.Client\OperatingSystemProxy.cs
-%WSDL% %SERVER_URL%/Organizations.asmx /out:.\WebsitePanel.Server.Client\OrganizationProxy.cs /namespace:WebsitePanel.Providers.HostedSolution /type:webClient /fields
-%WSE_CLEAN% .\WebsitePanel.Server.Client\OrganizationProxy.cs
+REM %WSDL% %SERVER_URL%/Organizations.asmx /out:.\WebsitePanel.Server.Client\OrganizationProxy.cs /namespace:WebsitePanel.Providers.HostedSolution /type:webClient /fields
+REM %WSE_CLEAN% .\WebsitePanel.Server.Client\OrganizationProxy.cs
REM %WSDL% %SERVER_URL%/ServiceProvider.asmx /out:.\WebsitePanel.Server.Client\ServiceProviderProxy.cs /namespace:WebsitePanel.Providers /type:webClient /fields
REM %WSE_CLEAN% .\WebsitePanel.Server.Client\ServiceProviderProxy.cs