陈嘉乐
2020-05-28 f759dc1e6f49c53733eafda82207c85af18f9931
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
old mode 100644 new mode 100755
@@ -470,24 +470,28 @@
                try
                {
                    var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID] as EditorCommonForm;
                    //重置左滑使能
                    Myform.ScrollEnabled = Myform.ScrollEnabled;
                    //触发界面再次激活的事件
                    int value = Myform.FormActionAgainEvent();
                    if (value == 1)
                    //点击很快时,这个东西会是null,但是DicActionForm里面不是null,不知道为什么
                    if (Myform != null)
                    {
                        //Log出力
                        HdlLogLogic.Current.WriteLog(1, Myform.FormID + " 被激活");
                        //重置左滑使能
                        Myform.ScrollEnabled = Myform.ScrollEnabled;
                        //触发界面再次激活的事件
                        int value = Myform.FormActionAgainEvent();
                        if (value == 1)
                        {
                            //Log出力
                            HdlLogLogic.Current.WriteLog(1, Myform.FormID + " 被激活");
                        }
                    }
                }
                catch (Exception ex)
                {
                    //出现未知错误,数据丢失
                    var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
                    alert.Show();
                    //var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
                    //alert.Show();
                    //Log出力
                    HdlLogLogic.Current.WriteLog(ex, "界面重新激活异常");
                    HdlLogLogic.Current.WriteLog(ex, "界面重新激活异常 " + UserCenterResourse.NowActionFormID);
                }
            }
        }
@@ -636,6 +640,9 @@
                //如果是虚拟住宅
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //设定一个时间
                    Config.Instance.LoginDateTime = new DateTime(1970, 1, 1);
                    Config.Instance.Save();
                    //收起左菜单
                    CommonPage.Instance.CloseLeftMenu();
                    //关闭所有打开了的界面
@@ -832,6 +839,9 @@
        /// <returns></returns>
        public async static Task<bool> InitUserCenterMenmoryAndThread(bool ShowPrompted = true)
        {
            //调用这个方法,都需要重新刷新主页
            UserView.UserPage.Instance.RefreshForm = true;
            //如果是虚拟住宅
            if (Config.Instance.Home.IsVirtually == true)
            {
@@ -869,7 +879,7 @@
                UserCenterResourse.ResidenceOption = UserCenterResourse.ResidenceOption.Load();
                //初始化登陆账号的信息
                var hadNet = await InitUserAccoutInfo();
                var hadNet = await InitUserAccoutInfo(true);
                //如果有网络的话
                if (hadNet == true)
                {
@@ -940,6 +950,7 @@
        /// </summary>
        private static void InitUserCenterMenmoryByVirtualHome()
        {
            UserCenterResourse.AccountOption.OldHomeStringId = Common.Config.Instance.Home.Id;
            //清空所有成员缓存
            ClearAllMemberMemory();
            //预创建个人中心全部的文件夹
@@ -952,6 +963,8 @@
            Common.LocalDevice.Current.ReFreshByLocal();
            //初始化房间(郭雪城那边不做处理,需要这里特殊执行一步)
            HdlRoomLogic.Current.RefreshAllRoomByLocation();
            //刷新左边刷新房间视图列表
            HdlRoomLogic.Current.RefreshRoomListView();
        }
        /// <summary>
@@ -974,10 +987,11 @@
            //当前主页,场景和功能所选择的分支 1:场景 2:功能
            UserCenterResourse.ResidenceOption.HomeMainPageSwitchIndex = 1;
            //当前分类,场景和功能所选择的分支 0:场景 1:功能 2:自动化
            UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex = 0;
            //切换住宅清除之前缓存数据;
            Common.Logic.LogicList.Clear();
            Common.Logic.LockLogicList.Clear();
            UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex = 0;
            //切换住宅清除之前逻辑缓存数据;
            Common.Logic.LogicList.Clear();
            Common.Logic.LockLogicList.Clear();
            Common.Logic.SoneLogicList.Clear();
        }
@@ -988,14 +1002,18 @@
        /// <summary>
        /// 初始化登陆账号的信息
        /// </summary>
        /// <param name="reLoad">是否从新从本地加载(重新初始化登陆账号的信息,不需要重新加载)</param>
        /// <returns></returns>
        private async static Task<bool> InitUserAccoutInfo()
        private async static Task<bool> InitUserAccoutInfo(bool reLoad)
        {
            //初始化个人信息的标识
            UserCenterResourse.UserInfo.InitUserInfoSuccess = false;
            //获取本地记录的用户信息
            UserCenterResourse.UserInfo = GetUserInformationFromLocation();
            UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, "Admin.png");
            if (reLoad == true)
            {
                //获取本地记录的用户信息
                UserCenterResourse.UserInfo = GetUserInformationFromLocation();
                UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, "Admin.png");
            }
            //获取登录账号的信息
            var pra = new AccountInfoPra();
@@ -1118,7 +1136,7 @@
        private async static Task<bool> ReInitUserAccoutInfo()
        {
            //重新初始化账号信息
            var result = await InitUserAccoutInfo();
            var result = await InitUserAccoutInfo(false);
            if (result == false)
            {
                return result;
@@ -1465,10 +1483,21 @@
        /// <param name="obj">需要序列化的东西</param>
        public static void SaveFileContent(string fullName, object obj)
        {
            var data = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
            var byteData = System.Text.Encoding.UTF8.GetBytes(data);
            var data = JsonConvert.SerializeObject(obj);
            var byteData = Encoding.UTF8.GetBytes(data);
            //写入内容
            Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData);
            System.IO.FileStream fileStream = null;
            try
            {
                fileStream = new System.IO.FileStream(fullName, System.IO.FileMode.Create, System.IO.FileAccess.Write);
                fileStream.Write(byteData, 0, byteData.Length);
                fileStream.Flush();
            }
            catch { }
            finally
            {
                fileStream?.Close();
            }
        }
        /// <summary>