protected void HandleServerDisconnect() { try { if (IsLoggedIn == false) { return; } m_tssUserName.Text = string.Empty; m_tssUserRole.Text = string.Empty; //UserId = UserName = UserRole = string.Empty; SystemParam.CurrentUser = null; AutoSync.GetInstance().Stop(); AutoSendMail.GetInstance().Stop(); CloseAllView(this); MessageBox.Show("Không thể kết nối tới máy chủ!", "Lỗi kết nối", MessageBoxButtons.OK, MessageBoxIcon.Error); IsLoggedIn = false; IsEditing = false; } catch (Exception exc) { AppLogger.logError(this.ToString(), exc); } }
protected void HandleLoginSucess() { try { m_tssUserName.Text = string.Format("Name: {0}", SystemParam.CurrentUser.user_name); m_tssUserRole.Text = string.Format("Role: {0}", EnumHelper.Parse <Constants.UserRole>(SystemParam.CurrentUser.role).GetDescription()); IsLoggedIn = true; //UserId = SystemParam.CurrentUser.id; //UserName = SystemParam.CurrentUser.user_name; //UserRole = SystemParam.CurrentUser.role; //init Data MainBusiness business = new MainBusiness(); string errorMessage = business.InitData(); if (string.IsNullOrEmpty(errorMessage) == false) { MessageBox.Show(errorMessage, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning); } AutoSync.GetInstance().Start(); AutoSendMail.GetInstance().Start(); } catch (Exception exc) { AppLogger.logError(this.ToString(), exc); } }
/// <summary> /// /// </summary> protected void logout() { string userName = SystemParam.CurrentUser.user_name; CloseAllView(this); SystemParam.IsLogged = false; SystemParam.CurrentUser = null; IsLoggedIn = false; ServerConnector.GetInstance().LogOut(userName, ClientRepository.GetInstance()._clientIp, ClientRepository.GetInstance()._clientPort); AutoSync.GetInstance().Stop(); }