HDL_ON/Common/HDLCommon.cs
@@ -4,6 +4,7 @@
using HDL_ON.UI.CSS;
using HDL_ON.DAL.Server;
using HDL_ON.UI;
using HDL_ON.Entity;
namespace HDL_ON
{
@@ -237,7 +238,99 @@
            }
        }
        #region 推送处理
        /// <summary>
        /// 推送消息处理
        /// </summary>
        /// <param name="jpushMessageInfo"></param>
        public void AdjustPushMessage(JPushMessageInfo jpushMessageInfo)
        {
            try
            {
                if (jpushMessageInfo.Extras != null && jpushMessageInfo.Extras.Contains("Offline"))
                {
                    Shared.Application.RunOnMainThread(() =>
                    {
                        //账号在别处登陆,被踢下线 跳转到登录页面
                        new Alert(Language.StringByID(StringId.Tip), Language.StringByID(StringId.LoggedOnOtherDevices), Language.StringByID(StringId.Close)).Show();
                        //2020-12-04 待增加退出登录操作
                        Logout();
                    });
                    return;
                }
                else
                {
                    Shared.Application.RunOnMainThread(() =>
                    {
                        new Alert(jpushMessageInfo.Title, jpushMessageInfo.Content, Language.StringByID(StringId.Close)).Show();
                    });
                    return;
                }
            }
            catch
            {
            }
        }
        /// <summary>
        /// 退出登录操作
        /// </summary>
        public void Logout()
        {
            try
            {
                Shared.Application.RunOnMainThread(() =>
                {
                    #region 保存本地数据至文件夹
                    string oldRegionRootPath = FileUtils.CreateRegionBackup(DB_ResidenceData.residenceData.CurReginID.ToString());
                    new System.Threading.Thread(() =>
                    {
                        try
                        {
                            var backuplist = FileUtils.ReadFiles();
                            FileUtils.DeleteRegionFiles(oldRegionRootPath);
                            //移动文件
                            foreach (var fileName in backuplist)
                            {
                                System.IO.FileInfo fileInfo = new System.IO.FileInfo(FileUtils.RootPath + fileName);
                                if (fileInfo.Exists)
                                {
                                    fileInfo.MoveTo(oldRegionRootPath + fileName);
                                    MainPage.Log("move file : " + fileName);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MainPage.Log($"xxx:{ex.Message}");
                        }
                        finally
                        {
                            FileUtils.DeleteAllFile();
                        }
                    }).Start();
                    #endregion
                    ////2.注销推送
                    new HttpServerRequest().SignOutPush();
                    //3.跳转登录页面
                    UserInfo.Current.LastTime = DateTime.MinValue;
                    UserInfo.Current.headImagePagePath = "LoginIcon/2.png";//重置用户头像
                    UserInfo.Current.SaveUserInfo();
                    MainPage.GoLoginPage(UserInfo.Current);
                    DB_ResidenceData.residenceData.EixtAccount();
                });
            }
            catch (Exception ex)
            {
                MainPage.Log($"xxx:{ex.Message}");
            }
        }
        #endregion
    }
}