// Uncomment the method below to handle the event raised after a feature has been activated.

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWeb website = properties.Feature.Parent as SPWeb;

            FileInfo file;

            if (properties.Feature.TryLocateElementFile("app2.config", out file) == false)
            {
                throw new FileNotFoundException("element file file not found", "app2.config");
            }

            foreach (KeyValueConfigurationElement appSetting in file.AppSettings())
            {
                string fullkey = Setting.BuildWebSitePropertyKey(appSetting.Key);

                if (website.AllProperties.Contains(fullkey))
                {
                    website.SetProperty(fullkey, appSetting.Value);
                }
                else
                {
                    website.AddProperty(fullkey, appSetting.Value);
                }

                website.Update();
            }
        }
Exemplo n.º 2
0
        public KeywordSettings Save()
        {
            string value   = new JavaScriptSerializer().Serialize(this);
            SPWeb  rootWeb = SPContext.Current.Site.RootWeb;

            rootWeb.AllowUnsafeUpdates = true;
            if (rootWeb.AllProperties.ContainsKey("SharePresenceKeywordSettings"))
            {
                rootWeb.AllProperties["SharePresenceKeywordSettings"] = value;
            }
            else
            {
                rootWeb.AddProperty("SharePresenceKeywordSettings", value);
            }

            rootWeb.Update();
            rootWeb.AllowUnsafeUpdates = false;
            return(this);
        }