wxr
2024-09-14 c00da77d00a479fa5d022346a6d9075f90a5c087
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>
@@ -305,35 +309,14 @@
                        ESOnVideo.Current.ShowESvideoVideoIntercom(eSVideoInfo, InterphoneType.FLVI.ToString());
                    }
                    else if (jpushMessageInfo.messageType == (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 pushHomeId = json["homeId"];
                            //if (pushHomeId == null || string.IsNullOrEmpty(pushHomeId.ToString())){
                            //    Console.WriteLine("homeId is null");
                            //    return;
                            //}
                            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 { }
                        //1.视对讲厂家类型
                        string interphoneTypeEnum = json["interphoneTypeEnum"].ToString();
@@ -372,6 +355,89 @@
                        }
                        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", "自研可视对讲铃声播放异常:" + 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();
@@ -379,6 +445,7 @@
                            eSVideoInfo.DeviceName = json["deviceName"].ToString();
                            eSVideoInfo.deviceSipAccount = json["deviceSipAccount"].ToString();
                            eSVideoInfo.spk = json["spk"].ToString();
                            //ShowAlert("狄耐克门口机呼叫");
                            //打开呼叫页面
@@ -470,6 +537,7 @@
            switch (UserInfo.Current.AccountString)
            {
                case "464027401@qq.com":
                case "649362315@qq.com":
                case "13580507523":
                case "15626203746":
                case "18316672920":
@@ -497,53 +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();
                    MainPage.Log("退出账号清空数据");
                    //4.注销HDLSIP账号登录 2021-08-20
                    HDLLinphone.Current.LogoutAllAccount();
                    MainPage.Log("注销HDLSIP账号登录");
                    //加载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.Hide();
                            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>
@@ -776,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)
                                            //{
@@ -806,7 +885,8 @@
                    }
                    else
                    {
                        IMessageCommon.Current.ShowErrorInfoAlter(result.Code);
                        if (result.Code != "-1")
                            IMessageCommon.Current.ShowErrorInfoAlter(result.Code);
                    }
                }
                catch (Exception ex)