黄学彪
2019-11-28 3a26f6025130dcaae4aa82ea19b16ad902450eb8
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
@@ -285,7 +285,7 @@
                        //如果用户已经退出了登陆,则不处理
                        return;
                    }
                    string msg = IMessageCommon.Current.GetMsgByRequestName(RequestName, revertObj.StateCode, pra);
                    string msg = IMessageCommon.Current.GetMsgByRequestName(RequestName, revertObj, pra);
                    if (msg != null)
                    {
                        var control = new ShowMsgControl(ShowMsgType.Tip, msg);
@@ -309,7 +309,7 @@
        /// </summary>
        /// <param name="checkAuthority">是否检测权限</param>
        /// <returns></returns>
        private static HttpConnectMode GetHttpConnectMode(bool checkAuthority)
        public static HttpConnectMode GetHttpConnectMode(bool checkAuthority)
        {
            if (checkAuthority == false)
            {
@@ -397,17 +397,21 @@
                        {
                            //设置当前激活的画面ID
                            UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
                            if (UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
                            //追加条件一:关闭的界面为EditorCommonForm的时候才处理
                            if ((form is EditorCommonForm) && UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
                            {
                                try
                                {
                                    var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID];
                                    //触发界面再次激活的事件
                                    int value = Myform.FormActionAgainEvent();
                                    if (value == 1)
                                    if (Myform is EditorCommonForm)
                                    {
                                        //Log出力
                                        HdlLogLogic.Current.WriteLog(1, Myform.FormID + " 被激活");
                                        //触发界面再次激活的事件
                                        int value = ((EditorCommonForm)Myform).FormActionAgainEvent();
                                        if (value == 1)
                                        {
                                            //Log出力
                                            HdlLogLogic.Current.WriteLog(1, Myform.FormID + " 被激活");
                                        }
                                    }
                                }
                                catch (Exception ex)
@@ -428,17 +432,21 @@
                            {
                                //设置当前激活的画面ID
                                UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
                                if (UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
                                //追加条件一:关闭的界面为EditorCommonForm的时候才处理
                                if ((form is EditorCommonForm) && UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
                                {
                                    try
                                    {
                                        var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID];
                                        //触发界面再次激活的事件
                                        int value = Myform.FormActionAgainEvent();
                                        if (value == 1)
                                        if (Myform is EditorCommonForm)
                                        {
                                            //Log出力
                                            HdlLogLogic.Current.WriteLog(1, Myform.FormID + " 被激活");
                                            //触发界面再次激活的事件
                                            int value = ((EditorCommonForm)Myform).FormActionAgainEvent();
                                            if (value == 1)
                                            {
                                                //Log出力
                                                HdlLogLogic.Current.WriteLog(1, Myform.FormID + " 被激活");
                                            }
                                        }
                                    }
                                    catch (Exception ex)
@@ -512,7 +520,7 @@
            Config.Instance.Home.IsOthreShare = isOthreShare;
            Config.Instance.Home.AccountType = accountType;
            Config.Instance.Home.MainUserDistributedMark = mainMark;
            Config.Instance.Home.Save();
            Config.Instance.Home.Save(false);
            //刷新本地网关文件
            HdlGatewayLogic.Current.ReFreshByLocal();
@@ -593,7 +601,7 @@
        {
            UserCenterResourse.Option.OldAccountId = string.Empty;
            //关闭所有接收
            HdlDeviceAttributeLogic.Current.RemoveAllEvent();
            HdlGatewayReceiveLogic.Current.RemoveAllEvent();
            //清除升级列表
            FirmwareUpdateResourse.dicDeviceUpdateList.Clear();
            FirmwareUpdateResourse.dicGatewayUpdateList.Clear();
@@ -614,7 +622,8 @@
                HdlGatewayLogic.Current.ClearAllRealGateway();
                try
                {
                    ZigBee.Device.ZbGateway.RemoteMqttClient?.DisconnectAsync();
                    //断开远程Mqtt连接
                    ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
                }
                catch { }
@@ -641,27 +650,22 @@
        /// </summary>
        public static void CloseAllOpenForm()
        {
            var listForm = new List<CommonFormBase>();
            var listId = new List<string>();
            foreach (CommonFormBase form in UserCenterResourse.DicActionForm.Values)
            while (UserView.HomePage.Instance.ChildrenCount > 0)
            {
                if (form.FormID != "UserMainForm")
                var view = UserView.HomePage.Instance.GetChildren(UserView.HomePage.Instance.ChildrenCount - 1);
                if (view is CommonFormBase)
                {
                    listForm.Insert(0, form);
                    listId.Add(form.FormID);
                    ((CommonFormBase)view).CloseForm();
                }
                else if (view is UserView.UserPage)
                {
                    break;
                }
                else
                {
                    view.RemoveFromParent();
                }
            }
            foreach (var id in listId)
            {
                UserCenterResourse.DicActionForm.Remove(id);
            }
            //关闭所有画面
            foreach (CommonFormBase form in listForm)
            {
                form.CloseForm();
            }
            listForm.Clear();
        }
        #endregion
@@ -783,13 +787,19 @@
            //APP缓存加载开始
            UserCenterResourse.Option.AppCanSignout = false;
            //强制指定不关闭进度条
            ProgressBar.SetCloseBarFlag(true);
            //只有在住宅ID不一样的时候才做这个操作
            if (Common.Config.Instance.HomeId != UserCenterResourse.Option.OldHomeStringId
                || Common.Config.Instance.Account != UserCenterResourse.Option.OldAccountId)
            {
                try
                {
                    //断开远程Mqtt连接
                    ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
                }
                catch { }
                //消息记录重新读取及检测
                ControlCommonResourse.ReadMessageAgain = true;
                //加载账号配置信息
                var optionInfo = UserCenterResourse.Option.Load();
                UserCenterResourse.Option = optionInfo;
@@ -811,11 +821,9 @@
                CreatAllUserCenterDirectory();
                //关闭所有接收
                HdlDeviceAttributeLogic.Current.RemoveAllEvent();
                HdlGatewayReceiveLogic.Current.RemoveAllEvent();
                //刷新安防上报信息
                HdlAlarmsLogic.Current.RefreshAlarmInfo();
                //添加保存安防设备报警的事件(不需要再执行任何操作,并且永久存在)
                HdlAlarmsLogic.Current.AddAlarmInfoEvent();
                //保存用户的登陆信息到本地
                SaveUserInformationToLocation();
@@ -843,19 +851,13 @@
                //刷新APP前一次选择的网关ID(可以反复调用,需要在网关初始化完了之后才能调用)
                HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId();
                //清空强制指定文本的附加信息
                ProgressBar.SetAppendText(string.Empty);
                //0:已经同步过,不需要同步,这个时候需要提示备份
                //if (result == 0)
                //{
                //    //开启自动备份提示
                //    HdlAutoBackupLogic.ShowAutoBackupPromptedForm();
                //}
                if (result == 0)
                {
                    //开启自动备份提示
                    HdlAutoBackupLogic.ShowAutoBackupPromptedForm();
                }
            }
            //恢复可关闭进度条
            ProgressBar.SetCloseBarFlag(false);
            //APP缓存加载完成
            UserCenterResourse.Option.AppCanSignout = true;
@@ -935,7 +937,7 @@
                    newHouse.IsOthreShare = house.IsOthreShare;
                    newHouse.AccountType = house.AccountType;
                    newHouse.MainUserDistributedMark = house.MainUserDistributedMark;
                    newHouse.Save();
                    newHouse.Save(false);
                }
            }
            if (string.IsNullOrEmpty(userInfo.UserName) == true)
@@ -946,6 +948,18 @@
            UserCenterResourse.UserInfo = userInfo;
            UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, "Admin.png");
            if (UserCenterResourse.UserInfo.HeadImage != null)
            {
                //写入头像内容
                Shared.IO.FileUtils.WriteFileByBytes(UserCenterResourse.UserInfo.UserIconFile, UserCenterResourse.UserInfo.HeadImage);
            }
            UserCenterResourse.UserInfo.HeadImage = null;
            //手势密码
            UserCenterResourse.Option.GestureAuthentication = UserCenterResourse.UserInfo.GesturePwd == null ? string.Empty : UserCenterResourse.UserInfo.GesturePwd;
            UserCenterResourse.UserInfo.GesturePwd = null;
            //密码验证
            UserCenterResourse.Option.PswAuthentication = UserCenterResourse.UserInfo.StringPwd == null ? string.Empty : UserCenterResourse.UserInfo.StringPwd;
            UserCenterResourse.UserInfo.StringPwd = null;
            //初始化管理员控制主人的连接地址(因为这个连接Token是不会改变的,所以只需要初始化一次)
            await InitAdminConnectMainInfo();
@@ -984,13 +998,12 @@
            {
                return;
            }
            string nowFile = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, "Admin.png");
            if (System.IO.File.Exists(nowFile) == true)
            if (System.IO.File.Exists(UserCenterResourse.UserInfo.UserIconFile) == true)
            {
                return;
            }
            //复制过去
            System.IO.File.Copy(defultFile, nowFile);
            System.IO.File.Copy(defultFile, UserCenterResourse.UserInfo.UserIconFile);
        }
        #endregion
@@ -1008,9 +1021,9 @@
            Config.Instance.AdminRequestBaseUrl = string.Empty;
            Config.Instance.AdminRequestToken = string.Empty;
            if (UserCenterResourse.UserInfo.AuthorityNo != 2)
            if (UserCenterResourse.UserInfo.AuthorityNo != 2 && UserCenterResourse.UserInfo.AuthorityNo != 3)
            {
                //拥有管理员权限的成员才能这样搞,  这里必须是2
                //时代变了,这里管理员和成员都能调用
                return true;
            }
            var pra = new