mac
2024-07-25 3f6685c77beeb12baf840733fb890860f4c26e7c
HDL_ON/UI/UI2/FuntionControlView/ChooseRoomPageBLL.cs
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using HDL_ON.Common;
using HDL_ON.DAL.Server;
using Shared;
namespace HDL_ON.UI
@@ -58,9 +60,44 @@
                        }
                    }
                }
                var waitPage = new Loading();
                bodyView.AddChidren(waitPage);
                new System.Threading.Thread(async() =>
                {
                    //function.UpdataRoomIds();
                    var pack = ApiUtlis.Ins.HttpRequest.UpdataDevcieBindRoomInfo(function);
                    //直接保存本地,
                    function.SaveFunctionFile();
                    if (pack.Code == StateCode.SUCCESS)
                    {
                        if (UI.RoomPage.bodyView != null)
                        {
                            Application.RunOnMainThread(() =>
                            {
                                UI.RoomPage.bodyView.ReLoadPage();
                            });
                        }
                        Entity.SpatialInfo.CurrentSpatial.InitRoomListFunctions();
                        try
                        {
                            //初始化住宅所有房间功能数据
                            foreach (var r in Entity.SpatialInfo.CurrentSpatial.RoomList)
                            {
                                Entity.SpatialInfo.CurrentSpatial.InitRoomFuntion(r);
                            }
                        }
                        catch (Exception ex)
                        {
                            MainPage.Log($"Init room function error : {ex.Message}");
                        }
                    }
                    else
                    {
                        IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
                    }
                function.UpdataRoomIds();
                Entity.SpatialInfo.CurrentSpatial.InitRoomListFunctions();
                })
                { IsBackground = true }.Start();
            };
        }
@@ -79,7 +116,37 @@
                function.roomIds.Remove(room.roomId);
                //room.RemoveRoomFunction(function);
            }
            function.UpdataRoomIds();
            //function.UpdataRoomIds();
            new System.Threading.Thread(() =>
            {
                try
                {
                    var pack = ApiUtlis.Ins.HttpRequest.UpdataDevcieBindRoomInfo(function);
                    //直接保存本地,
                    function.SaveFunctionFile();
                    if (pack.Code == StateCode.SUCCESS)
                    {
                        if (UI.RoomPage.bodyView != null)
                        {
                            Application.RunOnMainThread(() =>
                            {
                                UI.RoomPage.bodyView.ReLoadPage();
                            });
                        }
                    }
                    else
                    {
                        IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
                    }
                }
                catch (Exception ex){
                    MainPage.Log("房间绑定设备异常" + ex.Message);
                }
            })
            { IsBackground = true }.Start();
            if (function.roomIds.Count == Entity.SpatialInfo.CurrentSpatial.RoomList.Count)
            {
                btnChooseAll.IsSelected = true;