增加网站配置类,万仕达接口加密key从配置读取
This commit is contained in:
		
							parent
							
								
									bb286f8f58
								
							
						
					
					
						commit
						817e244ee9
					
				@ -76,7 +76,7 @@ namespace Cmdjy.Bll
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static DesHelper GetHelper() {
 | 
			
		||||
            if(_deshelper == null) {
 | 
			
		||||
                var key = "";
 | 
			
		||||
                var key = WebSettings.DesKey;
 | 
			
		||||
                byte[] IV = { 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08 };
 | 
			
		||||
                _deshelper = GetHelper(PaddingMode.PKCS7,CipherMode.CBC,IV,key);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -165,6 +165,7 @@
 | 
			
		||||
      <DependentUpon>Global.asax</DependentUpon>
 | 
			
		||||
    </Compile>
 | 
			
		||||
    <Compile Include="Properties\AssemblyInfo.cs" />
 | 
			
		||||
    <Compile Include="WebSettings.cs" />
 | 
			
		||||
    <Compile Include="ws\HisInterface.asmx.cs">
 | 
			
		||||
      <DependentUpon>HisInterface.asmx</DependentUpon>
 | 
			
		||||
      <SubType>Component</SubType>
 | 
			
		||||
 | 
			
		||||
@ -13,6 +13,10 @@
 | 
			
		||||
    <add key="webpages:Enabled" value="false" />
 | 
			
		||||
    <add key="ClientValidationEnabled" value="true" />
 | 
			
		||||
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
 | 
			
		||||
 | 
			
		||||
    <!--双方协商,需要8位长度,超过8位取8位,小于8位抛出异常-->
 | 
			
		||||
    <add key="DesKey" value="wsddjy19"/>
 | 
			
		||||
    
 | 
			
		||||
  </appSettings>
 | 
			
		||||
  <connectionStrings>
 | 
			
		||||
    <add name="DjyDbContext"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										27
									
								
								WebSiteCode/Cmdjy/Cmdjy/WebSettings.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								WebSiteCode/Cmdjy/Cmdjy/WebSettings.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,27 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
 | 
			
		||||
namespace Cmdjy
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// 网站配置
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class WebSettings
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 获取配置的值
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="key"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public static string GetValue(String key) {
 | 
			
		||||
            var val = ConfigurationManager.AppSettings[key];
 | 
			
		||||
            return val;
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 万仕达加密通信用的的加密key
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public static string DesKey {
 | 
			
		||||
            get => GetValue("DesKey") ?? throw new Exception("必须在web.config文件appSettings节配置DesKey的值");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user