| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using HDL_ON; |
| | | using HDL_ON.DAL; |
| | | using System.Net.Http; |
| | | using System.Threading.Tasks; |
| | | 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; |
| | |
| | | /// </summary> |
| | | public bool DownloadDataComplete = false; |
| | | |
| | | /// <summary> |
| | | /// token是否有效 |
| | | /// </summary> |
| | | public bool IsValidToken = false; |
| | | |
| | | public bool hadInternet = true; |
| | | /// <summary> |
| | | /// 下载数据 |
| | |
| | | try |
| | | { |
| | | //增加3秒云服务器连接检测,连不上服务器的时候不刷新数据 |
| | | hadInternet = true; |
| | | //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); |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"{this.GetType()}:加载缓存房间数据异常:{ex.Message}"); |
| | | MainPage.Log("Error",$"{this.GetType()}:加载缓存房间数据异常:{ex.StackTrace}"); |
| | | } |
| | | |
| | | try |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"{this.GetType()}:加载缓存设备数据异常:{ex.Message}"); |
| | | MainPage.Log("Error", $"{this.GetType()}:加载缓存设备数据异常:{ex.StackTrace}"); |
| | | } |
| | | |
| | | |
| | | return; |
| | | } |
| | | else |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"Error:下载数据1:{ex.Message}"); |
| | | MainPage.Log("Error", $"下载数据1:{ex.StackTrace}"); |
| | | DownloadDataComplete = true; |
| | | return; |
| | | } |
| | | finally |
| | | { |
| | | MainPage.Log("服务器连接状态:" + hadInternet); |
| | | if (!hadInternet) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | |
| | | code = Ins.HttpRequest.RefreshToken(); |
| | | if (code != StateCode.SUCCESS) |
| | | { |
| | | DownloadDataComplete = true; |
| | | IsValidToken= 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("Error", $"{this.GetType()}:加载缓存房间数据异常:{ex.StackTrace}"); |
| | | } |
| | | |
| | | 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("Error", $"{this.GetType()}:加载缓存设备数据异常:{ex.StackTrace}"); |
| | | } |
| | | MainPage.Log($"刷新token失败"); |
| | | |
| | | |
| | | if (waitPage != null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | |
| | | catch { } |
| | | }); |
| | | } |
| | | MainPage.Log($"刷新token失败"); |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | hadInternet = true; |
| | | } |
| | | MainPage.Log($"刷新token成功"); |
| | | //===================刷新住宅信息======================= |
| | |
| | | } |
| | | MainPage.Log($"刷新个人信息成功"); |
| | | |
| | | //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 ssd = System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(revData.list)); |
| | | FileUtlis.Files.WriteFileByBytes("SpatialInfoData", ssd); |
| | | }catch(Exception ex) |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"{this.GetType()}:保存房间信息异常:{ex.Message}"); |
| | | MainPage.Log("Error", $"{this.GetType()}:保存房间信息异常:{ex.StackTrace}"); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | |
| | | { |
| | | FunctionList.List.ClearDatas(); |
| | | MainPage.Log($"读取设备信息成功"); |
| | | MainPage.Log($"sid列表获取====\r\n" , deviceResult.Data.ToString()); |
| | | //MainPage.Log($"sid列表获取====\r\n", deviceResult.Data.ToString()); |
| | | var deviceList = JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString()); |
| | | if (deviceList == null) |
| | | { |
| | |
| | | { |
| | | UI.UI2.PersonalCenter.PirDevice.PirSend.LcSubAccessToken = video.subAccountToken; |
| | | } |
| | | else if (video.interphoneType == InterphoneType.HDL.ToString()) |
| | | { |
| | | isInterphoneType_HDL = true; |
| | | DB_ResidenceData.Instance.SupportFacePass = true; |
| | | DB_ResidenceData.Instance.SaveResidenceData(); |
| | | DB_ResidenceData.Instance.SupportFVDevice = true; |
| | | } |
| | | else if (video.interphoneType == InterphoneType.FREEVIEW.ToString()) |
| | | { |
| | | #if __IOS__ |
| | | try |
| | | { |
| | | FunctionList.List.videoIntercom.Remove(video); |
| | | --i; |
| | | }catch(Exception ex) |
| | | { |
| | | MainPage.Log("Error", $"ios 全视通异常 : {ex.StackTrace}"); |
| | | } |
| | | |
| | | #else |
| | | //为全视通可视对讲 |
| | | DB_ResidenceData.Instance.SupportFacePass = true; |
| | | Entity.DB_ResidenceData.Instance.SupportVisitorManage = true; |
| | | Entity.DB_ResidenceData.Instance.SupportFVDevice = true; |
| | | isInterphoneType_FREEVIEW = true; |
| | | #endif |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //======================获取Sip账号并且初始化SDK可视对讲设备列表==================== |
| | | //如果检测线程没启动,才继续下面操作 因为App有可能刚启动马上收到推送了,然后才执行到这里 |
| | | if (HDLLinphone.Current.CheckIncomingCallThreadIsNull()) |
| | | { |
| | | |
| | | //当前住宅是HDL可视对讲类型的设备 |
| | | 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("当前住宅不支持HDL可视对讲,退出登录所有账号"); |
| | | //当前住宅不支持HDL可视对讲 |
| | | 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 |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | MainPage.Log($"读取云端设备数据失败:Code:{deviceResult.Code}; Msg:{deviceResult.message}"); |
| | | } |
| | | }catch (Exception ex) |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"============设备============{ex.Message}"); |
| | | MainPage.Log("Error", $"============设备============{ex.StackTrace}"); |
| | | } |
| | | finally |
| | | { |
| | | complateDevice = true; |
| | | MainPage.Log($"============设备============完成" + FunctionList.List.Functions.Count); |
| | | } |
| | | |
| | | |
| | | //======================群控==================== |
| | | if (DB_ResidenceData.Instance.HomeGateway.isSupportGroupControl) |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"读取组控列表失败:{ex.Message}"); |
| | | MainPage.Log("Error", $"读取组控列表失败:{ex.StackTrace}"); |
| | | } |
| | | } |
| | | else |
| | |
| | | { |
| | | MainPage.Log($"读取云端场景数据失败:Code:{pack.Code}; Msg:{pack.message}"); |
| | | } |
| | | }catch(Exception ex) |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"===场景==={ex.Message}"); |
| | | MainPage.Log("Error", $"===场景==={ex.StackTrace}"); |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"数据初始化失败:{ex.Message}"); |
| | | MainPage.Log("Error", $"数据初始化失败:{ex.StackTrace}"); |
| | | } |
| | | finally |
| | | { |
| | |
| | | try |
| | | { |
| | | FunctionList.List.Read3tyFunctionStatus(); |
| | | }catch(Exception ex) |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log("读取第三方设备状态失败:"+ex.Message); |
| | | MainPage.Log("Error", "读取第三方设备状态失败:" + ex.StackTrace); |
| | | } |
| | | } |
| | | }); |
| | |
| | | { |
| | | if (DB_ResidenceData.Instance.CurrentRegion != null) |
| | | { |
| | | try |
| | | { |
| | | #region 读取本地数据 |
| | | //搜索网关 |
| | | DriverLayer.Control.Ins.SearchLoaclGateway(); |
| | | //重新连接mqtt |
| | | DAL.Mqtt.MqttClient.DisConnectRemote("刷新数据,重连mqtt",false); |
| | | #endregion |
| | | } |
| | | catch (Exception ex){ |
| | | MainPage.Log("Error", $"读取本地数据异常:{ex.StackTrace}"); |
| | | } |
| | | |
| | | try |
| | | { |
| | | HomePage.LoadEvent_CheckTokenValid(); |
| | | if (IsValidToken && !UserInfo.Current.IsTipedInvalidToken) |
| | | { |
| | | UserInfo.Current.IsTipedInvalidToken = true; |
| | | 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}"); |
| | | } |
| | | } |
| | | } |
| | | }) |
| | |
| | | { |
| | | lock (FunctionList.List.securities) |
| | | { |
| | | try |
| | | { |
| | | var pack = Ins.HttpRequest.GetSecurityList(); |
| | | if (pack.Code == StateCode.SUCCESS) |
| | | { |
| | |
| | | foreach (var function in packList) |
| | | { |
| | | 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()); |
| | |
| | | MainPage.Log($"读取安防列表失败:Code:{pack.Code}; Msg:{pack.message}"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log("Error", $"读取安防列表失败:Code:{ex.StackTrace}"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | var pack = Ins.HttpRequest.GetSecurityList(); |
| | | } |
| | | |
| | | //public async Task<bool> CanConnectToHost() |
| | | //{ |
| | | // try |
| | | // { |
| | | // using (HttpClient client = new HttpClient()) |
| | | // { |
| | | // client.Timeout = TimeSpan.FromSeconds(3); // 超时时间 |
| | | // HttpResponseMessage response = await client.GetAsync(HttpUtil.GlobalRequestHttpsHost); |
| | | // return response.IsSuccessStatusCode; |
| | | // } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // MainPage.Log(ex.StackTrace); |
| | | // return false; |
| | | // } |
| | | //} |
| | | |
| | | |
| | | } |
| | | } |
| | | |