xm
2020-04-16 6fa9d69da922c8049f5acfcbb9ce9fd26811024c
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs
File was renamed from ZigbeeApp20200414/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs
@@ -90,6 +90,7 @@
        /// 设置FrameLayout
        /// </summary>
        FrameLayout btnFuncSetFrameLayout;
        FrameLayout progressFrameLayoutMatch;
        /// <summary>
        /// 点击开布局
        /// </summary>
@@ -366,25 +367,32 @@
            };
            btnFrameLayout.AddChidren(closeFrameLayout);
            progressFrameLayoutMatch = new FrameLayout()
            {
                Width = Application.GetRealHeight(84),//639-35
                Height = Application.GetRealHeight(446),
                X = Application.GetMinReal(51),
                BackgroundColor = ZigbeeColor.Current.XMWhite,
            };
            btnFrameLayout.AddChidren(progressFrameLayoutMatch);
            var progressFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(9),//639-35
                Height = Application.GetRealHeight(446),
                X = Application.GetRealWidth(95),
                Y = Application.GetRealHeight(0),
                Width = Application.GetRealHeight(17),//639-35
                Gravity = Gravity.CenterHorizontal,
                BackgroundColor = ZigbeeColor.Current.XMVerticalSeekBar,
            };
            btnFrameLayout.AddChidren(progressFrameLayout);
            progressFrameLayoutMatch.AddChidren(progressFrameLayout);
            progressButton = new Button()
            {
                Width = Application.GetMinReal(84),//639-35
                Height = Application.GetMinReal(93),
                X = Application.GetRealWidth(58),
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(347),
                UnSelectedImagePath = "DoorLock/UnLockButton.png",
            };
            btnFrameLayout.AddChidren(progressButton);
            progressFrameLayoutMatch.AddChidren(progressButton);
            btnDoorOpenPic = new Button()
            {
@@ -679,6 +687,9 @@
                            }
                            NormallyOpenModeValue(tempRes);
                            Application.RunOnMainThread(async () =>
                            {
                            var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist();
                            if (resTemp == 1)
                            {
@@ -688,9 +699,6 @@
                            {
                                HaveLogicNormallyOpenMode = false;
                            }
                            Application.RunOnMainThread(() =>
                            {
                                UpdateNomallyOpenStatus();
                            });
                        }
                    }
@@ -753,6 +761,7 @@
                {
                    Application.RunOnMainThread(() =>
                    {
                        UpdateNomallyOpenStatus();
                        CommonPage.Loading.Hide();
                    });
                }
@@ -868,6 +877,10 @@
            };
            openFrameLayout.MouseUpEventHandler += hander1;
            btnDoorOpenPic.MouseUpEventHandler += hander1;
            if (progressButton.Y == Application.GetRealHeight(10))
            {
                progressFrameLayoutMatch.MouseUpEventHandler += hander1;
            }
            //关锁事件
            EventHandler<MouseEventArgs> hander2 = (sender, e) =>
@@ -1090,38 +1103,14 @@
                            //每次重新设置常开,默认时间都是12小时
                            DoorLockCommonInfo.NormallyOpenModeInvalidTime = 12;
                            NormallyOpenModeValue(true);
                            Application.RunOnMainThread(() =>
                            {
                            UpdateNomallyOpenStatus();
                            CommonPage.Loading.Hide();
                            });
                            //常开模式开启提示
                            string msgNomallyModeIsTurnOn = Language.StringByID(R.MyInternationalizationString.NomallyModeIsTurnOn);
                            var doorLockInValidSetting = Language.StringByID(R.MyInternationalizationString.DoorLockInValidSetting);
                            var alertNomallyModeIsTurnOn = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.DoorLockLogic, msgNomallyModeIsTurnOn, doorLockInValidSetting);
                            alertNomallyModeIsTurnOn.Show();
                            alertNomallyModeIsTurnOn.MsgControlClickEvent += async () =>
                            {
                                //默认创建常开模式的特殊逻辑
                                var res = await Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock);
                                if (!res)
                                {
                                    string msg0 = Language.StringByID(R.MyInternationalizationString.AddLogicNormallyModeFailed);
                                    this.ShowTipMsg(msg0);
                                    return;
                                }
                            };
                            //点击自动化
                            alertNomallyModeIsTurnOn.LogicClickEvent += () =>
                            {
                                //逻辑调用前记得移除
                                ZbGateway.StatusList.Remove(this);
                                //调用逻辑界面
                                Shared.Phone.Device.Logic.SkipView.SkipAddLogic(2, doorLock);
                            };
                            alertNomallyModeIsTurnOn.InvalidClickEvent += async () =>
                            {
                                NomallyOpenModeInvalidTimeDialog();
                            };
                            AlreadyOpenNormallyMode();
                        }
                    };
                };
@@ -1159,22 +1148,32 @@
                {
                    //上报“常开模式”已被取消,app默认了“常开模式”被取消
                    NormallyOpenModeValue(false);
                    UpdateNomallyOpenStatus();
                    //删除已经失效的“常开模式”的逻辑
                    var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3);
                    if (resTemp == 3)
                    Application.RunOnMainThread(() =>
                    {
                        string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed);
                        this.ShowTipMsg(msg0);
                        UpdateNomallyOpenStatus();
                    });
                    //删除已经失效的“常开模式”的逻辑
                    if (HaveLogicNormallyOpenMode)
                    {
                        var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3);
                        //if (resTemp == 3)
                        //{
                        //    string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed);
                        //    this.ShowTipMsg(msg0);
                        //}
                    }
                }
                else
                {
                    //app默认“常开模式”还是开启
                    NormallyOpenModeValue(true);
                    Application.RunOnMainThread(() =>
                    {
                    UpdateNomallyOpenStatus();
                    });
                }
            };
            alert.CancelClickEvent += async () =>
            {
                if (IsFromReport)
@@ -1182,12 +1181,15 @@
                    //上报“常开模式”已被取消
                    Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); });
                    //先删除已失效的“常开模式”的逻辑 
                    var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3);
                    if (resTemp == 3)
                    if (HaveLogicNormallyOpenMode)
                    {
                        string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed);
                        this.ShowTipMsg(msg0);
                        return;
                        var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3);
                        //if (resTemp == 3)
                        //{
                        //    string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed2);
                        //    this.ShowTipMsg(msg0);
                        //    return;
                        //}
                    }
                    //app重新开启“常开模式”
                    var result = await doorLock.SetNormallyOpenModeFuncAsync(true);
@@ -1196,7 +1198,10 @@
                        string msg0 = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime);
                        this.ShowTipMsg(msg0);
                        NormallyOpenModeValue(false);
                        Application.RunOnMainThread(() =>
                        {
                        UpdateNomallyOpenStatus();
                        });
                        return;
                    }
                    if (result.defaultControlResponseData.status != 0)
@@ -1204,22 +1209,28 @@
                        string msg1 = Language.StringByID(R.MyInternationalizationString.OpenNormallyOpenModeFailed);
                        this.ShowTipMsg(msg1);
                        NormallyOpenModeValue(false);
                        Application.RunOnMainThread(() =>
                        {
                        UpdateNomallyOpenStatus();
                        });
                        return;
                    }
                    else
                    {
                        //保持“常开成功”
                        NormallyOpenModeValue(true);
                        Application.RunOnMainThread(() =>
                        {
                        UpdateNomallyOpenStatus();
                        });
                        //创建常开模式的特殊逻辑 
                        var resu = await Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock);
                        if (!resu)
                        {
                            string msg0 = Language.StringByID(R.MyInternationalizationString.AddLogicNormallyModeFailed);
                            this.ShowTipMsg(msg0);
                            return;
                        }
                        //if (!resu)
                        //{
                        //    string msg0 = Language.StringByID(R.MyInternationalizationString.AddLogicNormallyModeFailed);
                        //    this.ShowTipMsg(msg0);
                        //}
                        CommonPage.Loading.Hide();
                    }
@@ -1228,23 +1239,33 @@
                {
                    //app操作不取消“常开模式”
                    NormallyOpenModeValue(true);
                    Application.RunOnMainThread(() =>
                    {
                    UpdateNomallyOpenStatus();
                    });
                }
            };
            alert.ConfirmClickEvent += async () =>
            {
                if (IsFromReport)
                {
                    //上报门锁“常开模式”已经取消,现在app确认“常开模式”取消
                    NormallyOpenModeValue(false);
                    Application.RunOnMainThread(() =>
                    {
                    UpdateNomallyOpenStatus();
                    });
                    //删除已经失效的“常开模式”的逻辑 
                    var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3);
                    if (resTemp == 3)
                    if (HaveLogicNormallyOpenMode)
                    {
                        string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed);
                        this.ShowTipMsg(msg0);
                        var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3);
                        //if (resTemp == 3)
                        //{
                        //    string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed);
                        //    this.ShowTipMsg(msg0);
                        //}
                    }
                }
                else
@@ -1271,22 +1292,65 @@
                        //app确认取消“常开模式”成功
                        NormallyOpenModeValue(false);
                        Application.RunOnMainThread(() =>
                        {
                        UpdateNomallyOpenStatus();
                        });
                        //删除设置常开模式创建的逻辑 
                        if (HaveLogicNormallyOpenMode)
                        {
                        var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3);
                        if (resTemp == 3)
                        {
                            string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed);
                            this.ShowTipMsg(msg0);
                            //因为目前机制问题,逻辑经常失败,所以不提示,后期机制要改,重新做一个这个界面
                            //if (resTemp == 3)
                            //{
                            //    string msg0 = Language.StringByID(R.MyInternationalizationString.CancelLogicNormallyModeFailed);
                            //    this.ShowTipMsg(msg0);
                            //}
                            //else if (resTemp == 2)
                            //{
                            //    string msg2 = Language.StringByID(R.MyInternationalizationString.CloseNormallyOpenModeSuccess);
                            //    this.ShowTipMsg(msg2);
                            //}
                        }
                        else if (resTemp == 2)
                        {
                            string msg2 = Language.StringByID(R.MyInternationalizationString.CloseNormallyOpenModeSuccess);
                            this.ShowTipMsg(msg2);
                        }
                    }
            };
                }
        /// <summary>
        /// 已经开启常开模式提示
        /// </summary>
        public void AlreadyOpenNormallyMode()
        {
            //常开模式开启提示
            string msgNomallyModeIsTurnOn = Language.StringByID(R.MyInternationalizationString.NomallyModeIsTurnOn);
            var doorLockInValidSetting = Language.StringByID(R.MyInternationalizationString.DoorLockInValidSetting);
            var alertNomallyModeIsTurnOn = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.DoorLockLogic, msgNomallyModeIsTurnOn, doorLockInValidSetting);
            alertNomallyModeIsTurnOn.Show();
            alertNomallyModeIsTurnOn.MsgControlClickEvent += async () =>
            {
                //默认创建常开模式的特殊逻辑
                var res = await Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock);
                //if (!res)
                //{
                //string msg0 = Language.StringByID(R.MyInternationalizationString.AddLogicNormallyModeFailed);
                // this.ShowTipMsg(msg0);
                //return;
                //}
            };
            //点击自动化
            alertNomallyModeIsTurnOn.LogicClickEvent += () =>
            {
                //逻辑调用前记得移除
                ZbGateway.StatusList.Remove(this);
                //调用逻辑界面
                Shared.Phone.Device.Logic.SkipView.SkipAddLogic(2, doorLock);
            };
            alertNomallyModeIsTurnOn.InvalidClickEvent += async () =>
            {
                NomallyOpenModeInvalidTimeDialog();
            };
        }
@@ -1323,12 +1387,16 @@
                 var res = await Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock);
                 if (!res)
                 {
                     //默认创建常开模式失败
                     string msg0 = Language.StringByID(R.MyInternationalizationString.AddLogicNormallyModeFailed);
                     this.ShowTipMsg(msg0);
                     return;
                     //二次加载弹窗 常开模式开启提示
                     NomallyOpenModeInvalidTimeDialog();
                 }
             };
        }
        /// <summary>
        /// 常开模式状态更新
        /// </summary>