wxr
2023-07-25 39b8b0b9bcf5805ada1a44e5dc72f05f9c6e4fcc
HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockUserManagerPage.cs
@@ -18,7 +18,7 @@
        VerticalScrolViewLayout contentView;
        FrameLayout userPermissionsView;
        Button btnUserName;
        //Button btnUserName;
        Function device;
        VideoDoorlockUser doorlockUser;
@@ -75,7 +75,7 @@
            };
            userNameView.AddChidren(btnEditUserNameIcon);
            btnUserName = new Button()
            var btnUserName = new Button()
            {
                X = Application.GetRealWidth(100),
                Width = Application.GetRealWidth(230),
@@ -94,6 +94,76 @@
            contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8) });
            initOptionView(false);
            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                Action<string> callBack = (str) =>
                {
                    if (string.IsNullOrEmpty(str))
                    {
                        new Tip()
                        {
                            CloseTime = 1,
                            Text = Language.StringByID(StringId.UesrNameCannotBeEmpty),
                            Direction = AMPopTipDirection.None,
                        }.Show(bodyView);
                        return;
                    }
                    if (str == UserInfo.Current.userName)
                    {
                        return;
                    }
                    if (System.Text.Encoding.Default.GetBytes(str).Length > 20)
                    {
                        new Tip()
                        {
                            CloseTime = 1,
                            Text = Language.StringByID(StringId.LengthOutOfRange),
                            Direction = AMPopTipDirection.None,
                        }.Show(bodyView);
                        return;
                    }
                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
                    new System.Threading.Thread(() =>
                    {
                        try
                        {
                            var resultObj = ApiUtlis.Ins.HttpRequest.EditDoorlockUserName(device.deviceId, doorlockUser.extUserId, str);
                            if (resultObj.Code == StateCode.SUCCESS)
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    btnUserName.Text = str;
                                });
                            }
                            else
                            {
                                //失败提示
                                IMessageCommon.Current.ShowErrorInfoAlter(resultObj.Code);
                            }
                        }
                        catch (Exception ex)
                        {
                            MainPage.Log($"update user name error : {ex.Message}");
                        }
                        finally
                        {
                            Application.RunOnMainThread(() =>
                            {
                                waitPage.Hide();
                            });
                        }
                    })
                    { IsBackground = true }.Start();
                };
                var pa = new PublicAssmebly();
                pa.entryMaxLength = 20;
                pa.LoadDialog_EditParater(StringId.ChangeName, doorlockUser.lockUserName, callBack, StringId.UesrNameCannotBeEmpty, 0, new List<string>());
            };
            btnUserName.MouseUpEventHandler = eventHandler;
            btnEditUserNameIcon.MouseUpEventHandler = eventHandler;
            userNameView.MouseUpEventHandler = eventHandler;
        }
        void initOptionView(bool isEdit)
@@ -712,60 +782,7 @@
        /// </summary>
        void LoadEvent_EditUserName()
        {
            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                Action<string> callBack = (str) =>
                {
                    if (string.IsNullOrEmpty(str))
                    {
                        new Tip()
                        {
                            CloseTime = 1,
                            Text = Language.StringByID(StringId.UesrNameCannotBeEmpty),
                            Direction = AMPopTipDirection.None,
                        }.Show(bodyView);
                        return;
                    }
                    if (str == UserInfo.Current.userName)
                    {
                        return;
                    }
                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
                    new System.Threading.Thread(() =>
                    {
                        try
                        {
                            var resultObj = ApiUtlis.Ins.HttpRequest.EditDoorlockUserName(device.deviceId, doorlockUser.extUserId,str);
                            if (resultObj.Code == StateCode.SUCCESS)
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    btnUserName.Text = str;
                                });
                            }
                            else
                            {
                                //失败提示
                                IMessageCommon.Current.ShowErrorInfoAlter(resultObj.Code);
                            }
                        }
                        catch (Exception ex)
                        {
                            MainPage.Log($"update user name error : {ex.Message}");
                        }
                        finally
                        {
                            Application.RunOnMainThread(() =>
                            {
                                waitPage.Hide();
                            });
                        }
                    })
                    { IsBackground = true }.Start();
                };
                new PublicAssmebly().LoadDialog_EditParater(StringId.ChangeName, doorlockUser.lockUserName, callBack, StringId.UesrNameCannotBeEmpty, 0, new System.Collections.Generic.List<string>());
            };
            btnUserName.MouseUpEventHandler = eventHandler;
            //btnUserName.MouseUpEventHandler = eventHandler;
        }