From 5e3150f8f603a90f29ab2f5a4b014a8bff564cb4 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期一, 14 十二月 2020 19:26:37 +0800
Subject: [PATCH] 2020-12-14 1.解锁页面UI提示文字优化修改。

---
 HDL_ON/DAL/Server/HttpServerRequest.cs |  142 ++++++++++++++++++++++++-----------------------
 1 files changed, 72 insertions(+), 70 deletions(-)

diff --git a/HDL_ON/DAL/Server/HttpServerRequest.cs b/HDL_ON/DAL/Server/HttpServerRequest.cs
index a69df89..f44b93d 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);
@@ -491,30 +491,32 @@
                         };
                         UserInfo.Current.regionList.Add(home);
                     }
-
-                    if (string.IsNullOrEmpty(UserInfo.Current.CurReginID))
+                    //浣忓畢琚垹闄�
+                    var findHome = UserInfo.Current.regionList.Find((obj) => obj.RegionID == DB_ResidenceData.Instance.CurrentRegion.RegionID);
+                    if (findHome == null)
                     {
-                        UserInfo.Current.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();
+                            };
+                            new UI.PublicAssmebly().TipMsg(StringId.Tip, StringId.ResidenceDeletedSwitchToAnotherResidence, action);
+                        });
                     }
                     else
                     {
-                        var curRegion = UserInfo.Current.regionList.Find((obj) => obj.RegionID == UserInfo.Current.CurReginID);
-                        if(curRegion == null)
-                        {
-                            UserInfo.Current.CurReginID = UserInfo.Current.regionList[0].RegionID;
-                            //鎭㈠澶囦唤
-                            //HDLCommon.Current.RestoreHomeBackup(DB_ResidenceData.residenceData.CurReginID);
-                        }
+                        //鍒锋柊褰撳墠浣忓畢
+                        DB_ResidenceData.Instance.CurrentRegion = findHome;
+                        DB_ResidenceData.Instance.SaveResidenceData();
+                        UserInfo.Current.SaveUserInfo();
+                        //鍒锋柊涓�娆′綇瀹呯綉鍏�
+                        GetHomeGatewayList();
                     }
-
-
-                    DB_ResidenceData.residenceData.SaveResidenceData();
-                    UserInfo.Current.SaveUserInfo();
-
-                    //鍒锋柊涓�娆′綇瀹呯綉鍏�
-                    GetHomeGatewayList();
                 }
             }
 
@@ -531,7 +533,7 @@
         {
             var requestObj = new AddOrUpdateHomeObj()
             {
-                homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID,
+                homeId = DB_ResidenceData.Instance.CurrentRegion.RegionID,
             };
 
             if (editId == 0)
@@ -554,32 +556,32 @@
         {
             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];
+                                DB_ResidenceData.Instance.HomeGateway = mHomeGatewayRes[0];
                                 if(mHomeGatewayRes[0].gatewayStatus == "ON_LINE")
                                 {
                                     DriverLayer.Control.Ins.IsRemote = true;
                                     DriverLayer.Control.Ins.GatewayOnline = true;
                                 }
-                                DB_ResidenceData.residenceData.SaveResidenceData();
+                                DB_ResidenceData.Instance.SaveResidenceData();
                                 return;
                             }
                         }
                         //鍏朵綑鎯呭喌娓呯┖缃戝叧淇℃伅
-                        DB_ResidenceData.residenceData.HomeGateway = null;
-                        DB_ResidenceData.residenceData.SaveResidenceData();
+                        DB_ResidenceData.Instance.HomeGateway = null;
+                        DB_ResidenceData.Instance.SaveResidenceData();
                     }
                 }
                 else
@@ -599,7 +601,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);
         }
 
@@ -628,7 +630,7 @@
         {
             var requestJson = HttpUtil.GetSignRequestJson(new UpdateChildNickNameObj()
             {
-                homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID,
+                homeId = DB_ResidenceData.Instance.CurrentRegion.RegionID,
                 childAccountId = childAccountId,
                 nickName = nickName,
             });
@@ -645,7 +647,7 @@
         {
             var requestJson = HttpUtil.GetSignRequestJson(new UpdateChildAllowCreateSceneObj()
             {
-                homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID,
+                homeId = DB_ResidenceData.Instance.CurrentRegion.RegionID,
                 childAccountId = childAccountId,
                 isAllowCreateScene = isAllow,
             });
@@ -686,7 +688,7 @@
         {
             var requestJson = HttpUtil.GetSignRequestJson(new GetShareObj()
             {
-                homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID,
+                homeId = DB_ResidenceData.Instance.CurrentRegion.RegionID,
                 childAccountId = childAccountId,
             });
 
@@ -825,7 +827,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);
 
@@ -859,7 +861,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());
@@ -894,15 +896,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,
                 };
@@ -917,8 +919,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;
@@ -963,7 +965,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);
@@ -975,11 +977,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);
@@ -1000,11 +1002,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);
@@ -1031,13 +1033,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)
@@ -1063,7 +1065,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
             {
@@ -1096,7 +1098,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
             {
@@ -1734,7 +1736,7 @@
         public ResponsePackNew GetDeviceList()
         {
             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("gatewayId", DB_ResidenceData.residenceData.HomeGateway.gatewayId);
             //d.Add("roomId", DB_ResidenceData.residenceData.residecenInfo.RegionID);//鍙帶鍙傛暟锛屽綋闇�瑕佸垎椤佃幏鍙栵紝鎬庝箞鐭ラ亾鍒嗛〉鎬绘暟
             //d.Add("searchType", DB_ResidenceData.residenceData.residecenInfo.RegionID);
@@ -1751,7 +1753,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);
@@ -1764,7 +1766,7 @@
         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);
@@ -1778,8 +1780,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);
@@ -1793,7 +1795,7 @@
         public ResponsePackNew UpdataDevcieInfo(Function function)
         {
             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", function.deviceId);//DriverLayer.Control.Ins.GatewayId);
             d.Add("name", function.name);
             d.Add("collect", function.collect);
@@ -1808,7 +1810,7 @@
         public ResponsePackNew BindDeviceToRoom(List<string> deviceIds,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("deviceIds", deviceIds);
             d.Add("roomIds", roomIds);
 
@@ -1821,7 +1823,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 });
 
@@ -1834,7 +1836,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);
 
@@ -1847,7 +1849,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);
@@ -1859,7 +1861,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);
@@ -1878,7 +1880,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);
@@ -1907,7 +1909,7 @@
         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);
@@ -1921,7 +1923,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);
@@ -1934,7 +1936,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);
@@ -1947,7 +1949,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);
@@ -1961,7 +1963,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);
@@ -1975,7 +1977,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);
@@ -1992,7 +1994,7 @@
         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);
@@ -2010,7 +2012,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);
@@ -2029,7 +2031,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);
@@ -2049,7 +2051,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