陈嘉乐
2020-05-19 0e0584b87851c56745bf73b1a961b80613dd0721
ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindTargetsPage.cs
@@ -67,10 +67,6 @@
        /// </summary>
        List<int> typeModeList;
        /// <summary>
        /// 网关中的场景列表
        /// </summary>
        public List<ScenesListInfo> gwScenesList = new List<ScenesListInfo>();
        /// <summary>
        /// 是否支持读取
        /// </summary>
        bool IsRead = false;
@@ -95,21 +91,12 @@
                    }
                    //获取本地场景列表
                    scList = HdlSceneLogic.Current.GetAllRoomSceneList();
                    //获取网关场景表
                    if (gwScenesList.Count == 0)
                    {
                        var gwSceneObj = await currentKey.GetSceneInfoAsync();
                        if (gwSceneObj != null && gwSceneObj.getSceneInfo != null)
                        {
                            gwScenesList = gwSceneObj.getSceneInfo.ScenesList;
                        }
                    }
                    //动态获取按键支持的大类
                    typeModeList = await GetTypeMode();
                    #region 读取面板当前模式
                    //读取按键当前模式
                    var tempDeata = await currentKey.ReadPanelConfigureInfoAsync();
                    var tempDeata = HdlDeviceBindLogic.Current.ReadPanelConfigureInfoAsync(currentKey);
                    if (tempDeata != null && tempDeata.deviceStatusReportData != null)
                    {
                        foreach (var attr in tempDeata.deviceStatusReportData.AttriBute)
@@ -136,7 +123,7 @@
                            GetDeviceBindResponseAllData getBindList = null;
                            if (IsRead)
                            {
                                getBindList = await currentKey.GetDeviceBindAsync();
                                getBindList = HdlDeviceBindLogic.Current.GetDeviceBindAsync(currentKey);
                                var bindDeviceListTemp = new System.Collections.Generic.List<BindListResponseObj> { };
                                var bindSceneListTemp = new System.Collections.Generic.List<BindListResponseObj> { };
                                if (getBindList != null && getBindList.getAllBindResponseData != null)
@@ -270,7 +257,7 @@
                    {
                        currentClusterID = 6;
                        currentKey.panelMode = 1;
                        var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey, gwScenesList);
                        var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey);
                        Shared.Phone.UserView.HomePage.Instance.AddChidren(addScenePage);
                        Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                        addScenePage.Show();
@@ -647,7 +634,7 @@
                     try
                     {
                         CommonPage.Loading.Start("");
                         var bindResult = await currentKey.ClearBindInfoAsync();
                         var bindResult = HdlDeviceBindLogic.Current.ClearBindInfoAsync(currentKey);
                         if (bindResult != null && bindResult.clearBindInfoResponseData != null)
                         {
                             if (bindResult.clearBindInfoResponseData.Result != 0)
@@ -658,10 +645,10 @@
                             }
                             else
                             {
                                 var temp = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Default);
                                 var temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Default);
                                 if (temp != null && temp.setWritableValueResponData?.Status != 0)
                                 {
                                     var temp1 = await currentKey.ConfigureHdlKeyValueAsync(Panel.KeyMode.Default);
                                     var temp1 = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Default);
                                     if (temp1 != null && temp1.setWritableValueResponData?.Status != 0)
                                     {
                                         new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ChangeBindMode), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnDel);
@@ -691,7 +678,6 @@
                             currentKey.bindList.Clear();
                             RefreshList();
                             //如果是场景,用户删除清空当前到房间列表
                             currentKey.RoomId = "";
                             currentKey.ReSave();
                         }
                         CommonPage.Loading.Hide();
@@ -740,21 +726,27 @@
            if (typeModeList == null)
            {
                //再次动态获取按键支持的大类
                CommonPage.Loading.Start();
                Application.RunOnMainThread(() =>
                {
                    CommonPage.Loading.Start();
                });
                typeModeList = await GetTypeMode();
                if (typeModeList == null)
                {
                    Application.RunOnMainThread(() =>
                    {
                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                        CommonPage.Loading.Hide();
                    });
                    CommonPage.Loading.Hide();
                    dialog.Close();
                    return;
                }
                else
                {
                    CommonPage.Loading.Hide();
                    Application.RunOnMainThread(() =>
                    {
                        CommonPage.Loading.Hide();
                    });
                }
            }
@@ -897,7 +889,7 @@
                                     var result = await RemoveTargets(bindSc, line2);
                                     if (result == 0)
                                     {
                                         var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey, gwScenesList);
                                         var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey);
                                         Shared.Phone.UserView.HomePage.Instance.AddChidren(addScenePage);
                                         Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                                         addScenePage.Show();
@@ -920,7 +912,7 @@
                        }
                        else
                        {
                            var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey, gwScenesList);
                            var addScenePage = new Shared.Phone.UserCenter.DeviceBind.AddScenePage(currentKey);
                            Shared.Phone.UserView.HomePage.Instance.AddChidren(addScenePage);
                            Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                            addScenePage.Show();
@@ -1124,6 +1116,13 @@
        /// <returns></returns>
        private async System.Threading.Tasks.Task<List<int>> GetTypeMode()
        {
            //如果当前住宅是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                //则默认全部功能都给它
                typeModeList = new List<int>() { 1, 100, 200, 300, 0, 101, 102 };
                return typeModeList;
            }
            if (typeModeList != null)
            {
                typeModeList.Clear();
@@ -1179,7 +1178,7 @@
            {
                CommonPage.Loading.Start("");
                var delResult = new DelDeviceBindResponseAllData();
                delResult = await currentKey.DelDeviceBindAsync(delDevice);
                delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice);
                if (delResult != null && delResult.delDeviceBindResponseData != null)
                {
                    if (delResult.delDeviceBindResponseData?.RemoveBindList != null)
@@ -1196,7 +1195,6 @@
                                    {
                                        currentKey.panelMode = 65535;
                                    }
                                    currentKey.RoomId = "";
                                    currentKey.ReSave();
                                    return 0;
                                    break;
@@ -1206,7 +1204,7 @@
                                    {
                                        CommonPage.Loading.Start("");
                                        var getBindList = await currentKey.GetDeviceBindAsync();
                                        var getBindList = HdlDeviceBindLogic.Current.GetDeviceBindAsync(currentKey);
                                        var bindDeviceListTemp = new System.Collections.Generic.List<BindListResponseObj> { };
                                        var bindSceneListTemp = new System.Collections.Generic.List<BindListResponseObj> { };
                                        if (getBindList != null)