From ea0b1e8e5f43c5fd0a7d479e25ede3b8cbea464a Mon Sep 17 00:00:00 2001
From: wxr <wxr@hdlchina.com.cn>
Date: 星期一, 02 十二月 2024 17:17:19 +0800
Subject: [PATCH] tcp;可视对讲;

---
 HDL_ON/Common/ApiUtlis.cs | 1127 ++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 570 insertions(+), 557 deletions(-)

diff --git a/HDL_ON/Common/ApiUtlis.cs b/HDL_ON/Common/ApiUtlis.cs
index d8172bf..c70e9f2 100644
--- a/HDL_ON/Common/ApiUtlis.cs
+++ b/HDL_ON/Common/ApiUtlis.cs
@@ -1,9 +1,9 @@
 锘縰sing System;
 using System.Collections.Generic;
-using HDL_ON;
-using HDL_ON.DAL;
+using System.Threading;
 using HDL_ON.DAL.Server;
 using HDL_ON.Entity;
+using HDL_ON.UI;
 using HDL_ON.UI.UI2.FuntionControlView.Video;
 using HDL_ON.UI.UI2.Intelligence.Automation;
 using Newtonsoft.Json;
@@ -43,235 +43,99 @@
                 return httpRequest;
             }
         }
-        /// <summary>
-        /// 璇诲彇璁惧鍔熻兘鏁版嵁瀹屾垚
-        /// </summary>
+        bool complateGetHomePagerInfo = false;
+        bool complateGetUserInfo = false;
+        bool complateGetRoomListInfo = false;
+        bool complateGetGroupControl = false;
+        bool complateGetSecurityListInfo = false;
+        bool complateGetLogicListInfo = false;
+        bool complateGet3tyInfo = false;
         bool complateDevice = false;
-        /// <summary>
-        /// 璇诲彇鍦烘櫙鏁版嵁瀹屾垚
-        /// </summary>
         bool complateScene = false;
-        //绾跨▼缁撴潫鏃堕棿
-        DateTime endTime1;
 
-        /// <summary>
-        /// 鏍¢獙缃戝叧鏄惁鍦ㄧ嚎
-        /// </summary>
-        public bool GatewayOnlineVerification()
-        {
-            bool result = DB_ResidenceData.Instance.HomeGateway.gatewayStatus;
-            DriverLayer.Control.Ins.GatewayOnline_Cloud = result;
-            if (!result)
-            {
-
-            }
-
-            return result;
-        }
         /// <summary>
         /// 涓嬭浇鏁版嵁瀹屾垚鏍囪
         /// </summary>
         public bool DownloadDataComplete = false;
 
-        public bool hadInternet = true;
+        /// <summary>
+        /// token鏄惁鏈夋晥
+        /// </summary>
+        public bool IsValidToken = true;
+
         /// <summary>
         /// 涓嬭浇鏁版嵁
         /// </summary>
         public void DownloadData()
         {
+            IsValidToken = true;
             if (MainPage.NoLoginMode)
             {
                 DownloadDataComplete = true;
                 return;
             }
-            endTime1 = DateTime.Now.AddSeconds(25);
-            complateDevice = complateScene = false;
 
             MainPage.Log($"寮�濮嬪悓姝ヤ簯绔暟鎹�");
-
             DownloadDataComplete = false;
 
             var waitPage = new Loading();
             MainPage.BaseView.AddChidren(waitPage);
             waitPage.Start(Language.StringByID(StringId.PleaseWait));
 
-
-            string code = StateCode.SUCCESS;
-
-            var downloadDataThread = new System.Threading.Thread(() =>
+            var downloadDataThread = new Thread(() =>
             {
+                MainPage.Log($"杩涘叆璇诲彇浜戠鏁版嵁绾跨▼");
                 try
                 {
-                    //澧炲姞3绉掍簯鏈嶅姟鍣ㄨ繛鎺ユ娴嬶紝杩炰笉涓婃湇鍔″櫒鐨勬椂鍊欎笉鍒锋柊鏁版嵁
-                    hadInternet = true;
-                    var dataList = new List<GlobalRegionListRes>();
-                    var requestJson = HttpUtil.GetSignRequestJson(new GetRegionListObj() { regionMark = HttpUtil.RegionMark });
-                    var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GlobalRegionList, requestJson, HttpUtil.GlobalRequestHttpsHost, "", 3);
-                    if (revertObj == null || revertObj.Code != StateCode.SUCCESS)
+                    #region ===================鍒锋柊Token=======================
+                    var code = Ins.HttpRequest.RefreshToken();
+                    if (code == StateCode.SUCCESS)
                     {
-                        DownloadDataComplete = true;
-                        hadInternet = false;
-                        try
-                        {
-                            var spatialInfoDataBytes = FileUtlis.Files.ReadFile("SpatialInfoData");
-                            if (spatialInfoDataBytes != null)
-                            {
-                                var spatialInfoDataString = System.Text.Encoding.UTF8.GetString(spatialInfoDataBytes);
-                                if (spatialInfoDataString != null && !string.IsNullOrEmpty(spatialInfoDataString))
-                                {
-                                    var spatialInfoDataList = JsonConvert.DeserializeObject<List<SpatialInfo>>(spatialInfoDataString);
-                                    SpatialInfo.CurrentSpatial.UpdateSpatialList(spatialInfoDataList);
-                                }
-                            }
-                        }
-                        catch (Exception ex)
-                        {
-                            MainPage.Log($"{this.GetType()}:鍔犺浇缂撳瓨鎴块棿鏁版嵁寮傚父:{ex.Message}");
-                        }
-
-                        try
-                        {
-                            var fileList = Common.FileUtlis.Files.ReadFiles();
-                            foreach (var file in fileList)
-                            {
-                                FunctionList.List.IniFunctionList(file, true);
-                            }
-                            Room.CurrentSpatial.InitRoomListFunctions();
-                        }
-                        catch (Exception ex)
-                        {
-                            MainPage.Log($"{this.GetType()}:鍔犺浇缂撳瓨璁惧鏁版嵁寮傚父:{ex.Message}");
-                        }
-
-
-                        return;
+                        IsValidToken = true;
+                        complateGetHomePagerInfo = complateGetUserInfo = complateGetRoomListInfo = complateGetGroupControl =
+                        complateGetSecurityListInfo = complateGetLogicListInfo = complateGet3tyInfo = complateDevice = complateScene = false;
                     }
                     else
                     {
-                        hadInternet = true;
+                        IsValidToken = false;
+                        DownloadDataComplete = true;
+                        complateGetHomePagerInfo = complateGetUserInfo = complateGetRoomListInfo = complateGetGroupControl =
+                        complateGetSecurityListInfo = complateGetLogicListInfo = complateGet3tyInfo = complateDevice = complateScene = true;
+                        //complateGetSecurityListInfo = false;
                     }
-                }
-                catch (Exception ex)
-                {
-                    MainPage.Log($"Error锛氫笅杞芥暟鎹�1锛歿ex.Message}");
-                    DownloadDataComplete = true;
-                    return;
-                }
-                finally
-                {
-                    if (!hadInternet)
+                    #endregion
+                    if (IsValidToken)
                     {
-                        Application.RunOnMainThread(() =>
+                        #region ===================鍒锋柊浣忓畢淇℃伅=======================
+                        new Thread(() =>
                         {
-                            if (waitPage != null)
-                            {
-                                waitPage.Hide();
-                                waitPage.RemoveFromParent();
-                            }
-                        });
-                    }
-                }
-                MainPage.Log($"杩涘叆璇诲彇浜戠鏁版嵁绾跨▼");
-                //===================鍒锋柊Token=======================
-                code = Ins.HttpRequest.RefreshToken();
-                if (code != StateCode.SUCCESS)
-                {
-                    if (waitPage != null)
-                    {
-                        Application.RunOnMainThread(() =>
-                        {
-                            try
-                            {
-                                waitPage.Hide();
-                                waitPage.RemoveFromParent();
-                                waitPage = null;
-                            }
-                            catch { }
-                        });
-                    }
-                    MainPage.Log($"鍒锋柊token澶辫触");
-                    return;
-                }
-                MainPage.Log($"鍒锋柊token鎴愬姛");
-                //===================鍒锋柊浣忓畢淇℃伅=======================
-                code = Ins.HttpRequest.GetHomePager();
-                if (code != StateCode.SUCCESS)
-                {
-                    if (waitPage != null)
-                    {
-                        Application.RunOnMainThread(() =>
-                        {
-                            try
-                            {
-                                waitPage.Hide();
-                                waitPage.RemoveFromParent();
-                                waitPage = null;
-                            }
-                            catch { }
-                        });
-                    }
-                    MainPage.Log($"鍒锋柊浣忓畢淇℃伅澶辫触");
-                    return;
-                }
-                MainPage.Log($"鍒锋柊浣忓畢淇℃伅鎴愬姛");
-                //===================鍒锋柊涓汉淇℃伅=======================
-                code = Ins.HttpRequest.GetUserInfo();
-                if (code != StateCode.SUCCESS)
-                {
-                    if (waitPage != null)
-                    {
-                        Application.RunOnMainThread(() =>
-                        {
-                            try
-                            {
-                                waitPage.Hide();
-                                waitPage.RemoveFromParent();
-                                waitPage = null;
-                            }
-                            catch { }
-                        });
-                    }
-                    MainPage.Log($"鍒锋柊涓汉淇℃伅澶辫触");
-                    return;
-                }
-                MainPage.Log($"鍒锋柊涓汉淇℃伅鎴愬姛");
+                            code = Ins.HttpRequest.GetHomePager();
+                            complateGetHomePagerInfo = true;
+                        })
+                        { IsBackground = true }.Start();
+                        #endregion
 
-                //int count = 0;
-                //while (count < 10)
-                //{
-                //    if (DB_ResidenceData.Instance.CheckWhetherGatewayIdIsNull())
-                //    {
-                //        System.Threading.Thread.Sleep(200);
-                //    }
-                //    else
-                //    {
-                //        break;
-                //    }
-                //    count++;
-                //}
-                //if (DB_ResidenceData.Instance.CheckWhetherGatewayIdIsNull())
-                //{
-                //    return;
-                //}
-
-                //return;
-
-                try
-                {
-                    //===================鎴块棿=======================
-                    var roomResult = Ins.HttpRequest.GetRoomList();
-                    if (roomResult.Code == StateCode.SUCCESS)
-                    {
-                        MainPage.Log($"璇诲彇鎴块棿淇℃伅鎴愬姛");
-                        var revData = JsonConvert.DeserializeObject<SpatialApiPack>(roomResult.Data.ToString());
-                        if (revData == null)
+                        #region ===================鍒锋柊涓汉淇℃伅=======================
+                        new Thread(() =>
                         {
-                            revData = new SpatialApiPack();
-                        }
+                            code = Ins.HttpRequest.GetUserInfo();
+                            complateGetUserInfo = true;
+                        })
+                        { IsBackground = true }.Start();
+                        #endregion
+
+                        #region ===================鎴块棿=======================
+                        new Thread(() =>
                         {
-                            SpatialInfo.CurrentSpatial.UpdateSpatialList(revData.list);
-                            new System.Threading.Thread(() =>
+                            var roomResult = Ins.HttpRequest.GetRoomList();
+                            if (roomResult.Code == StateCode.SUCCESS)
                             {
+                                var revData = JsonConvert.DeserializeObject<SpatialApiPack>(roomResult.Data.ToString());
+                                if (revData == null)
+                                {
+                                    revData = new SpatialApiPack();
+                                }
+                                SpatialInfo.CurrentSpatial.UpdateSpatialList(revData.list);
                                 try
                                 {
                                     var ssd = System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(revData.list));
@@ -279,390 +143,496 @@
                                 }
                                 catch (Exception ex)
                                 {
-                                    MainPage.Log($"{this.GetType()}:淇濆瓨鎴块棿淇℃伅寮傚父锛歿ex.Message}");
+                                    MainPage.Log("Error", $"{this.GetType()}:淇濆瓨鎴块棿淇℃伅寮傚父锛歿ex.StackTrace}");
                                 }
-                            })
-                            { IsBackground = true }.Start();
-                        }
-                    }
-                    else
-                    {
-                        MainPage.Log($"璇诲彇鎴块棿鏁版嵁澶辫触:Code:{roomResult.Code}; msg:{roomResult.message}");
-                    }
-
-                    //===================璁惧=======================
-                    new System.Threading.Thread(() =>
-                    {
-                        try
-                        {
-                            complateDevice = false;
-                            var deviceResult = Ins.HttpRequest.GetDeviceList("30", "1");
-                            if (deviceResult.Code == StateCode.SUCCESS)
-                            {
-                                FunctionList.List.ClearDatas();
-                                //MainPage.Log($"============璁惧============寮�濮�" + FunctionList.List.Functions.Count);
-                                //MainPage.Log($"璇诲彇璁惧淇℃伅鎴愬姛");
-                                MainPage.Log($"sid鍒楄〃鑾峰彇====\r\n", deviceResult.Data.ToString());
-                                var deviceList = JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString());
-                                if (deviceList == null)
-                                {
-                                    deviceList = new DevcieApiPack();
-                                }
-                                try
-                                {
-                                    while (deviceList.totalPage != deviceList.pageNo)
-                                    {
-                                        var deviceResult2 = Ins.HttpRequest.GetDeviceList("30", Convert.ToInt32(deviceList.pageNo) + 1 + "");
-                                        if (deviceResult2.Code == StateCode.SUCCESS)
-                                        {
-                                            var deviceList2 = JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString());
-                                            deviceList.pageNo = deviceList2.pageNo;
-                                            deviceList.list.AddRange(deviceList2.list);
-                                        }
-                                    }
-                                }
-                                catch (Exception ex)
-                                {
-                                }
-                                finally
-                                {
-
-                                }
-
-                                string delFile = "";
-                                if (FunctionList.List.GetDeviceFunctionList().Count > 0)
-                                {
-
-                                    for (int i = 0; i < FunctionList.List.GetDeviceFunctionList().Count;)
-                                    {
-                                        var localFunction = FunctionList.List.GetDeviceFunctionList()[i];
-                                        //if (SPK.MusicSpkList().Contains(localFunction.spk))
-                                        //{
-                                        //    i++;
-                                        //    continue;
-                                        //}
-                                        var newFunction = deviceList.list.Find((obj) => obj.deviceId == localFunction.deviceId);
-
-                                        if (delFile == localFunction.savePath)
-                                        {
-                                            i++;
-                                            continue;
-                                        }
-                                        delFile = localFunction.savePath;
-                                        FunctionList.List.DeleteFunction(localFunction);
-                                    }
-                                }
-                                //澶勭悊鍓╀笅鐨勬柊澧炲姛鑳�
-                                //int iiii = 0;
-                                foreach (var newFunction in deviceList.list)
-                                {
-                                    newFunction.AssembleStatus();
-                                    newFunction.SaveFunctionFile();
-                                    FunctionList.List.IniFunctionList(newFunction.savePath, true);
-                                    //MainPage.Log($"============璁惧============{iiii++}");
-                                }
-
-
-
-                                //===================璇诲彇鍙瀵硅鏁版嵁==========================
-                                //鍒ゆ柇鏄惁鏈夊彲瑙嗗璁叉暟鎹紝鏈夊垯鏄剧ず鍙瀵硅icon
-                                //var flVideoInfo = HttpRequest.CheckFlVideo();
-                                //if(flVideoInfo.Code == StateCode.SUCCESS)
-                                //{
-                                //    FunctionList.List.videoIntercom1111 = Newtonsoft.Json.JsonConvert.DeserializeObject<UI.UI2.FuntionControlView.Video.VideoClouds>(flVideoInfo.Data.ToString());
-                                //}
-
-                                //======================鑾峰彇鍙瀵硅璁惧鍒楄〃====================
-                                bool isInterphoneType_HDL = false;//鏄惁涓篐DLLinphone鍙瀵硅
-                                var videoInfo = VideoSend.GetVideoInfoList();
-                                if (videoInfo.Code == StateCode.SUCCESS)
-                                {
-                                    string videoList = videoInfo.Data.ToString();
-                                    FunctionList.List.videoIntercom = JsonConvert.DeserializeObject<List<UI.UI2.FuntionControlView.Video.Video>>(videoList);
-
-                                    for (int i = 0; i < FunctionList.List.videoIntercom.Count; i++)
-                                    {
-                                        var video = FunctionList.List.videoIntercom[i];
-
-                                        if (video.interphoneType == InterphoneType.HDL.ToString())
-                                        {
-                                            isInterphoneType_HDL = true;
-                                            DB_ResidenceData.Instance.SupportFacePass = true;
-                                            DB_ResidenceData.Instance.SaveResidenceData();
-                                            
-                                        }
-                                    }
-                                }
-
-
-                                //======================鑾峰彇Sip璐﹀彿骞朵笖鍒濆鍖朣DK鍙瀵硅璁惧鍒楄〃====================
-                                //濡傛灉妫�娴嬬嚎绋嬫病鍚姩锛屾墠缁х画涓嬮潰鎿嶄綔 鍥犱负App鏈夊彲鑳藉垰鍚姩椹笂鏀跺埌鎺ㄩ�佷簡锛岀劧鍚庢墠鎵ц鍒拌繖閲�
-                                if (HDLLinphone.Current.CheckIncomingCallThreadIsNull())
-                                {
-
-                                    //褰撳墠浣忓畢鏄疕DL鍙瀵硅绫诲瀷鐨勮澶�
-                                    if (isInterphoneType_HDL)
-                                    {
-                                        //HDLLinphone鍙瀵硅,鑾峰彇Sip璐﹀彿骞跺垵濮嬪寲SDK
-                                        HDLCallVideoInfo callVideoInfo = new HDLCallVideoInfo();
-                                        callVideoInfo.HomeId = DB_ResidenceData.Instance.CurrentRegion.id;
-                                        callVideoInfo.InterphoneType = InterphoneType.HDL.ToString();
-                                        HDLLinphone.Current.GetHDLSipInfoAndInitSDK(callVideoInfo);
-                                    }
-                                    else
-                                    {
-                                        Utlis.WriteLine("褰撳墠浣忓畢涓嶆敮鎸丠DL鍙瀵硅,閫�鍑虹櫥褰曟墍鏈夎处鍙�");
-                                        //褰撳墠浣忓畢涓嶆敮鎸丠DL鍙瀵硅
-                                        HDLLinphone.Current.LogoutAllAccount();
-                                    }
-                                }
-
                             }
-                            else
-                            {
-                                MainPage.Log($"璇诲彇浜戠璁惧鏁版嵁澶辫触:Code:{deviceResult.Code};  Msg:{deviceResult.message}");
-                            }
-                        }
-                        catch (Exception ex)
-                        {
-                            MainPage.Log($"============璁惧============{ex.Message}");
-                        }
-                        finally
-                        {
-                            complateDevice = true;
-                            MainPage.Log($"============璁惧============瀹屾垚" + FunctionList.List.Functions.Count);
-                        }
+                            complateGetRoomListInfo = true;
+                        })
+                        { IsBackground = true }.Start();
+                        #endregion
 
-
-                        //======================缇ゆ帶====================
-                        if (DB_ResidenceData.Instance.HomeGateway.isSupportGroupControl)
+                        #region ===================璁惧=======================
+                        new Thread(() =>
                         {
-                            var pack = Ins.HttpRequest.GetGroupControlList();
-                            if (pack != null)
+                            try
                             {
-                                if (pack.Code == StateCode.SUCCESS)
+                                var deviceResult = Ins.HttpRequest.GetDeviceList("30", "1");
+                                if (deviceResult.Code == StateCode.SUCCESS)
                                 {
+                                    MainPage.Log($"璇诲彇璁惧淇℃伅鎴愬姛");
+                                    //MainPage.Log($"sid鍒楄〃鑾峰彇====\r\n", deviceResult.Data.ToString());
+                                    var deviceList = JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString());
+                                    if (deviceList == null)
+                                    {
+                                        deviceList = new DevcieApiPack();
+                                    }
                                     try
                                     {
-                                        var groupControlList = JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString());
-                                        var readSidList = new List<string>();
-                                        foreach (var temp in groupControlList)
+                                        while (deviceList.totalPage != deviceList.pageNo)
                                         {
-                                            FunctionList.List.groupControls.Clear();
-                                            readSidList.Add(temp.userDeviceGroupControlId);
-                                            if (readSidList.Count >= 20)
+                                            var deviceResult2 = Ins.HttpRequest.GetDeviceList("30", Convert.ToInt32(deviceList.pageNo) + 1 + "");
+                                            if (deviceResult2.Code == StateCode.SUCCESS)
                                             {
-                                                var data = Ins.httpRequest.GetGroupControInfo(readSidList);
-                                                if (data != null)
-                                                {
-                                                    if (data.Code == StateCode.SUCCESS)
-                                                    {
-                                                        var groupControlInfoList = JsonConvert.DeserializeObject<List<GroupControl>>(data.Data.ToString());
-                                                        FunctionList.List.groupControls.AddRange(groupControlInfoList);
-                                                    }
-                                                    else
-                                                    {
-                                                        IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
-                                                    }
-                                                }
-                                                readSidList.Clear();
+                                                var deviceList2 = JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString());
+                                                deviceList.pageNo = deviceList2.pageNo;
+                                                deviceList.list.AddRange(deviceList2.list);
                                             }
-                                            //FunctionList.List.Functions.AddRange(FunctionList.List.groupControls);
-                                        }
-                                        if (readSidList.Count > 0)
-                                        {
-                                            var data = Ins.httpRequest.GetGroupControInfo(readSidList);
-                                            if (data != null)
-                                            {
-                                                if (data.Code == StateCode.SUCCESS)
-                                                {
-                                                    var groupControlInfoList = JsonConvert.DeserializeObject<List<GroupControl>>(data.Data.ToString());
-                                                    FunctionList.List.groupControls.AddRange(groupControlInfoList);
-                                                }
-                                                else
-                                                {
-                                                    IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
-                                                }
-                                            }
-                                            readSidList.Clear();
                                         }
                                     }
                                     catch (Exception ex)
                                     {
-                                        MainPage.Log($"璇诲彇缁勬帶鍒楄〃澶辫触:{ex.Message}");
+                                        MainPage.Log("Error", $"瑙f瀽璁惧淇℃伅寮傚父:{ex.StackTrace}");
+                                    }
+
+                                    string delFile = "";
+                                    if (FunctionList.List.GetDeviceFunctionList().Count > 0)
+                                    {
+                                        for (int i = 0; i < FunctionList.List.GetDeviceFunctionList().Count;)
+                                        {
+                                            var localFunction = FunctionList.List.GetDeviceFunctionList()[i];
+                                            var newFunction = deviceList.list.Find((obj) => obj.deviceId == localFunction.deviceId);
+
+                                            if (delFile == localFunction.savePath)
+                                            {
+                                                i++;
+                                                continue;
+                                            }
+                                            delFile = localFunction.savePath;
+                                            FunctionList.List.DeleteFunction(localFunction);
+                                        }
+                                    }
+                                    //澶勭悊鍓╀笅鐨勬柊澧炲姛鑳�
+                                    foreach (var newDevice in deviceList.list)
+                                    {
+                                        newDevice.AssembleStatus();
+                                        newDevice.SaveFunctionFile();
+                                        FunctionList.List.IniFunctionList(newDevice.savePath, true);
+                                    }
+
+
+                                    //===================璇诲彇鍙瀵硅鏁版嵁==========================
+                                    //鍒ゆ柇鏄惁鏈夊彲瑙嗗璁叉暟鎹紝鏈夊垯鏄剧ず鍙瀵硅icon
+                                    //var flVideoInfo = HttpRequest.CheckFlVideo();
+                                    //if(flVideoInfo.Code == StateCode.SUCCESS)
+                                    //{
+                                    //    FunctionList.List.videoIntercom1111 = Newtonsoft.Json.JsonConvert.DeserializeObject<UI.UI2.FuntionControlView.Video.VideoClouds>(flVideoInfo.Data.ToString());
+                                    //}
+
+                                    //======================鑾峰彇鍙瀵硅璁惧鍒楄〃====================
+                                    bool isInterphoneType_HDL = false;//鏄惁涓篐DLLinphone鍙瀵硅
+                                    bool isInterphoneType_FREEVIEW = false;//鏄惁涓哄叏瑙嗛�氬彲瑙嗗璁�
+                                    var videoInfo = VideoSend.GetVideoInfoList();
+                                    if (videoInfo.Code == StateCode.SUCCESS)
+                                    {
+                                        string videoList = videoInfo.Data.ToString();
+                                        FunctionList.List.videoIntercom = JsonConvert.DeserializeObject<List<UI.UI2.FuntionControlView.Video.Video>>(videoList);
+                                        for (int i = 0; i < FunctionList.List.videoIntercom.Count; i++)
+                                        {
+                                            var video = FunctionList.List.videoIntercom[i];
+
+                                            if (video.interphoneType == InterphoneType.HDL.ToString())
+                                            {
+                                                isInterphoneType_HDL = true;
+                                                DB_ResidenceData.Instance.SupportFacePass = true;
+                                                DB_ResidenceData.Instance.SaveResidenceData();
+                                            }
+                                        }
+                                    }
+
+
+                                    //======================鑾峰彇Sip璐﹀彿骞朵笖鍒濆鍖朣DK鍙瀵硅璁惧鍒楄〃====================
+                                    //濡傛灉妫�娴嬬嚎绋嬫病鍚姩锛屾墠缁х画涓嬮潰鎿嶄綔 鍥犱负App鏈夊彲鑳藉垰鍚姩椹笂鏀跺埌鎺ㄩ�佷簡锛岀劧鍚庢墠鎵ц鍒拌繖閲�
+                                    if (HDLLinphone.Current.CheckIncomingCallThreadIsNull())
+                                    {
+                                        //褰撳墠浣忓畢鏄疕DL鍙瀵硅绫诲瀷鐨勮澶�
+                                        if (isInterphoneType_HDL)
+                                        {
+                                            //HDLLinphone鍙瀵硅,鑾峰彇Sip璐﹀彿骞跺垵濮嬪寲SDK
+                                            HDLCallVideoInfo callVideoInfo = new HDLCallVideoInfo();
+                                            callVideoInfo.HomeId = DB_ResidenceData.Instance.CurrentRegion.id;
+                                            callVideoInfo.InterphoneType = InterphoneType.HDL.ToString();
+                                            HDLLinphone.Current.GetHDLSipInfoAndInitSDK(callVideoInfo);
+                                        }
+                                        else if (isInterphoneType_FREEVIEW)
+                                        {
+                                            //HDLLinphone鍙瀵硅,鑾峰彇Sip璐﹀彿骞跺垵濮嬪寲SDK
+                                            HDLCallVideoInfo callVideoInfo = new HDLCallVideoInfo();
+                                            callVideoInfo.HomeId = DB_ResidenceData.Instance.CurrentRegion.id;
+                                            callVideoInfo.InterphoneType = InterphoneType.FREEVIEW.ToString();
+                                            HDLLinphone.Current.GetHDLSipInfoAndInitSDK(callVideoInfo);
+                                        }
+                                        else
+                                        {
+                                            Utlis.WriteLine("褰撳墠浣忓畢涓嶆敮鎸丠DL鍙瀵硅,閫�鍑虹櫥褰曟墍鏈夎处鍙�");
+                                            //褰撳墠浣忓畢涓嶆敮鎸丠DL鍙瀵硅
+                                            HDLLinphone.Current.LogoutAllAccount();
+                                        }
+                                    }
+
+                                    //======================鐧诲綍鍏ㄨ閫�====================
+                                    if (isInterphoneType_FREEVIEW)
+                                    {
+
+#if __IOS__
+                                        //string systemVersion = UIKit.UIDevice.CurrentDevice.SystemVersion;
+                                        //string errorVersion = "16.2.0";
+                                        //if (systemVersion.CompareTo(errorVersion) < 0)///鍏ㄨ閫氫笉鍏煎ios16浠ヤ笂鐨勭郴缁燂紝涓嶈鍔犺浇杩欎釜鍏�
+                                        //{
+                                        //    List<VisitorTempPassword> dataList = new List<VisitorTempPassword>();
+                                        //    Dictionary<string, object> dictionary = new Dictionary<string, object>();
+                                        //    dictionary.Add("homeId", Entity.DB_ResidenceData.Instance.CurrentRegion.id);
+                                        //    var requestJson = HttpUtil.GetSignRequestJson(dictionary);
+                                        //    ResponsePackNew pack = HttpUtil.RequestHttpsPost(NewAPI.Api_Post_GetExtMemberInfo, requestJson);
+                                        //    if (pack != null)
+                                        //    {
+                                        //        var data = JsonConvert.DeserializeObject<FreeviewMemberInfo>(pack.Data.ToString());
+                                        //        //鐧诲綍鍏ㄨ閫�
+                                        //        Shared.IOS.HDLFVSDK.Video.Init("", data.extUserId, DB_ResidenceData.Instance.CurrentRegion.id, "78FF1E4D-FC0A-4E71-9B79-0448E4460BD7", "T0001", "120.77.53.170:9700", "120.77.53.170:21664");
+                                        //    }
+                                        //}
+#endif
+                                    }
+
+                                }
+                                else
+                                {
+                                    MainPage.Log($"璇诲彇浜戠璁惧鏁版嵁澶辫触:Code:{deviceResult.Code};  Msg:{deviceResult.message}");
+                                }
+                            }
+                            catch (Exception ex)
+                            {
+                                MainPage.Log("Error", $"============璁惧============{ex.StackTrace}");
+                            }
+                            finally
+                            {
+                                complateDevice = true;
+                                MainPage.Log($"============璁惧============瀹屾垚" + FunctionList.List.Functions.Count);
+                            }
+                        })
+                        { IsBackground = true }.Start();
+                        #endregion
+
+                        #region ======================缇ゆ帶====================
+                        new Thread(() =>
+                        {
+                            try
+                            {
+                                if (DB_ResidenceData.Instance.HomeGateway.isSupportGroupControl)
+                                {
+                                    var pack = Ins.HttpRequest.GetGroupControlList();
+                                    if (pack != null)
+                                    {
+                                        if (pack.Code == StateCode.SUCCESS)
+                                        {
+                                            try
+                                            {
+                                                var groupControlList = JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString());
+                                                var readSidList = new List<string>();
+                                                foreach (var temp in groupControlList)
+                                                {
+                                                    FunctionList.List.groupControls.Clear();
+                                                    readSidList.Add(temp.userDeviceGroupControlId);
+                                                    if (readSidList.Count >= 20)
+                                                    {
+                                                        var data = Ins.httpRequest.GetGroupControInfo(readSidList);
+                                                        if (data != null)
+                                                        {
+                                                            if (data.Code == StateCode.SUCCESS)
+                                                            {
+                                                                var groupControlInfoList = JsonConvert.DeserializeObject<List<GroupControl>>(data.Data.ToString());
+                                                                FunctionList.List.groupControls.AddRange(groupControlInfoList);
+                                                            }
+                                                            else
+                                                            {
+                                                                IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+                                                            }
+                                                        }
+                                                        readSidList.Clear();
+                                                    }
+                                                    //FunctionList.List.Functions.AddRange(FunctionList.List.groupControls);
+                                                }
+                                                if (readSidList.Count > 0)
+                                                {
+                                                    var data = Ins.httpRequest.GetGroupControInfo(readSidList);
+                                                    if (data != null)
+                                                    {
+                                                        if (data.Code == StateCode.SUCCESS)
+                                                        {
+                                                            var groupControlInfoList = JsonConvert.DeserializeObject<List<GroupControl>>(data.Data.ToString());
+                                                            FunctionList.List.groupControls.AddRange(groupControlInfoList);
+                                                        }
+                                                        else
+                                                        {
+                                                            IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+                                                        }
+                                                    }
+                                                    readSidList.Clear();
+                                                }
+                                            }
+                                            catch (Exception ex)
+                                            {
+                                                MainPage.Log("Error", $"璇诲彇缁勬帶鍒楄〃澶辫触:{ex.StackTrace}");
+                                            }
+                                        }
+                                        else
+                                        {
+                                            IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+                                        }
+                                    }
+                                }
+                            }
+                            catch (Exception ex)
+                            {
+                                MainPage.Log($"缇ゆ帶锛歿ex.StackTrace}");
+                            }
+                            finally
+                            {
+                                complateGetGroupControl = true;
+                            }
+                        })
+                        { IsBackground = true }.Start();
+                        #endregion
+
+                        #region ======================鍦烘櫙====================
+                        new Thread(() =>
+                        {
+                            try
+                            {
+                                var pack = Ins.HttpRequest.GetSceneList();
+                                if (pack.Code == StateCode.SUCCESS)
+                                {
+                                    MainPage.Log($"璇诲彇鍦烘櫙鏁版嵁鎴愬姛");
+                                    var sceneList = JsonConvert.DeserializeObject<List<Scene>>(pack.Data.ToString());
+                                    if (sceneList == null)
+                                    {
+                                        sceneList = new List<Scene>();
+                                    }
+                                    FunctionList.List.scenes.Clear();
+
+                                    //澶勭悊鍓╀笅鐨勬柊澧炲姛鑳�
+                                    foreach (var tempScene in sceneList)
+                                    {
+                                        tempScene.SaveSceneFile();
+                                        FunctionList.List.scenes.Add(tempScene);
+                                    }
+                                    MainPage.Log($"璇诲彇鍦烘櫙鏁版嵁鎴愬姛:{FunctionList.List.scenes.Count}");
+
+                                    //濡傛灉鏄竴绔彛闇�瑕佹彁鍓嶄笅杞藉満鏅暟鎹紝鍚﹀垯鎺у埗涓嶄簡涓�绔彛鍦烘櫙
+                                    if (DB_ResidenceData.Instance.GatewayType == 0)
+                                    {
+                                        var sceneIds = new List<string>();
+                                        foreach (var tempScene in FunctionList.List.scenes)
+                                        {
+                                            sceneIds.Add(tempScene.userSceneId);
+                                        }
+                                        var packInfo = HttpRequest.GetSceneListInfo(sceneIds);
+                                        if (packInfo.Code == StateCode.SUCCESS)
+                                        {
+                                            var serverTempList = JsonConvert.DeserializeObject<List<Scene>>(packInfo.Data.ToString());
+                                            foreach (var localScene in FunctionList.List.scenes)
+                                            {
+                                                var serverTemp = serverTempList.Find((obj) => obj.userSceneId == localScene.userSceneId);
+                                                if (serverTemp != null)
+                                                {
+                                                    localScene.functions = serverTemp.functions;
+                                                    localScene.SaveSceneFile();
+                                                }
+                                            }
+                                        }
                                     }
                                 }
                                 else
                                 {
-                                    IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
+                                    MainPage.Log($"璇诲彇浜戠鍦烘櫙鏁版嵁澶辫触:Code:{pack.Code}; Msg:{pack.message}");
                                 }
                             }
-                        }
-                        //======================鍦烘櫙====================
+                            catch (Exception ex)
+                            {
+                                MainPage.Log("Error", $"===鍦烘櫙==={ex.StackTrace}");
+                            }
+                            finally
+                            {
+                                complateScene = true;
+                            }
+                        })
+                        { IsBackground = true }.Start();
+                        #endregion
+
+                        #region ======================瀹夐槻====================
+                        new Thread(() =>
+                        {
+                            try
+                            {
+                                GetSecurityList();
+                            }
+                            catch (Exception ex)
+                            {
+                                MainPage.Log($"瀹夐槻锛歿ex.StackTrace}");
+                            }
+                            finally
+                            {
+                                complateGetSecurityListInfo = true;
+                            }
+                        })
+                        { IsBackground = true }.Start();
+                        #endregion
+
+                        #region ======================璇诲彇閫昏緫鍒楄〃====================
+                        new Thread(() =>
+                        {
+                            try
+                            {
+                                Logic.LogicList.Clear();//涓婚〉涓嬫媺寮哄埗鍒锋柊鑷姩鍖栧垪琛�
+                                MainView.GetLogicList();//璇诲彇鑷姩鍖栧垪琛�
+                            }
+                            catch (Exception ex)
+                            {
+                                MainPage.Log($"璇诲彇閫昏緫鍒楄〃锛歿ex.StackTrace}");
+                            }
+                            finally
+                            {
+                                complateGetLogicListInfo = true;
+                            }
+                        })
+                        { IsBackground = true }.Start();
+                        #endregion
+
+                        #region ======================娉ㄥ唽鎺ㄩ��====================
+                        httpRequest.RegisteredPush();
+                        #endregion
+
+                        #region ======================绗笁鏂硅澶�====================
+                        new Thread(() =>
+                        {
+                            try
+                            {
+                                FunctionList.List.Read3tyFunctionStatus();
+                            }
+                            catch (Exception ex)
+                            {
+                                MainPage.Log("Error", "璇诲彇绗笁鏂硅澶囩姸鎬佸け璐�:" + ex.StackTrace);
+                            }
+                            finally
+                            {
+                                complateGet3tyInfo = true;
+                            }
+                        })
+                        { IsBackground = true }.Start();
+                        #endregion
+                    }
+
+                    #region ===========缁堟涓嬭浇绾跨▼===========
+                    new Thread(() =>
+                    {
                         try
                         {
-                            complateScene = false;
-                            var pack = Ins.HttpRequest.GetSceneList();
-                            if (pack.Code == StateCode.SUCCESS)
+                            int sleepCout = 0;
+                            while (true)
                             {
-                                MainPage.Log($"璇诲彇鍦烘櫙鏁版嵁鎴愬姛");
-                                var sceneList = JsonConvert.DeserializeObject<List<Scene>>(pack.Data.ToString());
-                                if (sceneList == null)
+                                if (complateGetHomePagerInfo && complateGetUserInfo && complateGetRoomListInfo && complateGetGroupControl &&
+                                complateGetSecurityListInfo && complateGetLogicListInfo && complateGet3tyInfo && complateDevice && complateScene)
                                 {
-                                    sceneList = new List<Scene>();
+                                    break;
                                 }
-                                FunctionList.List.scenes.Clear();
-
-                                //澶勭悊鍓╀笅鐨勬柊澧炲姛鑳�
-                                foreach (var tempScene in sceneList)
+                                Thread.Sleep(100);
+                                if (sleepCout > 150)
                                 {
-                                    tempScene.SaveSceneFile();
-                                    FunctionList.List.scenes.Add(tempScene);
+                                    MainPage.Log("=======瓒呮椂锛岄��鍑轰紤鐪�=======");
+                                    break;
                                 }
-                                //濡傛灉鏄竴绔彛闇�瑕佹彁鍓嶄笅杞藉満鏅暟鎹紝鍚﹀垯鎺у埗涓嶄簡涓�绔彛鍦烘櫙
-                                if (DB_ResidenceData.Instance.GatewayType == 0)
+                                else
                                 {
-                                    var sceneIds = new List<string>();
-                                    foreach (var tempScene in FunctionList.List.scenes)
-                                    {
-                                        sceneIds.Add(tempScene.userSceneId);
-                                    }
-                                    var packInfo = HttpRequest.GetSceneListInfo(sceneIds);
-                                    if (packInfo.Code == StateCode.SUCCESS)
-                                    {
-                                        var serverTempList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(packInfo.Data.ToString());
-                                        foreach (var localScene in FunctionList.List.scenes)
-                                        {
-                                            var serverTemp = serverTempList.Find((obj) => obj.userSceneId == localScene.userSceneId);
-                                            if (serverTemp != null)
-                                            {
-                                                localScene.functions = serverTemp.functions;
-                                                localScene.SaveSceneFile();
-                                            }
-                                        }
-                                    }
-                                    else
-                                    {
-                                        IMessageCommon.Current.ShowErrorInfoAlter(packInfo.Code);
-                                    }
+                                    //MainPage.Log($"=======浼戠湢锛岀瓑寰呮暟鎹畕sleepCout}=======");
+                                    sleepCout++;
                                 }
                             }
-                            else
+                            LoadLocalData();
+                            Application.RunOnMainThread(() =>
                             {
-                                MainPage.Log($"璇诲彇浜戠鍦烘櫙鏁版嵁澶辫触:Code:{pack.Code}; Msg:{pack.message}");
-                            }
+                                if (waitPage != null)
+                                {
+                                    waitPage.RemoveFromParent();
+                                    waitPage = null;
+                                }
+                            });
                         }
-                        catch (Exception ex)
-                        {
-                            MainPage.Log($"===鍦烘櫙==={ex.Message}");
-                        }
+                        catch { }
                         finally
                         {
-                            complateScene = true;
+                            DownloadDataComplete = true;
+                            if (DB_ResidenceData.Instance.CurrentRegion != null)
+                            {
+                                //涓嶈�冭檻缃戝叧鎯呭喌锛岀洿鎺ヨ闃�
+                                DAL.Mqtt.MqttClient.InitState();
+
+                                #region 閲嶇疆TCP瀹㈡埛绔�
+                                try
+                                {
+                                    DriverLayer.Control.Ins.LocalTcpClientLogin = false;
+                                    if (DriverLayer.Control.Ins.myTcpClient != null)
+                                    {
+                                        DriverLayer.Control.Ins.myTcpClient.Dispose();
+                                        DriverLayer.Control.Ins.myTcpClient = null;
+                                    }
+                                }
+                                catch (Exception ex)
+                                {
+                                    MainPage.Log("Error", $"閲嶇疆TCP瀹㈡埛绔紓甯�:{ex.Message}");
+                                }
+                                #endregion
+
+                                try
+                                {
+                                    DriverLayer.Control.Ins.SearchLoaclGateway();
+                                }
+                                catch (Exception ex)
+                                {
+                                    MainPage.Log("Error", $"鎼滅储缃戝叧锛歿ex.StackTrace}");
+                                }
+
+                                try
+                                {
+                                    HomePage.LoadEvent_CheckTokenValid();
+                                    if (!IsValidToken && UserInfo.Current.TipInvalidToken)
+                                    {
+                                        UserInfo.Current.TipInvalidToken = false;
+                                        UserInfo.Current.SaveUserInfo();
+                                        Application.RunOnMainThread(() =>
+                                        {
+                                            try
+                                            {
+                                                new PublicAssmebly().TipOptionMsg(StringId.Tip, StringId.TokenInvalidTipMsg, StringId.OfflineControl, StringId.GoLogin, () =>
+                                                {
+                                                    HDLCommon.Current.Logout();
+                                                });
+                                            }
+                                            catch (Exception ex)
+                                            {
+                                                MainPage.Log("Error", $"鎻愮ず鐧诲綍鍑瘉绐楀彛鍔犺浇寮傚父:{ex.StackTrace}");
+                                            }
+                                        });
+                                    }
+                                }
+                                catch (Exception ex)
+                                {
+                                    MainPage.Log("Error", $"鏇存柊鐧诲綍鍑瘉鏂规硶璋冪敤寮傚父:{ex.StackTrace}");
+                                }
+                            }
                         }
-
-                        //======================瀹夐槻====================
-                        GetSecurityList();
-
-                        //===================璇诲彇閫昏緫鍒楄〃====================
-                        Logic.LogicList.Clear();//涓婚〉涓嬫媺寮哄埗鍒锋柊鑷姩鍖栧垪琛�
-                        MainView.GetLogicList();//璇诲彇鑷姩鍖栧垪琛�
                     })
                     { IsBackground = true }.Start();
+                    #endregion
 
-                    //======================娉ㄥ唽鎺ㄩ��====================
-                    httpRequest.RegisteredPush();
                 }
                 catch (Exception ex)
                 {
-                    MainPage.Log($"鏁版嵁鍒濆鍖栧け璐ワ細{ex.Message}");
-                }
-                finally
-                {
-                    Application.RunOnMainThread(() =>
-                    {
-                        MainPage.Log($"缁撴潫璇诲彇浜戠鏁版嵁绾跨▼");
-                        if (waitPage != null)
-                        {
-                            waitPage.RemoveFromParent();
-                            waitPage = null;
-                        }
-                    });
-                    //涓嶈�冭檻缃戝叧鎯呭喌锛岀洿鎺ヨ闃�
-                    DAL.Mqtt.MqttClient.InitState();
-
-                    try
-                    {
-                        FunctionList.List.Read3tyFunctionStatus();
-                    }
-                    catch (Exception ex)
-                    {
-                        MainPage.Log("璇诲彇绗笁鏂硅澶囩姸鎬佸け璐�:" + ex.Message);
-                    }
+                    MainPage.Log($"璇诲彇浜戠鏁版嵁绾跨▼寮傚父锛歿ex.StackTrace}");
                 }
             });
             downloadDataThread.IsBackground = true;
-            downloadDataThread.Priority = System.Threading.ThreadPriority.Highest;
+            downloadDataThread.Priority = ThreadPriority.Highest;
             downloadDataThread.Start();
 
-            //缃戠粶鍗¢】锛岀粓姝笅杞界嚎绋�
-            new System.Threading.Thread(() =>
-            {
-                try
-                {
-                    while (endTime1 > DateTime.Now)
-                    {
-                        if (complateDevice && complateScene)
-                        {
-                            break;
-                        }
-                        System.Threading.Thread.Sleep(100);
-                    }
-                    DownloadDataComplete = true;
-                    Application.RunOnMainThread(() =>
-                    {
-                        if (waitPage != null)
-                        {
-                            waitPage.RemoveFromParent();
-                            waitPage = null;
-                        }
-                    });
-                }
-                catch { }
-                finally
-                {
-                    if (DB_ResidenceData.Instance.CurrentRegion != null)
-                    {
-                        #region 璇诲彇鏈湴鏁版嵁
-                        //鎼滅储缃戝叧
-                        DriverLayer.Control.Ins.SearchLoaclGateway();
-                        //閲嶆柊杩炴帴mqtt
-                        DAL.Mqtt.MqttClient.DisConnectRemote("鍒锋柊鏁版嵁锛岄噸杩瀖qtt", false);
-                        #endregion
-
-                    }
-                }
-            })
-            { IsBackground = true }.Start();
-        }
-
-        /// <summary>
-        /// 鑾峰彇鍔熻兘淇℃伅
-        /// </summary>
-        public void GetFunctionInfo(string functionId)
-        {
-            var deviceResult = Ins.HttpRequest.GetDeviceInfo(functionId);
-            if (deviceResult.Code == StateCode.SUCCESS)
-            {
-                MainPage.Log($"璇诲彇璁惧淇℃伅鎴愬姛");
-                var packList = JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString());
-
-                foreach (var function in packList.list)
-                {
-                    function.SaveFunctionFile();
-                    FunctionList.List.IniFunctionList(function.savePath, true);
-                }
-            }
         }
 
         /// <summary>
@@ -672,51 +642,94 @@
         {
             lock (FunctionList.List.securities)
             {
-                var pack = Ins.HttpRequest.GetSecurityList();
-                if (pack.Code == StateCode.SUCCESS)
+                try
                 {
-                    var packList = JsonConvert.DeserializeObject<List<SecurityAlarm>>(pack.Data.ToString());
-                    Console.WriteLine("瀹夐槻鎬绘暟锛�" + packList.Count);
-                    var sidList = new List<string>();
-                    foreach (var function in packList)
+                    var pack = Ins.HttpRequest.GetSecurityList();
+                    if (pack.Code == StateCode.SUCCESS)
                     {
-                        sidList.Add(function.sid);
-                    }
-                    var infoListPack = Ins.httpRequest.GetSecurityInfo(sidList, new List<string>());
-                    var infoList = JsonConvert.DeserializeObject<List<SecurityAlarm>>(infoListPack.Data.ToString());
-                    if (infoList != null)
-                    {
-                        var filePathList = FileUtlis.Files.ReadFiles().FindAll((obj) => obj.StartsWith("SecurityData_"));
-                        if (filePathList != null)
+                        var packList = JsonConvert.DeserializeObject<List<SecurityAlarm>>(pack.Data.ToString());
+                        var sidList = new List<string>();
+                        foreach (var function in packList)
                         {
-                            foreach (var file in filePathList)
+                            sidList.Add(function.sid);
+                        }
+                        if (sidList.Count == 0)
+                        {
+                            return;
+                        }
+                        var infoListPack = Ins.httpRequest.GetSecurityInfo(sidList, new List<string>());
+                        var infoList = JsonConvert.DeserializeObject<List<SecurityAlarm>>(infoListPack.Data.ToString());
+                        if (infoList != null)
+                        {
+                            var filePathList = FileUtlis.Files.ReadFiles().FindAll((obj) => obj.StartsWith("SecurityData_"));
+                            if (filePathList != null)
                             {
-                                FileUtlis.Files.DeleteFile(file);
+                                foreach (var file in filePathList)
+                                {
+                                    FileUtlis.Files.DeleteFile(file);
+                                }
+                            }
+                            FunctionList.List.securities.Clear();
+                            foreach (var function in infoList)
+                            {
+                                function.SaveFile();
+                                FunctionList.List.IniFunctionList(function.savePath, true);
                             }
                         }
-                        FunctionList.List.securities.Clear();
-                        foreach (var function in infoList)
-                        {
-                            function.SaveFile();
-                            FunctionList.List.IniFunctionList(function.savePath, true);
-                        }
+                    }
+                    else
+                    {
+                        MainPage.Log($"璇诲彇瀹夐槻鍒楄〃澶辫触:Code:{pack.Code}; Msg:{pack.message}");
                     }
                 }
-                else
+                catch (Exception ex)
                 {
-                    MainPage.Log($"璇诲彇瀹夐槻鍒楄〃澶辫触:Code:{pack.Code}; Msg:{pack.message}");
+                    MainPage.Log("Error", $"璇诲彇瀹夐槻鍒楄〃澶辫触:Code:{ex.StackTrace}");
                 }
             }
         }
 
         /// <summary>
-        /// 鑾峰彇SIP璐﹀彿淇℃伅
+        /// 鍔犺浇鏈湴鏁版嵁
         /// </summary>
-        public void GetSipInfo()
+        private void LoadLocalData()
         {
-            var pack = Ins.HttpRequest.GetSecurityList();
+            MainPage.Log("=========APiUtlis寮�濮嬪姞杞芥暟鎹�=========");
+            FunctionList.List.ClearDatas();
+            try
+            {
+                var spatialInfoDataBytes = FileUtlis.Files.ReadFile("SpatialInfoData");
+                if (spatialInfoDataBytes != null)
+                {
+                    var spatialInfoDataString = System.Text.Encoding.UTF8.GetString(spatialInfoDataBytes);
+                    if (spatialInfoDataString != null && !string.IsNullOrEmpty(spatialInfoDataString))
+                    {
+                        var spatialInfoDataList = JsonConvert.DeserializeObject<List<SpatialInfo>>(spatialInfoDataString);
+                        SpatialInfo.CurrentSpatial.UpdateSpatialList(spatialInfoDataList);
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                MainPage.Log("Error", $"{this.GetType()}:鍔犺浇缂撳瓨鎴块棿鏁版嵁寮傚父:{ex.StackTrace}");
+            }
+
+            try
+            {
+                var fileList = FileUtlis.Files.ReadFiles();
+                foreach (var file in fileList)
+                {
+                    FunctionList.List.IniFunctionList(file, true);
+                }
+                Room.CurrentSpatial.InitRoomListFunctions();
+            }
+            catch (Exception ex)
+            {
+                MainPage.Log("Error", $"{this.GetType()}:鍔犺浇缂撳瓨璁惧鏁版嵁寮傚父:{ex.StackTrace}");
+            }
+
+            MainPage.Log("=========APiUtlis瀹屾垚鍔犺浇鏁版嵁=========");
         }
-
-
     }
+
 }
\ No newline at end of file

--
Gitblit v1.8.0