| | |
| | | /// 下载数据完成标记 |
| | | /// </summary> |
| | | public bool DownloadDataComplete = false; |
| | | |
| | | public bool hadInternet = true; |
| | | /// <summary> |
| | | /// 下载数据 |
| | | /// </summary> |
| | | public void DownloadData() |
| | | { |
| | | if (MainPage.InternetStatus == 0 || MainPage.NoLoginMode) |
| | | if (MainPage.NoLoginMode) |
| | | { |
| | | DownloadDataComplete = true; |
| | | return; |
| | |
| | | var waitPage = new Loading(); |
| | | MainPage.BaseView.AddChidren(waitPage); |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | |
| | | |
| | | string code = StateCode.SUCCESS; |
| | | |
| | | Inverter.Ins.H5Page = null;//重置光伏页面 |
| | | |
| | | var downloadDataThread = new System.Threading.Thread(() => |
| | | { |
| | | 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) |
| | | { |
| | | 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; |
| | | } |
| | | else |
| | | { |
| | | hadInternet = true; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"Error:下载数据1:{ex.Message}"); |
| | | DownloadDataComplete = true; |
| | | return; |
| | | } |
| | | finally |
| | | { |
| | | if (!hadInternet) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | 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; |
| | | } |
| | |
| | | code = Ins.HttpRequest.GetHomePager(); |
| | | if (code != StateCode.SUCCESS) |
| | | { |
| | | if (waitPage != null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | try |
| | | { |
| | | waitPage.Hide(); |
| | | waitPage.RemoveFromParent(); |
| | | waitPage = null; |
| | | } |
| | | catch { } |
| | | }); |
| | | } |
| | | MainPage.Log($"刷新住宅信息失败"); |
| | | return; |
| | | } |
| | |
| | | code = Ins.HttpRequest.GetUserInfo(); |
| | | if (code != StateCode.SUCCESS) |
| | | { |
| | | if (waitPage != null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | try |
| | | { |
| | | waitPage.Hide(); |
| | | waitPage.RemoveFromParent(); |
| | | waitPage = null; |
| | | } |
| | | catch { } |
| | | }); |
| | | } |
| | | MainPage.Log($"刷新个人信息失败"); |
| | | return; |
| | | } |
| | |
| | | if (roomResult.Code == StateCode.SUCCESS) |
| | | { |
| | | MainPage.Log($"读取房间信息成功"); |
| | | var revData = Newtonsoft.Json.JsonConvert.DeserializeObject<SpatialApiPack>(roomResult.Data.ToString()); |
| | | var revData = JsonConvert.DeserializeObject<SpatialApiPack>(roomResult.Data.ToString()); |
| | | if (revData == null) |
| | | { |
| | | revData = new SpatialApiPack(); |
| | | } |
| | | { |
| | | SpatialInfo.CurrentSpatial.UpdateSpatialList(revData.list); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | var ssd = System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(revData.list)); |
| | | FileUtlis.Files.WriteFileByBytes("SpatialInfoData", ssd); |
| | | }catch(Exception ex) |
| | | { |
| | | MainPage.Log($"{this.GetType()}:保存房间信息异常:{ex.Message}"); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | } |
| | | else |
| | |
| | | FunctionList.List.ClearDatas(); |
| | | //MainPage.Log($"============设备============开始" + FunctionList.List.Functions.Count); |
| | | //MainPage.Log($"读取设备信息成功"); |
| | | //MainPage.Log($"sid列表获取====" + deviceResult.Data.ToString()); |
| | | MainPage.Log($"sid列表获取====\r\n" , deviceResult.Data.ToString()); |
| | | var deviceList = JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString()); |
| | | if (deviceList == null) |
| | | { |
| | |
| | | string videoList = videoInfo.Data.ToString(); |
| | | FunctionList.List.videoIntercom = JsonConvert.DeserializeObject<List<UI.UI2.FuntionControlView.Video.Video>>(videoList); |
| | | |
| | | foreach (var video in FunctionList.List.videoIntercom) |
| | | for(int i =0;i< FunctionList.List.videoIntercom.Count;i++) |
| | | { |
| | | var video = FunctionList.List.videoIntercom[i]; |
| | | |
| | | if (video.interphoneType == InterphoneType.IMOUVISIAL.ToString()) |
| | | { |
| | | UI.UI2.PersonalCenter.PirDevice.PirSend.LcSubAccessToken = video.subAccountToken; |
| | |
| | | isInterphoneType_HDL = true; |
| | | DB_ResidenceData.Instance.SupportFacePass = true; |
| | | DB_ResidenceData.Instance.SaveResidenceData(); |
| | | |
| | | Entity.DB_ResidenceData.Instance.SupportFVDevice = true; |
| | | 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($"ios 全视通异常 : {ex.Message}"); |
| | | } |
| | | |
| | | #else |
| | | //为全视通可视对讲 |
| | | DB_ResidenceData.Instance.SupportFacePass = true; |
| | | Entity.DB_ResidenceData.Instance.SupportVisitorManage = true; |
| | | Entity.DB_ResidenceData.Instance.SupportFVDevice = true; |
| | | |
| | | //isInterphoneType_HDL = true; |
| | | isInterphoneType_FREEVIEW = true; |
| | | |
| | | #endif |
| | | } |
| | | } |
| | | } |
| | |
| | | //如果检测线程没启动,才继续下面操作 因为App有可能刚启动马上收到推送了,然后才执行到这里 |
| | | if (HDLLinphone.Current.CheckIncomingCallThreadIsNull()) |
| | | { |
| | | |
| | | //当前住宅是HDL可视对讲类型的设备 |
| | | if (isInterphoneType_HDL) |
| | | { |
| | |
| | | } |
| | | else if (isInterphoneType_FREEVIEW) |
| | | { |
| | | |
| | | //HDLLinphone可视对讲,获取Sip账号并初始化SDK |
| | | HDLCallVideoInfo callVideoInfo = new HDLCallVideoInfo(); |
| | | callVideoInfo.HomeId = DB_ResidenceData.Instance.CurrentRegion.id; |
| | |
| | | { |
| | | |
| | | #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"); |
| | | |
| | | } |
| | | } |
| | | //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 |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | //======================群控==================== |
| | | if (DB_ResidenceData.Instance.HomeGateway.isSupportGroupControl) |
| | | { |
| | | var pack = Ins.HttpRequest.GetGroupControlList(); |
| | |
| | | } |
| | | readSidList.Clear(); |
| | | } |
| | | //FunctionList.List.Functions.AddRange(FunctionList.List.groupControls); |
| | | } |
| | | if (readSidList.Count > 0) |
| | | { |
| | |
| | | |
| | | //======================安防==================== |
| | | GetSecurityList(); |
| | | |
| | | //===================读取逻辑列表==================== |
| | | Logic.LogicList.Clear();//主页下拉强制刷新自动化列表 |
| | | MainView.GetLogicList();//读取自动化列表 |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | |
| | | //===================读取逻辑列表========================== |
| | | Logic.LogicList.Clear();//主页下拉强制刷新自动化列表 |
| | | |
| | | //======================注册推送==================== |
| | | httpRequest.RegisteredPush(); |