| | |
| | | dialogBottomView.AddChidren (editor); |
| | | |
| | | editor.MouseUpEventHandler += (dff, ffd) => { |
| | | |
| | | |
| | | string remakeStr = etDeviceName.Text.Trim (); |
| | | if (string.IsNullOrEmpty (remakeStr)) { |
| | | //备注不能为空 |
| | |
| | | if (remakeBytes.Length > 20) { |
| | | new Alert ("", ErrorCode.RemarkLengthExceededTheLimit, "Close").Show (); |
| | | return; |
| | | } |
| | | |
| | | //修改云端备注 |
| | | var cloudDataLoop = CommonConfig.Current.FunctionList.Find ((obj) => obj.bus.SubnetID == commonDevice.SubnetID |
| | | && obj.bus.DeviceID == commonDevice.DeviceID && obj.bus.LoopId == commonDevice.LoopID); |
| | | if (cloudDataLoop == null) { |
| | | new Alert (Language.StringByID (R.MyInternationalizationString.Tip), "Data is not synchronized to the cloud.", Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | } else { |
| | | new System.Threading.Thread (() => { |
| | | var http = new HttpServerRequest (); |
| | | var pack = http.EditDeviceName (cloudDataLoop.deviceId, UserConfig.Instance.CurrentRegion.Id, remakeStr); |
| | | if (pack.Code != "0") { |
| | | new Alert (Language.StringByID (R.MyInternationalizationString.Tip), $"Cloud data modification failed({pack.Code}).", Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | } |
| | | }) { IsBackground = true }.Start (); |
| | | } |
| | | |
| | | MainPage.Loading.Start (); |
| | |
| | | IO.FileUtils.SaveEquipmentMessage (commonDevice, commonDevice.LoopID.ToString ()); |
| | | } |
| | | |
| | | |
| | | |
| | | successAction?.Invoke (); |
| | | |
| | | //IO.FileUtils.SaveEquipmentMessage (commonDevice, commonDevice.LoopID.ToString ()); |
| | | MainPage.Loading.Hide (); |
| | | dialog.Close (); |
| | | |
| | | }); |
| | | |
| | | //修改成功回调 |
| | | successAction?.Invoke (); |
| | | } else { |
| | | Application.RunOnMainThread (() => { |
| | | new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.FailureToModify), Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | |
| | | //string remakeStr = etDeviceName.Text.Trim (); |
| | | //if (string.IsNullOrEmpty (remakeStr)) { |
| | | // //备注不能为空 |
| | | // new Alert ("", ErrorCode.RemarksCannotBeEmpty, "Close").Show (); |
| | | // return; |
| | | //} |
| | | |
| | | //byte [] remakeBytes = CommonPage.MyEncodingGB2312.GetBytes (remakeStr); |
| | | //if (remakeBytes.Length > 20) { |
| | | // new Alert ("", ErrorCode.RemarkLengthExceededTheLimit, "Close").Show (); |
| | | // return; |
| | | //} |
| | | |
| | | //MainPage.Loading.Start (); |
| | | ////byte [] remakeBytes = CommonPage.MyEncodingGB2312.GetBytes (etDeviceName.Text.Trim ()); |
| | | //System.Threading.Tasks.Task.Run (() => { |
| | | // byte [] updateBytes = null; |
| | | // if (commonDevice.Type == DeviceType.LightSwitchSocket) { |
| | | // updateBytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, commonDevice.SubnetID, commonDevice.DeviceID, new byte [] { commonDevice.BigClass, 1, commonDevice.LoopID }); |
| | | // } else { |
| | | // updateBytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, commonDevice.SubnetID, commonDevice.DeviceID, new byte [] { commonDevice.BigClass, commonDevice.MinClass, commonDevice.LoopID }); |
| | | // } |
| | | // if (updateBytes == null) { |
| | | // Application.RunOnMainThread (() => { |
| | | // new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | // MainPage.Loading.Hide (); |
| | | // dialog.Close (); |
| | | // }); |
| | | // return; |
| | | // } |
| | | // byte [] uBytes = new byte [20]; |
| | | // Array.Copy (remakeBytes, 0, uBytes, 0, remakeBytes.Length < 20 ? remakeBytes.Length : 20); |
| | | // Array.Copy (uBytes, 0, updateBytes, 3, 20 < uBytes.Length ? 20 : uBytes.Length); |
| | | // byte [] reBytes = Control.ControlBytesSendHasReturn (Command.SetDeviceLoopInfo, commonDevice.SubnetID, commonDevice.DeviceID, updateBytes); |
| | | // if (reBytes != null) { |
| | | // Application.RunOnMainThread (() => { |
| | | // btnEquipment.Text = commonDevice.Name = etDeviceName.Text.Trim (); |
| | | // if (commonDevice.Type == DeviceType.InfraredMode) { |
| | | // //2020-07-03 修复红外电视修改后变红外模块问题 |
| | | // InfraredMode mTV = Newtonsoft.Json.JsonConvert.DeserializeObject<InfraredMode> (System.Text.Encoding.UTF8.GetString (commonBytes)); |
| | | // if (mTV == null) { |
| | | // IO.FileUtils.SaveEquipmentMessage (commonDevice, commonDevice.LoopID.ToString ()); |
| | | // } else { |
| | | // mTV.Name = etDeviceName.Text.Trim (); |
| | | // IO.FileUtils.SaveEquipmentMessage (mTV, mTV.LoopID.ToString ()); |
| | | // } |
| | | // } else { |
| | | // IO.FileUtils.SaveEquipmentMessage (commonDevice, commonDevice.LoopID.ToString ()); |
| | | // } |
| | | |
| | | // //IO.FileUtils.SaveEquipmentMessage (commonDevice, commonDevice.LoopID.ToString ()); |
| | | // MainPage.Loading.Hide (); |
| | | // dialog.Close (); |
| | | |
| | | // }); |
| | | |
| | | // //修改成功回调 |
| | | // successAction?.Invoke (); |
| | | // } else { |
| | | // Application.RunOnMainThread (() => { |
| | | // new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.FailureToModify), Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | // MainPage.Loading.Hide (); |
| | | // dialog.Close (); |
| | | // }); |
| | | // } |
| | | //}); |
| | | |
| | | |
| | | }; |
| | | dialog.Show (); |
| | | } |