예제 #1
0
        /// <summary>
        /// Checks if a site collection exists
        /// </summary>
        /// <param name="web">Tenant admin web</param>
        /// <param name="siteUrl">URL to the site collection</param>
        /// <returns>True if existing, false if not</returns>
        public static bool DoesSiteExistInTenant(this Web web, string siteUrl)
        {
            try
            {
                return(web.CheckIfSiteExistsInTenant(siteUrl, SITE_STATUS_ACTIVE) ||
                       web.CheckIfSiteExistsInTenant(siteUrl, SITE_STATUS_CREATING) ||
                       web.CheckIfSiteExistsInTenant(siteUrl, SITE_STATUS_RECYCLED));
            }
            catch (Exception ex)
            {
                if (ex is Microsoft.SharePoint.Client.ServerException && (ex.Message.IndexOf("Unable to access site") != -1 || ex.Message.IndexOf("Cannot get site") != -1))
                {
                    return(true);
                }
                else
                {
                    LoggingUtility.LogError("Could not determine if site exists in tenant.", ex, EventCategory.Site);
                }

                return(false);
            }
        }
예제 #2
0
 /// <summary>
 /// Checks if a site collection is Active
 /// </summary>
 /// <param name="web">Site to be processed - can be root web or sub site</param>
 /// <param name="siteUrl">URL to the site collection</param>
 /// <returns>True if active, false if not</returns>
 public static bool IsSiteActiveTenant(this Web web, string siteUrl)
 {
     try
     {
         return(web.CheckIfSiteExistsInTenant(siteUrl, "Active"));
     }
     catch (Exception ex)
     {
         if (ex.Message.StartsWith("Cannot get site"))
         {
             return(false);
         }
         LoggingUtility.LogError("Error finding if site is active tenant.", ex, EventCategory.Site);
         throw;
     }
 }
예제 #3
0
 /// <summary>
 /// Checks if a sub site exists
 /// </summary>
 /// <param name="web">Tenant admin web</param>
 /// <param name="siteUrl">URL to the sub site</param>
 /// <returns>True if existing, false if not</returns>
 public static bool SubSiteExistsInTenant(this Web web, string siteUrl)
 {
     try
     {
         return(web.CheckIfSiteExistsInTenant(siteUrl, ""));
     }
     catch (Exception ex)
     {
         if (ex is Microsoft.SharePoint.Client.ServerException && (ex.Message.IndexOf("Unable to access site") != -1 || ex.Message.IndexOf("Cannot get site") != -1))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }