黄学彪
2019-11-25 5727cf0b9b54da0a191dd1e23cb5abf21320fbff
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/TimeSettignPage.cs
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using Com.Autonavi.Amap.Mapcore;
using Java.Security;
using Shared.Common;
using ZigBee.Device;
@@ -14,33 +12,34 @@
        /// </summary>
        /// <param name="common"></param>
        /// <param name="typeTag"></param>
        public void DeviceInfoChange(CommonDevice common, string typeTag)
        public void DeviceInfoChange(CommonDevice tempDevice, string typeTag)
        {
            if (typeTag == "DeviceStatusReport" && common != null)
            if (typeTag == "DeviceStatusReport" && tempDevice != null)
            {
                var tempDevice = (CommonDevice)common;
                if (tempDevice.DeviceEpoint == doorLock.DeviceEpoint
                    && tempDevice.DeviceAddr == doorLock.DeviceAddr)
                if (tempDevice != null)
                {
                    var door = tempDevice as ZigBee.Device.DoorLock;
                    if (door != null && door.DeviceStatusReport != null && door.DeviceStatusReport.AttriBute != null)
                    if (tempDevice.DeviceEpoint == doorLock.DeviceEpoint
                                      && tempDevice.DeviceAddr == doorLock.DeviceAddr)
                    {
                        var dataReport = door.DeviceStatusReport.AttriBute[0];
                        if (door.DeviceStatusReport.CluterID == 10 && dataReport.AttributeId == 0)
                        if (tempDevice.DeviceStatusReport != null && tempDevice.DeviceStatusReport.AttriBute != null)
                        {
                            CurentDoorLockTime = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetLocalTime(dataReport.AttriButeData);
                            Application.RunOnMainThread(() =>
                            var dataReport = tempDevice.DeviceStatusReport.AttriBute[0];
                            if (tempDevice.DeviceStatusReport.CluterID == 10 && dataReport.AttributeId == 0)
                            {
                                textDisplayDate.Text = CurentDoorLockTime.Year + Language.StringByID(R.MyInternationalizationString.Year) + CurentDoorLockTime.Month + Language.StringByID(R.MyInternationalizationString.Month) + CurentDoorLockTime.Day + Language.StringByID(R.MyInternationalizationString.Day);
                                if (CurentDoorLockTime.Minute < 10)
                                CurentDoorLockTime = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetLocalTime(dataReport.AttriButeData);
                                Application.RunOnMainThread(() =>
                                {
                                    textDisplayTime.Text = CurentDoorLockTime.Hour + ":" + "0" + CurentDoorLockTime.Minute;
                                }
                                else
                                {
                                    textDisplayTime.Text = CurentDoorLockTime.Hour + ":" + CurentDoorLockTime.Minute;
                                }
                            });
                                    textDisplayDate.Text = CurentDoorLockTime.Year + Language.StringByID(R.MyInternationalizationString.Year) + CurentDoorLockTime.Month + Language.StringByID(R.MyInternationalizationString.Month) + CurentDoorLockTime.Day + Language.StringByID(R.MyInternationalizationString.Day);
                                    if (CurentDoorLockTime.Minute < 10)
                                    {
                                        textDisplayTime.Text = CurentDoorLockTime.Hour + ":" + "0" + CurentDoorLockTime.Minute;
                                    }
                                    else
                                    {
                                        textDisplayTime.Text = CurentDoorLockTime.Hour + ":" + CurentDoorLockTime.Minute;
                                    }
                                });
                            }
                        }
                    }
                }
@@ -108,7 +107,6 @@
            this.btnBack.MouseUpEventHandler += eHandlerBack;
            this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
            this.MidFrameLayout(this);
            MidFrameLayoutContent();
        }
@@ -116,10 +114,12 @@
        {
            if (setTimeType == "DoorLockTime")
            {
                // 只有重新启动时会慢,然后其他时刻都是有值的
                new System.Threading.Thread(() =>
                {
                    while (this.Parent != null)
                    {
                        //读门锁时间
                        doorLock.ReadAttri(ZigBee.Device.Cluster_ID.DoorLock, ZigBee.Device.AttriButeId.DoorLock);
                        System.Threading.Thread.Sleep(5 * 1000);
                    }
@@ -136,6 +136,12 @@
            var dtNow = DateTime.Now;
            for (int i = 0; i < 2; i++)
            {
                var rowLayout = new FrameLayout()
                {
                    Height = Application.GetRealHeight(58),
                };
                MidTopFrameLayout.AddChidren(rowLayout);
                var btnDateTime = new Button()
                {
                    Width = Application.GetRealWidth(560),
@@ -145,7 +151,7 @@
                    TextAlignment = TextAlignment.CenterLeft,
                    TextSize = 12,
                };
                MidTopFrameLayout.AddChidren(btnDateTime);
                rowLayout.AddChidren(btnDateTime);
                var textDisplayDateFrameLayout = new FrameLayout()
                {
@@ -153,7 +159,7 @@
                    Height = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(620),
                };
                MidTopFrameLayout.AddChidren(textDisplayDateFrameLayout);
                rowLayout.AddChidren(textDisplayDateFrameLayout);
                var btnNextFrameLayout = new FrameLayout()
                {
@@ -161,7 +167,7 @@
                    Height = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(956),
                };
                MidTopFrameLayout.AddChidren(btnNextFrameLayout);
                rowLayout.AddChidren(btnNextFrameLayout);
                var btnNext = new Button()
                {
@@ -189,7 +195,7 @@
                if (i == 0)
                {
                    btnDateTime.Y = Application.GetRealHeight(50);
                    rowLayout.Y = Application.GetRealHeight(50);
                    btnLine.Y = Application.GetRealHeight(23 + 127);
                    textDisplayDate = new Button()
@@ -197,9 +203,10 @@
                        TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                        TextAlignment = TextAlignment.CenterRight,
                        TextSize = 12,
                        Text = "_" + Language.StringByID(R.MyInternationalizationString.Year) + "_" + Language.StringByID(R.MyInternationalizationString.Month) + "_" + Language.StringByID(R.MyInternationalizationString.Day),
                    };
                    textDisplayDateFrameLayout.AddChidren(textDisplayDate);
                    textDisplayDateFrameLayout.Y = btnNextFrameLayout.Y = btnDateTime.Y;
                    //textDisplayDateFrameLayout.Y = btnNextFrameLayout.Y = btnDateTime.Y;
                    if (setTimeType != "DoorLockTime")
                    {
@@ -212,16 +219,17 @@
                }
                else if (i == 1)
                {
                    btnDateTime.Y = Application.GetRealHeight(200);
                    rowLayout.Y = Application.GetRealHeight(200);
                    btnLine.Y = Application.GetRealHeight(40 + 127 + 127);
                    textDisplayTime = new Button()
                    {
                        TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                        TextAlignment = TextAlignment.CenterRight,
                        TextSize = 12,
                        Text = "00:00",
                    };
                    textDisplayDateFrameLayout.AddChidren(textDisplayTime);
                    textDisplayDateFrameLayout.Y = btnNextFrameLayout.Y = btnDateTime.Y;
                    //textDisplayDateFrameLayout.Y = btnNextFrameLayout.Y = btnDateTime.Y;
                    if (setTimeType != "DoorLockTime")
                    {
@@ -403,6 +411,7 @@
                        {
                            this.btnBottomTitle.TextID = R.MyInternationalizationString.CurrentTime;
                        }
                        mUIPickerView.Y = Application.GetRealWidth(95);
                        var mList1 = new List<string>();
                        var mList2 = new List<string>();
@@ -451,6 +460,7 @@
                            curMin = m;
                            curSec = dtNow.Second;
                        };
                        if (setTimeType == "ValidTime")
                        {
                            Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateHour = curHour;
@@ -464,39 +474,43 @@
                            Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateSecond = curSec;
                        }
                        var btnOk = new Button
                        if (setTimeType != "DoorLockTime")
                        {
                            X = Application.GetRealWidth(919),
                            Y = Application.GetRealHeight(40),
                            Height = Application.GetRealHeight(58),
                            Width = Application.GetRealWidth(101),
                            Text = Language.StringByID(R.MyInternationalizationString.Complete),
                            TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                            TextSize = 14,
                        };
                        this.bottomRadiusFrameLayout.AddChidren(btnOk);
                        btnOk.MouseUpEventHandler += (sender1, e1) =>
                        {
                            if (setTimeType == "ValidTime")
                            var btnOk = new Button
                            {
                                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateHour = curHour;
                                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMinute = curMin;
                                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateSecond = curSec;
                            }
                            else
                                X = Application.GetRealWidth(919),
                                Y = Application.GetRealHeight(40),
                                Height = Application.GetRealHeight(58),
                                Width = Application.GetRealWidth(101),
                                Text = Language.StringByID(R.MyInternationalizationString.Complete),
                                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                                TextSize = 14,
                            };
                            this.bottomRadiusFrameLayout.AddChidren(btnOk);
                            btnOk.MouseUpEventHandler += (sender1, e1) =>
                            {
                                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateHour = curHour;
                                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMinute = curMin;
                                Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateSecond = curSec;
                            }
                            if (timeSetAction != null)
                            {
                                timeSetAction();
                            }
                            this.shadowRadiusFrameLayout.RemoveFromParent();
                        };
                                if (setTimeType == "ValidTime")
                                {
                                    Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateHour = curHour;
                                    Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateMinute = curMin;
                                    Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.ValidDateSecond = curSec;
                                }
                                else
                                {
                                    Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateHour = curHour;
                                    Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateMinute = curMin;
                                    Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.InValidDateSecond = curSec;
                                }
                                if (timeSetAction != null)
                                {
                                    timeSetAction();
                                }
                                this.shadowRadiusFrameLayout.RemoveFromParent();
                            };
                        }
                    }
                };
                rowLayout.MouseDownEventHandler += hander;
                btnDateTime.MouseDownEventHandler += hander;
                textDisplayDateFrameLayout.MouseDownEventHandler += hander;
                btnNextFrameLayout.MouseDownEventHandler += hander;
@@ -517,14 +531,20 @@
                    {
                        CommonPage.Loading.Start("");
                        var rectifyResult = await doorLock.RectifyDoorLockTimeAsync(int.Parse(setTimestamp));
                        if (rectifyResult != null && rectifyResult.setWritableValueResponData != null && rectifyResult.setWritableValueResponData.Status == 0)
                        if (rectifyResult != null && rectifyResult.setWritableValueResponData != null)
                        {
                            this.shadowRadiusFrameLayout.RemoveFromParent();
                            // new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RectifySuccess), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
                            if (rectifyResult.setWritableValueResponData.Status == 0)
                            {
                                this.shadowRadiusFrameLayout.RemoveFromParent();
                            }
                            else
                            {
                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RectifyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
                            }
                        }
                        else
                        {
                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.RectifyFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
                        }
                    }
                    catch { }