| | |
| | | DateTime oldTime = DateTime.MaxValue; |
| | | doorDialog.dialogBtnConfirm.MouseUpEventHandler += async (sender1, e1) => |
| | | { |
| | | Application.RunOnMainThread(() => { CommonPage.Loading.Start("Loading..."); }); |
| | | Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); }); |
| | | if (DateTime.Now < ZigBee.Device.DoorLock.minValue) |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 远程开锁请求 |
| | | /// 绑定远程开锁权限窗口 |
| | | /// </summary> |
| | | /// <param name="doorLock">门锁设备</param> |
| | | /// <param name="action">二次验证的结果成功后的通知</param> |
| | | /// <param name="progressButton">门锁开或关时进度显示</param> |
| | | /// <param name="btnDoorLockPic">门锁图片开/关显示</param> |
| | | public void RemoteUnlockRequest(ZigBee.Device.DoorLock doorLock, Action action, Button progressButton = null, Button btnDoorLockPic = null, Button btnStatus = null, Button btnDoorLockTitle = null) |
| | | { |
| | | if (string.IsNullOrEmpty(doorLock.RemoteUnlockPassword)) |
| | | /// <param name="doorLock"></param> |
| | | /// <param name="btnDoorLockTitle"></param> |
| | | public void BindRemoteUnlockDoorlock(ZigBee.Device.DoorLock doorLock, Button btnDoorLockTitle = null) |
| | | { |
| | | string msgRemoteUnlockRequest = Language.StringByID(R.MyInternationalizationString.BindRemoteUnlockDoorlock); |
| | | var alertRemoteUnlockRequest = new Shared.Phone.UserCenter.ShowMsgControl(ShowMsgType.Confirm, msgRemoteUnlockRequest, Language.StringByID(R.MyInternationalizationString.GoSetting)); |
| | |
| | | } |
| | | }; |
| | | }; |
| | | return; |
| | | } |
| | | |
| | | if (!UserCenterResourse.AccountOption.DoorUnLockByRemote) |
| | | /// <summary> |
| | | /// 系统二次确认窗口 |
| | | /// </summary> |
| | | public void SystemSecondAuthentication() |
| | | { |
| | | string msgDoorUnLockByRemote = Language.StringByID(R.MyInternationalizationString.GoPersonalCenter).Replace("{0}", "\r\n"); |
| | | var alertDoorUnLockByRemote = new Shared.Phone.UserCenter.ShowMsgControl(ShowMsgType.Confirm, msgDoorUnLockByRemote, Language.StringByID(R.MyInternationalizationString.GoSetting)); |
| | |
| | | var form = new UserCenter.UserMain.SecondAuthenticationForm(); |
| | | form.AddForm(); |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 远程开锁请求 |
| | | /// </summary> |
| | | /// <param name="doorLock">门锁设备</param> |
| | | /// <param name="action">二次验证的结果成功后的通知</param> |
| | | /// <param name="progressButton">门锁开或关时进度显示</param> |
| | | /// <param name="btnDoorLockPic">门锁图片开/关显示</param> |
| | | public void RemoteUnlockRequest(ZigBee.Device.DoorLock doorLock, Action action, Button progressButton = null, Button btnDoorLockPic = null, Button btnStatus = null, Button btnDoorLockTitle = null) |
| | | { |
| | | if (string.IsNullOrEmpty(doorLock.RemoteUnlockPassword)) |
| | | { |
| | | BindRemoteUnlockDoorlock(doorLock, btnDoorLockTitle); |
| | | return; |
| | | } |
| | | |
| | | if (!UserCenterResourse.AccountOption.DoorUnLockByRemote) |
| | | { |
| | | SystemSecondAuthentication(); |
| | | return; |
| | | } |
| | | |
| | |
| | | }); |
| | | //远程开锁 |
| | | var remoteControlResult = await doorLock.RemoteControlAsync(doorLock.RemoteUnlockPassword); |
| | | //开锁成功,返回默认响应 |
| | | |
| | | //远程开锁成功,返回默认响应 |
| | | if (remoteControlResult != null && remoteControlResult.responseData != null) |
| | | { |
| | | if (remoteControlResult.responseData.status == 0) |
| | |
| | | { |
| | | if (progressButton != null) |
| | | { |
| | | progressButton.Y = Application.GetRealHeight(347); |
| | | progressButton.Y = Application.GetRealHeight(10); |
| | | } |
| | | if (btnDoorLockPic != null) |
| | | { |
| | | btnDoorLockPic.IsSelected = false; |
| | | btnDoorLockPic.IsSelected = true; |
| | | } |
| | | if (btnStatus != null) |
| | | { |
| | | btnStatus.Text = Language.StringByID(R.MyInternationalizationString.DoorLockOpen); |
| | | btnStatus.Text = Language.StringByID(R.MyInternationalizationString.Current) + Language.StringByID(R.MyInternationalizationString.DoorLockOpen); |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.UnlockSuccess), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(CommonPage.Instance); |
| | | } |
| | | }); |
| | | //开锁成功,默认5秒后门锁自动关锁,根据不同的门锁可能时间不同,这里以“H06C”门锁给的时间 |
| | | System.Threading.Thread.Sleep(5000); |
| | | } |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (progressButton != null) |
| | | { |
| | | progressButton.Y = Application.GetRealHeight(347); |
| | | } |
| | | if (btnDoorLockPic != null) |
| | | { |
| | | btnDoorLockPic.IsSelected = false; |
| | | } |
| | | if (btnStatus != null) |
| | | { |
| | | btnStatus.Text = Language.StringByID(R.MyInternationalizationString.CLose); |
| | | } |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.UnlockFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(CommonPage.Instance); |
| | | }); |
| | | } |
| | | } |
| | | //用于远程开锁的门锁中的密码被删除情况 |
| | | else if (remoteControlResult != null && remoteControlResult.IsPawDispear == true) |
| | | { |
| | | //远程开锁有3次连续操作失败的机会 |
| | | ZigBee.Device.DoorLock.failedCount--; |
| | | if (ZigBee.Device.DoorLock.failedCount != 0) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (progressButton != null) |
| | | { |
| | | progressButton.Y = Application.GetRealHeight(347); |
| | | } |
| | | if (btnDoorLockPic != null) |
| | | { |
| | | btnDoorLockPic.IsSelected = false; |
| | | } |
| | | if (btnStatus != null) |
| | | { |
| | | btnStatus.Text = Language.StringByID(R.MyInternationalizationString.CLose); |
| | | } |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.UnlockFailed), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(CommonPage.Instance); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | //3次操作失败远程开锁失败后,重写设置远程开锁密码 |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (progressButton != null) |
| | | { |
| | | progressButton.Y = Application.GetRealHeight(347); |
| | | } |
| | | if (btnDoorLockPic != null) |
| | | { |
| | | btnDoorLockPic.IsSelected = false; |
| | | } |
| | | if (btnStatus != null) |
| | | { |
| | | btnStatus.Text = Language.StringByID(R.MyInternationalizationString.CLose); |
| | | } |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.DoorlockPasswordDispear), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(CommonPage.Instance); |
| | | CommonPage.Loading.Hide(); |
| | | doorLock.RemoteUnlockPassword = ""; |
| | | var functionSetting = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(doorLock); |
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(functionSetting); |
| | |
| | | }); |
| | | } |
| | | } |
| | | //远程开锁失败的情况 |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(CommonPage.Instance); |
| | | }); |
| | | } |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | |
| | | } |
| | | if (btnStatus != null) |
| | | { |
| | | btnStatus.Text = Language.StringByID(R.MyInternationalizationString.CLose); |
| | | } |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(CommonPage.Instance); |
| | | }); |
| | | } |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (btnStatus != null) |
| | | { |
| | | btnStatus.Text = Language.StringByID(R.MyInternationalizationString.CLose); |
| | | btnStatus.Text = Language.StringByID(R.MyInternationalizationString.Current) + Language.StringByID(R.MyInternationalizationString.CLose); |
| | | } |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | |
| | | } |
| | | } |
| | | |
| | | #region ■ 一般方法___________________________ |
| | | |
| | | /// <summary> |
| | | /// 显示错误信息窗口 |
| | | /// </summary> |
| | | /// <param name="msg"></param> |
| | | public void ShowErrorMsg(string msg) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | var contr = new ShowMsgControl(ShowMsgType.Error, msg); |
| | | contr.Show(); |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 显示Tip信息窗口 |
| | | /// </summary> |
| | | /// <param name="msg"></param> |
| | | public void ShowTipMsg(string msg) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | var contr = new ShowMsgControl(ShowMsgType.Tip, msg); |
| | | contr.Show(); |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |