/// <summary>
/// 获取充值类型和游戏名称 列表
/// 带缓存
/// </summary>
public DataSet GetSysTxTypesNameAndSericeNameByCache()
{
DataSet dsTypesList = new DataSet();
string strUseCache = ConfigurationManager.AppSettings["Flash.UserControl.FlashHot.UseCache"];
int iCacheTime = Int32.Parse(ConfigurationManager.AppSettings["Flash.UserControl.FlashHot.CacheTime"]);
string strCacheKey = "cache_sysTxTpesName_serviceName_by_cache";
if (strUseCache.ToLower() == "true")
{
//从缓存中读取
dsTypesList=(DataSet)System.Web.HttpContext.Current.Cache[strCacheKey];
}
SysTxTypesBLL sysTxTypesBLL = new SysTxTypesBLL();
//计算排名
if (dsTypesList == null)
{
dsTypesList = sysTxTypesBLL.GetSysConfigNameList();
if (dsTypesList == null)
{
return null;
}
if (strUseCache.ToLower() == "true")
{
//写入缓存
System.Web.HttpContext.Current.Cache.Insert(strCacheKey, dsTypesList, null, DateTime.Now.AddSeconds(iCacheTime), System.Web.Caching.Cache.NoSlidingExpiration);
}
}
if (dsTypesList.Tables.Count<= 0)
{
return null;
}
return dsTypesList;
}
//=============该函数直接调用即可===============//
/// <summary>
/// 根据充值类型Code查询Name (该函数不访问数据库)
/// </summary>
/// <param name="typeCode">充值类型Code</param>
/// <returns></returns>
public static string GetTypesNameByTypeCode(string typeCode)
{
if (!string.IsNullOrEmpty(typeCode))
{
TranscationBLL transcationBLL = new TranscationBLL();
//2、获取系统配置名称(code对应的name,数据库Db_corebilling)
DataTable dbTxTypeName = new DataTable();//充值类型
DataSet dsTypesList = transcationBLL.GetSysTxTypesNameAndSericeNameByCache();
if (dsTypesList != null && dsTypesList.Tables.Count > 1)
{
dbTxTypeName = dsTypesList.Tables[0];
}
Dictionary<string, string> dic = new Dictionary<string, string>();
if (dbTxTypeName != null && dbTxTypeName.Rows.Count > 0)
{
for (int i = 0; i < dbTxTypeName.Rows.Count; i++)
{
if (dbTxTypeName.Rows[i]["tx_type_code"] != null && dbTxTypeName.Rows[i]["tx_type_name"] != null)
{
dic.Add(dbTxTypeName.Rows[i]["tx_type_code"].ToString(), dbTxTypeName.Rows[i]["tx_type_name"].ToString());
}
}
}
return dic[typeCode].ToString();
}
else
{
return "";
}
}