黄学彪
2019-10-10 2ed75b8b337048e5d75e6d9ec8307633134f02fd
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
@@ -395,8 +395,33 @@
                            UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
                            if (UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
                            {
                                //触发界面再次激活的事件
                                UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID]?.FormActionAgainEvent();
                                var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID];
                                if (Myform != null)
                                {
                                    try
                                    {
                                        //触发界面再次激活的事件
                                        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.uUnknownErrorAndDataLost));
                                        alert.Show();
                                        //Log出力
                                        string msg = ex.Message + "\r\n";
                                        msg += ex.TargetSite.ToString();
                                        HdlLogLogic.Current.WriteLog(-1, msg);
                                    }
                                }
                                //释放这个变量
                                Myform = null;
                            }
                        }
                        else if (actionForm != null && actionForm is UserView.UserPage)
@@ -408,8 +433,30 @@
                                UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
                                if (UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
                                {
                                    //触发界面再次激活的事件
                                    UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID]?.FormActionAgainEvent();
                                    var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID];
                                    try
                                    {
                                        //触发界面再次激活的事件
                                        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.uUnknownErrorAndDataLost));
                                        alert.Show();
                                        //Log出力
                                        string msg = ex.Message + "\r\n";
                                        msg += ex.TargetSite.ToString();
                                        HdlLogLogic.Current.WriteLog(-1, msg);
                                    }
                                    //释放这个变量
                                    Myform = null;
                                }
                            }
                        }
@@ -563,7 +610,7 @@
            FirmwareUpdateResourse.dicDeviceUpdateList.Clear();
            FirmwareUpdateResourse.dicGatewayUpdateList.Clear();
            new System.Threading.Thread(async () =>
            HdlThreadLogic.Current.RunThread(async () =>
            {
                //检测APP是否能够退出
                while (UserCenterResourse.AppCanSignout == false)
@@ -599,8 +646,7 @@
                    Shared.Common.CommonPage.Instance.AddChidren(formLogin);
                    formLogin.Show(account);
                });
            })
            { IsBackground = true }.Start();
            });
        }
        /// <summary>
@@ -926,12 +972,12 @@
        private static UserInformation GetUserInformationFromLocation()
        {
            string fileName = CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.UserInfoFile);
            if (System.IO.File.Exists(fileName) == false)
            var value = LoadFileContent(fileName);
            if (value == null)
            {
                return new UserInformation();
            }
            var varByte = Shared.IO.FileUtils.ReadFile(fileName);
            var info = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInformation>(System.Text.Encoding.UTF8.GetString(varByte));
            var info = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInformation>(value);
            return info;
        }
@@ -940,12 +986,9 @@
        /// </summary>
        private static void SaveUserInformationToLocation()
        {
            var data = Newtonsoft.Json.JsonConvert.SerializeObject(UserCenterResourse.UserInfo);
            var byteData = System.Text.Encoding.UTF8.GetBytes(data);
            string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.UserInfoFile);
            //写入内容
            Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData);
            SaveFileContent(fullName, UserCenterResourse.UserInfo);
            //搞一下主人的默认头像
            string defultFile = IO.FileUtils.GetImageFilePath("Center/Admin.png");
@@ -1114,6 +1157,10 @@
            directory = System.IO.Path.Combine(LocalDirectory, DirNameResourse.DownLoadShardDirectory);
            Global.CreateEmptyDirectory(directory);
            //LOG出力【文件夹】
            directory = System.IO.Path.Combine(LocalDirectory, DirNameResourse.LogDirectory);
            Global.CreateEmptyDirectory(directory);
            //用户图片目录路径【文件夹】
            if (!System.IO.Directory.Exists(UserCenterResourse.UserPictruePath))
            {
@@ -1242,5 +1289,37 @@
            return System.Text.Encoding.Default.GetString(ms.ToArray());
        }
        #endregion
        #region ■ 文件保存和读取_____________________
        /// <summary>
        /// 文件保存(整天忘记,所以建一个函数来玩玩)
        /// </summary>
        /// <param name="fullName">全路径</param>
        /// <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);
            //写入内容
            Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData);
        }
        /// <summary>
        /// 读取文件(文件不存在返回null,整天忘记,所以建一个函数来玩玩)
        /// </summary>
        /// <param name="fullName">全路径</param>
        /// <returns></returns>
        public static string LoadFileContent(string fullName)
        {
            if (System.IO.File.Exists(fullName) == false)
            {
                return null;
            }
            var varByte = Shared.IO.FileUtils.ReadFile(fullName);
            return System.Text.Encoding.UTF8.GetString(varByte);
        }
        #endregion
    }
}