void updateOnlineState(int userID, bool state) { UsersEF vRecord = new UsersEF(); vRecord.Online = state; m_BasicDBClass.UpdateRecord <UsersEF>(vRecord, userID); }
public UsersEF[] GetAllNormalUsers() { UsersEF vUserEF = new UsersEF(); vUserEF.IsUse = true; return(m_BasicDBClass.SelectRecordsEx(vUserEF)); }
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); }
// 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); }
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); }
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); }
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); }
/// <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); }
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); }
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); }
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); }
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); } }
/// <summary> /// 校验用户合法性 /// </summary> bool checkUserLegal(int UserID, string Token) { UsersEF vUserInfo = m_BasicDBClass.SelectRecordByPrimaryKeyEx <UsersEF>(UserID); return(vUserInfo.ID == 0 ? false : true); }
public UsersEF GetUserInfo(int UserID) { UsersEF vData = m_BasicDBClass.SelectRecordByPrimaryKeyEx <UsersEF>(UserID); return(vData); }
// PUT: api/Heartbeat/5 public bool Put([FromBody] UsersEF UserInfo) { UserManage vUserManage = new UserManage(); return(vUserManage.HeartBeat(UserInfo.ID.Value, UserInfo.Token)); }
// POST: api/Heartbeat public void Post([FromBody] UsersEF UserInfo) { }