示例#1
0
            private static void SetSiteConfiguration(String key, String value)
            {
                Data.Guid guid = CurrentSite.Guid;

                SiteConfigurationDao dao = new SiteConfigurationDao();
                SiteConfiguration result = dao.FindByKey(guid, key);
                if (result == null)
                    result = new SiteConfiguration();

                result.Name = key;
                result.Value = value;
                result.SubscriptionGuid = guid.Value;
                using (Transaction tx = new Transaction())
                {
                    dao.Save<SiteConfiguration>(result);
                    tx.Commit();
                }

                Cache.Clear(key);
                Cache.Add(key, value);
            }
示例#2
0
            private static String GetSiteConfiguration(String key, String def, Boolean required)
            {
                String value = Cache.Get<String>(key);
                if (value == null)
                {
                    Data.Guid guid = CurrentSite.Guid;
                    SiteConfigurationDao dao = new SiteConfigurationDao();

                    Gooeycms.Data.Model.SiteConfiguration result = dao.FindByKey(guid, key);
                    value = def;
                    if (result != null)
                        value = result.Value;

                    if ((required) && (String.IsNullOrEmpty(value)))
                        throw new ArgumentNullException("The configuration value for the site:" + guid + " and key " + key + " has not been set. This value is required for the site to function properly.");

                    Cache.Add(key, value);
                }
                return value;
            }