private const int FILE_BUFFER_LENGTH = 5000000; // ~5MB /// <summary> /// Gets site collections in raw form. /// </summary> /// <param name="packageId">Package to which desired site collections belong.</param> /// <param name="organizationId">Organization to which desired site collections belong.</param> /// <param name="filterColumn">Filter column name.</param> /// <param name="filterValue">Filter value.</param> /// <param name="sortColumn">Sort column name.</param> /// <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) { 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, ResourceGroups.SharepointFoundationServer, typeof(SharePointSiteCollection), true, filterColumn, filterValue, sortColumn, startRow, Int32.MaxValue); List <SharePointSiteCollection> items = PackageController.CreateServiceItemsList(result, 1).ConvertAll <SharePointSiteCollection>(delegate(ServiceProviderItem item) { return((SharePointSiteCollection)item); }); 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); }
private static List <SharePointSiteCollection> 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); }
/// <summary> /// Deletes SharePoint site collections which belong to organization. /// </summary> /// <param name="organizationId">Site collection id within metabase.</param> 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); } }
public List <SharePointSiteCollection> GetSharePointSiteCollectionPaged(int packageId, int organizationId, string filterColumn, string filterValue, int maximumRows, int startRowIndex, string sortColumn) { if (!String.IsNullOrEmpty(filterValue)) { filterValue = filterValue + "%"; } result = ES.Services.HostedSharePointServers.GetSiteCollectionsPaged(packageId, organizationId, filterColumn, filterValue, sortColumn, startRowIndex, maximumRows); return(result.SiteCollections); }
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); }
private void SaveItem() { if (!Page.IsValid) { return; } if (this.SiteCollectionId == 0) { if (this.userSelector.GetAccount() == null) { localMessageBox.ShowWarningMessage("HOSTEDSHAREPOINT_NO_USERS"); return; } // new item try { item = new SharePointSiteCollection(); if (!UseSharedSLL(PanelSecurity.PackageId)) { SharePointSiteCollectionListPaged existentSiteCollections = ES.Services.HostedSharePointServers.GetSiteCollectionsPaged(PanelSecurity.PackageId, this.OrganizationId, "ItemName", String.Format("%{0}", this.domain.DomainName), 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, this.txtHostName.Text.ToLower() + "." + this.domain.DomainName)) { localMessageBox.ShowWarningMessage("HOSTEDSHAREPOINT_DOMAIN_IN_USE"); return; } } item.Name = this.txtHostName.Text.ToLower() + "." + this.domain.DomainName; } else { item.Name = string.Empty; } // get form data item.OrganizationId = this.OrganizationId; item.Id = this.SiteCollectionId; item.PackageId = PanelSecurity.PackageId; item.LocaleId = Int32.Parse(this.ddlLocaleID.SelectedValue); item.OwnerLogin = this.userSelector.GetSAMAccountName(); item.OwnerEmail = this.userSelector.GetPrimaryEmailAddress(); item.OwnerName = this.userSelector.GetDisplayName(); item.Title = txtTitle.Text; item.Description = txtDescription.Text; item.MaxSiteStorage = maxStorage.QuotaValue; item.WarningStorage = warningStorage.QuotaValue; int result = ES.Services.HostedSharePointServers.AddSiteCollection(item); if (result < 0) { localMessageBox.ShowResultMessage(result); return; } } catch (Exception ex) { localMessageBox.ShowErrorMessage("HOSTEDSHAREPOINT_ADD_SITECOLLECTION", ex); return; } } else { ES.Services.HostedSharePointServers.UpdateQuota(PanelRequest.ItemID, SiteCollectionId, editMaxStorage.QuotaValue, editWarningStorage.QuotaValue); } // return RedirectToSiteCollectionsList(); }