/// <summary> /// 获取某业务类型下所有的下拉框 /// </summary> /// <param name="type"></param> /// <returns></returns> public static DataView getEnumDisplayNameList(businessType type) { object businessType = WebCache.Get("FileCache-businessType"); if (businessType == null) { #region 初始化枚举数据 DataTable dtData = new DataTable(); dtData.Columns.Add("type", typeof(string)); dtData.Columns.Add("name", typeof(string)); dtData.Columns.Add("value", typeof(int)); dtData.Rows.Add(new object[] { "productType", 0, "实体商品" }); dtData.Rows.Add(new object[] { "productType", 1, "卡密商品" }); dtData.Rows.Add(new object[] { "productType", 2, "游戏商品" }); dtData.Rows.Add(new object[] { "productStatus", 0, "正常" }); dtData.Rows.Add(new object[] { "productStatus", 1, "下架" }); WebCache.Max("FileCache-businessType", dtData, new CacheDependency("businessType")); #endregion } DataTable dataTable = businessType as DataTable; DataView dvResult = new DataView(dataTable, string.Format("type='{0}' "), type.ToString() , DataViewRowState.CurrentRows); return(dvResult); }
/// <summary> /// 获取网站配置 /// </summary> /// <param name="cacheable">是否使用缓存读取</param> public static SiteSettings GetMasterSettings(bool cacheable = true) { if (!cacheable) { WebCache.Remove("FileCache-MasterSettings"); } XmlDocument document = WebCache.Get("FileCache-MasterSettings") as XmlDocument; if (document == null) { string masterSettingsFilename = GetMasterSettingsFilename(); if (!File.Exists(masterSettingsFilename)) { return(null); } document = new XmlDocument(); document.Load(masterSettingsFilename); if (cacheable) { WebCache.Max("FileCache-MasterSettings", document, new CacheDependency(masterSettingsFilename)); } } return(SiteSettings.FromXml(document)); }
/// <summary> /// 设置缓存. /// </summary> /// <param name="key">缓存关键字.</param> /// <param name="ocache">需要缓存的对像.</param> public void SetCache(string key, object ocache) { WebCache.Max(key, ocache); }
/// <summary> /// 设置缓存. /// </summary> /// <param name="ocache">需要缓存的对像.</param> public void SetCache(object ocache) { WebCache.Max(CacheKey, ocache); }