コード例 #1
0
ファイル: DbHelper.cs プロジェクト: hezhangxi/rms
 /// <summary>
 /// 构造函数,初始化类实例
 /// </summary>
 public DbHelper()
 {
     try
     {
         bool   tempConStringEncrypt = Convert.ToBoolean(ConfigurationManager.AppSettings["ConStringEncrypt"]);
         string tempConString        = string.Empty;
         if (tempConStringEncrypt == true)
         {
             tempConString  = ConfigurationManager.AppSettings["ConCiphertextString"].ToString();
             this.ConString = DbEncrypt.DESDecrypt(tempConString, "SIMByZMM");
         }
         else
         {
             this.ConString = ConfigurationManager.AppSettings["ConExpresslyString"].ToString();
         }
         this.mySqlConnection = new SqlConnection(this.ConString);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #2
0
ファイル: PubConstant.cs プロジェクト: hezhangxi/rms
 /// <summary>
 /// 获取连接字符串
 /// </summary>
 private static string GetConnectionString()
 {
     try
     {
         bool   tempConStringEncrypt = Convert.ToBoolean(ConfigurationManager.AppSettings["ConStringEncrypt"]);
         string returnConString = string.Empty, tempConString = string.Empty;
         if (tempConStringEncrypt == true)
         {
             tempConString = ConfigurationManager.AppSettings["ConCiphertextString"].ToString();
             AssemblyAttribute tempAACall = new AssemblyAttribute();
             string            tempKey    = tempAACall.AssemblyDescription + "By" + tempAACall.AssemblyCompany;
             returnConString = DbEncrypt.DESDecrypt(tempConString, tempKey);
         }
         else
         {
             returnConString = ConfigurationManager.AppSettings["ConExpresslyString"].ToString();
         }
         return(returnConString);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }