Esempio n. 1
0
        /// <summary>
        /// Sets a connection string for a website.
        /// </summary>
        /// <param name="name">Name of the website.</param>
        /// <param name="key">Connection string key.</param>
        /// <param name="value">Value for the connection string.</param>
        /// <param name="connectionStringType">Type of connection string.</param>
        public void SetConnectionString(string name, string key, string value, DatabaseType connectionStringType)
        {
            Site       website       = GetWebsite(name);
            SiteConfig configuration = WebsiteChannel.GetSiteConfig(
                subscriptionId, website.WebSpace, website.Name);

            var index = configuration.ConnectionStrings.FindIndex(cs => cs.Name.Equals(key, StringComparison.OrdinalIgnoreCase));

            if (index == -1)
            {
                configuration.ConnectionStrings.Add(new ConnStringInfo()
                {
                    Name             = key,
                    ConnectionString = value,
                    Type             = connectionStringType
                });
            }
            else
            {
                configuration.ConnectionStrings[index].ConnectionString = value;
                configuration.ConnectionStrings[index].Type             = connectionStringType;
            }

            WebsiteChannel.UpdateSiteConfig(subscriptionId, website.WebSpace, website.Name, configuration);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds an AppSetting of a website.
        /// </summary>
        /// <param name="name">The website name</param>
        /// <param name="key">The app setting name</param>
        /// <param name="value">The app setting value</param>
        public void AddAppSetting(string name, string key, string value)
        {
            Site       website       = GetWebsite(name);
            SiteConfig configuration = WebsiteChannel.GetSiteConfig(
                SubscriptionId,
                website.WebSpace,
                website.Name);

            configuration.AppSettings.Add(new NameValuePair()
            {
                Name = key, Value = value
            });
            WebsiteChannel.UpdateSiteConfig(SubscriptionId, website.WebSpace, website.Name, configuration);
        }
Esempio n. 3
0
        private void SetSiteDiagnosticsSettings(
            string name,
            bool webServerLogging,
            bool detailedErrorMessages,
            bool failedRequestTracing,
            bool setFlag)
        {
            Site       website       = GetWebsite(name);
            SiteConfig configuration = WebsiteChannel.GetSiteConfig(
                subscriptionId,
                website.WebSpace,
                website.Name);

            configuration.HttpLoggingEnabled          = webServerLogging ? setFlag : configuration.HttpLoggingEnabled;
            configuration.DetailedErrorLoggingEnabled = detailedErrorMessages ? setFlag :
                                                        configuration.DetailedErrorLoggingEnabled;
            configuration.RequestTracingEnabled = failedRequestTracing ? setFlag : configuration.RequestTracingEnabled;

            WebsiteChannel.UpdateSiteConfig(subscriptionId, website.WebSpace, website.Name, configuration);
        }
Esempio n. 4
0
        /// <summary>
        /// Sets an AppSetting of a website.
        /// </summary>
        /// <param name="name">The website name</param>
        /// <param name="key">The app setting name</param>
        /// <param name="value">The app setting value</param>
        public void SetAppSetting(string name, string key, string value)
        {
            Site       website       = GetWebsite(name);
            SiteConfig configuration = WebsiteChannel.GetSiteConfig(
                subscriptionId,
                website.WebSpace,
                website.Name);

            int index = GetAppSettingIndex(name, key);

            if (index != -1)
            {
                configuration.AppSettings[index].Value = value;
            }
            else
            {
                configuration.AppSettings.Add(new NameValuePair()
                {
                    Name = key, Value = value
                });
            }

            WebsiteChannel.UpdateSiteConfig(subscriptionId, website.WebSpace, website.Name, configuration);
        }