From 145b157ba183ebf877c93ed2dbb01ec737c993d3 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 08 十二月 2020 18:59:33 +0800 Subject: [PATCH] Merge branch 'WJC' --- HDL_ON/DAL/Server/HttpUtil.cs | 82 +++++++++++++++++++++++++++++----------- 1 files changed, 59 insertions(+), 23 deletions(-) diff --git a/HDL_ON/DAL/Server/HttpUtil.cs b/HDL_ON/DAL/Server/HttpUtil.cs index 0fa2299..e7fa703 100644 --- a/HDL_ON/DAL/Server/HttpUtil.cs +++ b/HDL_ON/DAL/Server/HttpUtil.cs @@ -152,16 +152,16 @@ try { - //if (string.IsNullOrEmpty(urlHead)) - //{ - // urlHead = UserInfo.Current.RequestHttpsHost; - //} - //string requestFullUrl = urlHead + apiPath; + if (string.IsNullOrEmpty(urlHead)) + { + urlHead = UserInfo.Current.RequestHttpsHost; + } + string requestFullUrl = urlHead + apiPath; - //**************娴嬭瘯************** - string requestFullUrl = GlobalRequestHttpsHost + apiPath; - //**************娴嬭瘯************** + ////**************娴嬭瘯************** + //string requestFullUrl = GlobalRequestHttpsHost + apiPath; + ////**************娴嬭瘯************** RestClient client = new RestClient(requestFullUrl); @@ -208,6 +208,7 @@ { try { + ResponsePackNew revertObj = new ResponsePackNew() { }; revertObj = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePackNew>(response.Content); //*****涓�浜涘垽绌哄鐞�***************** @@ -264,14 +265,15 @@ #region RestRequest try { - //if (string.IsNullOrEmpty (urlHead)) { - // urlHead = UserInfo.Current.RequestHttpsHost; - //} - //string requestFullUrl = urlHead + apiPath; + if (string.IsNullOrEmpty(urlHead)) + { + urlHead = UserInfo.Current.RequestHttpsHost; + } + string requestFullUrl = urlHead + apiPath; - //**************娴嬭瘯************** - string requestFullUrl = GlobalRequestHttpsHost + apiPath; - //**************娴嬭瘯************** + ////**************娴嬭瘯************** + //string requestFullUrl = GlobalRequestHttpsHost + apiPath; + ////**************娴嬭瘯************** RestClient client = new RestClient(requestFullUrl); //client.Timeout = mTimeout * 1000; @@ -334,14 +336,15 @@ try { - //if (string.IsNullOrEmpty (urlHead)) { - // urlHead = UserInfo.Current.RequestHttpsHost; - //} - //string requestFullUrl = urlHead + apiPath; + if (string.IsNullOrEmpty(urlHead)) + { + urlHead = UserInfo.Current.RequestHttpsHost; + } + string requestFullUrl = urlHead + apiPath; - //**************娴嬭瘯************** - string requestFullUrl = GlobalRequestHttpsHost + apiPath; - //**************娴嬭瘯************** + ////**************娴嬭瘯************** + //string requestFullUrl = GlobalRequestHttpsHost + apiPath; + ////**************娴嬭瘯************** RestClient client = new RestClient(requestFullUrl); //client.Timeout = mTimeout * 1000; @@ -422,6 +425,38 @@ } /// <summary> + /// 涓嬭浇鏂囦欢 璇锋眰鏈嶅姟鍣ㄦ柟娉� + /// </summary> + /// <param name="apiPath"></param> + /// <param name="bodyParameterJson"></param> + /// <param name="queryDictionary"></param> + /// <param name="urlHead"></param> + /// <param name="replaceToken"></param> + /// <param name="mTimeout"></param> + /// <returns></returns> + public static byte[] HttpsDownload(string requestFullUrl, int mTimeout = 30) + { + #region RestRequest + try + { + RestClient client = new RestClient(requestFullUrl); + RestRequest request = new RestRequest(Method.GET); + request.Timeout = mTimeout * 1000; + + IRestResponse response = client.Execute(request); + return response.RawBytes; + } + catch (Exception ex) + { + HDL_ON.Utlis.WriteLine(ex.Message); + return null; + } + #endregion + + } + + + /// <summary> /// /// </summary> const string APP_KEY = "HDL-HOME-APP-TEST"; @@ -437,7 +472,8 @@ static string GetTimestamp() { System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 褰撳湴鏃跺尯 - return ((long)(DateTime.Now - startTime).TotalSeconds).ToString(); // 鐩稿樊绉掓暟 + return ((long)(DateTime.Now - startTime).TotalMilliseconds).ToString(); // 鐩稿樊绉掓暟 + //return ((long)(DateTime.Now - startTime).TotalSeconds).ToString(); // 鐩稿樊绉掓暟 } /// <summary> -- Gitblit v1.8.0