private IPersistenceProvider GetPersistenceProvider(XmlNodeReader node) { string dbName = node.GetAttribute("name"); string dbType = node.GetAttribute("type"); IPersistenceProvider rdb = null; if (dbName != null) { if (dbType == null || dbType == "") { Assert.Fail(Error.NoSupportDatabase); } else { string dbClassName = GetDbClassName(dbType); try { rdb = (IPersistenceProvider)this.GetType().Assembly.CreateInstance(dbClassName); if (rdb == null) { throw new Exception(); } } catch { Assert.Fail(Error.DatabaseConnectError); } } rdb.Name = dbName; this.m_DatabaseMaps.Add(dbName, new DatabaseMap(dbName)); int i = node.Depth; string pName = ""; string pValue = ""; string connectionString = ""; string strPassword = ""; bool blnEncrypt = false; string strEncryptClass = ""; while (node.Read() && node.Depth > i) { if ((node.NodeType == XmlNodeType.Element) && (node.Name == "parameter")) { pName = node.GetAttribute("name"); pValue = node.GetAttribute("value"); if ((pName != null) && (pValue != null)) { if (pName.ToLower() == "password") { strPassword = pValue; } else if (pName.ToLower() == "encrypt") { blnEncrypt = true; strEncryptClass = pValue; } else { connectionString += pName + "=" + pValue + ";"; } //add window verification processing if (pName.ToLower() == "windows connection") { blnEncrypt = false; connectionString = pValue; break; } } } } if (blnEncrypt) { if (strEncryptClass.Equals("")) { BaseEncryptClass baseEncry = new BaseEncryptClass(); pValue = baseEncry.Decrypt(strPassword); } else { try { BaseEncryptClass baseEncry = (BaseEncryptClass)LoadType(strEncryptClass).Assembly.CreateInstance(strEncryptClass); pValue = baseEncry.Decrypt(strPassword); } catch (Exception) { Assert.Fail("Load custom decryption function" + strEncryptClass + "Error,Please check if the decryption function exists!!!"); } } //Access if (dbType == "MSAccess") { connectionString += string.Format("Jet OLEDB:Database Password={0}", pValue); } else { connectionString += "password="******";"; } } rdb.Initialize(connectionString); } return(rdb); }
/// <summary> /// ×Ö·û´®¼ÓÃÜ /// </summary> /// <param name="ostr"></param> /// <returns></returns> public static string Encrypt(string ostr) { BaseEncryptClass class2 = new BaseEncryptClass(); return(class2.Encrypt(ostr)); }
public static string Encrypt(string ostr) { BaseEncryptClass baseEncryptClass = new BaseEncryptClass(); return(baseEncryptClass.Encrypt(ostr)); }
/// <summary> /// ×Ö·û´®½âÃÜ /// </summary> /// <param name="estr"></param> /// <returns></returns> public static string Decrypt(string estr) { BaseEncryptClass class2 = new BaseEncryptClass(); return(class2.Decrypt(estr)); }
public static string Decrypt(string estr) { BaseEncryptClass baseEncryptClass = new BaseEncryptClass(); return(baseEncryptClass.Decrypt(estr)); }