public IAsyncResult BeginSetDiagnosticsSettings(DiagnosticsSettings diagnosticsSettings, AsyncCallback callback, object state)
 {
     throw new NotImplementedException();
 }
        public override void ExecuteCmdlet()
        {
            if (CurrentSubscription == null)
            {
                throw new Exception(Resources.NoDefaultSubscriptionMessage);
            }

            if (!string.IsNullOrEmpty(Name))
            {
                // Show website
                Site websiteObject = RetryCall(s => Channel.GetSite(s, Name, "repositoryuri,publishingpassword,publishingusername"));
                if (websiteObject == null)
                {
                    throw new Exception(string.Format(Resources.InvalidWebsite, Name));
                }

                SiteConfig websiteConfiguration = null;
                InvokeInOperationContext(() =>
                {
                    websiteConfiguration = RetryCall(s => Channel.GetSiteConfig(s, websiteObject.WebSpace, websiteObject.Name));
                    WaitForOperation(CommandRuntime.ToString());
                });

                // Add to cache
                Cache.AddSite(CurrentSubscription.SubscriptionId, websiteObject);

                DiagnosticsSettings diagnosticsSettings = new DiagnosticsSettings();
                if (websiteObject.State == "Running")
                {
                    WebsitesClient = WebsitesClient ?? new WebsitesClient(CurrentSubscription, WriteDebug);

                    try
                    {
                        diagnosticsSettings = WebsitesClient.GetApplicationDiagnosticsSettings(Name);
                    }
                    catch
                    {
                        // Ignore the exception and use default values.
                    }
                }

                // Output results
                WriteObject(new SiteWithConfig(websiteObject, websiteConfiguration, diagnosticsSettings), false);
            }
            else
            {
                // Show websites
                WebSpaces webspaces = null;
                InvokeInOperationContext(() =>
                {
                    webspaces = RetryCall(s => Channel.GetWebSpaces(s));
                    WaitForOperation(CommandRuntime.ToString());
                });

                List<Site> websites = new List<Site>();
                foreach (var webspace in webspaces)
                {
                    InvokeInOperationContext(() =>
                    {
                        websites.AddRange(RetryCall(s => Channel.GetSites(s, webspace.Name, "repositoryuri,publishingpassword,publishingusername")));
                        WaitForOperation(CommandRuntime.ToString());
                    });
                }

                // Add to cache
                Cache.SaveSites(CurrentSubscription.SubscriptionId, new Sites(websites));

                // Output results
                WriteWebsites(websites);
            }
        }
        public SiteWithConfig(Site site, SiteConfig siteConfig)
        {
            Site = site;
            SiteConfig = siteConfig;
            AppSettings = new Hashtable();
            DiagnosticsSettings = new DiagnosticsSettings();

            if (SiteConfig.AppSettings != null)
            {
                foreach (var setting in SiteConfig.AppSettings)
                {
                    AppSettings[setting.Name] = setting.Value;
                }
            }
        }
 public SiteWithConfig(Site site, SiteConfig siteConfig, DiagnosticsSettings diagnosticsSettings)
     : this(site, siteConfig)
 {
     DiagnosticsSettings = diagnosticsSettings;
 }
 public SiteWithConfig()
 {
     Site = new Site();
     SiteConfig = new SiteConfig();
     AppSettings = new Hashtable();
     DiagnosticsSettings = new DiagnosticsSettings();
 }