HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-09-30 404cdc88627f942df7944af04ee05b9d527752d6
ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs
old mode 100644 new mode 100755
@@ -102,59 +102,59 @@
        /// <param name="common">Common.</param>
        /// <param name="typeTag">Type tag.</param>
        public void DeviceInfoChange(CommonDevice common, string typeTag)
        {
        {
            //设备上报状态中 当CluterID=3,就证明该设备在线,直接标记
            if (typeTag == "DeviceStatusReport")
            {
                Application.RunOnMainThread(() =>
                {
                    try
                    {
                        for (int i = 0; deviceVerticalScrolViewLayout != null && i < deviceVerticalScrolViewLayout.ChildrenCount; i++)
                        {
                            var rowFL = deviceVerticalScrolViewLayout.GetChildren(i) as FrameLayout;
                            var rowLayout = rowFL.GetChildren(0) as RowLayout;
                            var deviceUI = rowLayout.Tag as DeviceUI;
                            if (deviceUI.CommonDevice == null || rowLayout.ChildrenCount == 0)
                            {
                                //设备为空或者控件为空
                                continue;
                            }
                            if (common.DeviceAddr != deviceUI.CommonDevice.DeviceAddr || common.DeviceEpoint != deviceUI.CommonDevice.DeviceEpoint)
                            {
                                //判断是否为当前设备
                                continue;
                            }
                            var frameLayout = rowLayout.GetChildren(0) as FrameLayout;
                            switch (deviceUI.CommonDevice.Type)
                            {
                                case DeviceType.OnOffOutput:
                                    //开关功能
                                    if ((common as ZigBee.Device.ToggleLight).DeviceStatusReport.CluterID == 6)
                                    {
                                        var onOffOutputLight = deviceUI.CommonDevice as ZigBee.Device.ToggleLight;
                                        onOffOutputLight.DeviceStatusReport = (common as ZigBee.Device.ToggleLight).DeviceStatusReport;
                                        for (int j = 0; j < frameLayout.ChildrenCount; j++)
                                        {
                                            var tempView = frameLayout.GetChildren(j);
                                            if (tempView.Tag == null)
                                            {
                                                continue;
                                            }
                                            if (tempView.Tag.ToString() == deviceStatus_OnOffStatus)
                                            {
            if (typeTag == "DeviceStatusReport")
            {
                Application.RunOnMainThread(() =>
                {
                    try
                    {
                        for (int i = 0; deviceVerticalScrolViewLayout != null && i < deviceVerticalScrolViewLayout.ChildrenCount; i++)
                        {
                            var rowFL = deviceVerticalScrolViewLayout.GetChildren(i) as FrameLayout;
                            var rowLayout = rowFL.GetChildren(0) as RowLayout;
                            var deviceUI = rowLayout.Tag as DeviceUI;
                            if (deviceUI.CommonDevice == null || rowLayout.ChildrenCount == 0)
                            {
                                //设备为空或者控件为空
                                continue;
                            }
                            if (common.DeviceAddr != deviceUI.CommonDevice.DeviceAddr || common.DeviceEpoint != deviceUI.CommonDevice.DeviceEpoint)
                            {
                                //判断是否为当前设备
                                continue;
                            }
                            var frameLayout = rowLayout.GetChildren(0) as FrameLayout;
                            switch (deviceUI.CommonDevice.Type)
                            {
                                case DeviceType.OnOffOutput:
                                    //开关功能
                                    if ((common as ZigBee.Device.ToggleLight).DeviceStatusReport.CluterID == 6)
                                    {
                                        var onOffOutputLight = deviceUI.CommonDevice as ZigBee.Device.ToggleLight;
                                        onOffOutputLight.DeviceStatusReport = (common as ZigBee.Device.ToggleLight).DeviceStatusReport;
                                        for (int j = 0; j < frameLayout.ChildrenCount; j++)
                                        {
                                            var tempView = frameLayout.GetChildren(j);
                                            if (tempView.Tag == null)
                                            {
                                                continue;
                                            }
                                            if (tempView.Tag.ToString() == deviceStatus_OnOffStatus)
                                            {
                                                //记录、更新状态
                                                if (onOffOutputLight.DeviceStatusReport.AttriBute == null || onOffOutputLight.DeviceStatusReport.AttriBute.Count == 0)
                                                {
                                                    continue;
                                                }
                                                onOffOutputLight.OnOffStatus = onOffOutputLight.DeviceStatusReport.AttriBute[0].AttriButeData;
                                                (tempView as Button).IsSelected = onOffOutputLight.OnOffStatus == 1;
                                                (tempView as Button).IsSelected = onOffOutputLight.OnOffStatus == 1;
                                                //记录回复时间
                                                onOffOutputLight.LastDateTime = DateTime.Now;
                                            }
                                        }
                                            }
                                        }
                                    }
                                    //当CluterID=3,就证明该设备在线,直接标记
                                    if ((common as ZigBee.Device.ToggleLight).DeviceStatusReport.CluterID == 3)
@@ -177,34 +177,34 @@
                                        }
                                    }
                                    break;
                                    break;
                                case DeviceType.AirSwitch:
                                    //开关功能
                                    if ((common as ZigBee.Device.AirSwitch).DeviceStatusReport.CluterID == 6)
                                    {
                                        var airSwitch = deviceUI.CommonDevice as ZigBee.Device.AirSwitch;
                                        airSwitch.DeviceStatusReport = (common as ZigBee.Device.AirSwitch).DeviceStatusReport;
                                        for (int j = 0; j < frameLayout.ChildrenCount; j++)
                                        {
                                            var tempView = frameLayout.GetChildren(j);
                                            if (tempView.Tag == null)
                                            {
                                                continue;
                                            }
                                            if (tempView.Tag.ToString() == deviceStatus_OnOffStatus)
                                            {
                                case DeviceType.AirSwitch:
                                    //开关功能
                                    if ((common as ZigBee.Device.AirSwitch).DeviceStatusReport.CluterID == 6)
                                    {
                                        var airSwitch = deviceUI.CommonDevice as ZigBee.Device.AirSwitch;
                                        airSwitch.DeviceStatusReport = (common as ZigBee.Device.AirSwitch).DeviceStatusReport;
                                        for (int j = 0; j < frameLayout.ChildrenCount; j++)
                                        {
                                            var tempView = frameLayout.GetChildren(j);
                                            if (tempView.Tag == null)
                                            {
                                                continue;
                                            }
                                            if (tempView.Tag.ToString() == deviceStatus_OnOffStatus)
                                            {
                                                //记录、更新状态
                                                if (airSwitch.DeviceStatusReport.AttriBute == null || airSwitch.DeviceStatusReport.AttriBute.Count == 0)
                                                {
                                                    return;
                                                }
                                                airSwitch.OnOffStatus = airSwitch.DeviceStatusReport.AttriBute[0].AttriButeData;
                                                (tempView as Button).IsSelected = airSwitch.OnOffStatus == 1;
                                                (tempView as Button).IsSelected = airSwitch.OnOffStatus == 1;
                                                //记录回复时间
                                                airSwitch.LastDateTime = DateTime.Now;
                                            }
                                        }
                                            }
                                        }
                                    }
                                    //当CluterID=3,就证明该设备在线,直接标记
                                    if ((common as ZigBee.Device.AirSwitch).DeviceStatusReport.CluterID == 3)
@@ -226,12 +226,12 @@
                                            }
                                        }
                                    }
                                    break;
                                    break;
                                case DeviceType.WindowCoveringDevice:
                                case DeviceType.WindowCoveringDevice:
                                    if ((common as ZigBee.Device.Rollershade).DeviceStatusReport.CluterID == 3)
                                    {
                                        var rollershade = deviceUI.CommonDevice as ZigBee.Device.Rollershade;
                                        var rollershade = deviceUI.CommonDevice as ZigBee.Device.Rollershade;
                                        rollershade.IsOnline = 1;
                                        for (int j = 0; j < frameLayout.ChildrenCount; j++)
                                        {
@@ -248,7 +248,7 @@
                                            }
                                        }
                                    }
                                    break;
                                    break;
                                case DeviceType.Thermostat:
                                    //AC功能
@@ -425,94 +425,94 @@
                                    }
                                    break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine($"Error:{ex.Message}");
                    }
                });
            }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine($"Error:{ex.Message}");
                    }
                });
            }
            //设备在线状态上报
            else if (typeTag == "OnlineStatusChange")
            {
                Application.RunOnMainThread(() =>
                {
                    try
                    {
                        for (int i = 0; deviceVerticalScrolViewLayout != null && i < deviceVerticalScrolViewLayout.ChildrenCount; i++)
                        {
                            var rowFL = deviceVerticalScrolViewLayout.GetChildren(i) as FrameLayout;
                            var rowLayout = rowFL.GetChildren(0) as RowLayout;
                            var deviceUI = rowLayout.Tag as DeviceUI;
                            if (deviceUI.CommonDevice == null || rowLayout.ChildrenCount == 0)
                            {
                                //设备为空或者控件为空
                                continue;
                            }
                            if (common.DeviceAddr != deviceUI.CommonDevice.DeviceAddr || common.DeviceEpoint != deviceUI.CommonDevice.DeviceEpoint)
                            {
                                //判断是否为当前设备
                                continue;
                            }
                            var frameLayout = rowLayout.GetChildren(0) as FrameLayout;
                            switch (deviceUI.CommonDevice.Type)
                            {
                                case DeviceType.OnOffOutput:
                                    var onOffOutputLight = deviceUI.CommonDevice as ToggleLight;
                                    onOffOutputLight.IsOnline = (common as ToggleLight).IsOnline;
                                    for (int j = 0; j < frameLayout.ChildrenCount; j++)
                                    {
                                        var tempView = frameLayout.GetChildren(j);
                                        if (tempView.Tag == null)
                                        {
                                            continue;
                                        }
                                        if (tempView.Tag.ToString() == deviceStatus_Online)
                                        {
                                            (tempView as Button).IsSelected = onOffOutputLight.IsOnline == 1;
                                        }
                                    }
                                    //记录回复时间
                                    onOffOutputLight.LastDateTime = DateTime.Now;
                                    break;
                                case DeviceType.AirSwitch:
                                    var airSwitch = deviceUI.CommonDevice as AirSwitch;
                                    airSwitch.IsOnline = (common as AirSwitch).IsOnline;
                                    for (int j = 0; j < frameLayout.ChildrenCount; j++)
                                    {
                                        var tempView = frameLayout.GetChildren(j);
                                        if (tempView.Tag == null)
                                        {
                                            continue;
                                        }
                                        if (tempView.Tag.ToString() == deviceStatus_Online)
                                        {
                                            (tempView as Button).IsSelected = airSwitch.IsOnline == 1;
                                        }
                                    }
                                    //记录回复时间
                                    airSwitch.LastDateTime = DateTime.Now;
                                    break;
                                case DeviceType.WindowCoveringDevice:
                                    var rollershade = deviceUI.CommonDevice as ZigBee.Device.Rollershade;
                                    rollershade.IsOnline = (common as Rollershade).IsOnline;
                                    for (int j = 0; j < frameLayout.ChildrenCount; j++)
                                    {
                                        var tempView = frameLayout.GetChildren(j);
                                        if (tempView.Tag == null)
                                        {
                                            continue;
                                        }
                                        if (tempView.Tag.ToString() == deviceStatus_Online)
                                        {
                                            (tempView as Button).IsSelected = rollershade.IsOnline == 1;
                                        }
                                    }
                                    //记录回复时间
                                    rollershade.LastDateTime = DateTime.Now;
                                    break;
            else if (typeTag == "OnlineStatusChange")
            {
                Application.RunOnMainThread(() =>
                {
                    try
                    {
                        for (int i = 0; deviceVerticalScrolViewLayout != null && i < deviceVerticalScrolViewLayout.ChildrenCount; i++)
                        {
                            var rowFL = deviceVerticalScrolViewLayout.GetChildren(i) as FrameLayout;
                            var rowLayout = rowFL.GetChildren(0) as RowLayout;
                            var deviceUI = rowLayout.Tag as DeviceUI;
                            if (deviceUI.CommonDevice == null || rowLayout.ChildrenCount == 0)
                            {
                                //设备为空或者控件为空
                                continue;
                            }
                            if (common.DeviceAddr != deviceUI.CommonDevice.DeviceAddr || common.DeviceEpoint != deviceUI.CommonDevice.DeviceEpoint)
                            {
                                //判断是否为当前设备
                                continue;
                            }
                            var frameLayout = rowLayout.GetChildren(0) as FrameLayout;
                            switch (deviceUI.CommonDevice.Type)
                            {
                                case DeviceType.OnOffOutput:
                                    var onOffOutputLight = deviceUI.CommonDevice as ToggleLight;
                                    onOffOutputLight.IsOnline = (common as ToggleLight).IsOnline;
                                    for (int j = 0; j < frameLayout.ChildrenCount; j++)
                                    {
                                        var tempView = frameLayout.GetChildren(j);
                                        if (tempView.Tag == null)
                                        {
                                            continue;
                                        }
                                        if (tempView.Tag.ToString() == deviceStatus_Online)
                                        {
                                            (tempView as Button).IsSelected = onOffOutputLight.IsOnline == 1;
                                        }
                                    }
                                    //记录回复时间
                                    onOffOutputLight.LastDateTime = DateTime.Now;
                                    break;
                                case DeviceType.AirSwitch:
                                    var airSwitch = deviceUI.CommonDevice as AirSwitch;
                                    airSwitch.IsOnline = (common as AirSwitch).IsOnline;
                                    for (int j = 0; j < frameLayout.ChildrenCount; j++)
                                    {
                                        var tempView = frameLayout.GetChildren(j);
                                        if (tempView.Tag == null)
                                        {
                                            continue;
                                        }
                                        if (tempView.Tag.ToString() == deviceStatus_Online)
                                        {
                                            (tempView as Button).IsSelected = airSwitch.IsOnline == 1;
                                        }
                                    }
                                    //记录回复时间
                                    airSwitch.LastDateTime = DateTime.Now;
                                    break;
                                case DeviceType.WindowCoveringDevice:
                                    var rollershade = deviceUI.CommonDevice as ZigBee.Device.Rollershade;
                                    rollershade.IsOnline = (common as Rollershade).IsOnline;
                                    for (int j = 0; j < frameLayout.ChildrenCount; j++)
                                    {
                                        var tempView = frameLayout.GetChildren(j);
                                        if (tempView.Tag == null)
                                        {
                                            continue;
                                        }
                                        if (tempView.Tag.ToString() == deviceStatus_Online)
                                        {
                                            (tempView as Button).IsSelected = rollershade.IsOnline == 1;
                                        }
                                    }
                                    //记录回复时间
                                    rollershade.LastDateTime = DateTime.Now;
                                    break;
                                case DeviceType.Thermostat:
                                    var ac = deviceUI.CommonDevice as ZigBee.Device.AC;
                                    ac.IsOnline = (common as ZigBee.Device.AC).IsOnline;
@@ -549,14 +549,14 @@
                                    //记录回复时间
                                    dimmableLight.LastDateTime = DateTime.Now;
                                    break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine($"主页功能刷新-Error:{ex.Message}");
                    }
                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine($"主页功能刷新-Error:{ex.Message}");
                    }
                });
            }
        }
        /// <summary>
@@ -1053,7 +1053,7 @@
        /// <returns><c>true</c>, if bind gateway was haded, <c>false</c> otherwise.</returns>
        private bool HadBindGateway()
        {
            var gatewayList = Common.LocalGateway.Current.GetAllLocalGateway();
            var gatewayList = UserCenter.HdlGatewayLogic.Current.GetAllLocalGateway();
            if (gatewayList.Count == 0)
            {
                return false;
@@ -1095,8 +1095,8 @@
        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
        private void GoToAddGateWay(object sender, MouseEventArgs mouseEventArgs)
        {
            UserCenter.Gateway.SelectNewGateWayForm selectNewGateWayForm = new UserCenter.Gateway.SelectNewGateWayForm { };
            selectNewGateWayForm.AddForm(selectNewGateWayForm);
            var selectNewGateWayForm = new UserCenter.GatewayAdd.NewGateWaySelectForm();
            selectNewGateWayForm.AddForm();
        }
        #endregion
@@ -1471,9 +1471,9 @@
                            //开关灯
                            var light = device.CommonDevice as ToggleLight;
                            //补上非远程
                            if (light.Gateway == null)
                            {
                                continue;
                            if (light.Gateway == null)
                            {
                                continue;
                            }
                            if (light.Gateway.IsVirtual)
                            {
@@ -2666,20 +2666,20 @@
        private void ChangeResidence(House home)
        {
            try
            {
            {
                CommonPage.Loading.Start();
                new System.Threading.Thread(async () =>
                new System.Threading.Thread(async () =>
                 {
                     Config.Instance.HomeId = home.Id;
                     Global.CreateHomeDirectory(home.Id);
                     Config.Instance.Save();
                     //刷新个人中心的内存及线程
                     Config.Instance.Save();
                     //刷新个人中心的内存及线程
                     await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
                     Room.InitAllRoom();
                     Application.RunOnMainThread(() =>
                     {
                     {
                         Show();
                         CommonPage.Loading.Hide();
                     });
@@ -2687,12 +2687,12 @@
                { IsBackground = true }.Start();
            }
            catch (Exception ex)
            {
            {
                Application.RunOnMainThread(() =>
                {
                {
                    CommonPage.Loading.Hide();
                    new Alert(Language.StringByID(R.MyInternationalizationString.Tip), Language.StringByID(R.MyInternationalizationString.CheckInternet), Language.StringByID(R.MyInternationalizationString.Close)).Show();
                    Console.WriteLine(ex.Message);
                    //new Alert(Language.StringByID(R.MyInternationalizationString.Tip), Language.StringByID(R.MyInternationalizationString.CheckInternet), Language.StringByID(R.MyInternationalizationString.Close)).Show();
                    Console.WriteLine(ex.Message);
                });
            }
        }