| | |
| | | }); |
| | | } |
| | | } catch (Exception ex) { |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | } finally { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | |
| | | ItemButton.MouseUpEventHandler += (sender, e) => { |
| | | Action action = () => { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Start ("please wait..."); |
| | | MainPage.Loading.Start ("Please wait..."); |
| | | }); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | try { |
| | |
| | | InitDevcieRow (alexaDeviceLista, bodyView); |
| | | }); |
| | | } catch (Exception ex) { |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | } finally { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | |
| | | System.Threading.Tasks.Task.Factory.StartNew (() => { |
| | | try { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Start ("please wait..."); |
| | | MainPage.Loading.Start ("Please wait..."); |
| | | }); |
| | | foreach (var newDevicePath in roomDeviceFilePathList) { |
| | | var common = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (newDevicePath))); |
| | |
| | | // DeviceName = common.Name, DeviceID = common.DeviceID, Id = 1, DeviceType = common.Type.ToString (), LoopID = common.LoopID, |
| | | // MAC = UserConfig.Instance.GatewayMAC, RegionID = UserConfig.Instance.CurrentRegion.RegionID, SubnetID = common.SubnetID |
| | | //}); |
| | | |
| | | |
| | | if (common != null) { |
| | | var oldDevice = alexaDeviceLista.Find ((obj) => obj.SubnetID == common.SubnetID && obj.DeviceID == common.DeviceID && obj.LoopID == common.LoopID && obj.DeviceType == common.Type.ToString ()); |
| | | var commonType = common.Type.ToString (); |
| | | if (commonType == "CurtainModel") { |
| | | commonType = "CurtainModule"; |
| | | } else if (commonType == "LightEnergySwitch" || commonType == "LightSwitchSocket" || commonType == "LightEnergySocket") { |
| | | commonType = "LightSwitch"; |
| | | } else if (commonType == "ACInfrared") { |
| | | commonType = "HVAC"; |
| | | } |
| | | var oldDevice = alexaDeviceLista.Find ((obj) => obj.SubnetID == common.SubnetID && obj.DeviceID == common.DeviceID && obj.LoopID == common.LoopID && obj.DeviceType == commonType); |
| | | if (oldDevice == null) { |
| | | AddDevice (common); |
| | | var isSuccess = AddDevice (common); |
| | | if (!isSuccess) { |
| | | //跳出循环 |
| | | break; |
| | | } |
| | | } else { |
| | | //2020-07-21 如果已经存在 匹配设备备注是否需要更新 |
| | | if (oldDevice.DeviceName != common.Name) { |
| | | //Utlis.WriteLine ("名字不匹配,提交更新:" + common.Name); |
| | | var oldName = oldDevice.DeviceName; |
| | | oldDevice.DeviceName = common.Name; |
| | | var isSuccess = UpdateDevice (oldDevice); |
| | | if (!isSuccess) { |
| | | //还原 |
| | | oldDevice.DeviceName = oldName; |
| | | //Utlis.WriteLine ("更新失败!!!!"); |
| | | } else { |
| | | //Utlis.WriteLine ("更新成功!"); |
| | | } |
| | | } else { |
| | | //Utlis.WriteLine ("名字一样不用更新:"+ common.Name); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | foreach (var oldDevice in alexaDeviceLista) { |
| | | var oldDevicePath = "Equipment_" + oldDevice.DeviceType + "_" + oldDevice.SubnetID + "_" + oldDevice.DeviceID + "_" + (oldDevice.LoopID.ToString ().Length < 2 ? "0" + oldDevice.LoopID.ToString () : oldDevice.LoopID.ToString ()); |
| | | |
| | | if (!roomDeviceFilePathList.Contains (oldDevicePath)) { |
| | | var roomDeviceFilePathListNew = new List<string> (); |
| | | foreach (var path in roomDeviceFilePathList) { |
| | | var deviceFilePath = path; |
| | | if (deviceFilePath.Contains ("LightEnergySocket")) { |
| | | deviceFilePath = deviceFilePath.Replace ("LightEnergySocket", "LightSwitch"); |
| | | } else if (deviceFilePath.Contains ("LightEnergySwitch")) { |
| | | deviceFilePath = deviceFilePath.Replace ("LightEnergySwitch", "LightSwitch"); |
| | | } else if (deviceFilePath.Contains ("LightSwitchSocket")) { |
| | | deviceFilePath = deviceFilePath.Replace ("LightSwitchSocket", "LightSwitch"); |
| | | } else if (deviceFilePath.Contains ("ACInfrared")) { |
| | | deviceFilePath = deviceFilePath.Replace ("ACInfrared", "HVAC"); |
| | | } else if (deviceFilePath.Contains ("CurtainModel")) { |
| | | deviceFilePath = deviceFilePath.Replace ("CurtainModel", "CurtainModule"); |
| | | } |
| | | roomDeviceFilePathListNew.Add (deviceFilePath); |
| | | } |
| | | |
| | | foreach (var oldDevice in alexaDeviceLista) { |
| | | var oldDevicePath = "Equipment_" + oldDevice.DeviceType + "_" + oldDevice.SubnetID + "_" + oldDevice.DeviceID + "_" + (oldDevice.LoopID.ToString ().Length < 2 ? "0" + oldDevice.LoopID.ToString () : oldDevice.LoopID.ToString ()); |
| | | if (!roomDeviceFilePathListNew.Contains (oldDevicePath)) { |
| | | DelDevice (oldDevice.Id); |
| | | Console.WriteLine ("delDevice " + oldDevice.DeviceName); |
| | | Utlis.WriteLine ("delDevice " + oldDevice.DeviceName); |
| | | } |
| | | } |
| | | |
| | |
| | | var oldScene = alexaSceneList.Find ((obj) => obj.SceneName == tempScene.Name); |
| | | if (oldScene == null) { |
| | | int sceneDeviceCount = tempScene.DeviceFilePathList.Count; |
| | | var uploadScene = new SceneAndDeviceList () { MAC = UserConfig.Instance.GatewayMAC, RegionID = UserConfig.Instance.CurrentRegion.RegionID, SceneName = tempScene.Name }; |
| | | var uploadScene = new SceneAndDeviceList () { MAC = UserConfig.Instance.GatewayMAC, RegionID = UserConfig.Instance.CurrentRegion.Id, SceneName = tempScene.Name }; |
| | | |
| | | byte [] replyBytes = null; |
| | | if (!tempScene.busScene) { |
| | |
| | | uploadScene.DeviceListObject.Add (new AddCloudSceneDeviceData () { |
| | | Command = (int)Command.UpdataCurtainModelStutas, SubnetId = device.SubnetID, DeviceId = device.DeviceID, |
| | | DeviceName = device.Name, DeviceType = "CurtainModule", LoopId = device.LoopID, |
| | | DataString = device.Status.ToString () |
| | | DataString = ((byte)device.Status).ToString () |
| | | }); |
| | | } |
| | | } else if (common.Type == DeviceType.CurtainRoller) { |
| | |
| | | uploadScene.DeviceListObject.Add (new AddCloudSceneDeviceData () { |
| | | Command = (int)Command.UpdataCurtainModelStutas, SubnetId = device.SubnetID, DeviceId = device.DeviceID, |
| | | DeviceName = device.Name, DeviceType = "CurtainRoller", LoopId = device.LoopID, |
| | | DataString = (device.Status + 3).ToString () |
| | | DataString = ((byte)device.CurtainProress + 3).ToString () |
| | | }); |
| | | } |
| | | } else if (common.Type == DeviceType.CurtainTrietex) { |
| | |
| | | uploadScene.DeviceListObject.Add (new AddCloudSceneDeviceData () { |
| | | Command = (int)Command.UpdataCurtainModelStutas, SubnetId = device.SubnetID, DeviceId = device.DeviceID, |
| | | DeviceName = device.Name, DeviceType = "CurtainRoller", LoopId = device.LoopID, |
| | | DataString = (device.Status + 3).ToString () |
| | | DataString = ((byte)device.CurtainProress + 3).ToString () |
| | | }); |
| | | } |
| | | } else if (common.Type == DeviceType.HVAC || common.Type == DeviceType.ACInfrared) { |
| | |
| | | Command = (int)Command.SetScene, SubnetId = device.SubnetID, DeviceId = device.DeviceID, |
| | | DeviceName = device.Name, DeviceType = "SceneControl", LoopId = device.AreaID, |
| | | DataString = device.AreaSceneID.ToString () |
| | | }); |
| | | } |
| | | } else if (common.Type == DeviceType.UniversalDevice) {//2020-09-02 新增通用开关 |
| | | var device = Newtonsoft.Json.JsonConvert.DeserializeObject<UniversalDevice> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); |
| | | if (device != null) { |
| | | uploadScene.DeviceListObject.Add (new AddCloudSceneDeviceData () { |
| | | Command = (int)Command.SetCommonSwitch, SubnetId = device.SubnetID, DeviceId = device.DeviceID, |
| | | DeviceName = device.Name, DeviceType = "UniversalDevice", LoopId = device.LoopID, |
| | | DataString = device.SendBytes[1].ToString(), |
| | | }); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | AddScene (uploadScene); |
| | | var isSuccess = AddScene (uploadScene); |
| | | if (!isSuccess) { |
| | | //跳出循环 |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | alexaDeviceLista = ReadDeviceList (); |
| | | Application.RunOnMainThread (() => { |
| | |
| | | }); |
| | | |
| | | } catch (Exception ex) { |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | } finally { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | |
| | | System.Threading.Tasks.Task.Factory.StartNew (() => { |
| | | try { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Start ("please wait..."); |
| | | MainPage.Loading.Start ("Please wait..."); |
| | | }); |
| | | var tempRoom = new Room (); |
| | | foreach (var device in alexaDeviceLista) {//特殊处理服务器与本地设备类型不一样的设备 |
| | | var deviceTypeSaveString = device.DeviceType; |
| | | if (deviceTypeSaveString == "CurtainModule") { |
| | | deviceTypeSaveString = "CurtainModel"; |
| | | if (deviceTypeSaveString == "CurtainModel") { |
| | | deviceTypeSaveString = "CurtainModule"; |
| | | } else if (deviceTypeSaveString == "LightEnergySwitch") { |
| | | deviceTypeSaveString = "LightSwitch"; |
| | | } else if (deviceTypeSaveString == "LightEnergySocket") { |
| | |
| | | userDeviceListPage.ShowPage (action, saveAction); |
| | | }); |
| | | } catch (Exception ex) { |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | } finally { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | |
| | | public List<UpdateDeviceObj> ReadDeviceList () |
| | | { |
| | | var deviceList = new List<UpdateDeviceObj> (); |
| | | var requestObj = new DeviceByRegionListObj () { RegionID = UserConfig.Instance.CurrentRegion.RegionID }; |
| | | var requestObj = new GetDeviceListObj () { RegionID = UserConfig.Instance.CurrentRegion.Id }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps ("DeviceByRegionList", requestJson); |
| | | if (revertObj.StateCode == "SUCCESS") { |
| | | deviceList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<UpdateDeviceObj>> (revertObj.ResponseData.ToString()); |
| | | var revertObj = MainPage.RequestHttps (API.GetDeviceList, requestJson); |
| | | if (revertObj.StateCode.ToUpper () == StateCode.SUCCESS) { |
| | | deviceList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<UpdateDeviceObj>> (revertObj.ResponseData.ToString ()); |
| | | } else { |
| | | //2020-06-29 弹窗提示错误 |
| | | ShowErrorInfo (revertObj.StateCode); |
| | | |
| | | } |
| | | return deviceList; |
| | | } |
| | |
| | | /// </summary> |
| | | public bool AddDevice (Common device) |
| | | { |
| | | var uploadDevice = new AlexaDevice () { |
| | | RegionID = UserConfig.Instance.CurrentRegion.RegionID, MAC = UserConfig.Instance.GatewayMAC.Replace (".", ""), |
| | | var uploadDevice = new AlexaDeviceObj () { |
| | | RegionID = UserConfig.Instance.CurrentRegion.Id, MAC = UserConfig.Instance.GatewayMAC.Replace (".", ""), |
| | | DeviceName = device.Name, DeviceID = device.DeviceID, SubnetID = device.SubnetID, LoopID = device.LoopID, DeviceType = device.Type.ToString () |
| | | }; |
| | | if (device.Type.ToString () == "CurtainModel") { |
| | |
| | | } else if (device.Type.ToString () == "ACInfrared") { |
| | | uploadDevice.DeviceType = "HVAC"; |
| | | } |
| | | var requestObj = new UploadDevicesObj () { Device = uploadDevice }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps ("UploadDevices", requestJson); |
| | | if (revertObj.StateCode == "SUCCESS") { |
| | | //var requestObj = new UploadDevicesObj () { Device = uploadDevice }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (uploadDevice); |
| | | var revertObj = MainPage.RequestHttps (API.UploadDevices, requestJson); |
| | | if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) { |
| | | return true; |
| | | }else if (revertObj.StateCode == "Exist") { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.AddTip (ErrorCode.AddFailed + " " + ErrorCode.NameExist + " ( " + device.Name + " )"); |
| | | }); |
| | | return true; |
| | | } else { |
| | | //2020-06-29 弹出提示错误 |
| | | ShowUploadDevicesInfo (revertObj.StateCode); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 上传设备 错误提示 |
| | | /// </summary> |
| | | /// <param name="stateCodeStr"></param> |
| | | void ShowUploadDevicesInfo (string stateCodeStr,bool bUpload = true) |
| | | { |
| | | string mes = ""; |
| | | if (stateCodeStr == "NoRecord") { |
| | | //住宅未绑定网关! |
| | | mes = ErrorCode.HomeNoRecord; |
| | | } else if (stateCodeStr == "NoExist") { |
| | | //住宅不存在! |
| | | mes = ErrorCode.HomeNoExist; |
| | | } else if (stateCodeStr == "Exist") { |
| | | //设备名称已存在 |
| | | mes = ErrorCode.NameExist; |
| | | } else if (stateCodeStr == ErrorCode.NetworkError) { |
| | | mes = ErrorCode.NetworkError; |
| | | } else { |
| | | mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr; |
| | | |
| | | } |
| | | if (!string.IsNullOrEmpty (mes)) { |
| | | Application.RunOnMainThread (() => { |
| | | if (bUpload) { |
| | | MainPage.AddTip (ErrorCode.AddFailed + " " + mes); |
| | | } else { |
| | | MainPage.AddTip ("Update failed! " + mes); |
| | | } |
| | | |
| | | //new Alert ("", ErrorCode.AddFailed + " " + mes, Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 错误提醒 |
| | | /// </summary> |
| | | /// <param name="stateCodeStr"></param> |
| | | void ShowErrorInfo (string stateCodeStr) |
| | | { |
| | | string mes = ""; |
| | | if (stateCodeStr == ErrorCode.NetworkError) { |
| | | mes = ErrorCode.NetworkError; |
| | | } else { |
| | | mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr; |
| | | |
| | | } |
| | | if (!string.IsNullOrEmpty (mes)) { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.AddTip (ErrorCode.OperationFailed + " " + mes); |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 刷新设备名字 |
| | | /// </summary> |
| | | public bool UpdateDevice (UpdateDeviceObj mUpdateDeviceObj) |
| | | { |
| | | var mUpdateAlexaDeviceObj = new UpdateAlexaDeviceObj () { |
| | | Id = mUpdateDeviceObj.Id, |
| | | DeviceType = mUpdateDeviceObj.DeviceType, |
| | | SubnetID = mUpdateDeviceObj.SubnetID, |
| | | DeviceID = mUpdateDeviceObj.DeviceID, |
| | | LoopID = mUpdateDeviceObj.LoopID, |
| | | DeviceName = mUpdateDeviceObj.DeviceName, |
| | | MAC = mUpdateDeviceObj.MAC, |
| | | RegionID = UserConfig.Instance.CurrentRegion.Id, |
| | | }; |
| | | |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (mUpdateAlexaDeviceObj); |
| | | var revertObj = MainPage.RequestHttps (API.UpdateDevice, requestJson); |
| | | if (revertObj.StateCode.ToUpper () == StateCode.SUCCESS) { |
| | | return true; |
| | | } else if (revertObj.StateCode == "Exist") { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.AddTip ("Update failed!" + " " + ErrorCode.NameExist + " ( " + mUpdateDeviceObj.DeviceName + " )"); |
| | | }); |
| | | return true; |
| | | } else { |
| | | //2020-06-29 弹出提示错误 |
| | | ShowUploadDevicesInfo (revertObj.StateCode, false); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | /// <summary> |
| | | /// 删除设备 |
| | | /// </summary> |
| | | public bool DelDevice(int commonId) |
| | | public bool DelDevice(string commonId) |
| | | { |
| | | var requestObj = new DelDeviceObj () { Id = commonId }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps ("DelDevice", requestJson); |
| | | if (revertObj.StateCode == "SUCCESS") { |
| | | var revertObj = MainPage.RequestHttps (API.DeleteDevice, requestJson); |
| | | if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) { |
| | | return true; |
| | | } else { |
| | | //2020-06-29 弹窗提示错误 |
| | | ShowErrorInfo (revertObj.StateCode); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | public List<SceneByRegion> ReadSceneList () |
| | | { |
| | | var sceneList = new List<SceneByRegion> (); |
| | | var requestObj = new SceneByRegionListObj () { RegionID = UserConfig.Instance.CurrentRegion.RegionID }; |
| | | var requestObj = new SceneByRegionListObj () { RegionID = UserConfig.Instance.CurrentRegion.Id }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps ("SceneByRegionList", requestJson); |
| | | if (revertObj.StateCode == "SUCCESS") { |
| | | var revertObj = MainPage.RequestHttps (API.GetSceneList, requestJson); |
| | | if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) { |
| | | sceneList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SceneByRegion>> (revertObj.ResponseData.ToString ()); |
| | | } else { |
| | | //2020-06-29 弹窗提示错误 |
| | | ShowErrorInfo (revertObj.StateCode); |
| | | } |
| | | return sceneList; |
| | | } |
| | |
| | | public bool AddScene (SceneAndDeviceList sceneMark) |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (sceneMark); |
| | | var revertObj = MainPage.RequestHttps ("AddSceneAndDeviceList", requestJson); |
| | | if (revertObj.StateCode == "SUCCESS") { |
| | | var revertObj = MainPage.RequestHttps (API.AddSceneAndDeviceList, requestJson); |
| | | if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) { |
| | | //var requestAddDeviceObj = new BindDeviceToSceneItemObj () { SceneId = sceneId, Command = command, DeviceID = 0, DataString = dataString }; |
| | | //var requestAddDeviceJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestAddDeviceObj); |
| | | //var revertAddDeviceObj = MainPage.RequestHttps ("BindDeviceToSceneItem", requestAddDeviceJson); |
| | | //if (revertAddDeviceObj.StateCode == "SUCCESS") { |
| | | //if (revertAddDeviceObj.StateCode.ToUpper() == StateCode.SUCCESS) { |
| | | return true; |
| | | //} |
| | | } else if (revertObj.StateCode == "Exist") { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.AddTip (ErrorCode.AddFailed + " " + ErrorCode.NameExist + " ( " + sceneMark.SceneName + " )"); |
| | | }); |
| | | return true; |
| | | } else { |
| | | //2020-06-29 弹出提示错误 |
| | | ShowUploadDevicesInfo (revertObj.StateCode); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | |
| | | // var requestAddDeviceObj = new BindDeviceToSceneItemObj () { SceneId = sceneId, Command = command, DeviceID = 0, DataString = dataString }; |
| | | // var requestAddDeviceJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestAddDeviceObj); |
| | | // var revertAddDeviceObj = MainPage.RequestHttps ("BindDeviceToSceneItem", requestAddDeviceJson); |
| | | // if (revertAddDeviceObj.StateCode == "SUCCESS") { |
| | | // if (revertAddDeviceObj.StateCode.ToUpper() == StateCode.SUCCESS) { |
| | | // return true; |
| | | // } |
| | | // return false; |
| | |
| | | /// <summary> |
| | | /// 删除场景 |
| | | /// </summary> |
| | | public bool DelScene (int sceneId) |
| | | public bool DelScene (string sceneId) |
| | | { |
| | | var requestObj = new DeleteScene () { Id = sceneId }; |
| | | var requestObj = new DeleteSceneObj () { Id = sceneId }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps ("DeleteScene", requestJson); |
| | | if (revertObj.StateCode == "SUCCESS") { |
| | | var revertObj = MainPage.RequestHttps (API.DeleteScene, requestJson); |
| | | if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) { |
| | | return true; |
| | | } else { |
| | | //2020-06-29 弹窗提示错误 |
| | | ShowErrorInfo (revertObj.StateCode); |
| | | } |
| | | return false; |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="bodyView"></param> |
| | | /// <param name="isScene"></param> |
| | | void AddTopTitleView (VerticalScrolViewLayout bodyView, bool isScene = false) { |
| | | var chooseTypeView = new RowLayout () { |
| | | Height = Application.GetRealHeight (80), |
| | | BackgroundColor = SkinStyle.Current.TitileView, |
| | | }; |
| | | bodyView.AddChidren (chooseTypeView); |
| | | Button btnEquipmentIcon = new Button () { |
| | | Width = Application.GetRealHeight (65), |
| | | Height = Application.GetRealHeight (65), |
| | | UnSelectedImagePath = "Item/LogicModule.png", |
| | | X = Application.GetRealWidth (30), |
| | | Gravity = Gravity.CenterVertical, |
| | | }; |
| | | chooseTypeView.AddChidren (btnEquipmentIcon); |
| | | |
| | | Button btnEquipmentType = new Button () { |
| | | Width = Application.GetRealHeight (460), |
| | | X = btnEquipmentIcon.Right, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = Language.StringByID (R.MyInternationalizationString.Device), |
| | | TextColor = SkinStyle.Current.TextColor1, |
| | | SelectedTextColor = SkinStyle.Current.DialogTextColor |
| | | }; |
| | | chooseTypeView.AddChidren (btnEquipmentType); |
| | | |
| | | if (isScene) { |
| | | btnEquipmentIcon.UnSelectedImagePath = "Scene/Scene.png"; |
| | | btnEquipmentType.Text = Language.StringByID (R.MyInternationalizationString.Scenes); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加设备界面 |
| | |
| | | public void InitDevcieRow (List<UpdateDeviceObj> list, VerticalScrolViewLayout bodyView) |
| | | { |
| | | bodyView.RemoveAll (); |
| | | |
| | | if (list.Count > 0) { |
| | | //添加标题 |
| | | AddTopTitleView (bodyView); |
| | | } |
| | | |
| | | foreach (var device in list) { |
| | | var rowView = new RowLayout () { |
| | | Height = Application.GetRealHeight (110), |
| | |
| | | alert.Show (); |
| | | alert.ResultEventHandler += (s, dd) => { |
| | | if (dd) { |
| | | if (DelDevice (device.Id)) { |
| | | rowView.RemoveFromParent (); |
| | | list.Remove (device); |
| | | } |
| | | //if (DelDevice (device.Id)) { |
| | | // rowView.RemoveFromParent (); |
| | | // list.Remove (device); |
| | | //} |
| | | |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load)); |
| | | }); |
| | | try { |
| | | var result = DelDevice (device.Id); |
| | | Application.RunOnMainThread (() => { |
| | | if (result) { |
| | | rowView.RemoveFromParent (); |
| | | list.Remove (device); |
| | | } |
| | | }); |
| | | |
| | | } catch { } finally { |
| | | |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | }; |
| | | }; |
| | |
| | | /// </summary> |
| | | public void InitSceneRow (List<SceneByRegion> list, VerticalScrolViewLayout bodyView) |
| | | { |
| | | if (list.Count > 0) { |
| | | //添加标题 |
| | | AddTopTitleView (bodyView, true); |
| | | } |
| | | |
| | | foreach (var scene in list) { |
| | | var rowView = new RowLayout () { |
| | | Height = Application.GetRealHeight (110), |
| | |
| | | alert.Show (); |
| | | alert.ResultEventHandler += (s, dd) => { |
| | | if (dd) { |
| | | if (DelScene (scene.SceneId)) { |
| | | rowView.RemoveFromParent (); |
| | | list.Remove (scene); |
| | | } |
| | | //if (DelScene (scene.SceneId)) { |
| | | // rowView.RemoveFromParent (); |
| | | // list.Remove (scene); |
| | | //} |
| | | |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load)); |
| | | }); |
| | | try { |
| | | var result = DelScene (scene.SceneId); |
| | | Application.RunOnMainThread (() => { |
| | | if (result) { |
| | | rowView.RemoveFromParent (); |
| | | list.Remove (scene); |
| | | } |
| | | }); |
| | | |
| | | } catch { } finally { |
| | | |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | }; |
| | | }; |