| | |
| | | /// 公共域名就近解析 |
| | | /// </summary> |
| | | public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com"; |
| | | public const string APP_KEY = "HDL-HOME-APP"; |
| | | public const string SECRET_KEY = "CPL345bn28gHnvi9G4tYbq3cTYkiHC"; |
| | | |
| | | |
| | | //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 APP_KEY = "HDL-HOME-APP-TEST"; |
| | | //public 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> |
| | | /// 请求超时时间 |
| | | /// </summary> |
| | | public const int TIME_OUT = 15; |
| | | public const int TIME_OUT = 10; |
| | | /// <summary> |
| | | /// 特殊接口请求超时时间 |
| | | /// </summary> |
| | |
| | | #endregion |
| | | |
| | | #region **********网络请求封装********** |
| | | |
| | | /// <summary> |
| | | /// Get 请求服务器方法 |
| | | /// </summary> |
| | |
| | | |
| | | if(MainPage.NoLoginMode) |
| | | { |
| | | return new ResponsePackNew() { Code = "0" }; |
| | | return new ResponsePackNew() { Code = "0" ,Data = "" }; |
| | | } |
| | | if (!Common.ApiUtlis.Ins.hadInternet) |
| | | { |
| | | MainPage.Log("没有外网,直接退出请求"); |
| | | return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR, message = Language.StringByID(StringId.FailedRequestServer) }; |
| | | } |
| | | #region HttpWebRequest |
| | | try |
| | |
| | | request.AddUrlSegment(data.Key, data.Value.ToString()); |
| | | } |
| | | } |
| | | |
| | | IRestResponse response = client.Execute(request); |
| | | MainPage.Log("发送:"+ requestFullUrl, response.Request.Body?.Value.ToString()); |
| | | if(apiPath == NewAPI.API_POST_Login) |
| | | { |
| | | var ddd = Newtonsoft.Json.JsonConvert.SerializeObject(response); |
| | | //Console.WriteLine(ddd); |
| | | } |
| | | if (response.StatusCode == HttpStatusCode.OK) |
| | | { |
| | | try |
| | |
| | | revertObj.Data = ""; |
| | | } |
| | | //*****一些判空处理***************** |
| | | |
| | | HDL_ON.Utlis.WriteLine("接收", requestFullUrl, response.Content); |
| | | return revertObj; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | catch { } |
| | | } |
| | | return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR }; |
| | | return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR, message = Language.StringByID(StringId.FailedRequestServer) }; |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | HDL_ON.Utlis.WriteLine(ex.Message); |
| | | return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR }; |
| | | return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR ,message = Language.StringByID(StringId.FailedRequestServer) }; |
| | | } |
| | | |
| | | #endregion |
| | |
| | | /// 刷新 Token |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | static bool RefreshToken() |
| | | static bool RefreshToken(bool canRefresh = true) |
| | | { |
| | | try |
| | | { |
| | |
| | | UserInfo.Current.RefreshToken = revertData.refreshToken; |
| | | UserInfo.Current.LastTime = DateTime.Now; |
| | | UserInfo.Current.SaveUserInfo(); |
| | | return true; |
| | | #if __IOS__ |
| | | var sdm = new SiriKit.SceneDateManager(); |
| | | sdm.AccessToken = UserInfo.Current.LoginTokenString; |
| | | sdm.RefreshToken = UserInfo.Current.RefreshToken; |
| | | #endif |
| | | return true; |
| | | } |
| | | else if (revertObj.Code == StateCode.PasswrodError) |
| | | { |
| | |
| | | else |
| | | { |
| | | HDL_ON.Utlis.WriteLine(response.Content); |
| | | return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR }; |
| | | return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR, message = Language.StringByID(StringId.FailedRequestServer) }; |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | HDL_ON.Utlis.WriteLine(ex.Message); |
| | | return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR }; |
| | | return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR, message = Language.StringByID(StringId.FailedRequestServer) }; |
| | | } |
| | | |
| | | #endregion |
| | |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region **********签名校验********** |
| | | |