public static GetSite ( string subscriptionId, string website ) : Site | ||
subscriptionId | string | |
website | string | |
return | Site |
private static Site GetFromCache(IWebSiteManagementClient client, string website) { Site site = Cache.GetSite(client.Credentials.SubscriptionId, website); if (site != null) { // Verify site still exists try { WebSiteGetParameters input = new WebSiteGetParameters(); input.PropertiesToInclude.Add("repositoryuri"); input.PropertiesToInclude.Add("publishingpassword"); input.PropertiesToInclude.Add("publishingusername"); return(client.WebSites.Get(site.WebSpace, site.Name, input).ToSite()); } catch { // Website is removed or webspace changed, remove from cache Cache.RemoveSite(client.Credentials.SubscriptionId, site); throw; } } return(null); }
public static Site GetSiteWithCache( this IWebsitesServiceManagement proxy, string subscriptionId, string website, string propertiesToInclude) { // Try to get the website's webspace from the cache Site site = Cache.GetSite(subscriptionId, website, propertiesToInclude); if (site != null) { try { return(proxy.GetSite(subscriptionId, site.WebSpace, site.Name, propertiesToInclude)); } catch { // The website is removed or it's webspace changed. Cache.RemoveSite(subscriptionId, site); throw; } } // Get all available webspace using REST API WebSpaces webspaces = proxy.GetWebSpaces(subscriptionId); // Iterate over all the webspaces until finding the website. foreach (WebSpace webspace in webspaces) { Sites websites = proxy.GetSites(subscriptionId, webspace.Name, propertiesToInclude); var matchWebsite = websites.FirstOrDefault(w => w.Name.Equals(website, System.StringComparison.InvariantCultureIgnoreCase)); if (matchWebsite != null) { return(matchWebsite); } } // The website does not exist. return(null); }