From c96d62ac9c6bb1d880a9170f9dd477fcb5f76fc0 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期三, 01 二月 2023 10:16:11 +0800 Subject: [PATCH] 备注同步功能 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Room/GenericDialog.cs | 95 +++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 91 insertions(+), 4 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Room/GenericDialog.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Room/GenericDialog.cs index 6e22cda..310a1e9 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Room/GenericDialog.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Room/GenericDialog.cs @@ -96,6 +96,8 @@ dialogBottomView.AddChidren (editor); editor.MouseUpEventHandler += (dff, ffd) => { + + string remakeStr = etDeviceName.Text.Trim (); if (string.IsNullOrEmpty (remakeStr)) { //澶囨敞涓嶈兘涓虹┖ @@ -107,6 +109,21 @@ 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 (); @@ -146,14 +163,14 @@ 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 (); @@ -162,6 +179,76 @@ }); } }); + + + //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 (); } -- Gitblit v1.8.0