From 7232642ff48a7fbde2018cde652f3e771fa58025 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期三, 27 一月 2021 14:32:55 +0800
Subject: [PATCH] 20200127-英文版处理

---
 HDL_ON/DAL/Server/HttpServerRequest.cs |  469 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 234 insertions(+), 235 deletions(-)

diff --git a/HDL_ON/DAL/Server/HttpServerRequest.cs b/HDL_ON/DAL/Server/HttpServerRequest.cs
index 36f80d6..c27acef 100644
--- a/HDL_ON/DAL/Server/HttpServerRequest.cs
+++ b/HDL_ON/DAL/Server/HttpServerRequest.cs
@@ -59,7 +59,7 @@
             d.Add("QueryType", queryType);
             d.Add("loopId", loopId);
             d.Add("NowMonth", nowMonth);
-            d.Add("MAC", DB_ResidenceData.residenceData.residenceGatewayMAC);
+            d.Add("MAC", DB_ResidenceData.Instance.residenceGatewayMAC);
             d.Add("LocalTimeZone", 8);
             var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d);
             return RequestHttps("https://developer.hdlcontrol.com/api/GetSensorPushHistory", jsonString, true);
@@ -99,14 +99,14 @@
         public ResponsePackNew GetRegionByAccount(string account)
         {
             var requestJson = HttpUtil.GetSignRequestJson(new RegionByAccountObj() { account = account });
-            return HttpUtil.RequestHttpsPost(NewAPI.API_POST_GetRegionByAccount, requestJson);
+            return HttpUtil.RequestHttpsPost(NewAPI.API_POST_GetRegionByAccount, requestJson, HttpUtil.GlobalRequestHttpsHost);
         }
 
         /// <summary>
         /// 鍒锋柊Token
         /// </summary>
         /// <returns></returns>
-        public bool RefreshToken()
+        public string RefreshToken()
         {
             var requestJson = HttpUtil.GetSignRequestJson(new RefreshTokenObj()
             {
@@ -120,16 +120,50 @@
                 UserInfo.Current.RefreshToken = revertData.refreshToken;
                 UserInfo.Current.LastTime = DateTime.Now;
                 UserInfo.Current.SaveUserInfo();
-                return true;
             }
-            return false;
+            return revertObj.Code;
         }
 
         #endregion
 
+        /// <summary>
+        /// 缁戝畾璋冭瘯浜哄憳鎻愪氦鐨勪綇瀹�,涓�涓綇瀹呭彧鑳界粦瀹氫竴娆�
+        /// </summary>
+        /// <returns></returns>
+        public ResponsePackNew BindingResidence(string strUrl)
+        {
+            try
+            {
+                if (strUrl.Contains("app/home/deliver") == false)
+                {
+                    //闈炴硶鐨刄RL 杩斿洖涓�涓嚜瀹氫箟鐨勭姸鎬佺爜
+                    return new ResponsePackNew() { Code = "-100" };
+                }
+                var client = new RestSharp.RestClient(strUrl);
+
+                var request = new RestSharp.RestRequest(RestSharp.Method.GET);
+                request.Timeout = 5 * 1000;
+                request.AddHeader("content-type", "application/json");
+                request.AddHeader("Authorization", UserInfo.Current.LoginTokenString);
+
+                var response = client.Execute(request);
+                if (response.StatusCode == HttpStatusCode.OK)
+                {
+                    return Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePackNew>(response.Content);
+                }
+                else
+                {
+                    return null;
+                }
+            }
+            catch
+            {
+                return null;
+            }
+        }
 
         #region 娉ㄥ唽銆佺櫥褰曢儴鍒�
-       
+
 
         /// <summary>
         /// 閫氱敤 鍙戦�侀獙璇佺爜鏂规硶
@@ -204,7 +238,7 @@
         /// <returns></returns>
         public ResponsePackNew ValidataCodeAndRegister(string account, string password, string code, bool isPhone = false)
         {
-            var requestObj = new RegisterObj() { loginPwd = password, verifyCode = code, memberName = account };
+            var requestObj = new RegisterObj() { loginPwd = password, verifyCode = code};//, memberName = account 
             if (isPhone)
             {
                 requestObj.memberPhone = account;
@@ -275,7 +309,7 @@
         /// 鑾峰彇鐢ㄦ埛淇℃伅
         /// </summary>
         /// <returns></returns>
-        public void GetUserInfo(bool bGetHeadImage = true)
+        public string GetUserInfo(bool bGetHeadImage = true)
         {
             var requestJson = HttpUtil.GetSignRequestJson(new NullObj());
             var resultObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_GetMemberInfo, requestJson);
@@ -285,6 +319,7 @@
                 UserInfo.Current.userEmailInfo = info.memberEmail;
                 UserInfo.Current.userMobileInfo = info.memberPhone;
                 UserInfo.Current.userName = info.memberName;
+                
                 if (!string.IsNullOrEmpty(info.memberPhonePrefix))
                 {
                     UserInfo.Current.areaCode = info.memberPhonePrefix;
@@ -292,82 +327,32 @@
                 //鏄惁闇�瑕佽幏鍙栧ご鍍�
                 if (bGetHeadImage)
                 {
-                    var imageKey = ImageUtlis.Current.GetHeadImageKey(info.memberId);
-                   
-                    var headImageBytes = ImageUtlis.Current.DownHeadImage(info.memberId);
-
-                    if (headImageBytes != null && headImageBytes.Length > 0)
+                    //2020-12-15 淇敼澶村儚鏂规
+                    if (!string.IsNullOrEmpty(info.memberHeadIcon))
                     {
-                        //UserInfo.Current.headImagePageBytes = headImageBytes;
-                        UserInfo.Current.headImagePagePath = imageKey;
+                        var headImageBytes = ImageUtlis.Current.DownHeadImageByImageKey(info.memberHeadIcon);
+
+                        if (headImageBytes != null && headImageBytes.Length > 0)
+                        {
+                            UserInfo.Current.headImagePagePath = info.memberHeadIcon;
+                            //UserInfo.Current.headImagePagePath = imageKey;
+                        }
                     }
                 }
 
                 UserInfo.Current.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-- >
-            //     UserInfo.Current.userEmailInfo = dataStr.GetValue("Email").ToString();
-            //     UserInfo.Current.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);
-            //             UserInfo.Current.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();
-            //             UserInfo.Current.headImagePagePath = filePath;
-            //        }
-            //    }
-            //    catch (Exception ex)
-            //    {
-            //        MainPage.Log($"download headImage error : {ex.Message}");
-            //    }
-            //    finally
-            //    {
-            //        if (fs != null)
-            //        {
-            //            fs.Close();
-            //        }
-            //    }
-            //    // "GesturePwd": null,  < !--鎵嬪娍瀵嗙爜-- >
-            //    // "StringPwd": null , < !--瀛楃涓插瘑鐮�-- >
-            //     UserInfo.Current.userName = dataStr.GetValue("UserName").ToString();
-
-            //    Application.RunOnMainThread(() =>
-            //    {
-            //    });
-
-            //     UserInfo.Current.SaveUserInfo();
-            //    MainPage.Log("鑾峰彇鐢ㄦ埛淇℃伅鎴愬姛銆�");
-            //}
-
+            return resultObj.Code;
         }
 
         /// <summary>
         /// 鑾峰彇鐢ㄦ埛澶村儚
         /// </summary>
         /// <param name="userId"></param>
-        public void GetUserHeadImage(string userId)
+        public void GetUserHeadImageByKey(string imageKey)
         {
-            var imageKey = ImageUtlis.Current.GetHeadImageKey(userId);
-
-            var headImageBytes = ImageUtlis.Current.DownHeadImage(userId);
+            var headImageBytes = ImageUtlis.Current.DownHeadImageByImageKey(imageKey);
 
             if (headImageBytes != null && headImageBytes.Length > 0)
             {
@@ -389,6 +374,20 @@
             });
             return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_UpdateMemberInfo, requestJson);
         }
+
+        ///// <summary>
+        ///// 鏇存柊鐢ㄦ埛澶村儚
+        ///// </summary>
+        ///// <param name="userName"></param>
+        ///// <returns></returns>
+        //public ResponsePackNew UpdateMemberHeadIcon(string memberHeadIcon)
+        //{
+        //    var requestJson = HttpUtil.GetSignRequestJson(new UpdateMemberHeadIconRes()
+        //    {
+        //        memberHeadIcon = memberHeadIcon
+        //    });
+        //    return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_UpdateMemberInfo, requestJson);
+        //}
 
         ///// <summary>
         ///// 鏇存柊鐢ㄦ埛澶村儚
@@ -451,16 +450,13 @@
             var resultObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Gethomepager, requestJson);
             if (resultObj.Code == StateCode.SUCCESS)
             {
+                UserInfo.Current.regionList = new List<RegionInfoRes>();
                 var homeList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RegionInfoResNew>>(resultObj.Data.ToString());
                 if (homeList == null || homeList.Count == 0)
                 {
-
-
                 }
                 else
                 {
-                    UserInfo.Current.regionList = new List<RegionInfoRes>();
-
                     foreach (var mHome in homeList)
                     {
                         var home = new RegionInfoRes()
@@ -479,114 +475,53 @@
                             homeRegionName = mHome.homeRegionName,
                             homeRegionId = mHome.homeRegionId,
                             Address = mHome.homeAddress,
+                            isAllowCreateScene = mHome.isAllowCreateScene,
                         };
-                        if (home.IsOthreShare)
-                        {
-                            continue;
-                        }
                         UserInfo.Current.regionList.Add(home);
                     }
-
-                    if (string.IsNullOrEmpty(DB_ResidenceData.residenceData.CurReginID))
+                    //-------濡傛灉璐﹀彿鏄娆$櫥褰�
+                    if (DB_ResidenceData.Instance.CurrentRegion == null || string.IsNullOrEmpty(DB_ResidenceData.Instance.CurrentRegion.RegionID))
                     {
-                        DB_ResidenceData.residenceData.CurReginID = UserInfo.Current.regionList[0].RegionID;
-                        //鎭㈠澶囦唤
-                        HDLCommon.Current.RestoreHomeBackup(DB_ResidenceData.residenceData.CurReginID);
+                        //鍒锋柊褰撳墠浣忓畢
+                        DB_ResidenceData.Instance.CurrentRegion = UserInfo.Current.regionList[0];
+                        DB_ResidenceData.Instance.SaveResidenceData();
+                        UserInfo.Current.SaveUserInfo();
+                        //鍒锋柊涓�娆′綇瀹呯綉鍏�
+                        GetHomeGatewayList();
                     }
                     else
                     {
-                        var curRegion = UserInfo.Current.regionList.Find((obj) => obj.RegionID == DB_ResidenceData.residenceData.CurReginID);
-                        if(curRegion == null)
+                        //浣忓畢琚垹闄�
+                        var findHome = UserInfo.Current.regionList.Find((obj) => obj.RegionID == DB_ResidenceData.Instance.CurrentRegion.RegionID);
+                        if (findHome == null)
                         {
-                            DB_ResidenceData.residenceData.CurReginID = UserInfo.Current.regionList[0].RegionID;
-                            //鎭㈠澶囦唤
-                            HDLCommon.Current.RestoreHomeBackup(DB_ResidenceData.residenceData.CurReginID);
+                            Shared.Application.RunOnMainThread(() =>
+                            {
+                                DB_ResidenceData.Instance.CurrentRegion = UserInfo.Current.regionList[0];
+                                GetHomeGatewayList();
+                                DB_ResidenceData.Instance.SaveResidenceData();
+                                UserInfo.Current.SaveUserInfo();
+                                Action action = () =>
+                                {
+                                    MainPage.GoUserPage(true);
+                                };
+                                new UI.PublicAssmebly().TipMsg(StringId.Tip, StringId.ResidenceDeletedSwitchToAnotherResidence, action);
+                            });
+                        }
+                        else
+                        {
+                            //鍒锋柊褰撳墠浣忓畢
+                            DB_ResidenceData.Instance.CurrentRegion = findHome;
+                            DB_ResidenceData.Instance.SaveResidenceData();
+                            UserInfo.Current.SaveUserInfo();
+                            //鍒锋柊涓�娆′綇瀹呯綉鍏�
+                            GetHomeGatewayList();
                         }
                     }
-
-
-                    DB_ResidenceData.residenceData.SaveResidenceData();
-                    UserInfo.Current.SaveUserInfo();
-
-                    //鍒锋柊涓�娆′綇瀹呯綉鍏�
-                    GetHomeGatewayList();
                 }
-
             }
 
             return resultObj.Code;
-
-            //string jsonString = "{" +
-            //                    "\"RequestVersion\":" + "\"" + MainPage.VersionString + "\"" + "," +
-            //                    "\"RequestSource\":" + "\"" + "2" + "\"" + "," +
-            //                    "\"HomeType\":" + "\"" + "1" + "\"" + "," +
-            //                    "\"LoginAccessToken\":" + "\"" +  UserInfo.Current.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"
-            //        //    }
-            //        //  ]
-            //        //}}
-            //         UserInfo.Current.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;
-            //            }
-            //             UserInfo.Current.regionList.Add(home);
-            //            if (string.IsNullOrEmpty(DB_ResidenceData.residenceData.CurReginID))
-            //            {
-            //                DB_ResidenceData.residenceData.CurReginID =  UserInfo.Current.regionList[0].RegionID;
-            //            }
-            //        }
-            //        DB_ResidenceData.residenceData.SaveResidenceData();
-            //         UserInfo.Current.SaveUserInfo();
-            //    }
-            //}
-            //return responsePack.StateCode;
         }
 
         /// <summary>
@@ -599,7 +534,7 @@
         {
             var requestObj = new AddOrUpdateHomeObj()
             {
-                homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID,
+                homeId = DB_ResidenceData.Instance.CurrentRegion.RegionID,
             };
 
             if (editId == 0)
@@ -618,47 +553,74 @@
         /// <summary>
         /// 鑾峰彇鍒锋柊褰撳墠浣忓畢鐨勭綉鍏冲垪琛�
         /// </summary>
-        public void GetHomeGatewayList()
+        public string GetHomeGatewayList()
         {
             try
             {
-                if (string.IsNullOrEmpty(DB_ResidenceData.residenceData.residecenInfo.RegionID)) return;
-                var nowhomeId = DB_ResidenceData.residenceData.residecenInfo.RegionID;
+                if (string.IsNullOrEmpty(DB_ResidenceData.Instance.CurrentRegion.RegionID)) return "";
+                var nowhomeId = DB_ResidenceData.Instance.CurrentRegion.RegionID;
                 var requestJson = HttpUtil.GetSignRequestJson(new HomeIdObj() { homeId = nowhomeId });
                 var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_GetGatewayList, requestJson);
                 if (revertObj.Code == StateCode.SUCCESS)
                 {
                     var mHomeGatewayRes = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomeGatewayInfo>>(revertObj.Data.ToString());
-                    if (nowhomeId == DB_ResidenceData.residenceData.residecenInfo.RegionID)
+                    if (nowhomeId == DB_ResidenceData.Instance.CurrentRegion.RegionID)
                     {
                         if (mHomeGatewayRes != null)
                         {
                             if (mHomeGatewayRes.Count > 0)
                             {
-                                DB_ResidenceData.residenceData.HomeGateway = mHomeGatewayRes[0];
-                                if(mHomeGatewayRes[0].gatewayStatus == "ON_LINE")
-                                {
-                                    DriverLayer.Control.Ins.IsRemote = true;
-                                    DriverLayer.Control.Ins.GatewayOnline = true;
-                                }
-                                DB_ResidenceData.residenceData.SaveResidenceData();
-                                return;
+                                DB_ResidenceData.Instance.HomeGateway = mHomeGatewayRes[0];
+                                //if (mHomeGatewayRes[0].gatewayStatus)
+                                //{
+                                //    DriverLayer.Control.Ins.GatewayOnline = true;
+                                //}
+                                //else
+                                //{
+                                //    DriverLayer.Control.Ins.GatewayOnline = false;
+                                //}
+                                DB_ResidenceData.Instance.SaveResidenceData();
+                                return revertObj.Code;
                             }
                         }
                         //鍏朵綑鎯呭喌娓呯┖缃戝叧淇℃伅
-                        DB_ResidenceData.residenceData.HomeGateway = null;
-                        DB_ResidenceData.residenceData.SaveResidenceData();
+                        DB_ResidenceData.Instance.HomeGateway = null;
+                        DB_ResidenceData.Instance.SaveResidenceData();
                     }
                 }
                 else
                 {
                     //鎻愮ず閿欒
                 }
+                return revertObj.Code;
             }
             catch
             {
-
+                return "";
             }
+        }
+        /// <summary>
+        /// 鑾峰彇缃戝叧淇℃伅
+        /// </summary>
+        public string GetGatewayInfo()
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
+            d.Add("gatewayId", DB_ResidenceData.Instance.HomeGateway.gatewayId);
+            var jsonString = HttpUtil.GetSignRequestJson(d);
+            var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetGatewayInfo, jsonString);
+            if (revertObj.Code == StateCode.SUCCESS)
+            {
+                var mHomeGatewayRes = Newtonsoft.Json.JsonConvert.DeserializeObject<HomeGatewayInfo>(revertObj.Data.ToString());
+                if (mHomeGatewayRes != null)
+                {
+                    if(mHomeGatewayRes.gatewayStatus)
+                    {
+                        DriverLayer.Control.Ins.GatewayOnline = true;
+                    }
+                }
+            }
+            return revertObj.Code;
         }
 
         /// <summary>
@@ -667,7 +629,7 @@
         /// <returns></returns>
         public ResponsePackNew GetResidenceMemberAccount()
         {
-            var requestJson = HttpUtil.GetSignRequestJson(new HomeIdObj() { homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID });
+            var requestJson = HttpUtil.GetSignRequestJson(new HomeIdObj() { homeId = DB_ResidenceData.Instance.CurrentRegion.RegionID });
             return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Child_FindAll, requestJson);
         }
 
@@ -696,7 +658,7 @@
         {
             var requestJson = HttpUtil.GetSignRequestJson(new UpdateChildNickNameObj()
             {
-                homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID,
+                homeId = DB_ResidenceData.Instance.CurrentRegion.RegionID,
                 childAccountId = childAccountId,
                 nickName = nickName,
             });
@@ -713,7 +675,7 @@
         {
             var requestJson = HttpUtil.GetSignRequestJson(new UpdateChildAllowCreateSceneObj()
             {
-                homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID,
+                homeId = DB_ResidenceData.Instance.CurrentRegion.RegionID,
                 childAccountId = childAccountId,
                 isAllowCreateScene = isAllow,
             });
@@ -754,7 +716,7 @@
         {
             var requestJson = HttpUtil.GetSignRequestJson(new GetShareObj()
             {
-                homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID,
+                homeId = DB_ResidenceData.Instance.CurrentRegion.RegionID,
                 childAccountId = childAccountId,
             });
 
@@ -893,7 +855,7 @@
         public ResponsePackNew BindResidenceMemberAccount(string subAccount, string nickName)
         {
             //娣诲姞瀛愯处鍙�
-            var requestObj = new ChildAddObj() { homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID, account = subAccount, nickName = nickName };
+            var requestObj = new ChildAddObj() { homeId = DB_ResidenceData.Instance.CurrentRegion.RegionID, account = subAccount, nickName = nickName };
             var requestJson = HttpUtil.GetSignRequestJson(requestObj);
             return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Child_Add, requestJson);
 
@@ -927,7 +889,7 @@
                     attachClientId = attachClientId,
                     homeType = HomeTypeEnum.BUSPRO.ToString()
                 });
-                var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GetMqttRemoteInfo, requestJson, DB_ResidenceData.residenceData.residecenInfo.regionUrl);
+                var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GetMqttRemoteInfo, requestJson, DB_ResidenceData.Instance.CurrentRegion.regionUrl);
                 if (revertObj.Code == StateCode.SUCCESS)
                 {
                     return Newtonsoft.Json.JsonConvert.DeserializeObject<MqttInfo>(revertObj.Data.ToString());
@@ -962,15 +924,15 @@
                 isProduce = false;
 #endif
 
-                if (string.IsNullOrEmpty(UserInfo.Current.PushDeviceToken)) {
+                if (string.IsNullOrEmpty(OnAppConfig.Instance.PushDeviceToken)) {
                     Utlis.WriteLine("PushDeviceToken 涓虹┖");
                     return false;
                 }
 
                 var mAddpushinfoObj = new AddpushinfoObj()
                 {
-                    pushToken = UserInfo.Current.PushDeviceToken,
-                    deviceName = UserInfo.Current.PhoneName,
+                    pushToken = OnAppConfig.Instance.PushDeviceToken,
+                    deviceName = OnAppConfig.Instance.PhoneName,
                     deviceType = deviceType,
                     produce = isProduce,
                 };
@@ -985,8 +947,8 @@
                         var pushId = revertObj.Data.ToString();
                         if (!string.IsNullOrEmpty(pushId))
                         {
-                            UserInfo.Current.PushId = pushId;
-                            UserInfo.Current.SaveUserInfo();
+                            OnAppConfig.Instance.PushId = pushId;
+                            OnAppConfig.Instance.SaveConfig();
                             Utlis.WriteLine("PushId: " + pushId);
                            
                             return true;
@@ -1031,7 +993,7 @@
 
             var requestJson = HttpUtil.GetSignRequestJson(new GetMessageListObj()
             {
-                pushId = UserInfo.Current.PushId,
+                pushId = OnAppConfig.Instance.PushId,
                 pushType = pushType
             });
             return HttpUtil.RequestHttpsPost(NewAPI.API_POST_PushSerivce_Getpushmessagelist, requestJson);
@@ -1043,11 +1005,11 @@
         /// <returns></returns>
         public bool PushSerivceClearmessagelist()
         {
-            if (string.IsNullOrEmpty(UserInfo.Current.PushId)) return false;
+            if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) return false;
 
             var requestJson = HttpUtil.GetSignRequestJson(new PushIdObj()
             {
-                pushId = UserInfo.Current.PushId
+                pushId = OnAppConfig.Instance.PushId
             });
 
             var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_PushSerivce_Clearmessagelist, requestJson);
@@ -1068,11 +1030,11 @@
         /// <returns></returns>
         public bool PushSerivceSignOut()
         {
-            if (string.IsNullOrEmpty(UserInfo.Current.PushId)) return false;
+            if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) return false;
             try
             {
                 var requestJson = HttpUtil.GetSignRequestJson(new PushIdObj() {
-                    pushId = UserInfo.Current.PushId
+                    pushId = OnAppConfig.Instance.PushId
                 });
                
                 var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_PushSerivce_DeleteToken, requestJson);
@@ -1099,13 +1061,13 @@
         /// <returns></returns>
         public bool PushSerivceMarkAllMessageRead()
         {
-            if (string.IsNullOrEmpty(UserInfo.Current.PushId)) return false;
+            if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) return false;
 
             try
             {
                 var requestJson = HttpUtil.GetSignRequestJson(new PushIdObj()
                 {
-                    pushId = UserInfo.Current.PushId
+                    pushId = OnAppConfig.Instance.PushId
                 });
                 var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_PushSerivce_ALLMarkread, requestJson);
                 if (revertObj.Code == StateCode.SUCCESS)
@@ -1131,7 +1093,7 @@
         /// <returns></returns>
         public bool PushSerivceMarkMessageRead(string msgId)
         {
-            if (string.IsNullOrEmpty(UserInfo.Current.PushId)) return false;
+            if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) return false;
 
             try
             {
@@ -1164,7 +1126,7 @@
         /// <returns></returns>
         public bool PushSerivceDeleteMessage(string msgId)
         {
-            if (string.IsNullOrEmpty(UserInfo.Current.PushId)) return false;
+            if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) return false;
 
             try
             {
@@ -1802,8 +1764,8 @@
         public ResponsePackNew GetDeviceList()
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
-            d.Add("gatewayId", DB_ResidenceData.residenceData.HomeGateway.gatewayId);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
+            //d.Add("gatewayId", DB_ResidenceData.residenceData.HomeGateway.gatewayId);
             //d.Add("roomId", DB_ResidenceData.residenceData.residecenInfo.RegionID);//鍙帶鍙傛暟锛屽綋闇�瑕佸垎椤佃幏鍙栵紝鎬庝箞鐭ラ亾鍒嗛〉鎬绘暟
             //d.Add("searchType", DB_ResidenceData.residenceData.residecenInfo.RegionID);
             //d.Add("pageSize", DB_ResidenceData.residenceData.residecenInfo.RegionID);
@@ -1819,7 +1781,7 @@
         public ResponsePackNew GetDeviceInfoList(List<string> functionIds)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("deviceIds", functionIds);
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
@@ -1832,10 +1794,11 @@
         public ResponsePackNew RefreshDeviceStatus(List<string> functionIds)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("deviceIds", functionIds);
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
+            MainPage.Log($"璇诲彇璁惧鐘舵�侊細{requestJson}");
             return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_RefreshDeviceStatus, requestJson);
         }
 
@@ -1846,8 +1809,8 @@
         public ResponsePackNew ControlDevice(List<ApiAlinkControlActionObj> actionObjs)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
-            d.Add("gatewayId", DB_ResidenceData.residenceData.HomeGateway.gatewayId);//DriverLayer.Control.Ins.GatewayId);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
+            d.Add("gatewayId", DB_ResidenceData.Instance.HomeGateway.gatewayId);//DriverLayer.Control.Ins.GatewayId);
             d.Add("actions", actionObjs);
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
@@ -1861,8 +1824,8 @@
         public ResponsePackNew UpdataDevcieInfo(Function function)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
-            d.Add("gatewayId", DB_ResidenceData.residenceData.HomeGateway.gatewayId);//DriverLayer.Control.Ins.GatewayId);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
+            d.Add("deviceId", function.deviceId);
             d.Add("name", function.name);
             d.Add("collect", function.collect);
             d.Add("roomIds", function.roomIds);
@@ -1871,17 +1834,33 @@
             return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_EditDevice, requestJson);
         }
         /// <summary>
-        /// 璁惧缁戝畾鎴块棿
+        /// 鏇存柊璁惧缁戝畾鎴块棿淇℃伅
         /// </summary>
-        public string BindDeviceToRoom(string deviceId,string roomId)
+        /// <returns></returns>
+        public ResponsePackNew UpdataDevcieBindRoomInfo(Function function)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
-            d.Add("deviceIds", new List<string>() { deviceId});
-            d.Add("roomIds", new List<string>() { roomId});
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
+            d.Add("deviceId", function.deviceId);
+            d.Add("roomIds", function.roomIds);
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
-            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_BindDeviceToRoom, requestJson).Code;
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_EditDevice, requestJson);
+        }
+
+
+        /// <summary>
+        /// 璁惧缁戝畾鎴块棿
+        /// </summary>
+        public ResponsePackNew BindDeviceToRoom(List<string> deviceIds,List<string> roomIds)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
+            d.Add("deviceIds", deviceIds);
+            d.Add("roomIds", roomIds);
+
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_BindDeviceToRoom, requestJson);
         }
         /// <summary>
         /// 璁惧瑙g粦鎴块棿
@@ -1889,7 +1868,7 @@
         public string UnbindDeviceToRoom(string deviceId, string roomId)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("deviceIds", new List<string>() { deviceId });
             d.Add("roomIds", new List<string>() { roomId });
 
@@ -1902,7 +1881,7 @@
         public string EditDeviceName(string deviceId, string deviceName)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("deviceId", deviceId);
             d.Add("name", deviceName);
 
@@ -1915,7 +1894,7 @@
         public ResponsePackNew CollectDevice(string deviceId)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("deviceIds",new List<string>() { deviceId });
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
@@ -1927,7 +1906,7 @@
         public ResponsePackNew CancelCollectDevice(string deviceId)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("deviceIds", new List<string>() { deviceId });
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
@@ -1946,7 +1925,7 @@
         public ResponsePackNew GetSceneList(string roomId = null)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             if (roomId != null)
             {
                 d.Add("roomId", roomId);
@@ -1966,8 +1945,23 @@
             d.Add("userSceneIds",new List<string>() { seceneId });
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
-            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetSecneList, requestJson);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetSecneInfo, requestJson);
         }
+
+        /// <summary>
+        /// 鑾峰彇鍦烘櫙璇︽儏鍒楄〃
+        /// </summary>
+        /// <param name="seceneId">鍦烘櫙ID</param>
+        /// <returns></returns>
+        public ResponsePackNew GetSceneListInfo(List<string> seceneIds)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("userSceneIds", seceneIds);
+
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetSecneInfo, requestJson);
+        }
+
         /// <summary>
         /// 娣诲姞鍦烘櫙
         /// </summary>
@@ -1975,11 +1969,15 @@
         public ResponsePackNew AddScene(Scene scene)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("scenes", new List<Scene>() { scene });
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
-            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_AddSecne, requestJson);
+            var pack = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_AddSecne, requestJson);
+
+            MainPage.Log($"{pack.Data}");
+
+            return pack;
         }
         /// <summary>
         /// 缂栬緫鍦烘櫙
@@ -1989,7 +1987,7 @@
         public ResponsePackNew EditScene(Scene scene)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("scenes", new List<Scene>() { scene });
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
@@ -2002,7 +2000,7 @@
         public string DeleteScene(string userSceneId)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("userSceneIds", new List<string>() { userSceneId });
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
@@ -2015,7 +2013,7 @@
         public string ExecuteScene(string userSceneId)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("userSceneIds", new List<string>() { userSceneId });
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
@@ -2029,7 +2027,7 @@
         public string CollectScene(string userSceneId)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("userSceneIds", new List<string>() { userSceneId });
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
@@ -2043,7 +2041,7 @@
         public string CancelCollectScene(string userSceneId)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("userSceneIds", new List<string>() { userSceneId });
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
@@ -2060,11 +2058,12 @@
         public ResponsePackNew GetRoomList(string GetType = "All")
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             if (GetType != "All")
             {
                 d.Add("roomType", GetType);
             }
+            d.Add("pageSize", "1000");
             var requestJson = HttpUtil.GetSignRequestJson(d);
             var pack = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetRoomList, requestJson);
             
@@ -2078,7 +2077,7 @@
         public ResponsePackNew AddRoom(List<SpatialInfo> rooms)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("rooms", rooms);
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
@@ -2097,7 +2096,7 @@
         public ResponsePackNew UpdateRoom(List<SpatialInfo> rooms)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("rooms", rooms);
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
@@ -2117,7 +2116,7 @@
         public ResponsePackNew DeleteRoom(List<string> roomIds)
         {
             Dictionary<string, object> d = new Dictionary<string, object>();
-            d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
             d.Add("ids", roomIds);
 
             var requestJson = HttpUtil.GetSignRequestJson(d);

--
Gitblit v1.8.0