/// <summary> /// 保存系统参数配置 /// </summary> /// <param name="type"></param> /// <param name="value"></param> /// <returns></returns> public bool SaveSetting(SystemSetting.SettingType type, string value) { using (DbExecutor db = NewExecutor(IsolationLevel.ReadUncommitted)) { SystemSetting setting = new SystemSetting() { Type = type, Value = value }; if (setting.Exists(db)) { setting.Update(db); } else { setting.Add(db); } db.AddCallback(() => { SystemCaching.Instance().SaveSetting(type, value); }); db.Commit(); } return(true); }
/// <summary> /// 获取系统的参数配置(Redis中读取,不存在则从数据库读取) /// </summary> /// <param name="type"></param> /// <returns></returns> protected string GetSetting(SystemSetting.SettingType type) { string value = SystemCaching.Instance().GetSetting(type); if (string.IsNullOrEmpty(value)) { value = this.ReadDB.ExecuteScalar <SystemSetting, string>(t => t.Value, t => t.Type == type); if (!string.IsNullOrEmpty(value)) { SystemCaching.Instance().SaveSetting(type, value); } } return(value); }
public Task SaveSetting([FromForm] SystemSetting.SettingType type, [FromForm] string value) { return(this.GetResult(SettingAgent.Instance().SaveSetting(type, value))); }
/// <summary> /// 保存设置信息 /// </summary> /// <param name="type"></param> /// <param name="value"></param> public void SaveSetting(SystemSetting.SettingType type, string value) { string key = $"{SETTING}{type}"; this.NewExecutor().StringSet(key, value.GetRedisValue()); }
/// <summary> /// 获取配置信息 /// </summary> /// <param name="type"></param> /// <returns></returns> public string GetSetting(SystemSetting.SettingType type) { string key = $"{SETTING}{type}"; return(this.NewExecutor().StringGet(key).GetRedisValue <string>()); }
/// <summary> /// 获取系统配置 /// </summary> /// <param name="type"></param> /// <returns></returns> public new string GetSetting(SystemSetting.SettingType type) { return(base.GetSetting(type)); }