wxr
2024-12-02 ea0b1e8e5f43c5fd0a7d479e25ede3b8cbea464a
HDL_ON/DAL/Server/HttpUtil.cs
@@ -12,25 +12,76 @@
{
    public class HttpUtil
    {
        static HttpUtil _HttpUtil;
        public static HttpUtil Ins
        {
            get
            {
                if (_HttpUtil == null)
                {
                    _HttpUtil = new HttpUtil();
                }
                return _HttpUtil;
            }
        }
        #region **********全局常量**********
        //public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com";
        //public const string APP_KEY = "QWERREWQ";
        //public const string SECRET_KEY = "CPBUCTRLCPBUABCD";
        string _GlobalRequestHttpsHost;
        /// <summary>
        /// 固定域名,正式环境
        /// 公共域名就近解析
        /// </summary>
        public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com";
        const string APP_KEY = "HDL-HOME-APP";
        const string SECRET_KEY = "CPL345bn28gHnvi9G4tYbq3cTYkiHC";
        public string GlobalRequestHttpsHost
        {
            get
            {
                _GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com";
                if (OnAppConfig.Instance.HostType == RequestHostType.ONLINE)
                    _GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com";
                else if (OnAppConfig.Instance.HostType == RequestHostType.TEST)
                    _GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";
                else if (OnAppConfig.Instance.HostType == RequestHostType.DEV)
                    _GlobalRequestHttpsHost = "http://59.41.255.150:7777";
                return _GlobalRequestHttpsHost;
            }
        }
        string app_key;
        public string APP_KEY
        {
            get
            {
                app_key = "QWERREWQ";
                if (OnAppConfig.Instance.HostType == RequestHostType.ONLINE)
                    app_key = "QWERREWQ";
                else if (OnAppConfig.Instance.HostType == RequestHostType.TEST)
                    app_key = "HDL-HOME-APP-TEST";
                else if (OnAppConfig.Instance.HostType == RequestHostType.DEV)
                    app_key = "CPEVRLRT";
                return app_key;
            }
        }
        string _SECRET_KEY;
        public string SECRET_KEY
        {
            get
            {
                _SECRET_KEY = "CPBUCTRLCPBUABCD";
                if (OnAppConfig.Instance.HostType == RequestHostType.ONLINE)
                    _SECRET_KEY = "CPBUCTRLCPBUABCD";
                else if (OnAppConfig.Instance.HostType == RequestHostType.TEST)
                    _SECRET_KEY = "WeJ8TY88vbakCcnvH8G1tDUqzLWY8yss";
                else if (OnAppConfig.Instance.HostType == RequestHostType.DEV)
                    _SECRET_KEY = "CPEVRLSJCPEVRLSZ";
                return _SECRET_KEY;
            }
        }
        //public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";
        //const string APP_KEY = "HDL-HOME-APP-TEST";
        //const string SECRET_KEY = "WeJ8TY88vbakCcnvH8G1tDUqzLWY8yss";
        //public const string GlobalRequestHttpsHost = "http://59.41.255.150:7777";//mmmm
        //const string APP_KEY = "CPEVRLRT";
        //const string SECRET_KEY = "CPEVRLSJCPEVRLSZ";
        /// <summary>
        /// RegionMark
        /// </summary>
@@ -165,13 +216,11 @@
            #region HttpWebRequest
            try
            {
                if (string.IsNullOrEmpty(urlHead))
                {
                    urlHead = OnAppConfig.Instance.RequestHttpsHost;
                }
                string requestFullUrl = urlHead + apiPath;
                RestClient client = new RestClient(requestFullUrl);
@@ -191,7 +240,6 @@
                {
                    request.AddHeader("Authorization", replaceToken); 
                }
           
                if (bodyParameterJson != null)
                {
@@ -611,7 +659,7 @@
                //2. 计算sign
                if (paramDictionary != null)
                {
                    paramDictionary.Add("appKey", APP_KEY);
                    paramDictionary.Add("appKey", Ins.APP_KEY);
                    paramDictionary.Add("timestamp", GetTimestamp());
                    //2.1 字典升序
                    paramDictionary = paramDictionary.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value);
@@ -642,7 +690,7 @@
                    }
                    //2.3 拼接SECRET_KEY
                    str = str.Substring(0, str.Length - 1) + SECRET_KEY;
                    str = str.Substring(0, str.Length - 1) + Ins.SECRET_KEY;
                    //2.4 MD5转换+转小写
                    var signstr = SignMD5Encrypt(str);
                    paramDictionary.Add("sign", signstr);