From 96c686f89f126ad4cf1e262b83301fb7cc8bf2d5 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期四, 07 十一月 2019 10:57:31 +0800
Subject: [PATCH] 2019.11.7

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs |  124 ++++++++++++++++++++++++++++++++--------
 1 files changed, 98 insertions(+), 26 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
index 3c92302..a6b048b 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
@@ -47,7 +47,7 @@
             }
             var revertObj = JsonConvert.DeserializeObject<ResponsePack>(Encoding.UTF8.GetString(byteData));
             //妫�娴嬫槸鍚﹀瓨鍦ㄩ敊璇俊鎭�
-            return CheckNotEorrorMsg(revertObj, RequestName, listNotShowError);
+            return CheckNotEorrorMsg(revertObj, RequestName, listNotShowError, obj);
         }
 
         /// <summary>
@@ -114,7 +114,7 @@
             }
             var revertObj = JsonConvert.DeserializeObject<ResponsePack>(Encoding.UTF8.GetString(byteData));
             //妫�娴嬮敊璇�
-            bool notError = CheckNotEorrorMsg(revertObj, RequestName, listNotShowError);
+            bool notError = CheckNotEorrorMsg(revertObj, RequestName, listNotShowError, obj);
             if (notError == false)
             {
                 return null;
@@ -165,7 +165,7 @@
                     var data = JsonConvert.DeserializeObject<ResponsePack>(data2);
                     if (data != null && string.IsNullOrEmpty(data.StateCode) == false)
                     {
-                        bool notError = CheckNotEorrorMsg(data, RequestName, listNotShowError);
+                        bool notError = CheckNotEorrorMsg(data, RequestName, listNotShowError, obj);
                         if (notError == false)
                         {
                             return null;
@@ -256,7 +256,8 @@
         /// <param name="revertObj">浠庢帴鍙f帴鏀跺埌鐨勬暟鎹�</param>
         /// <param name="RequestName">璇锋眰鎺ュ彛</param>
         /// <param name="listNotShowError">涓嶉渶瑕佹樉绀洪敊璇殑閿欒绫诲埆(鎺ュ彛杩斿洖鐨勯敊璇被鍒�)</param>
-        public static bool CheckNotEorrorMsg(ResponsePack revertObj, string RequestName, List<string> listNotShowError = null)
+        /// <param name="pra">璇锋眰鐨勫弬鏁�</param>
+        public static bool CheckNotEorrorMsg(ResponsePack revertObj, string RequestName, List<string> listNotShowError = null, object pra = null)
         {
             if (revertObj == null)
             {
@@ -284,14 +285,17 @@
                         //濡傛灉鐢ㄦ埛宸茬粡閫�鍑轰簡鐧婚檰,鍒欎笉澶勭悊
                         return;
                     }
-                    string msg = IMessageCommon.Current.GetMsgByRequestName(RequestName, revertObj.StateCode);
-                    var control = new ShowMsgControl(ShowMsgType.Tip, msg);
-                    control.Show();
-
-                    //鏃犳晥鐧诲綍Token
-                    if (revertObj.StateCode == "NoLogin")
+                    string msg = IMessageCommon.Current.GetMsgByRequestName(RequestName, revertObj.StateCode, pra);
+                    if (msg != null)
                     {
-                        UserCenterLogic.ReLoginAgain(Config.Instance.Account, false);
+                        var control = new ShowMsgControl(ShowMsgType.Tip, msg);
+                        control.Show();
+
+                        //鏃犳晥鐧诲綍Token
+                        if (revertObj.StateCode == "NoLogin")
+                        {
+                            UserCenterLogic.ReLoginAgain(Config.Instance.Account, false);
+                        }
                     }
                 });
 
@@ -395,8 +399,26 @@
                             UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
                             if (UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
                             {
-                                //瑙﹀彂鐣岄潰鍐嶆婵�娲荤殑浜嬩欢
-                                UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID]?.FormActionAgainEvent();
+                                try
+                                {
+                                    var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID];
+                                    //瑙﹀彂鐣岄潰鍐嶆婵�娲荤殑浜嬩欢
+                                    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鍑哄姏
+                                    HdlLogLogic.Current.WriteLog(ex);
+                                }
                             }
                         }
                         else if (actionForm != null && actionForm is UserView.UserPage)
@@ -408,8 +430,26 @@
                                 UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
                                 if (UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
                                 {
-                                    //瑙﹀彂鐣岄潰鍐嶆婵�娲荤殑浜嬩欢
-                                    UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID]?.FormActionAgainEvent();
+                                    try
+                                    {
+                                        var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID];
+                                        //瑙﹀彂鐣岄潰鍐嶆婵�娲荤殑浜嬩欢
+                                        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鍑哄姏
+                                        HdlLogLogic.Current.WriteLog(ex);
+                                    }
                                 }
                             }
                         }
@@ -563,7 +603,7 @@
             FirmwareUpdateResourse.dicDeviceUpdateList.Clear();
             FirmwareUpdateResourse.dicGatewayUpdateList.Clear();
 
-            new System.Threading.Thread(async () =>
+            HdlThreadLogic.Current.RunThread(async () =>
             {
                 //妫�娴婣PP鏄惁鑳藉閫�鍑�
                 while (UserCenterResourse.AppCanSignout == false)
@@ -589,7 +629,7 @@
                     //閫氱煡浜戠锛屽凡缁忛��鍑虹櫥闄�
                     var result = await CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync("ZigbeeUsers/SignOut", null, "GET");
                 }
-                Application.RunOnMainThread(() =>
+                HdlThreadLogic.Current.RunMain(() =>
                 {
                     //鍏抽棴鎵�鏈夋墦寮�浜嗙殑鐣岄潰
                     CloseAllOpenForm();
@@ -599,8 +639,7 @@
                     Shared.Common.CommonPage.Instance.AddChidren(formLogin);
                     formLogin.Show(account);
                 });
-            })
-            { IsBackground = true }.Start();
+            });
         }
 
         /// <summary>
@@ -926,12 +965,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 +979,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 +1150,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 +1282,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>
+        /// 璇诲彇鏂囦欢(鏂囦欢涓嶅瓨鍦ㄨ繑鍥瀗ull,鏁村ぉ蹇樿,鎵�浠ュ缓涓�涓嚱鏁版潵鐜╃帺)
+        /// </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
     }
 }

--
Gitblit v1.8.0