From 1ecba3f7432912d4eb7637355f4dfae676059e00 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 15 十二月 2020 17:23:58 +0800 Subject: [PATCH] 1 --- HDL_ON/DAL/Server/HttpServerRequest.cs | 131 +++++++++++++++++++++++++------------------ 1 files changed, 75 insertions(+), 56 deletions(-) diff --git a/HDL_ON/DAL/Server/HttpServerRequest.cs b/HDL_ON/DAL/Server/HttpServerRequest.cs index 15c157b..71bfe0f 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,45 @@ }; UserInfo.Current.regionList.Add(home); } - - if (string.IsNullOrEmpty(UserInfo.Current.CurReginID)) + //-------濡傛灉璐﹀彿鏄娆$櫥褰� + if (DB_ResidenceData.Instance.CurrentRegion == null || string.IsNullOrEmpty(DB_ResidenceData.Instance.CurrentRegion.RegionID)) { - UserInfo.Current.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 == UserInfo.Current.CurReginID); - if(curRegion == null) + //浣忓畢琚垹闄� + 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 + { + //鍒锋柊褰撳墠浣忓畢 + DB_ResidenceData.Instance.CurrentRegion = findHome; + DB_ResidenceData.Instance.SaveResidenceData(); + UserInfo.Current.SaveUserInfo(); + //鍒锋柊涓�娆′綇瀹呯綉鍏� + GetHomeGatewayList(); } } - - - DB_ResidenceData.residenceData.SaveResidenceData(); - UserInfo.Current.SaveUserInfo(); - - //鍒锋柊涓�娆′綇瀹呯綉鍏� - GetHomeGatewayList(); } } @@ -531,7 +546,7 @@ { var requestObj = new AddOrUpdateHomeObj() { - homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID, + homeId = DB_ResidenceData.Instance.CurrentRegion.RegionID, }; if (editId == 0) @@ -554,32 +569,36 @@ { 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.IsRemote = true; DriverLayer.Control.Ins.GatewayOnline = true; } - DB_ResidenceData.residenceData.SaveResidenceData(); + else + { + DriverLayer.Control.Ins.GatewayOnline = false; + } + 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 +618,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 +647,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 +664,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 +705,7 @@ { var requestJson = HttpUtil.GetSignRequestJson(new GetShareObj() { - homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID, + homeId = DB_ResidenceData.Instance.CurrentRegion.RegionID, childAccountId = childAccountId, }); @@ -825,7 +844,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 +878,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()); @@ -1734,7 +1753,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 +1770,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 +1783,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 +1797,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 +1812,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 +1827,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 +1840,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 +1853,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 +1866,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 +1878,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 +1897,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); @@ -1898,7 +1917,7 @@ 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> /// 娣诲姞鍦烘櫙 @@ -1907,7 +1926,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 +1940,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 +1953,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 +1966,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 +1980,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 +1994,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 +2011,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 +2029,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 +2048,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 +2068,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