/// <summary> /// 设置COOKIE /// </summary> /// <param name="var">变量</param> /// <returns>结果</returns> private double SETCOOKIE(CVariable var) { string cookieName = m_indicator.GetText(var.m_parameters[0]); UserCookieService cookieService = DataCenter.UserCookieService; UserCookie cookie = new UserCookie(); cookie.m_key = cookieName; cookie.m_value = m_indicator.GetText(var.m_parameters[1]); return(cookieService.AddCookie(cookie)); }
/// <summary> /// 获取COOKIE /// </summary> /// <param name="var">变量</param> /// <returns>状态</returns> private double GETCOOKIE(CVariable var) { string cookieName = m_indicator.GetText(var.m_parameters[1]); UserCookieService cookieService = DataCenter.UserCookieService; UserCookie cookie = new UserCookie(); if (cookieService.GetCookie(cookieName, ref cookie) > 0) { CVariable newVar = new CVariable(m_indicator); newVar.m_expression = "'" + cookie.m_value + "'"; m_indicator.SetVariable(var.m_parameters[0], newVar); return(1); } return(0); }
/// <summary> /// 登录 /// </summary> public void Login() { DataCenter.LoadData(1); Close(); return; int state = DataCenter.Connect(); if (state == -1) { m_mainFrame.ShowMessageBox("无法连接服务器!", "提示", 0); return; } TabControlA tabLogin = GetTabControl("tabLogin"); TabPageA selectedTabpage = tabLogin.SelectedTabPage; TextBoxA txtUserName = GetTextBox("txtUserName"); TextBoxA txtPassword = GetTextBox("txtPassword"); String userName = txtUserName.Text; String passWord = txtPassword.Text; if (userName.Length == 0) { m_mainFrame.ShowMessageBox("请输入邮箱!", "提示", 0); return; } if (userName.IndexOf("@") == -1) { m_mainFrame.ShowMessageBox("邮箱格式不符合要求!", "提示", 0); return; } if (passWord.Length == 0) { m_mainFrame.ShowMessageBox("请输入密码!", "提示", 0); return; } int ret = m_loginService.Login(userName, passWord, m_loginRequestID); if (ret != -1) { UserCookieService cookieService = DataCenter.UserCookieService; UserCookie cookie = new UserCookie(); cookie.m_key = "LOGININFO"; cookie.m_value = userName + "," + passWord; cookieService.AddCookie(cookie); m_window.Enabled = false; } }
/// <summary> /// 显示 /// </summary> public override void Show() { UserCookieService cookieService = DataCenter.UserCookieService; UserCookie cookie = new UserCookie(); if (cookieService.GetCookie("LOGININFO", ref cookie) > 0) { String[] strs = cookie.m_value.Split(','); if (strs.Length >= 2) { TextBoxA txtUserName = GetTextBox("txtUserName"); TextBoxA txtPassword = GetTextBox("txtPassword"); txtUserName.Text = strs[0]; txtPassword.Text = strs[1]; } } base.Show(); }