/// <summary> /// Check SPS/STS site /// </summary> /// <param name="portalUrl"></param> public void CheckSite(string portalUrl) { using (SPGlobalAdmin gAdm = new SPGlobalAdmin()) { SPVirtualServer vSrv = gAdm.OpenVirtualServer(new Uri(portalUrl)); if (vSrv.Sites.Count >= 0) { m_CurrentStatus = eCheckStatus.Passed; return; } m_CurrentStatus = eCheckStatus.Warning; } }
/// <summary> /// Run find&replace process on root of the specified site (or site collection) /// </summary> /// <param name="sharePointSiteURL"></param> public void FindReplace(string sharePointSiteURL) { SPSite site = null; SPWeb web = null; m_IsCanceled = false; m_IsCanceling = false; try { site = new SPSite(sharePointSiteURL); web = site.OpenWeb(); web.AllowUnsafeUpdates = true; if (web.WebTemplate == "SPS") { if (m_Parameters.IncludeSubSites) { SPGlobalAdmin gAdm = new SPGlobalAdmin(); SPVirtualServer vSrv = gAdm.OpenVirtualServer(new Uri(sharePointSiteURL)); foreach (SPSite Site in vSrv.Sites) { web = Site.OpenWeb(); FindReplaceWebs(web); } } else { FindReplaceWebs(web); } } else { FindReplaceWebs(web); } } catch (Exception ex) { OnError(ex, "FindReplaceComponent.FindReplace"); } finally { if (web != null) { web.Close(); web.Dispose(); web = null; } } }
/// <summary> /// Return an specified site accoding to URL /// </summary> /// <param name="siteURL"></param> /// <returns></returns> public SPWeb GetSite(string portalURL, string siteURL) { SPWeb ResultSite = null; SPGlobalAdmin gAdm = new SPGlobalAdmin(); SPVirtualServer vSrv = gAdm.OpenVirtualServer(new Uri(portalURL)); foreach (SPSite site in vSrv.Sites) { if (site.Url.ToLower() == siteURL.ToLower()) { ResultSite = site.RootWeb; break; } } return(ResultSite); }
/// <summary> /// Prepare child sites of sharepoint portal /// </summary> /// <param name="sharePointSiteURL"></param> protected void PreparePortalSites(string sharePointSiteURL) { using (SPGlobalAdmin gAdm = new SPGlobalAdmin()) { SPVirtualServer vSrv = gAdm.OpenVirtualServer(new Uri(sharePointSiteURL)); for (int i = 0; i < vSrv.Sites.Count; i++) { using (SPSite Site = vSrv.Sites[i]) { using (SPWeb web = Site.OpenWeb()) { m_SitesQueue.Enqueue(web.Url.ToString()); } } } GC.Collect(); GC.WaitForPendingFinalizers(); } }
public void TestDeleteSPSite() { string result = result = RunBuild(String.Format(CultureInfo.InvariantCulture, _xmlProjectTemplate, _newSPSiteUrl, "true")); SPGlobalAdmin globalAdmin = new SPGlobalAdmin(); System.Uri uri = new System.Uri(_newSPSiteServerUrl); SPVirtualServer vs = globalAdmin.OpenVirtualServer(uri); bool siteWasDeleted = true; foreach (SPSite site in vs.Sites) { if (site.RootWeb.Title.Equals(_newSPSiteTitle)) { siteWasDeleted = false; } } Assertion.Assert("The site was not deleted.", siteWasDeleted); }
/// <summary> /// Get portal website /// </summary> /// <returns></returns> public SPWeb GetPortalSite(string portalUrl) { SPWeb PortalWeb = null; using (SPGlobalAdmin gAdm = new SPGlobalAdmin()) { SPVirtualServer vSrv = gAdm.OpenVirtualServer(new Uri(portalUrl)); for (int i = 0; i < vSrv.Sites.Count; i++) { using (SPSite site = vSrv.Sites[i]) { if (site.RootWeb.WebTemplate == "SPS") { PortalWeb = site.RootWeb; break; } } } } return(PortalWeb); }
public void TestCreateSPSiteInvalidUrlWithoutFailOnError() { string[] parameters = new string[] { "false", "foo", _newSPSiteAbbreviation, _newSPSiteTitle, _newSPSiteDescription, _newSPSiteTemplate, _newSPSiteManagedPath, _newSPSiteOwnerLogin, _newSPSiteOwnerName, _newSPSiteOwnerEmail, _newSPSiteContactLogin, _newSPSiteContactName, _newSPSiteContactEmail, }; string result = result = RunBuild(String.Format( CultureInfo.InvariantCulture, _xmlProjectTemplate, parameters)); SPGlobalAdmin globalAdmin = new SPGlobalAdmin(); System.Uri uri = new System.Uri(_newSPSiteServerUrl); SPVirtualServer vs = globalAdmin.OpenVirtualServer(uri); bool siteWasCreated = false; foreach (SPSite site in vs.Sites) { if (site.RootWeb.Title.Equals(_newSPSiteTitle)) { siteWasCreated = true; } } Assertion.Assert("The site was not created.", !siteWasCreated); }