Ejemplo n.º 1
0
        void updateOnlineState(int userID, bool state)
        {
            UsersEF vRecord = new UsersEF();

            vRecord.Online = state;
            m_BasicDBClass.UpdateRecord <UsersEF>(vRecord, userID);
        }
Ejemplo n.º 2
0
        public UsersEF[] GetAllNormalUsers()
        {
            UsersEF vUserEF = new UsersEF();

            vUserEF.IsUse = true;
            return(m_BasicDBClass.SelectRecordsEx(vUserEF));
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        // GET: api/Login/5
        public UsersEF Get(string UserName, string Password)
        {
            UserManage vUserManage = new UserManage();
            UsersEF    vUsers      = vUserManage.Login(UserName, Password);

            //JavaScriptSerializer vJSC = new System.Web.Script.Serialization.JavaScriptSerializer();
            //string vResult= vJSC.Serialize(vUsers);
            return(vUsers);
        }
Ejemplo n.º 5
0
        public bool DeleteUses(int UserID)
        {
            bool    vResult = false;
            UsersEF vUserEF = new UsersEF();

            vUserEF.ID    = UserID;
            vUserEF.IsUse = false;
            vResult       = m_BasicDBClass.UpdateRecord(vUserEF);
            return(vResult);
        }
Ejemplo n.º 6
0
        public UsersEF GetUserInfo(string UserName)
        {
            UsersEF vUserEF = new UsersEF();

            vUserEF.UserName = UserName;
            UsersEF[] vData = m_BasicDBClass.SelectRecordsEx(vUserEF);
            if (vData.Length > 0)
            {
                vUserEF = vData[0];
            }
            return(vUserEF);
        }
Ejemplo n.º 7
0
 public ActionResult EditUser(int UserID)
 {
     UserManage vUserMange = new UserManage();
     EditUserViewModel vUserModel = new EditUserViewModel();
     UsersEF vUserInfo = vUserMange.GetUserInfo(UserID);
     vUserModel.ID = vUserInfo.ID.Value;
     vUserModel.UserName = vUserInfo.UserName;
     vUserModel.Password = vUserInfo.Password;
     vUserModel.Power = vUserInfo.Power.Value;
     vUserModel.PowerList = createPowerSelectList();
     return View(vUserModel);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 心跳包
        /// </summary>
        /// <returns></returns>
        public bool HeartBeat(int UserID, string Token)
        {
            bool vResult = false;

            if (checkUserLegal(UserID, Token))
            {
                UsersEF vHeartBeat = new UsersEF();
                vHeartBeat.LateLoginTime = DateTime.Now;
                updateOnlineState(UserID, true);
                vResult = m_BasicDBClass.UpdateRecord(vHeartBeat, UserID);
            }
            return(vResult);
        }
Ejemplo n.º 9
0
        public bool AddUser(string UserName, string Password, int Power)
        {
            bool    vResult = false;
            UsersEF vUserEF = new UsersEF();

            vUserEF.UserName = UserName;
            vUserEF.Password = Password;
            vUserEF.Power    = Power;
            vUserEF.IsUse    = true;
            if (m_BasicDBClass.InsertRecord(vUserEF) > 0)
            {
                vResult = true;
            }
            return(vResult);
        }
Ejemplo n.º 10
0
        public bool UpdateUser(int UserID, string Password, int Power)
        {
            bool    vResult = false;
            UsersEF vUserEF = new UsersEF();

            vUserEF.ID       = UserID;
            vUserEF.Password = Password;

            vUserEF.Power = Power;
            vUserEF.IsUse = true;
            if (m_BasicDBClass.UpdateRecord(vUserEF))
            {
                vResult = true;
            }
            return(vResult);
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        public ActionResult AddUser(AddUserViewModel Model)
        {
            UserManage vUserMange = new UserManage();
            UsersEF vUserInfo =  vUserMange.GetUserInfo(Model.UserName);
            if (vUserInfo.ID == null || vUserInfo.ID == 0 || vUserInfo.IsUse == false)
            {

                if (vUserMange.AddUser(Model.UserName, Model.Password, Model.Power))
                    return RedirectToAction("UserList", "Admin");
                else
                {
                    ModelState.AddModelError("", "添加用户失败");
                    Model.PowerList = createPowerSelectList();
                    return View(Model);
                }
            }
            else
            {
                ModelState.AddModelError("", "用户名重复");
                Model.PowerList = createPowerSelectList();
                return View(Model);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 校验用户合法性
        /// </summary>
        bool checkUserLegal(int UserID, string Token)
        {
            UsersEF vUserInfo = m_BasicDBClass.SelectRecordByPrimaryKeyEx <UsersEF>(UserID);

            return(vUserInfo.ID == 0 ? false : true);
        }
Ejemplo n.º 14
0
        public UsersEF GetUserInfo(int UserID)
        {
            UsersEF vData = m_BasicDBClass.SelectRecordByPrimaryKeyEx <UsersEF>(UserID);

            return(vData);
        }
Ejemplo n.º 15
0
        // PUT: api/Heartbeat/5
        public bool Put([FromBody] UsersEF UserInfo)
        {
            UserManage vUserManage = new UserManage();

            return(vUserManage.HeartBeat(UserInfo.ID.Value, UserInfo.Token));
        }
Ejemplo n.º 16
0
 // POST: api/Heartbeat
 public void Post([FromBody] UsersEF UserInfo)
 {
 }