From ed3bfb7462d44747230437717e8673a5192f833f Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期一, 30 十一月 2020 20:34:51 +0800 Subject: [PATCH] 2020-11-30-2 --- HDL_ON/DAL/Server/HttpServerRequest.cs | 632 ++++++++++++++++++++------------------------------------- 1 files changed, 220 insertions(+), 412 deletions(-) diff --git a/HDL_ON/DAL/Server/HttpServerRequest.cs b/HDL_ON/DAL/Server/HttpServerRequest.cs index b31745f..a69664e 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,174 +91,124 @@ 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() == StateCode.SUCCESS) - { - 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:楠岃瘉鐮佺櫥闄� 5:鏁忔劅鏁版嵁</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> - /// <param name="account">璐﹀彿</param> - /// <param name="password">瀵嗙爜</param> - /// <returns></returns> - public ResponsePackNew LoginByPassword(string account, string password) + public ResponsePack LoginByPassword(string account, string password) { - var requestJson = HttpUtil.GetSignRequestJson(new LoginObj() - { - account = account, - loginPwd = password - }); - return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Login, requestJson); + string jsonString = "{" + + "\"Account\":" + "\"" + account + "\"" + "," + + "\"Password\":" + "\"" + password + "\"" + + "}"; + return RequestHttps($"{severAddress}/ZigbeeUsers/Login", jsonString, false); } /// <summary> /// 楠岃瘉鐮佺櫥褰� /// </summary> - /// <param name="account">璐﹀彿</param> - /// <param name="vCode">楠岃瘉鐮�</param> - /// <returns></returns> - public ResponsePackNew LoginValidCode(string account, string vCode) + public ResponsePack LoginValidCode(string account,string vCode) { - var requestJson = HttpUtil.GetSignRequestJson(new LoginObj() - { - account = account, - verifyCode = vCode, - grantType = "verify" - }); - return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Login, requestJson); + 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); } /// <summary> /// 楠岃瘉鐭俊鎴栬�呴偖绠遍獙璇佺爜锛屼箣鍚庢敞鍐� /// </summary> - /// <param name="account">閭鎴栬�呮墜鏈哄彿</param> + /// <param name="account">璐﹀彿</param> /// <param name="password">瀵嗙爜</param> + /// <param name="entryPassword">纭瀵嗙爜</param> /// <param name="code">楠岃瘉鐮�</param> - /// <param name="isPhone">鏄惁鎵嬫満</param> + /// <param name="areaCode"></param> /// <returns></returns> - public ResponsePackNew ValidataCodeAndRegister(string account, string password, string code, bool isPhone = false) + public ResponsePack ValidataCodeAndRegister(string account, string password, string entryPassword, string code, int areaCode) { - 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); + //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); } + /// <summary> - /// 蹇樿瀵嗙爜锛岄噸缃瘑鐮� + /// 鑾峰彇娉ㄥ唽楠岃瘉鐮� /// </summary> - /// <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) + public ResponsePack GetRegisterVerCode(string account) { - 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); + string jsonString = "{" + + "\"Account\":" + "\"" + account + "\"" + "," + + "\"Company\":" + MainPage.Company + "," + + "\"Language\":" + "\"" + Language.CurrentLanguage.ToLower() + "\"" + "," + + "\"AreaCode\":" + 86 + + "}"; + return RequestHttps($"{severAddress}/ZigbeeUsers/RegisterSendVerCode", jsonString, false); + } + + + /// <summary> + /// 鑾峰彇鐧诲綍楠岃瘉鐮� + /// </summary> + public ResponsePack GetLoginVerCode(string account) + { + + string jsonString = "{" + + "\"Account\":" + "\"" + account + "\"" + "," + + "\"AreaCode\":" + "86" + + "}"; + return RequestHttps($"{severAddress}/ZigbeeUsers/LoginSendVerCode", jsonString, false); + } ///// <summary> - ///// 鑾峰彇鐧诲綍楠岃瘉鐮� + ///// 鍙戦�侀獙璇佺爜 ///// </summary> - //public ResponsePack GetLoginVerCode(string account) + //public ResponsePack SendSms(string account) //{ - // string jsonString = "{" + // "\"Account\":" + "\"" + account + "\"" + "," + - // "\"AreaCode\":" + "86" + + // "\"Company\":" + MainPage.Company + "," + + // "\"Language\":" + "\"" + Language.CurrentLanguage + "\"" + "," + + // "\"AreaCode\":" + OnAppConfig.Instance.CountryNumber + // "}"; // return RequestHttps($"{severAddress}/ZigbeeUsers/LoginSendVerCode", jsonString, false); //} @@ -266,30 +216,19 @@ /// <summary> /// 楠岃瘉楠岃瘉鐮� /// </summary> - /// <param name="verifyType">楠岃瘉绫诲瀷</param> - /// <param name="account">楠岃瘉璐﹀彿</param> - /// <param name="code">楠岃瘉鐮�</param> - /// <param name="isPhone">鏄惁鎵嬫満</param> - /// <param name="verifySuccessFail">楠岃瘉閫氳繃鍚庯紝楠岃瘉鐮佹槸鍚﹀け鏁�</param> + /// <param name="account"></param> + /// <param name="code"></param> /// <returns></returns> - public ResponsePackNew ValidatorCode(VerifyType verifyType, string account, string code, bool isPhone, bool verifySuccessFail = true) + public ResponsePack ValidatorCode(string account, string code, int countryIndex) { - var requestObj = new VerifyCodeCheckObj() { verifyCode = code, verifyType = (int)verifyType , verifySuccessFail = verifySuccessFail }; - if (isPhone) - { - //鎵嬫満 - requestObj.phone = account; - } - else - { - //閭 - requestObj.mail = account; - } - var requestJson = HttpUtil.GetSignRequestJson(requestObj); - return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Verification_Check, requestJson); + string jsonString = "{" + + "\"Account\":" + "\"" + account + "\"" + "," + + "\"Code\":" + "\"" + code + "\"" + "," + + "\"Language\":" + "\"" + Language.CurrentLanguage + "\"" + "," + + "\"AreaCode\":" + countryIndex + + "}"; + return RequestHttps($"{severAddress}/ZigbeeUsers/ValidatorCode", jsonString, false); } - - /// <summary> /// 閲嶈瀵嗙爜 @@ -312,111 +251,56 @@ /// 鑾峰彇鐢ㄦ埛淇℃伅 /// </summary> /// <returns></returns> - public void GetUserInfo(bool bGetHeadImage = true) + public void GetUserInfo() { - var requestJson = HttpUtil.GetSignRequestJson(new NullObj()); - var resultObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_GetMemberInfo, requestJson); - if (resultObj.Code == StateCode.SUCCESS) - { - var info = Newtonsoft.Json.JsonConvert.DeserializeObject<MemberInfoRes>(resultObj.Data.ToString()); - MainPage.LoginUser.userEmailInfo = info.memberEmail; - MainPage.LoginUser.userMobileInfo = info.memberPhone; - MainPage.LoginUser.userName = info.memberName; - MainPage.LoginUser.areaCode = info.memberPhonePrefix; - //鏄惁闇�瑕佽幏鍙栧ご鍍� - if (bGetHeadImage) - { - var headImageBytes = DownHeadImage(); - if (headImageBytes != null) - { - MainPage.LoginUser.headImagePageBytes = headImageBytes; - FileStream fs = null; - try - { - MainPage.LoginUser.headImagePageBytes = headImageBytes; - var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/", "headImage.png"); - fs = new FileStream(filePath, FileMode.Create, FileAccess.Write); - fs.Write(headImageBytes, 0, headImageBytes.Length); - fs.Flush(); - MainPage.LoginUser.headImagePagePath = filePath; - } - catch (Exception ex) - { - MainPage.Log($"download headImage error : {ex.Message}"); - } - finally - { - if (fs != null) - { - fs.Close(); - } - } + Dictionary<string, object> d = new Dictionary<string, object>(); + var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(d); + var revertObj = RequestHttps($"{severAddress}/ZigbeeUsers/GetAccountInfo", requestJson, true); + if (revertObj.StateCode.ToUpper() == "SUCCESS") + { + var dataStr = JObject.FromObject(revertObj.ResponseData); + //"DistributedMark": "96439601-fd26-4768-8440-1d9dfa32c109", < !--甯愬彿Id-- > + MainPage.LoginUser.userEmailInfo = dataStr.GetValue("Email").ToString(); + MainPage.LoginUser.userMobileInfo = dataStr.GetValue("Phone").ToString(); + FileStream fs = null; + try + { + var headImageString = dataStr.GetValue("HeadImage").ToString(); + if (!string.IsNullOrEmpty(headImageString)) + { + var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(headImageString); + var headImageBytes = Newtonsoft.Json.JsonConvert.DeserializeObject<byte[]>(jsonString); + MainPage.LoginUser.headImagePageBytes = headImageBytes; + var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/", "headImage.png"); + fs = new FileStream(filePath, FileMode.Create, FileAccess.Write); + fs.Write(headImageBytes, 0, headImageBytes.Length); + fs.Flush(); + MainPage.LoginUser.headImagePagePath = filePath; + } + } catch (Exception ex) + { + MainPage.Log($"download headImage error : {ex.Message}"); + } + finally + { + if (fs != null) + { + fs.Close(); } } + // "GesturePwd": null, < !--鎵嬪娍瀵嗙爜-- > + // "StringPwd": null , < !--瀛楃涓插瘑鐮�-- > + MainPage.LoginUser.userName = dataStr.GetValue("UserName").ToString(); + + Application.RunOnMainThread(() => + { + }); MainPage.LoginUser.SaveUserInfo(); MainPage.Log("鑾峰彇鐢ㄦ埛淇℃伅鎴愬姛銆�"); } - - // Dictionary<string, object> d = new Dictionary<string, object>(); - //var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(d); - //var revertObj = RequestHttps($"{severAddress}/ZigbeeUsers/GetAccountInfo", requestJson, true); - - //if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) - //{ - // var dataStr = JObject.FromObject(revertObj.ResponseData); - // //"DistributedMark": "96439601-fd26-4768-8440-1d9dfa32c109", < !--甯愬彿Id-- > - // MainPage.LoginUser.userEmailInfo = dataStr.GetValue("Email").ToString(); - // MainPage.LoginUser.userMobileInfo = dataStr.GetValue("Phone").ToString(); - // FileStream fs = null; - // try - // { - // var headImageString = dataStr.GetValue("HeadImage").ToString(); - // if (!string.IsNullOrEmpty(headImageString)) - // { - // var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(headImageString); - // var headImageBytes = Newtonsoft.Json.JsonConvert.DeserializeObject<byte[]>(jsonString); - // MainPage.LoginUser.headImagePageBytes = headImageBytes; - // var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/", "headImage.png"); - // fs = new FileStream(filePath, FileMode.Create, FileAccess.Write); - // fs.Write(headImageBytes, 0, headImageBytes.Length); - // fs.Flush(); - // MainPage.LoginUser.headImagePagePath = filePath; - // } - // } - // catch (Exception ex) - // { - // MainPage.Log($"download headImage error : {ex.Message}"); - // } - // finally - // { - // if (fs != null) - // { - // fs.Close(); - // } - // } - // // "GesturePwd": null, < !--鎵嬪娍瀵嗙爜-- > - // // "StringPwd": null , < !--瀛楃涓插瘑鐮�-- > - // MainPage.LoginUser.userName = dataStr.GetValue("UserName").ToString(); - - // Application.RunOnMainThread(() => - // { - // }); - - // MainPage.LoginUser.SaveUserInfo(); - // MainPage.Log("鑾峰彇鐢ㄦ埛淇℃伅鎴愬姛銆�"); - //} - - } - - /// <summary> - /// 涓嬭浇鐢ㄦ埛澶村儚 - /// </summary> - public byte[] DownHeadImage() - { - return HttpUtil.RequestHttpsDownload(NewAPI.API_POST_Head_Down, null); } /// <summary> @@ -424,12 +308,14 @@ /// </summary> /// <param name="userName"></param> /// <returns></returns> - public ResponsePackNew EditUserName(string userName) + public ResponsePack EditUserName(string userName) { - var requestJson = HttpUtil.GetSignRequestJson(new UpdateMemberNameRes() { - memberName = userName - }); - return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_UpdateMemberInfo, requestJson); + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add("UserName", userName); + var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(d); + var revertObj = RequestHttps($"{severAddress}/ZigbeeUsers/UpdateUserName", requestJson, true); + return revertObj; + } /// <summary> @@ -442,86 +328,89 @@ FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); byte[] bytes = new byte[fs.Length]; fs.Read(bytes, 0, bytes.Length); - var revertObj = HttpUtil.RequestHttpsUpload(RestSharp.Method.POST, NewAPI.API_POST_Head_Upload, bytes); - return revertObj.Code; + + Dictionary<string, byte[]> d = new Dictionary<string, byte[]>(); + d.Add("HeadImage", bytes); + var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(d); + + var revertObj = RequestHttps($"{severAddress}/ZigbeeUsers/UpdateHeadImage", requestJson, true); + return revertObj.StateCode; } /// <summary> /// 鏇存敼缁戝畾璐︽埛鐨勯偖绠辨垨鑰呮墜鏈哄彿 - /// 2020-11-16 寰呬慨鏀� /// </summary> /// <param name="account"></param> - /// <param name="code"></param> - /// <param name="isPhone"></param> /// <returns></returns> - public string BindAccount(string account, string code = "", bool isPhone = false) + public string BindAccount(string account) { - var requestObj = new BindWithAccountObj() { verifyCode = code}; - if (isPhone) - { - //鎵嬫満 - requestObj.memberPhone = account; - } - else - { - //閭 - requestObj.memberEmail = account; - } - var requestJson = HttpUtil.GetSignRequestJson(requestObj); - return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_BindWithAccount, requestJson).Code; + string jsonString = "{" + "\"Account\":" + "\"" + account + "\"" + "}"; + var responsePack = RequestHttps($"{severAddress}/ZigbeeUsers/BindAccount", jsonString, true); + return responsePack.StateCode; } - - /// <summary> - /// 瑙g粦鎵嬫満鎴栬�呴偖绠� - /// </summary> - /// <param name="isPhone"></param> - /// <returns></returns> - public string UnBindAccount(bool isPhone) - { - var requestObj = new UnBindAccountObj() { unBindLabel = isPhone ? "PHONE": "EMAIL" }; - var requestJson = HttpUtil.GetSignRequestJson(requestObj); - return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_UnbindWithAccount, requestJson).Code; - } - #endregion #region 浣忓畢閮ㄥ垎 /// <summary> /// 鑾峰彇浣忓畢鍒楄〃 /// </summary> - public string GetHomePager(HomeTypeEnum homeType = HomeTypeEnum.ALL) + public string GetHomePager() { - var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new GetHomeListObj() { homeType = homeType.ToString() }); - var resultObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Gethomepager, requestJson); - if(resultObj.Code == StateCode.SUCCESS) - { - var homeList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RegionInfoResNew>>(resultObj.Data.ToString()); - if (homeList == null || homeList.Count == 0) { + string jsonString = "{" + + "\"RequestVersion\":" + "\"" + MainPage.VersionString + "\"" + "," + + "\"RequestSource\":" + "\"" + "2" + "\"" + "," + + "\"HomeType\":" + "\"" + "1" + "\"" + "," + + "\"LoginAccessToken\":" + "\"" + MainPage.LoginUser.loginTokenString + "\"" + + "}"; + var responsePack = RequestHttps($"{severAddress}/App/GetHomePager", jsonString,false); + if (responsePack.StateCode.ToUpper() == "SUCCESS") + { + var dataStr = JObject.FromObject(responsePack.ResponseData); + //娌℃湁浣忓畢 + if (dataStr.GetValue("PageData").ToString() == "[]") + { } else { + //{ + // { + // "Id": "1107487", + // "HomeStatus": 2, + // "UserGuid": "22980", + // "Name": "鍟�", + // "Address": null, + // "Longitude": 0.0, + // "Latitude": 0.0, + // "RegionName": null, + // "Company": null, + // "ContactPerson": null, + // "ContactPersonPhone": null, + // "Remarks": null, + // "ChangeDate": null, + // "AccountType": 0, + // "CreatedOnUtc": "2020-05-27T06:52:03", + // "IsOthreShare": false, + // "MainUserDistributedMark": null, + // "HomeGateways": [ + // { + // "GatewayUniqueId": "4E47323347591243" + // } + // ] + //}} MainPage.LoginUser.regionList = new List<RegionInfoRes>(); - - foreach (var mHome in homeList) + foreach (var jsonData in dataStr.GetValue("PageData")) { + var homeJsonStr = JObject.FromObject(jsonData); var home = new RegionInfoRes() { - RegionID = mHome.Id, - Name = mHome.homeName, - IsOthreShare = mHome.IsOtherShare, - accountType = mHome.accountType, - isRemoteControl = mHome.isRemoteControl, - longitude = mHome.longitude, - latitude = mHome.latitude, - deliverstatus = mHome.deliverstatus, - homeType = mHome.homeType, - regionUrl = mHome.regionUrl, - emqUrl = mHome.emqUrl, - homeRegionName = mHome.homeRegionName, - homeRegionId = mHome.homeRegionId, - Address = mHome.homeAddress, + RegionID = homeJsonStr.GetValue("Id").ToString(), + RegionName = homeJsonStr.GetValue("RegionName").ToString(), + Name = homeJsonStr.GetValue("Name").ToString(), + Address = homeJsonStr.GetValue("Address").ToString(), + IsOthreShare = (bool)homeJsonStr.GetValue("IsOthreShare"), + homeGateways = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomeGateways>>(homeJsonStr.GetValue("HomeGateways").ToString()), }; if (home.IsOthreShare) { @@ -536,82 +425,8 @@ DB_ResidenceData.residenceData.SaveResidenceData(); MainPage.LoginUser.SaveUserInfo(); } - } - - return resultObj.Code; - - //string jsonString = "{" + - // "\"RequestVersion\":" + "\"" + MainPage.VersionString + "\"" + "," + - // "\"RequestSource\":" + "\"" + "2" + "\"" + "," + - // "\"HomeType\":" + "\"" + "1" + "\"" + "," + - // "\"LoginAccessToken\":" + "\"" + MainPage.LoginUser.loginTokenString + "\"" + - // "}"; - //var responsePack = RequestHttps($"{severAddress}/App/GetHomePager", jsonString, false); - - //if (responsePack.StateCode.ToUpper() == StateCode.SUCCESS_CODE) - //{ - // var dataStr = JObject.FromObject(responsePack.ResponseData); - // //娌℃湁浣忓畢 - // if (dataStr.GetValue("PageData").ToString() == "[]") - // { - - // } - // else - // { - // //{ - // // { - // // "Id": "1107487", - // // "HomeStatus": 2, - // // "UserGuid": "22980", - // // "Name": "鍟�", - // // "Address": null, - // // "Longitude": 0.0, - // // "Latitude": 0.0, - // // "RegionName": null, - // // "Company": null, - // // "ContactPerson": null, - // // "ContactPersonPhone": null, - // // "Remarks": null, - // // "ChangeDate": null, - // // "AccountType": 0, - // // "CreatedOnUtc": "2020-05-27T06:52:03", - // // "IsOthreShare": false, - // // "MainUserDistributedMark": null, - // // "HomeGateways": [ - // // { - // // "GatewayUniqueId": "4E47323347591243" - // // } - // // ] - // //}} - // MainPage.LoginUser.regionList = new List<RegionInfoRes>(); - // foreach (var jsonData in dataStr.GetValue("PageData")) - // { - // var homeJsonStr = JObject.FromObject(jsonData); - // var home = new RegionInfoRes() - // { - // RegionID = homeJsonStr.GetValue("Id").ToString(), - // RegionName = homeJsonStr.GetValue("RegionName").ToString(), - // Name = homeJsonStr.GetValue("Name").ToString(), - // Address = homeJsonStr.GetValue("Address").ToString(), - // IsOthreShare = (bool)homeJsonStr.GetValue("IsOthreShare"), - // homeGateways = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomeGateways>>(homeJsonStr.GetValue("HomeGateways").ToString()), - // }; - // if (home.IsOthreShare) - // { - // continue; - // } - // MainPage.LoginUser.regionList.Add(home); - // if (string.IsNullOrEmpty(DB_ResidenceData.residenceData.CurReginID)) - // { - // DB_ResidenceData.residenceData.CurReginID = MainPage.LoginUser.regionList[0].RegionID; - // } - // } - // DB_ResidenceData.residenceData.SaveResidenceData(); - // MainPage.LoginUser.SaveUserInfo(); - // } - //} - //return responsePack.StateCode; + return responsePack.StateCode; } /// <summary> /// 缂栬緫浣忓畢淇℃伅 @@ -640,31 +455,25 @@ /// 鑾峰彇浣忓畢涓嬬殑鎴愬憳璐﹀彿 /// </summary> /// <returns></returns> - public ResponsePackNew GetResidenceMemberAccount() + public ResponsePack GetResidenceMemberAccount() { - var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new HomeIdObj() { homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID }); - var replaceToken = MainPage.LoginUser.loginTokenString; - //濡傛灉褰撳墠鎵�鍒嗕韩浣忓畢鍜屼负绠$悊鍛橈紝鏇挎崲涓轰富浜簍oken - //寰呭鐞�... - return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Child_FindAll, requestJson, DB_ResidenceData.residenceData.residecenInfo.regionUrl, replaceToken); + Dictionary<string, object> d = new Dictionary<string, object>(); + d.Add("DistributedMark", DB_ResidenceData.residenceData.residecenInfo.RegionID); + string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); + return RequestHttps($"{severAddress}/ZigbeeUsers/GetSubAccountByDistributedMark", jsonString, true); } /// <summary> /// 鍒犻櫎浣忓畢涓嬬殑鎴愬憳璐﹀彿 /// </summary> /// <returns></returns> - public ResponsePackNew DeleteResidenceMemberAccount(ResidenceMemberInfo subaccount) + public ResponsePack DeleteResidenceMemberAccount(string memberAccount) { - var requestObj = new ChildDeleteObj() - { - childAccountId = subaccount.childAccountId, - homeId = subaccount.homeId - }; - var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); - var replaceToken = MainPage.LoginUser.loginTokenString; - //濡傛灉褰撳墠鎵�鍒嗕韩浣忓畢鍜屼负绠$悊鍛橈紝鏇挎崲涓轰富浜簍oken - //寰呭鐞�... - return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Child_Delete, requestJson, DB_ResidenceData.residenceData.residecenInfo.regionUrl, replaceToken); + Dictionary<string, object> d = new Dictionary<string, object>(); + d.Add("SubAccount", memberAccount); + d.Add("HouseDistributedMark", DB_ResidenceData.residenceData.residecenInfo.RegionID); + string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); + return RequestHttps($"{severAddress}/ZigbeeUsers/DeletedSubAccount", jsonString, true); } /// <summary> @@ -673,7 +482,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); @@ -713,7 +522,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); @@ -785,7 +594,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); @@ -865,8 +674,7 @@ } System.Threading.Thread.Sleep(1000); } - Shared.Application.RunOnMainThread(() => - { + Shared.Application.RunOnMainThread(() => { try { HDL_ON.UI.HomePage.LoadEvent_RefreshAir(); @@ -883,7 +691,7 @@ /// 璇锋眰Mqtt鏁版嵁 /// </summary> /// <param name="dataStringJson">璇锋眰鐨勫弬鏁�.</param> - public ResponsePack RequestMqttInfo(string dataStringJson) + public ResponsePack RequestMqttInfo( string dataStringJson) { ResponsePack revertObj = null; @@ -929,7 +737,7 @@ /// <summary> /// 鑾峰彇浣忓畢澶囦唤鍒楄〃 /// </summary> - public Dictionary<int, string> GetRegionLastBackupId() + public Dictionary<int,string> GetRegionLastBackupId() { //Dialog dialog = new Dialog(); //dialog.Show(); @@ -939,7 +747,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