From 017af840d60fd6a56da9711308bf8239cb7fc1e6 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期五, 13 十一月 2020 11:01:01 +0800 Subject: [PATCH] 2020-11-13 1.部分接口替换备份 --- HDL_ON/DAL/Server/HttpServerRequest.cs | 229 +++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 150 insertions(+), 79 deletions(-) diff --git a/HDL_ON/DAL/Server/HttpServerRequest.cs b/HDL_ON/DAL/Server/HttpServerRequest.cs index a69664e..376cf97 100644 --- a/HDL_ON/DAL/Server/HttpServerRequest.cs +++ b/HDL_ON/DAL/Server/HttpServerRequest.cs @@ -50,7 +50,7 @@ /// <param name="nowMonth"></param> /// <param name="mac"></param> /// <returns></returns> - public ResponsePack GetSensorHistory(int subnetId,int deviceId,int bigClass,int minClass,int queryType,int loopId,int nowMonth,string mac) + public ResponsePack GetSensorHistory(int subnetId, int deviceId, int bigClass, int minClass, int queryType, int loopId, int nowMonth, string mac) { Dictionary<string, object> d = new Dictionary<string, object>(); d.Add("SubnetID", subnetId); @@ -63,7 +63,7 @@ d.Add("MAC", DB_ResidenceData.residenceData.residenceGatewayMAC); d.Add("LocalTimeZone", 8); var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); - return RequestHttps("https://developer.hdlcontrol.com/api/GetSensorPushHistory", jsonString,true); + return RequestHttps("https://developer.hdlcontrol.com/api/GetSensorPushHistory", jsonString, true); } @@ -91,99 +91,166 @@ return result; } + #region 鈻� 閫氱敤璇锋眰鎺ュ彛_______________________ + /// <summary> + /// 鏍规鐢ㄦ埛璐﹀彿鑾峰彇娉ㄥ唽鍖哄煙 鍏嶇櫥褰� // 妫�娴嬭处鍙锋槸鍚︽敞鍐屼篃鐢ㄨ繖涓帴鍙� + /// </summary> + /// <param name="account"></param> + /// <returns></returns> + public ResponsePackNew GetRegionByAccount(string account) + { + var requestJson = HttpUtil.GetSignRequestJson(new RegionByAccountObj() { account = account }); + return HttpUtil.RequestHttpsPost(NewAPI.API_POST_GetRegionByAccount, requestJson); + } + + /// <summary> + /// 鍒锋柊Token + /// </summary> + /// <returns></returns> + public bool RefreshToken() + { + var requestJson = HttpUtil.GetSignRequestJson(new RefreshTokenObj() + { + refreshToken = MainPage.LoginUser.refreshToken, + }); + var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Login, requestJson); + if (revertObj.Code.ToUpper() == HttpUtil.SUCCESS_CODE) + { + var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes>(revertObj.Data.ToString()); + MainPage.LoginUser.loginTokenString = revertData.headerPrefix + revertData.accessToken; + MainPage.LoginUser.lastTime = DateTime.Now; + MainPage.LoginUser.SaveUserInfo(); + return true; + } + return false; + } + + #endregion + #region 娉ㄥ唽銆佺櫥褰曢儴鍒� /// <summary> + /// 鑾峰彇璇锋眰鎻愪氦鐨勮瑷�鍙傛暟 + /// </summary> + public string GetPostLanguageType() + { + return Language.CurrentLanguage == "Chinese" ? LanguageTypeEnum.CHINESE.ToString() : LanguageTypeEnum.ENGLISH.ToString(); + } + + /// <summary> + /// 閫氱敤 鍙戦�侀獙璇佺爜鏂规硶 + /// </summary> + /// <param name="verifyType">1:娉ㄥ唽 2锛氭壘鍥炲瘑鐮� 3锛氱櫥闄� 4:缁戝畾</param> + /// <param name="account">閭鎴栬�呮墜鏈哄彿</param> + /// <param name="isPhone">鏄惁鎵嬫満</param> + /// <param name="phoneZoneCode">鎵嬫満鍥藉鍖哄彿</param> + /// <returns></returns> + public ResponsePackNew VerificationCodeSend(VerifyType verifyType, string account, bool isPhone = false, string phoneZoneCode = "86") + { + var requestObj = new VerifyCodeSendObj() + { + verifyType = (int)verifyType, + languageType = GetPostLanguageType() + }; + // 鏄惁鏄墜鏈� + if (isPhone) + { + requestObj.phone = account; + requestObj.phonePrefix = phoneZoneCode; + } + else + { + requestObj.mail = account; + } + // 瓒呮椂鏃堕棿璁剧疆涓�20绉掞紝搴旇娴嬭瘯娴峰鏈嶅姟鍣ㄥ彂閫侀獙璇佺爜鍝嶅簲鏃堕棿寰堜箙 + var requestJson = HttpUtil.GetSignRequestJson(requestObj); + return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Verification_Send, requestJson, "", "", HttpUtil.TIME_OUT_LONG); + } + + /// <summary> /// 璐﹀彿鐧诲綍-浣跨敤瀵嗙爜 /// </summary> - public ResponsePack LoginByPassword(string account, string password) + /// <param name="account">璐﹀彿</param> + /// <param name="password">瀵嗙爜</param> + /// <returns></returns> + public ResponsePackNew LoginByPassword(string account, string password) { - string jsonString = "{" + - "\"Account\":" + "\"" + account + "\"" + "," + - "\"Password\":" + "\"" + password + "\"" + - "}"; - return RequestHttps($"{severAddress}/ZigbeeUsers/Login", jsonString, false); + var requestJson = HttpUtil.GetSignRequestJson(new LoginObj() + { + account = account, + loginPwd = password + }); + return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Login, requestJson); } /// <summary> /// 楠岃瘉鐮佺櫥褰� /// </summary> - public ResponsePack LoginValidCode(string account,string vCode) + /// <param name="account">璐﹀彿</param> + /// <param name="vCode">楠岃瘉鐮�</param> + /// <returns></returns> + public ResponsePackNew LoginValidCode(string account, string vCode) { - Dictionary<string, object> d = new Dictionary<string, object>(); - d.Add("Account", account); - d.Add("Code", vCode); - d.Add("Language", Language.CurrentLanguage); - d.Add("AreaCode", "86"); - var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); - return RequestHttps($"{severAddress}/ZigbeeUsers/LoginValidCode", jsonString, false); - } - - /// <summary> - /// 鎵嬫満鍙风爜娉ㄥ唽 - /// </summary> - /// <param name="mobileNumber"></param> - /// <param name="password"></param> - /// <param name="language"></param> - public ResponsePack RegisterPhone(string mobileNumber, string password, string language) - { - string jsonString = "{" + - "\"Account\":" + "\"" + mobileNumber + "\"" + "," + - "\"Password\":" + "\"" + password + "\"" + "," + - "\"Language\":" + "\"" + language + "\"" + - "\"AreaCode\":" + "\"" + "86" + "\"" + - "}"; - return RequestHttps($"{severAddress}/SignIn", jsonString, false); - } - - public ResponsePack GetAreaCode() - { - string requestJson = "{}"; - return RequestHttps($"{severAddress}/ZigbeeUsers/GetAreaCode", requestJson, false); + var requestJson = HttpUtil.GetSignRequestJson(new LoginObj() + { + account = account, + verifyCode = vCode, + grantType = "verify" + }); + return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Login, requestJson); } /// <summary> /// 楠岃瘉鐭俊鎴栬�呴偖绠遍獙璇佺爜锛屼箣鍚庢敞鍐� /// </summary> - /// <param name="account">璐﹀彿</param> + /// <param name="account">閭鎴栬�呮墜鏈哄彿</param> /// <param name="password">瀵嗙爜</param> - /// <param name="entryPassword">纭瀵嗙爜</param> /// <param name="code">楠岃瘉鐮�</param> - /// <param name="areaCode"></param> + /// <param name="isPhone">鏄惁鎵嬫満</param> /// <returns></returns> - public ResponsePack ValidataCodeAndRegister(string account, string password, string entryPassword, string code, int areaCode) + public ResponsePackNew ValidataCodeAndRegister(string account, string password, string code, bool isPhone = false) { - //var requestObj = new ValidateSmsCodeObj() { Phone = accout, Code = code }; - //var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); - string requestJson = "{" + - "\"Account\":" + "\"" + account + "\"" + "," + - "\"Password\":" + "\"" + password + "\"" + "," + - "\"EnterPassword\":" + "\"" + entryPassword + "\"" + "," + - "\"Language\":" + "\"" + Language.CurrentLanguage.ToLower() + "\"" + "," + - "\"Code\":" + "\"" + code + "\"" + "," + - "\"RegisterSoruce\":" + 0 + "," + - "\"AreaCode\":" + 86 + - "}"; - return RequestHttps($"{severAddress}/ZigbeeUsers/ValidataCodeAndRegisterAccount", requestJson, false); + var requestObj = new RegisterObj() { loginPwd = password, verifyCode = code, memberName = account }; + if (isPhone) + { + requestObj.memberPhone = account; + } + else + { + requestObj.memberEmail = account; + } + var requestJson = HttpUtil.GetSignRequestJson(requestObj); + return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_Register, requestJson); } - /// <summary> - /// 鑾峰彇娉ㄥ唽楠岃瘉鐮� + /// 蹇樿瀵嗙爜锛岄噸缃瘑鐮� /// </summary> - public ResponsePack GetRegisterVerCode(string account) + /// <param name="account">閭鎴栬�呮墜鏈哄彿</param> + /// <param name="password">鏂板瘑鐮�</param> + /// <param name="vCode">楠岃瘉鐮�</param> + /// <param name="isPhone">鏄惁鎵嬫満璐﹀彿</param> + /// <returns></returns> + public ResponsePackNew ForgetPassword(string account, string password, string vCode, bool isPhone) { - string jsonString = "{" + - "\"Account\":" + "\"" + account + "\"" + "," + - "\"Company\":" + MainPage.Company + "," + - "\"Language\":" + "\"" + Language.CurrentLanguage.ToLower() + "\"" + "," + - "\"AreaCode\":" + 86 + - "}"; - return RequestHttps($"{severAddress}/ZigbeeUsers/RegisterSendVerCode", jsonString, false); - + var requestObj = new ForgetPwdObj() { verifyCode = vCode, loginPwd = password }; + if (isPhone) + { + //鎵嬫満蹇樿瀵嗙爜 + requestObj.memberPhone = account; + } + else + { + //閭蹇樿瀵嗙爜 + requestObj.memberEmail = account; + } + var requestJson = HttpUtil.GetSignRequestJson(requestObj); + return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_ForgetPwd, requestJson); } - + + + /// <summary> @@ -194,7 +261,7 @@ string jsonString = "{" + "\"Account\":" + "\"" + account + "\"" + "," + - "\"AreaCode\":" + "86" + + "\"AreaCode\":" + "86" + "}"; return RequestHttps($"{severAddress}/ZigbeeUsers/LoginSendVerCode", jsonString, false); } @@ -230,6 +297,8 @@ return RequestHttps($"{severAddress}/ZigbeeUsers/ValidatorCode", jsonString, false); } + + /// <summary> /// 閲嶈瀵嗙爜 /// </summary> @@ -257,7 +326,7 @@ var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(d); var revertObj = RequestHttps($"{severAddress}/ZigbeeUsers/GetAccountInfo", requestJson, true); - if (revertObj.StateCode.ToUpper() == "SUCCESS") + if (revertObj.StateCode.ToUpper() == HttpUtil.SUCCESS_CODE) { var dataStr = JObject.FromObject(revertObj.ResponseData); //"DistributedMark": "96439601-fd26-4768-8440-1d9dfa32c109", < !--甯愬彿Id-- > @@ -278,7 +347,8 @@ fs.Flush(); MainPage.LoginUser.headImagePagePath = filePath; } - } catch (Exception ex) + } + catch (Exception ex) { MainPage.Log($"download headImage error : {ex.Message}"); } @@ -362,9 +432,9 @@ "\"HomeType\":" + "\"" + "1" + "\"" + "," + "\"LoginAccessToken\":" + "\"" + MainPage.LoginUser.loginTokenString + "\"" + "}"; - var responsePack = RequestHttps($"{severAddress}/App/GetHomePager", jsonString,false); + var responsePack = RequestHttps($"{severAddress}/App/GetHomePager", jsonString, false); - if (responsePack.StateCode.ToUpper() == "SUCCESS") + if (responsePack.StateCode.ToUpper() == HttpUtil.SUCCESS_CODE) { var dataStr = JObject.FromObject(responsePack.ResponseData); //娌℃湁浣忓畢 @@ -482,7 +552,7 @@ /// <param name="nickName"></param> /// <param name="subAccountGuid"></param> /// <returns></returns> - public ResponsePack EditSubAccountNickName(string nickName,string subAccountGuid) + public ResponsePack EditSubAccountNickName(string nickName, string subAccountGuid) { Dictionary<string, object> d = new Dictionary<string, object>(); d.Add("SubAccountGuid", subAccountGuid); @@ -522,7 +592,7 @@ /// 鑾峰彇浣忓畢涓嬪瓙璐﹀彿鐨勫叡浜暟鎹� /// </summary> /// <returns></returns> - public ResponsePack GetShareData(string memberId,string hId) + public ResponsePack GetShareData(string memberId, string hId) { Dictionary<string, object> d = new Dictionary<string, object>(); d.Add("DistributedMark", memberId); @@ -594,7 +664,7 @@ /// <param name="subAccount"></param> /// <param name="nickName"></param> /// <returns></returns> - public ResponsePack BindResidenceMemberAccount(string subAccount,string nickName) + public ResponsePack BindResidenceMemberAccount(string subAccount, string nickName) { Dictionary<string, object> d = new Dictionary<string, object>(); d.Add("SubAccount", subAccount); @@ -674,7 +744,8 @@ } System.Threading.Thread.Sleep(1000); } - Shared.Application.RunOnMainThread(() => { + Shared.Application.RunOnMainThread(() => + { try { HDL_ON.UI.HomePage.LoadEvent_RefreshAir(); @@ -691,7 +762,7 @@ /// 璇锋眰Mqtt鏁版嵁 /// </summary> /// <param name="dataStringJson">璇锋眰鐨勫弬鏁�.</param> - public ResponsePack RequestMqttInfo( string dataStringJson) + public ResponsePack RequestMqttInfo(string dataStringJson) { ResponsePack revertObj = null; @@ -737,7 +808,7 @@ /// <summary> /// 鑾峰彇浣忓畢澶囦唤鍒楄〃 /// </summary> - public Dictionary<int,string> GetRegionLastBackupId() + public Dictionary<int, string> GetRegionLastBackupId() { //Dialog dialog = new Dialog(); //dialog.Show(); @@ -747,7 +818,7 @@ d.Add("LevelID", DB_ResidenceData.residenceData.residecenInfo.RegionID);// 199200); var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(d); var revertObj = RequestHttps("https://developer.hdlcontrol.com/api/GetUserFolder", requestJson, true); - if(revertObj == null || revertObj.ResponseData == null) + if (revertObj == null || revertObj.ResponseData == null) { return new Dictionary<int, string>(); } -- Gitblit v1.8.0