Exemple #1
0
        /// <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));
        }
Exemple #2
0
        /// <summary>
        /// 更新会话
        /// </summary>
        /// <param name="cookie">会话</param>
        /// <returns>状态</returns>
        public int UpdateCookie(UserCookie cookie)
        {
            String sql = String.Format("UPDATE USERCOOKIE SET VALUE = '{0}' WHERE USERID = {1} AND KEY = '{2}'",
                                       CStrA.GetDBString(cookie.m_value), m_userID, CStrA.GetDBString(cookie.m_key));
            SQLiteConnection conn = new SQLiteConnection(m_connectStr);
            SQLiteCommand    cmd  = conn.CreateCommand();

            cmd.CommandText = sql;
            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();
            return(1);
        }
Exemple #3
0
        /// <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);
        }
Exemple #4
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;
            }
        }
Exemple #5
0
        /// <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();
        }
Exemple #6
0
        /// <summary>
        /// 添加用户Cookie
        /// </summary>
        /// <param name="cookie">消息</param>
        /// <returns>状态</returns>
        public int AddCookie(UserCookie cookie)
        {
            UserCookie oldCookie = new UserCookie();

            if (GetCookie(cookie.m_key, ref oldCookie) > 0)
            {
                UpdateCookie(cookie);
            }
            else
            {
                String sql = String.Format("INSERT INTO USERCOOKIE(USERID, KEY, VALUE, MODIFYTIME, CREATETIME) values ({0}, '{1}', '{2}','1970-1-1','1970-1-1')",
                                           m_userID, CStrA.GetDBString(cookie.m_key), CStrA.GetDBString(cookie.m_value));
                SQLiteConnection conn = new SQLiteConnection(m_connectStr);
                conn.Open();
                SQLiteCommand cmd = conn.CreateCommand();
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            return(1);
        }
Exemple #7
0
        /// <summary>
        /// 获取用户Cookie
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="cookie">会话</param>
        /// <returns>状态</returns>
        public int GetCookie(String key, ref UserCookie cookie)
        {
            int              state = 0;
            String           sql   = String.Format("SELECT * FROM USERCOOKIE WHERE USERID = {0} AND KEY = '{1}'", m_userID, CStrA.GetDBString(key));
            SQLiteConnection conn  = new SQLiteConnection(m_connectStr);
            SQLiteCommand    cmd   = conn.CreateCommand();

            cmd.CommandText = sql;
            conn.Open();
            SQLiteDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cookie.m_userID = reader.GetInt32(0);
                cookie.m_key    = reader.GetString(1);
                cookie.m_value  = reader.GetString(2);
                state           = 1;
            }
            reader.Close();
            conn.Close();
            return(state);
        }