/// <summary> /// 检查登录状态 /// </summary> /// <returns></returns> public bool CheckLogin() { try { if (LogicUser.Instance.getUserInfoByToken(MyUserInfo.LoginToken)) { LoginSync = true; return(true); } LoginSync = false; this.BeginInvoke((Action)(delegate() //等待结束 { MyUserInfo my = new MyUserInfo(); my.SetUserData(null); if (wxlogin != null) { wxlogin.isStartTask = false; wxlogin.isCloseWinForm = true; wxlogin.Close(); wxlogin = null; } if (winTask != null) { winTask.isStartTask = false; winTask.Close(); winTask = null; } openControl(new LoginControl(this)); })); return(false); } catch (Exception) { return(false); } }
/// <summary> /// 设置登录用户数据 /// </summary> /// <param name="user"></param> public void SetLoginData(UserModel user) { MyUserInfo my = new MyUserInfo(); my.SetUserData(user); if (user != null) { LoginSync = true; MyUserInfo.currentUserId = user.userid; LoadMyConfig(); GetDefaultTemplateText(); InitDataBase(); ((Action)(delegate() { while (LoginSync) { CheckLogin(); System.Threading.Thread.Sleep(10000); } })).BeginInvoke(null, null); } }