From d53e6af2c5f17838fa79659614b15a2a1f383399 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期五, 31 三月 2023 10:04:58 +0800 Subject: [PATCH] 1 --- Crabtree/SmartHome/HDL/Common/HttpUtil/HttpUtil.cs | 88 +++++++++++++++++++++++++++++++++----------- 1 files changed, 66 insertions(+), 22 deletions(-) diff --git a/Crabtree/SmartHome/HDL/Common/HttpUtil/HttpUtil.cs b/Crabtree/SmartHome/HDL/Common/HttpUtil/HttpUtil.cs index 8308e82..3b3f764 100644 --- a/Crabtree/SmartHome/HDL/Common/HttpUtil/HttpUtil.cs +++ b/Crabtree/SmartHome/HDL/Common/HttpUtil/HttpUtil.cs @@ -1,4 +1,10 @@ -锘縰sing System; +锘�/**鍙戝竷鐜 浣跨敤鍙戝竷鐜 鍙戝竷鐨勬寮忕鍚岾EY**/ +#define Distribution + +///**娴嬭瘯鐜 浣跨敤娴嬭瘯鐜 浣跨敤娴嬭瘯鐨勭鍚岾EY**/ +//#undef Distribution + +using System; using System.Collections.Generic; using System.Linq; using System.Net; @@ -7,6 +13,8 @@ //using HDL_ON.Entity; using RestSharp; using Shared.SimpleControl; + + namespace Shared { @@ -38,12 +46,46 @@ #endregion #region **********缃戠粶璇锋眰灏佽********** + + + + +#if Distribution + ///**********姝e紡鐜********** /// <summary> /// 鍥哄畾鍩熷悕,姝e紡鐜 /// 鍏叡鍩熷悕灏辫繎瑙f瀽 /// </summary> - //public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com"; +#if DEBUG1 public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com"; +#else + public const string GlobalRequestHttpsHost = "https://bahrain-gateway.hdlcontrol.com"; +#endif + /// <summary> + /// + /// </summary> + const string APP_KEY = "HDL-HOME-IND-APP"; + /// <summary> + /// + /// </summary> + const string SECRET_KEY = "yPL345bn68gHnvilG4tYbq3cTYkiHu"; + +#else + ///**********娴嬭瘯鐜********** + /// <summary> + /// 鍥哄畾鍩熷悕,娴嬭瘯澧� + /// 鍏叡鍩熷悕灏辫繎瑙f瀽 + /// </summary> + public const string GlobalRequestHttpsHost = "https://china-gateway.hdlcontrol.com"; + /// <summary> + /// + /// </summary> + const string APP_KEY = "HDL-APP-TENANT"; + /// <summary> + /// + /// </summary> + const string SECRET_KEY = "CeL345bn28gHnvi9G4tYcq3cTYkiiC"; +#endif /// <summary> /// Get 璇锋眰鏈嶅姟鍣ㄦ柟娉� @@ -151,7 +193,7 @@ /// <returns></returns> static ResponsePackNew RequestHttpsBase (Method method, string apiPath, string bodyParameterJson = null, Dictionary<string, object> queryDictionary = null, Dictionary<string, object> urlSegmentDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = 10) { - #region HttpWebRequest +#region HttpWebRequest try { if (string.IsNullOrEmpty (urlHead)) { @@ -179,7 +221,7 @@ } if (bodyParameterJson != null) { - request.AddParameter ("application/json", bodyParameterJson, ParameterType.RequestBody); + request.AddParameter ("application/json", bodyParameterJson, ParameterType.RequestBody); } if (queryDictionary != null) { @@ -224,7 +266,7 @@ return new ResponsePackNew () { Code = StateCode.NETWORK_ERROR }; } - #endregion +#endregion } @@ -295,7 +337,7 @@ /// <returns></returns> public static byte [] RequestHttpsDownload (string apiPath, string bodyParameterJson = null, Dictionary<string, object> queryDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = 20) { - #region RestRequest +#region RestRequest try { if (string.IsNullOrEmpty (urlHead)) { urlHead = GlobalRequestHttpsHost; @@ -335,7 +377,7 @@ Utlis.WriteLine (ex.Message); return null; } - #endregion +#endregion } @@ -353,7 +395,7 @@ /// <returns></returns> public static ResponsePackNew RequestHttpsUpload (Method method, string apiPath, object bodyParameterObject = null, Dictionary<string, object> queryDictionary = null, Dictionary<string, object> urlSegmentDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = 20) { - #region HttpWebRequest +#region HttpWebRequest try { if (string.IsNullOrEmpty (urlHead)) { @@ -420,7 +462,7 @@ return new ResponsePackNew () { Code = StateCode.NETWORK_ERROR }; } - #endregion +#endregion } @@ -436,7 +478,7 @@ /// <returns></returns> public static byte [] HttpsDownload (string requestFullUrl, int mTimeout = 30) { - #region RestRequest +#region RestRequest try { RestClient client = new RestClient (requestFullUrl); RestRequest request = new RestRequest (Method.GET); @@ -448,21 +490,23 @@ Utlis.WriteLine (ex.Message); return null; } - #endregion +#endregion } - #endregion +#endregion - #region **********绛惧悕鏍¢獙********** - /// <summary> - /// - /// </summary> - const string APP_KEY = "HDL-HOME-APP-TEST"; - /// <summary> - /// - /// </summary> - const string SECRET_KEY = "WeJ8TY88vbakCcnvH8G1tDUqzLWY8yss"; +#region **********绛惧悕鏍¢獙********** + ///// <summary> + ///// + ///// </summary> + //const string APP_KEY = "HDL-HOME-APP-TEST"; + ///// <summary> + ///// + ///// </summary> + //const string SECRET_KEY = "WeJ8TY88vbakCcnvH8G1tDUqzLWY8yss"; + + /// <summary> /// 鑾峰彇褰撳墠鏃堕棿鎴冲�� @@ -554,7 +598,7 @@ } } - #endregion +#endregion } /// <summary> -- Gitblit v1.8.0