| | |
| | | using System.Text; |
| | | using HDL_ON.Entity; |
| | | using RestSharp; |
| | | using Shared; |
| | | |
| | | namespace HDL_ON.DAL.Server |
| | | { |
| | |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 固定域名 |
| | | /// 固定域名,正式环境 |
| | | /// </summary> |
| | | //public const string GlobalRequestHttpsHost = "https://center.hdlcontrol.com"; |
| | | //public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com"; |
| | | public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com"; |
| | | |
| | | /// <summary> |
| | |
| | | public static ResponsePackNew RequestHttpsPostFroHome(string apiPath, string bodyParameterJson, int mTimeout = 10) |
| | | { |
| | | string urlHead = DB_ResidenceData.residenceData.residecenInfo.regionUrl; |
| | | var replaceToken = ""; |
| | | if (DB_ResidenceData.residenceData.residecenInfo.IsOthreShare) |
| | | { |
| | | replaceToken = DB_ResidenceData.residenceData.MasterToken; |
| | | } |
| | | return RequestHttps(Method.POST, apiPath, bodyParameterJson, null, null, urlHead, replaceToken, mTimeout); |
| | | //var replaceToken = ""; |
| | | //if (DB_ResidenceData.residenceData.residecenInfo.IsOthreShare) |
| | | //{ |
| | | // replaceToken = DB_ResidenceData.residenceData.MasterToken; |
| | | //} |
| | | return RequestHttps(Method.POST, apiPath, bodyParameterJson, null, null, urlHead, "", mTimeout); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | 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); |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | |
| | | ResponsePackNew revertObj = new ResponsePackNew() { }; |
| | | revertObj = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePackNew>(response.Content); |
| | | //*****一些判空处理***************** |
| | |
| | | #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; |
| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | /// <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"; |
| | |
| | | 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> |