Пример #1
0
        public static bool Set(SettingFlag flag, string value)
        {
            var key = flag.ToString();

            using (var DB = new SSMMEntities())
            {
                var val = DB.Setting.FirstOrDefault(x => x.Key == key);
                if (val != null)
                {
                    if (val.Value == value)
                    {
                        return(true);
                    }
                    val.Value = value;
                }
                else
                {
                    DB.Setting.Add(new Setting()
                    {
                        Key   = key,
                        Value = value
                    });
                }
                if (DB.SaveChanges() > 0)
                {
                    SettingCache.Cache.UpdateCacheValue(key);
                    return(true);
                }
                return(false);
            }
        }
        /// <summary>
        /// 获取数据
        /// </summary>
        public string Get(SettingFlag flag)
        {
            var key = flag.ToString();
            var dto = GetValue(key);

            if (dto != null)
            {
                return(dto.Value);
            }
            else
            {
                return("");
            }
        }