Пример #1
0
        public UsersEF Login(string UserName, string Password)
        {
            UsersEF vResult = new UsersEF();
            UsersEF vUserEF = new UsersEF();

            vUserEF.UserName = UserName;
            vUserEF.Password = Password;
            vUserEF.IsUse    = true;
            DataTable vTable = m_BasicDBClass.SelectRecords(vUserEF);

            if (vTable.Rows.Count > 0)
            {
                CommClass.ConvertDataRowToStruct(ref vUserEF, vTable.Rows[0]);
                if (vUserEF.LateLoginTime == null || (DateTime.Now - vUserEF.LateLoginTime).Value.TotalSeconds >= 60 || vUserEF.Online == false)
                {
                    vUserEF.LateLoginTime = DateTime.Now;
                    vUserEF.Token         = DateTime.Now.ToString("mmssyyyyMMddHH");
                    if (m_BasicDBClass.UpdateRecord(vUserEF))
                    {
                        UserOperateLog vUserOperateLog = new UserOperateLog();
                        vUserOperateLog.WriteLog(vUserEF.ID.Value, vUserEF.UserName, "用户登录");
                        updateOnlineState(vUserEF.ID.Value, true);
                        vResult = vUserEF;
                    }
                }
                else
                {
                    vResult.ID = -1;
                }
            }
            vTable.Clear();
            vTable.Dispose();
            return(vResult);
        }
Пример #2
0
        public bool Logout(string UserName, string Token)
        {
            bool    vResult = false;
            UsersEF vUserEF = new UsersEF();

            vUserEF.UserName = UserName;
            vUserEF.Token    = Token;
            UsersEF[] vQueryData = m_BasicDBClass.SelectRecordsEx(vUserEF);
            if (vQueryData.Length > 0)
            {
                UserOperateLog vLog = new UserOperateLog();
                vLog.WriteLog(vQueryData[0].ID.Value, UserName, "用户退出");
                updateOnlineState(vQueryData[0].ID.Value, false);
                vResult = true;
            }
            return(vResult);
        }