| | |
| | | }
|
| | | var revertObj = JsonConvert.DeserializeObject<ResponsePack>(Encoding.UTF8.GetString(byteData));
|
| | | //检测是否存在错误信息
|
| | | return CheckNotEorrorMsg(revertObj, RequestName, listNotShowError);
|
| | | return CheckNotEorrorMsg(revertObj, RequestName, listNotShowError, obj);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | }
|
| | | 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;
|
| | |
| | | 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;
|
| | |
| | | /// <param name="revertObj">从接口接收到的数据</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)
|
| | | {
|
| | |
| | | //如果用户已经退出了登陆,则不处理
|
| | | 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);
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | |
| | | /// </summary>
|
| | | /// <param name="checkAuthority">是否检测权限</param>
|
| | | /// <returns></returns>
|
| | | private static HttpConnectMode GetHttpConnectMode(bool checkAuthority)
|
| | | public static HttpConnectMode GetHttpConnectMode(bool checkAuthority)
|
| | | {
|
| | | if (checkAuthority == false)
|
| | | {
|
| | |
| | | {
|
| | | //设置当前激活的画面ID
|
| | | UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
|
| | | if (UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
|
| | | //追加条件一:关闭的界面为EditorCommonForm的时候才处理
|
| | | if ((form is EditorCommonForm) && UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
|
| | | {
|
| | | var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID];
|
| | | if (Myform != null)
|
| | | try
|
| | | {
|
| | | try
|
| | | var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID];
|
| | | if (Myform is EditorCommonForm)
|
| | | {
|
| | | //触发界面再次激活的事件
|
| | | int value = Myform.FormActionAgainEvent();
|
| | | int value = ((EditorCommonForm)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;
|
| | | 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)
|
| | |
| | | {
|
| | | //设置当前激活的画面ID
|
| | | UserCenterResourse.NowActionFormID = UserCenterResourse.listActionFormId[index];
|
| | | if (UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
|
| | | //追加条件一:关闭的界面为EditorCommonForm的时候才处理
|
| | | if ((form is EditorCommonForm) && UserCenterResourse.DicActionForm.ContainsKey(UserCenterResourse.NowActionFormID) == true)
|
| | | {
|
| | | var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID];
|
| | | try
|
| | | {
|
| | | //触发界面再次激活的事件
|
| | | int value = Myform.FormActionAgainEvent();
|
| | | if (value == 1)
|
| | | var Myform = UserCenterResourse.DicActionForm[UserCenterResourse.NowActionFormID];
|
| | | 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)
|
| | |
| | | alert.Show();
|
| | |
|
| | | //Log出力
|
| | | string msg = ex.Message + "\r\n";
|
| | | msg += ex.TargetSite.ToString();
|
| | | HdlLogLogic.Current.WriteLog(-1, msg);
|
| | | HdlLogLogic.Current.WriteLog(ex);
|
| | | }
|
| | | //释放这个变量
|
| | | Myform = null;
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | /// <param name="all">true:全部删除(用于住宅删除) false:重要的文件不删除</param>
|
| | | public static void DeleteAllLocationFile(bool all = true)
|
| | | {
|
| | | string dPath = UserCenterResourse.LocalRootPath;
|
| | | string dPath = Config.Instance.FullPath;
|
| | | if (System.IO.Directory.Exists(dPath) == false)
|
| | | {
|
| | | return;
|
| | |
| | | //不能删除Config文件
|
| | | return true;
|
| | | }
|
| | | else if (fileName.StartsWith("DeviceUI_") == true)
|
| | | {
|
| | | //不能删除设备UI文件
|
| | | return true;
|
| | | }
|
| | | else if (fileName.StartsWith("House_") == true)
|
| | | {
|
| | | //不能删除住宅文件
|
| | |
| | | /// <param name="noticeDb">是否通知云端</param>
|
| | | public static void ReLoginAgain(string account = "", bool noticeDb = true)
|
| | | {
|
| | | UserCenterResourse.oldAccountId = string.Empty;
|
| | | UserCenterResourse.Option.OldAccountId = string.Empty;
|
| | | //关闭所有接收
|
| | | HdlDeviceAttributeLogic.Current.RemoveAllEvent();
|
| | | //清除升级列表
|
| | |
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //检测APP是否能够退出
|
| | | while (UserCenterResourse.AppCanSignout == false)
|
| | | while (UserCenterResourse.Option.AppCanSignout == false)
|
| | | {
|
| | | await Task.Delay(500);
|
| | | }
|
| | |
| | | try
|
| | | {
|
| | | ZigBee.Device.ZbGateway.RemoteMqttClient?.DisconnectAsync();
|
| | | ZigBee.Device.ZbGateway.RemoteMqttClient = null;
|
| | | }
|
| | | catch { }
|
| | |
|
| | |
| | | //通知云端,已经退出登陆
|
| | | var result = await CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync("ZigbeeUsers/SignOut", null, "GET");
|
| | | }
|
| | | Application.RunOnMainThread(() =>
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //关闭所有打开了的界面
|
| | | CloseAllOpenForm();
|
| | |
| | | /// <returns></returns>
|
| | | public static string CombinePath(params object[] listNames)
|
| | | {
|
| | | string rootPath = UserCenterResourse.LocalRootPath;
|
| | | string rootPath = Config.Instance.FullPath;
|
| | | if (listNames == null || listNames.Length == 0)
|
| | | {
|
| | | return rootPath;
|
| | |
| | | public async static Task<bool> InitUserCenterMenmoryAndThread()
|
| | | {
|
| | | //APP缓存加载开始
|
| | | UserCenterResourse.AppCanSignout = false;
|
| | | UserCenterResourse.Option.AppCanSignout = false;
|
| | |
|
| | | //强制指定不关闭进度条
|
| | | ProgressBar.SetCloseBarFlag(true);
|
| | |
|
| | | //只有在住宅ID不一样的时候才做这个操作
|
| | | if (Common.Config.Instance.HomeId != UserCenterResourse.oldHomeStringId
|
| | | || Common.Config.Instance.Account != UserCenterResourse.oldAccountId)
|
| | | if (Common.Config.Instance.HomeId != UserCenterResourse.Option.OldHomeStringId
|
| | | || Common.Config.Instance.Account != UserCenterResourse.Option.OldAccountId)
|
| | | {
|
| | | //变更根目录路径
|
| | | UserCenterResourse.LocalRootPath = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, Config.Instance.Home.Id);
|
| | | UserCenterResourse.UserPictruePath = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, DirNameResourse.UserPictrueDirectory);
|
| | |
|
| | | //加载账号配置信息
|
| | | var optionInfo = UserCenterResourse.Option.Load();
|
| | | UserCenterResourse.Option = optionInfo;
|
| | | //变更根用户图片目录路径
|
| | | UserCenterResourse.Option.UserPictruePath = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, DirNameResourse.UserPictrueDirectory);
|
| | |
|
| | | //初始化登陆账号的信息
|
| | | await InitUserAccoutInfo();
|
| | |
| | | //保存用户的登陆信息到本地
|
| | | SaveUserInformationToLocation();
|
| | |
|
| | | UserCenterResourse.oldHomeStringId = Common.Config.Instance.HomeId;
|
| | | UserCenterResourse.oldAccountId = Common.Config.Instance.Account;
|
| | | UserCenterResourse.Option.OldHomeStringId = Common.Config.Instance.HomeId;
|
| | | UserCenterResourse.Option.OldAccountId = Common.Config.Instance.Account;
|
| | |
|
| | | //同步数据(二次调用没关系)
|
| | | var result = await HdlAutoBackupLogic.SynchronizeDbAutoBackupData();
|
| | |
| | | //同步云端的网关id,如果本地拥有云端不存在的id,则表示应该被换绑了,直接删除
|
| | | HdlGatewayLogic.Current.SynchronizeDbGateway();
|
| | |
|
| | | //初始化住宅对象
|
| | | Common.Config.Instance.Home = House.GetHouseByHouseId(Common.Config.Instance.HomeId);
|
| | |
|
| | | //初始化房间(郭雪城那边不做处理,需要这里特殊执行一步)
|
| | | Room.RefreshAllRoomByLocation();
|
| | |
|
| | |
| | | ProgressBar.SetAppendText(string.Empty);
|
| | |
|
| | | //0:已经同步过,不需要同步,这个时候需要提示备份
|
| | | if (result == 0)
|
| | | {
|
| | | //开启自动备份提示
|
| | | //HdlAutoBackupLogic.ShowAutoBackupPromptedForm();
|
| | | }
|
| | | //if (result == 0)
|
| | | //{
|
| | | // //开启自动备份提示
|
| | | // HdlAutoBackupLogic.ShowAutoBackupPromptedForm();
|
| | | //}
|
| | | }
|
| | |
|
| | | //恢复可关闭进度条
|
| | | ProgressBar.SetCloseBarFlag(false);
|
| | | //APP缓存加载完成
|
| | | UserCenterResourse.AppCanSignout = true;
|
| | | UserCenterResourse.Option.AppCanSignout = true;
|
| | |
|
| | | return true;
|
| | | }
|
| | |
| | | {
|
| | | //获取本地记录的用户信息
|
| | | UserCenterResourse.UserInfo = GetUserInformationFromLocation();
|
| | | UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.UserPictruePath, "Admin.png");
|
| | | UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, "Admin.png");
|
| | |
|
| | | //获取登录账号的信息
|
| | | var pra = new AccountInfoPra();
|
| | |
| | | }
|
| | |
|
| | | UserCenterResourse.UserInfo = userInfo;
|
| | | UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.UserPictruePath, "Admin.png");
|
| | | 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();
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | string nowFile = System.IO.Path.Combine(UserCenterResourse.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
|
| | |
| | | Global.CreateEmptyDirectory(directory);
|
| | |
|
| | | //用户图片目录路径【文件夹】
|
| | | if (!System.IO.Directory.Exists(UserCenterResourse.UserPictruePath)) |
| | | if (UserCenterResourse.Option.UserPictruePath != string.Empty && !System.IO.Directory.Exists(UserCenterResourse.Option.UserPictruePath)) |
| | | { |
| | | System.IO.Directory.CreateDirectory(UserCenterResourse.UserPictruePath); |
| | | System.IO.Directory.CreateDirectory(UserCenterResourse.Option.UserPictruePath); |
| | | }
|
| | | }
|
| | |
|