/// <summary> /// 获取数据库连接字符串(<connectionStrings>节点) /// </summary> /// <param name="key"></param> /// <returns></returns> public static string GetConnString(string key) { var conn = ConfigurationManager.ConnectionStrings[key]; if (conn == null) { throw new Exception(EnumCommon.GetDescription(ConfigEnum.AppSetting)); } return(ConfigurationManager.ConnectionStrings[key].ConnectionString); }
/// <summary> /// 得到生肖 /// </summary> /// <param name="year">年</param> /// <returns></returns> public static string GetAnimalFromBirthday(int year) { List <string> animateList = EnumCommon.ToDictionary <AnimalEnum>().Select(x => x.Value).ToList(); int tmp = year - 2008; if (year < 2008) { return(animateList[tmp % 12 + 12]); } return(animateList[tmp % 12]); }
/// <summary> /// 得到密钥 /// </summary> /// <param name="key">用户输入密钥</param> /// <returns></returns> private static string FindEncryptKey(string key) { if (!string.IsNullOrEmpty(key)) { return(key);//用户输入秘钥 } if (!string.IsNullOrEmpty(AesEncryptionKey)) { return(AesEncryptionKey); } AesEncryptionKey = ConfigCommon.GetConfig(AesEncryptionKeyNamePresent); if (!string.IsNullOrEmpty(AesEncryptionKey)) { return(AesEncryptionKey); } throw new Exception(string.Format(EnumCommon.GetDescription(ConfigEnum.AppSetting), AesEncryptionKeyNamePresent)); }