From 2ed75b8b337048e5d75e6d9ec8307633134f02fd Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 10 十月 2019 11:33:04 +0800
Subject: [PATCH] 个人中心添加楼层和创建房间,实装二级验证

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs |  107 ++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 93 insertions(+), 14 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
index 3c92302..cb79387 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
+++ b/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 () =>
             {
                 //妫�娴婣PP鏄惁鑳藉閫�鍑�
                 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>
+        /// 璇诲彇鏂囦欢(鏂囦欢涓嶅瓨鍦ㄨ繑鍥瀗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