| | |
| | | using System; |
| | | /**发布环境 使用发布环境 发布的正式签名KEY**/ |
| | | #define Distribution |
| | | |
| | | ///**测试环境 使用测试环境 使用测试的签名KEY**/ |
| | | //#undef Distribution |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Net; |
| | |
| | | //using HDL_ON.Entity; |
| | | using RestSharp; |
| | | using Shared.SimpleControl; |
| | | |
| | | |
| | | |
| | | namespace Shared |
| | | { |
| | |
| | | #endregion |
| | | |
| | | #region **********网络请求封装********** |
| | | |
| | | |
| | | |
| | | |
| | | #if Distribution |
| | | ///**********正式环境********** |
| | | /// <summary> |
| | | /// 固定域名,正式环境 |
| | | /// 公共域名就近解析 |
| | | /// </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> |
| | | /// 固定域名,测试境 |
| | | /// 公共域名就近解析 |
| | | /// </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 请求服务器方法 |
| | |
| | | /// <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)) { |
| | |
| | | return new ResponsePackNew () { Code = StateCode.NETWORK_ERROR }; |
| | | } |
| | | |
| | | #endregion |
| | | #endregion |
| | | |
| | | } |
| | | |
| | |
| | | /// <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; |
| | |
| | | Utlis.WriteLine (ex.Message); |
| | | return null; |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | } |
| | | |
| | |
| | | /// <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)) { |
| | |
| | | return new ResponsePackNew () { Code = StateCode.NETWORK_ERROR }; |
| | | } |
| | | |
| | | #endregion |
| | | #endregion |
| | | |
| | | } |
| | | |
| | |
| | | /// <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); |
| | |
| | | Utlis.WriteLine (ex.Message); |
| | | return null; |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region **********签名校验********** |
| | | #region **********签名校验********** |
| | | ///// <summary> |
| | | ///// |
| | | ///// </summary> |
| | |
| | | ///// </summary> |
| | | //const string SECRET_KEY = "WeJ8TY88vbakCcnvH8G1tDUqzLWY8yss"; |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | const string APP_KEY = "HDL-HOME-IND-APP-TEST"; |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | const string SECRET_KEY = "yeJ8TY98vbakCpnvH8G1tDUqzLWY8yts"; |
| | | |
| | | ///// <summary> |
| | | ///// |
| | | ///// </summary> |
| | | //const string APP_KEY = "HDL-HOME-IND-APP"; |
| | | ///// <summary> |
| | | ///// |
| | | ///// </summary> |
| | | //const string SECRET_KEY = "yPL345bn68gHnvilG4tYbq3cTYkiHu"; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取当前时间戳值 |
| | |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | #endregion |
| | | } |
| | | |
| | | /// <summary> |