From c00da77d00a479fa5d022346a6d9075f90a5c087 Mon Sep 17 00:00:00 2001 From: wxr <wxr@hdlchina.com.cn> Date: 星期六, 14 九月 2024 10:05:34 +0800 Subject: [PATCH] 退出登录时间调整,新风,音乐 --- HDL_ON/Common/HDLCommon.cs | 282 ++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 200 insertions(+), 82 deletions(-) diff --git a/HDL_ON/Common/HDLCommon.cs b/HDL_ON/Common/HDLCommon.cs index 1e5d28d..601e1a7 100644 --- a/HDL_ON/Common/HDLCommon.cs +++ b/HDL_ON/Common/HDLCommon.cs @@ -7,6 +7,10 @@ using HDL_ON.Entity; using System.Threading; using HDL_ON.DriverLayer; +#if __IOS__ +using Other; +using Shared.IOS.HDLLinphoneSDK; +#endif namespace HDL_ON { /// <summary> @@ -258,10 +262,12 @@ { try { + //Console.WriteLine($"鎺ユ敹鍒版帹閫侊紝锛岋紝锛�.{Newtonsoft.Json.JsonConvert.SerializeObject(jpushMessageInfo).ToString()}"); + //Extras涓虹┖涓嶅鐞� if (string.IsNullOrEmpty(jpushMessageInfo.Extras)) return; - if (jpushMessageInfo.Extras.Contains(PushMessageType.OffLine.ToString())) + if (jpushMessageInfo.Extras == (PushMessageType.OffLine.ToString())) { CheckLogout(); } @@ -273,14 +279,14 @@ if (string.IsNullOrEmpty(jpushMessageInfo.messageType)) return; //鎶ヨ鎺ㄩ�佹墠寮圭獥鎻愮ず锛坢essageType鍖呭惈Alarm鍏抽敭瀛楃殑锛� - if (jpushMessageInfo.messageType.Contains(PushMessageType.Alarm.ToString())) + if (jpushMessageInfo.messageType == (PushMessageType.Alarm.ToString())) { - //钀ょ煶闂ㄩ攣鏇存柊寮�閿佸浘鏍� - HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock.CommonMethod.Current.UpdateDoorLockState(PushMessageType.Alarm, jpushMessageInfo.HomeId, jpushMessageInfo.spk, jpushMessageInfo.Extras); - //鎶ヨ鎺ㄩ�佸脊绐楁彁绀� - ShowAlarmPushMessage(jpushMessageInfo, true); + //鎶ヨ鎺ㄩ�佸脊绐楁彁绀� + ShowAlarmPushMessage(jpushMessageInfo, true); + //钀ょ煶闂ㄩ攣鎺ㄩ�� + HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock.CommonMethod.Current.DoorLockPush(jpushMessageInfo); } - else if (jpushMessageInfo.messageType.Contains(PushMessageType.FLCall.ToString())) + else if (jpushMessageInfo.messageType == (PushMessageType.FLCall.ToString())) { if (string.IsNullOrEmpty(jpushMessageInfo.expantContent)) return; @@ -303,26 +309,14 @@ ESOnVideo.Current.ShowESvideoVideoIntercom(eSVideoInfo, InterphoneType.FLVI.ToString()); } - else if (jpushMessageInfo.messageType.Contains(PushMessageType.HDL_INTERPHONE.ToString())) + else if (jpushMessageInfo.messageType == PushMessageType.HDL_INTERPHONE.ToString()) { if (string.IsNullOrEmpty(jpushMessageInfo.expantContent)) return; //瀛楁鍏煎闂锛屽彧鑳界洿鎺ュ彇鍊间簡 var json = Newtonsoft.Json.Linq.JObject.Parse(jpushMessageInfo.expantContent); - try - { - var pushTime = json["pushTime"]; - if (!string.IsNullOrEmpty(pushTime.ToString())) - { - var pushDateTime = Utlis.UnixToDateTimeMS(Convert.ToInt64(pushTime)); - if (pushDateTime.AddSeconds(30) < DateTime.Now) - { - return; - } - } - } - catch { } + //1.瑙嗗璁插巶瀹剁被鍨� string interphoneTypeEnum = json["interphoneTypeEnum"].ToString(); @@ -346,10 +340,104 @@ //钀ょ煶鐚溂 eSVideoInfo.Lc_AccessToken = json["subToken"].ToString();//"瀛愯处鍙穞oken eSVideoInfo.DeviceSerial = json["devSerial"].ToString();//璁惧搴忓垪鍙� + eSVideoInfo.Lc_DeviceId = json["deviceId"].ToString(); + eSVideoInfo.spk = json["spk"].ToString(); + eSVideoInfo.HomeId = jpushMessageInfo.HomeId; + if (json.ContainsKey("msgId") && !string.IsNullOrEmpty(json["msgId"].ToString())) + { + eSVideoInfo.msgId = json["msgId"].ToString(); + } + if (json.ContainsKey("currentTime") && !string.IsNullOrEmpty(json["currentTime"].ToString())) + { + eSVideoInfo.currentTime = json["currentTime"].ToString(); + } } else if (interphoneTypeEnum == InterphoneType.HDL.ToString()) { + try + { + var pushTime = json["pushTime"]; + if (pushTime == null) + { + return; + } + if (!string.IsNullOrEmpty(pushTime.ToString())) + { + var pushDateTime = Utlis.UnixToDateTimeMS(Convert.ToInt64(pushTime)); + if (pushDateTime.AddSeconds(30) < DateTime.Now) + { + return; + } + } + } + catch { } + + + +#if __ANDROID__ + Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.MissedCallsTime = 30; + Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.SetMediaPlayerLooping(true); + Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.PlayRingtone(); + new Thread(() => + { + try + { + DateTime dateTime = DateTime.Now; + while (true) + { + Thread.Sleep(1000); + if (!Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.MediaPlayerPlayingStatus || dateTime.AddSeconds(Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.MissedCallsTime) <= DateTime.Now) + { + break; + } + } + Com.Hdl.Hdllinphonesdk.HDLLinphoneKit.Instance.SetMediaPlayerLooping(false); + } + catch (Exception ex) + { + MainPage.Log("error", "鑷爺鍙瀵硅閾冨0鎾斁寮傚父:" + ex.Message); + } + }) + { IsBackground = true }.Start(); + +#elif __IOS__ + SoundPlayer.Ins.PlaySound(); + new Thread(() => { + int count = 0; + while (true) + { + if (SoundPlayer.Ins.player == null) + { + break; + } + if (!SoundPlayer.Ins.player.Playing) + { + break; + } + System.Threading.Thread.Sleep(1000); + count++; + MainPage.Log("linphone 鍛煎彨璁℃椂锛�" + count); + if (count > 29) + { + SoundPlayer.Ins.StopSound(); + Application.RunOnMainThread(() => { + try + { + HDLLinPhoneSDK.Instance().HideIntercomeVC(); + }catch(Exception ex) + { + MainPage.Log("error", "ios linphone 鍛煎彨瓒呮椂鍏抽棴鐣岄潰寮傚父锛�" + ex.Message); + } + }); + break; + } + } + }) + { IsBackground = true }.Start(); +#endif + + //HDL Linphone 鐙勮�愬厠 eSVideoInfo.HomeId = jpushMessageInfo.HomeId; eSVideoInfo.callId = json["callId"].ToString(); @@ -357,6 +445,7 @@ eSVideoInfo.DeviceName = json["deviceName"].ToString(); eSVideoInfo.deviceSipAccount = json["deviceSipAccount"].ToString(); eSVideoInfo.spk = json["spk"].ToString(); + //ShowAlert("鐙勮�愬厠闂ㄥ彛鏈哄懠鍙�"); //鎵撳紑鍛煎彨椤甸潰 @@ -384,25 +473,19 @@ ESOnVideo.Current.ShowESvideoVideoIntercom(eSVideoInfo, interphoneTypeEnum); } - else if (jpushMessageInfo.messageType.Contains(PushMessageType.Prompt.ToString())) + else if (jpushMessageInfo.messageType == (PushMessageType.Prompt.ToString())) { ShowAlarmPushMessage(jpushMessageInfo, false); + //钀ょ煶闂ㄩ攣鎺ㄩ�� + HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock.CommonMethod.Current.DoorLockPush(jpushMessageInfo); } - else if (jpushMessageInfo.messageType.Contains(PushMessageType.DOOR_BELL.ToString())) + else if (jpushMessageInfo.messageType == (PushMessageType.DOOR_BELL.ToString())) { - try - { - if (string.IsNullOrEmpty(jpushMessageInfo.expantContent)) return; - var expantContent = Newtonsoft.Json.JsonConvert.DeserializeObject<UI.UI2.FuntionControlView.VideoDoorLock.ExpantContent>(jpushMessageInfo.expantContent); - if (expantContent == null) - { - return; - } - ///瑙嗛闂ㄩ攣 - HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock.CommonMethod.Current.SkipRTVActivity(expantContent.devSerial, expantContent.deviceId, expantContent.spk, true); - } - catch { } + //钀ょ煶闂ㄩ攣鎺ㄩ�� + HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock.CommonMethod.Current.DoorLockPush(jpushMessageInfo); } + + } } catch (Exception EX) @@ -440,11 +523,25 @@ /// </summary> public void CheckLogout() { +#if __IOS__ + try{ + HDL_ON_iOS.AppDelegate.rootViewController.PopToRootViewController(false); + }catch(Exception ex){ + MainPage.Log($"鍥炲埌璺熺被澶辫触:{ex.Message}"); + } +#else + //Application.Activity.StartActivity() +#endif + //娴嬭瘯璐﹀彿锛屼笉鎸や笅绾� switch (UserInfo.Current.AccountString) { case "464027401@qq.com": + case "649362315@qq.com": + case "13580507523": case "15626203746": + case "18316672920": + return; } @@ -454,7 +551,13 @@ //璐﹀彿鍦ㄥ埆澶勭櫥闄嗭紝琚涪涓嬬嚎 璺宠浆鍒扮櫥褰曢〉闈� new Alert(Language.StringByID(StringId.Tip), Language.StringByID(StringId.LoggedOnOtherDevices), Language.StringByID(StringId.Close)).Show(); - Logout(); + try + { + Logout(); + }catch (Exception ex) + { + MainPage.Log($"鎸や笅绾垮紓甯�:{ex.Message}"); + } } /// <summary> @@ -462,50 +565,63 @@ /// </summary> public void Logout() { - //鍔犺浇Loading鏁堟灉 - var waitPage = new Loading(); - MainPage.BaseView.AddChidren(waitPage); - waitPage.Start(Language.StringByID(StringId.PleaseWait)); - - new Thread(() => + try { - try + Application.RunOnMainThread(() => { - //2.娉ㄩ攢鎺ㄩ�� - new HttpServerRequest().SignOutPush(); - //3.璺宠浆鐧诲綍椤甸潰 - UserInfo.Current.LastTime = DateTime.MinValue; - UserInfo.Current.SaveUserInfo(); - DB_ResidenceData.Instance.EixtAccount(); - //4.娉ㄩ攢HDLSIP璐﹀彿鐧诲綍 2021-08-20 - HDLLinphone.Current.LogoutAllAccount(); + //鍔犺浇Loading鏁堟灉 + var waitPage = new Loading(); + MainPage.BaseView.AddChidren(waitPage); + waitPage.Start(Language.StringByID(StringId.PleaseWait)); + + new Thread(() => + { + try + { + //2.娉ㄩ攢鎺ㄩ�� + new HttpServerRequest().SignOutPush(); + //3.璺宠浆鐧诲綍椤甸潰 + UserInfo.Current.LastTime = DateTime.MinValue; + UserInfo.Current.SaveUserInfo(); + DB_ResidenceData.Instance.EixtAccount(); + MainPage.Log("閫�鍑鸿处鍙锋竻绌烘暟鎹�"); + //4.娉ㄩ攢HDLSIP璐﹀彿鐧诲綍 2021-08-20 + HDLLinphone.Current.LogoutAllAccount(); + MainPage.Log("娉ㄩ攢HDLSIP璐﹀彿鐧诲綍"); #if __IOS__ - //5.鍏ㄨ閫氱櫥鍑� - Shared.IOS.HDLFVSDK.Video.Logout(); - //6.娓呯┖Siri鍏变韩鏁版嵁淇℃伅 - new Other.SkipControl().SetData(false, "", "", "", ""); - var sDM = new SiriKit.SceneDateManager(); - Console.WriteLine($"IsLogin:{sDM.IsLgoin};accessToken:{sDM.AccessToken};refreshToken:{sDM.RefreshToken};RegionUrl:{sDM.RegionUrl};HomeId:{sDM.HomeId}"); + //5.鍏ㄨ閫氱櫥鍑� + //Shared.IOS.HDLFVSDK.Video.Logout(); + //6.娓呯┖Siri鍏变韩鏁版嵁淇℃伅 + new Other.SkipControl().SetData(false, "", "", "", ""); + var sDM = new SiriKit.SceneDateManager(); + Console.WriteLine($"IsLogin:{sDM.IsLgoin};accessToken:{sDM.AccessToken};refreshToken:{sDM.RefreshToken};RegionUrl:{sDM.RegionUrl};HomeId:{sDM.HomeId}"); #endif - } - catch (Exception ex) - { - MainPage.Log($"xxx:{ex.Message}"); - } - finally - { - Application.RunOnMainThread(() => - { - if (waitPage != null) - { - waitPage.RemoveFromParent(); - waitPage = null; } - MainPage.GoLoginPage(UserInfo.Current); - }); - } - }).Start(); + catch (Exception ex) + { + MainPage.Log($"xxx:{ex.Message}"); + } + finally + { + Application.RunOnMainThread(() => + { + if (waitPage != null) + { + waitPage.Hide(); + waitPage.RemoveFromParent(); + waitPage = null; + } + MainPage.GoLoginPage(UserInfo.Current); + }); + } + }).Start(); + }); + } + catch (Exception ex) + { + MainPage.Log("Error", $"閫�鍑虹櫥褰曞紓甯�:{ex.StackTrace}"); + } } /// <summary> @@ -589,9 +705,9 @@ } - #endregion +#endregion - #region 鈻� 甯哥敤鏂规硶_______________________ +#region 鈻� 甯哥敤鏂规硶_______________________ /// <summary> /// 璁剧疆涓嬪垝绾挎寜閽姸鎬� /// 缁熶竴灏佽璁剧疆鏂规硶 @@ -652,7 +768,7 @@ if (internetStatus == 0)//娌℃湁缃戠粶杩炴帴 0 { MainPage.InternetStatus = 0; - DAL.Mqtt.MqttClient.InitState(); + //DAL.Mqtt.MqttClient.DisConnectRemote();//.InitState(); } else if (internetStatus == 1)//3,4G鐨勭綉缁滆繛鎺� 1 { @@ -666,9 +782,9 @@ Control.Ins.SearchLoaclGateway(); } } - #endregion +#endregion - #region 璺宠浆鎵撳紑钀ょ煶浜戞柟娉� +#region 璺宠浆鎵撳紑钀ょ煶浜戞柟娉� /// <summary> /// 鑾峰彇瀛愯处鍙穞oken骞惰烦杞澶囧垪琛ㄩ〉闈� @@ -738,7 +854,8 @@ ((BaseActivity)Shared.Application.Activity).SetPermission(result => { //2023骞�03鏈�29鏃�13:08:35 淇敼 - Com.Videogo.Hdl.HDLEzvizSdk.Instance.Init(Application.Activity.Application, ezChildAccessToken, UserInfo.Current.LoginTokenString, UserInfo.Current.RefreshToken, OnAppConfig.Instance.RequestHttpsHost, "1aa98a90489b4838b966b57018b4b04b", 1, DB_ResidenceData.Instance.CurrentRegion.id); + Com.Videogo.Hdl.HDLEzvizSdk.Instance.Init(Application.Activity.Application, ezChildAccessToken, UserInfo.Current.LoginTokenString, UserInfo.Current.RefreshToken, OnAppConfig.Instance.RequestHttpsHost, "1aa98a90489b4838b966b57018b4b04b", 1, DB_ResidenceData.Instance.CurrentRegion.id, + HttpUtil.APP_KEY, HttpUtil.SECRET_KEY); Com.Videogo.Hdl.HDLEzvizSdk.Instance.JumpToCameraListActivity(Shared.Application.Activity, list); //if (result) //{ @@ -768,7 +885,8 @@ } else { - IMessageCommon.Current.ShowErrorInfoAlter(result.Code); + if (result.Code != "-1") + IMessageCommon.Current.ShowErrorInfoAlter(result.Code); } } catch (Exception ex) @@ -789,6 +907,6 @@ { IsBackground = true }.Start(); } - #endregion +#endregion } } -- Gitblit v1.8.0