public bool SaveConfig(BaseConfig_DT model, int DT_id) { //return SerializationHelper.Save(model, this.xmlpath); Type type = model.GetType(); Lebi_DT_Config cf; foreach (System.Reflection.PropertyInfo p in type.GetProperties()) { if (p.GetValue(model, null) == null) { continue; } cf = B_Lebi_DT_Config.GetModel("DT_id = " + DT_id + " and Name='" + p.Name + "'"); if (cf == null) { cf = new Lebi_DT_Config(); cf.Name = p.Name; cf.Value = p.GetValue(model, null).ToString(); cf.DT_id = DT_id; B_Lebi_DT_Config.Add(cf); } else { cf.Name = p.Name; cf.Value = p.GetValue(model, null).ToString(); B_Lebi_DT_Config.Update(cf); } } ShopCache.SetBaseConfig(DT_id);//更新缓存 return(true); }
/// <summary> /// 获取一个设置值 /// </summary> /// <param name="key"></param> /// <returns></returns> public static string Get(string key) { Lebi_DT_Config conf = B_Lebi_DT_Config.GetModel("DT_id = " + ShopPage.GetDT() + " and Name='" + key + "'"); if (conf == null) { return(""); } return(conf.Value); }
/// <summary> /// 设置一个设置值 /// </summary> /// <param name="key"></param> /// <param name="value"></param> public static void Set(string key, string value) { Lebi_DT_Config conf = B_Lebi_DT_Config.GetModel("DT_id = " + ShopPage.GetDT() + " and Name='" + key + "'"); if (conf == null) { conf = new Lebi_DT_Config(); conf.Name = key; conf.Value = value; B_Lebi_DT_Config.Add(conf); } else { conf.Value = value; B_Lebi_DT_Config.Update(conf); } }