コード例 #1
0
ファイル: SysConfig.cs プロジェクト: vinilin/SYTD
 private void UpdatePwdEncrypt(string connString)
 {
     string result = "";
     try
     {
         XmlDocument xmlDoc = new XmlDocument();
         xmlDoc.Load(HttpContext.Current.Server.MapPath(HttpRuntime.AppDomainAppVirtualPath) + "/web.Config");
         //xmlDoc.Load("../web.Config");
         XmlNode configurationNode = xmlDoc.SelectSingleNode("configuration");
         XmlNode appSettingsNode = configurationNode.SelectSingleNode("appSettings");
         XmlNodeList addNodes = appSettingsNode.SelectNodes("add");
         foreach (XmlNode i in addNodes)
         {
             if (i.Attributes["key"].Value.ToString().ToUpper() == "WEBSERVICELINKPWD")
             {
                 EncryptDES en = new EncryptDES();
                 result = en.EncryptString(connString);
                 i.Attributes["value"].Value = result;
                 xmlDoc.Save(HttpContext.Current.Server.MapPath(HttpRuntime.AppDomainAppVirtualPath) + "/web.Config");
             }
         }
     }
     catch (Exception ex)
     {
         Log.LogError(ex.ToString(), "修改配置文件");
     }
 }
コード例 #2
0
ファイル: SysConfig.cs プロジェクト: vinilin/SYTD
 public string GetWebServiceLinkPwd()
 {
     string result = "";
     try
     {
         result = GetValueByKey("WebServiceLinkPwd");
         if (!result.ToUpper().StartsWith("9999999999"))
         {
             UpdatePwdEncrypt(result);
         }
         else
         {
             EncryptDES en = new EncryptDES();
             result = en.DecryptString(result);
         }
     }
     catch (ConfigurationException ex)
     {
         Log.LogError(ex.Message, "获取WEBSERVICE连接密码字符串");
     }
     return result;
 }