/// <summary> ///根据主键值查找Log_Login记录 /// </summary> /// <param name="keyId">KeyId</param> /// <returns>Log_Login</returns> public Log_Login FindLog_Login(int keyId) { string sql = @"SELECT KeyId, PersonId, LoginIP, LoginHostName, LoginMac, LoginTime, LogoutTime FROM dbo.Log_Login WHERE KeyId = @KeyId"; Database db = DatabaseFactory.CreateDatabase(DBLink.SysDBLink.ToString()); DbCommand command = db.GetSqlStringCommand(sql); db.AddInParameter(command, "KeyId", DbType.Int32, keyId); Log_Login log_Login = null; using (IDataReader dr = db.ExecuteReader(command)) { if (dr.Read()) { log_Login = new Log_Login(); log_Login.KeyId = (int)dr["KeyId"]; log_Login.PersonId = (int)dr["PersonId"]; log_Login.LoginIP = (string)dr["LoginIP"]; log_Login.LoginHostName = (string)dr["LoginHostName"]; log_Login.LoginMac = (string)dr["LoginMac"]; log_Login.LoginTime = (DateTime)dr["LoginTime"]; log_Login.LogoutTime = dr["LogoutTime"] == DBNull.Value ? null : (DateTime?)dr["LogoutTime"]; } } return(log_Login); }
public void AddLogLogin(string session, string user) { IUserService svc = new UserService(); var model = new Log_Login(); model.SessionID = session; model.UserID = user; svc.AddLogLogin(model); }
public Log_Login AddLogLogin(Log_Login model) { var dc = new eprocdbDataContext(); model.LoginID = Guid.NewGuid(); model.LoginDate = DateTime.Now; dc.Log_Logins.InsertOnSubmit(model); dc.SubmitChanges(); return(model); }
public ActionResult ALogin(Account Login) { isAdminLogin(); var ret = _accountService.Login(Login.UserName, Login.Password); if (ret != null) { if (ret.decentralization == 3) { ModelState.AddModelError("", "Bạn không đủ quyền để đăng nhập vào hệ thống"); return(View()); } else if (ret.locked == true) { ModelState.AddModelError("", "Tài khoản của bạn đã bị khoá"); return(View()); } else { Log_Login log = new Log_Login(); log.idAccount = ret.idUser; log.status = true; log.at_time = DateTime.Now; try { _LogLoginService.Add(log); } catch { } Session["admin"] = ret as Account; return(RedirectToAction("Index", "Admin")); } } else { var logUser = _accountService.Get(Login.UserName); if (logUser != null) { Log_Login log = new Log_Login(); log.idAccount = logUser.idUser; log.status = false; log.at_time = DateTime.Now; try { _LogLoginService.Add(log); } catch { } } ModelState.AddModelError("", "Tài khoản hoặc mật khẩu chưa chính xác"); return(View()); } }
private void log_Login() { using (DatabaseEntities context = new DatabaseEntities()) { Log_Login log = new Log_Login() { cpfCliente = cliente.cpf, data = DateTime.Now }; context.Log_Login.Add(log); context.SaveChanges(); } }
public ActionResult Login(Account Login) { isLogin(); var ret = _accountService.Login(Login.UserName, Login.Password); if (ret != null && ret.decentralization == 3) { if (ret.locked == true) { ModelState.AddModelError("", "Tài khoản của bạn đã bị khoá"); return(View()); } Session["user"] = ret as Account; Log_Login log = new Log_Login(); log.idAccount = ret.idUser; log.status = true; log.at_time = DateTime.Now; try { _LogLoginService.Add(log); } catch { } //Response.Redirect("cpanel.aspx", false); return(RedirectToAction("Index", "Home")); } else { var logUser = _accountService.Get(Login.UserName); if (logUser != null) { Log_Login log = new Log_Login(); log.idAccount = logUser.idUser; log.status = false; log.at_time = DateTime.Now; try { _LogLoginService.Add(log); } catch { } } ModelState.AddModelError("", "Tài khoản hoặc mật khẩu chưa chính xác"); return(View()); } }
/// <summary> /// 返回满足查询条件的Log_Login实体列表 /// </summary> /// <param name="param">查询条件</param> /// <returns>Log_Login实体列表</returns> public IList <Log_Login> GetLog_Logins(QueryParameter param) { string sql = @"SELECT KeyId, PersonId, LoginIP, LoginHostName, LoginMac, LoginTime, LogoutTime FROM dbo.Log_Login"; if (param != null) { sql = QueryParameter.CompleteSqlString(sql, param); } Database db = DatabaseFactory.CreateDatabase(DBLink.SysDBLink.ToString()); DbCommand command = db.GetSqlStringCommand(sql); if (param != null) { //设置参数 foreach (IExpression exp in param.WhereExpressions) { if (exp is SimpleExpression) { SimpleExpression simple = exp as SimpleExpression; db.AddInParameter(command, simple.ExpName, simple.DbType, simple.Value); } } } IList <Log_Login> list = new List <Log_Login>(); using (IDataReader dr = db.ExecuteReader(command)) { while (dr.Read()) { Log_Login log_Login = new Log_Login(); log_Login.KeyId = (int)dr["KeyId"]; log_Login.PersonId = (int)dr["PersonId"]; log_Login.LoginIP = (string)dr["LoginIP"]; log_Login.LoginHostName = (string)dr["LoginHostName"]; log_Login.LoginMac = (string)dr["LoginMac"]; log_Login.LoginTime = (DateTime)dr["LoginTime"]; log_Login.LogoutTime = dr["LogoutTime"] == DBNull.Value ? null : (DateTime?)dr["LogoutTime"]; list.Add(log_Login); } } return(list); }
/// <summary> /// 更新Log_Login记录 /// </summary> /// <param name="log_Login">Log_Login对象</param> /// <returns>受影响的记录数</returns> public int UpdateLog_Login(Log_Login log_Login) { string sql = @"UPDATE dbo.Log_Login SET PersonId = @PersonId, LoginIP = @LoginIP, LoginHostName = @LoginHostName, LoginMac = @LoginMac, LoginTime = @LoginTime, LogoutTime = @LogoutTime WHERE KeyId = @KeyId"; Database db = DatabaseFactory.CreateDatabase(DBLink.SysDBLink.ToString()); DbCommand command = db.GetSqlStringCommand(sql); db.AddInParameter(command, "KeyId", DbType.Int32, log_Login.KeyId); db.AddInParameter(command, "PersonId", DbType.Int32, log_Login.PersonId); db.AddInParameter(command, "LoginIP", DbType.String, log_Login.LoginIP); db.AddInParameter(command, "LoginHostName", DbType.String, log_Login.LoginHostName); db.AddInParameter(command, "LoginMac", DbType.String, log_Login.LoginMac); db.AddInParameter(command, "LoginTime", DbType.DateTime, log_Login.LoginTime); db.AddInParameter(command, "LogoutTime", DbType.DateTime, log_Login.LogoutTime.HasValue ? (object)log_Login.LogoutTime : DBNull.Value); return(db.ExecuteNonQuery(command)); }
/// <summary> /// Thêm Log đăng nhập khi người dùng đăng nhập /// </summary> /// <param name="log"></param> /// <returns></returns> public bool Add(Log_Login log) { IRepository <Log_Login> repository = _unitOfWork.Repository <Log_Login>(); try { logger.Info("Start audit login"); repository.Add(log); _unitOfWork.SaveChange(); logger.Info("End audit login"); return(true); } catch (Exception ex) { logger.Info("Error audit login: " + ex.Message); return(false); } }
/// <summary> /// 登陆信息写入日志 /// </summary> /// <param name="userID">用户ID</param> /// <param name="hospitalID">医院ID</param> /// <param name="detail">详细登陆信息</param> public static void WriteLogLogin(int userID, int hospitalID, string detail) { using (MedicalBaseEntities context = new MedicalBaseEntities()) { List <Log_Login> loginList = new List <Log_Login>(); loginList = (from p in context.Log_Login select p).ToList <Log_Login>(); var login = new Log_Login(); login.LoginDate = System.DateTime.UtcNow; login.UserID = userID; login.HospitalID = hospitalID; login.Detail = detail; context.Log_Login.AddObject(login); context.SaveChanges(); } }
public static void Login(string uid, string nickName, string ip, string channelName, string versionName, string loginType) { Log_Login logLogin = new Log_Login() { Uid = uid, ip = ip, channel_name = channelName, version_name = versionName, login_type = loginType, nick_name = nickName }; NHibernateHelper.LogLoginManager.Add(logLogin); if (!hashSet.Contains(uid)) { SendStopServerReward(uid); } }
/// <summary> /// 更新Log_Login /// </summary> /// <param name="log_Login">实体类</param> /// <param name="logEntity">日志类</param> /// <returns></returns> public string UpdateLog_Login(Log_Login log_Login, Log_Operate logEntity) { string strResult = ""; using (TransactionScope trans = new TransactionScope()) { try { this._log_LoginDAO.UpdateLog_Login(log_Login); Log_OperateFacade logFacade = new Log_OperateFacade(); int intLog = logFacade.CreateLog_Operate(logEntity); trans.Complete(); } catch (Exception ex) { strResult = ex.Message; } } return(strResult); }
/// <summary> /// 创建Log_Login /// </summary> /// <param name="log_Login">实体类</param> /// <param name="logEntity">日志类</param> /// <param name="strResult">错误信息</param> /// <returns></returns> public int InsertLog_Login(Log_Login log_Login, Log_Operate logEntity, ref string strResult) { int intResult = 0; using (TransactionScope trans = new TransactionScope()) { try { this._log_LoginDAO.InsertLog_Login(log_Login); Log_OperateFacade logFacade = new Log_OperateFacade(); logEntity.OperateFunction = "新增_log_Login表ID为" + intResult.ToString() + "的数据"; int intLog = logFacade.CreateLog_Operate(logEntity); trans.Complete(); } catch (Exception ex) { strResult = ex.Message; } } return(intResult); }
/// <summary> /// 插入Log_Login记录 /// </summary> /// <param name="log_Login">Log_Login对象</param> /// <returns></returns> public int InsertLog_Login(Log_Login log_Login) { string sql = @"INSERT INTO dbo.Log_Login(PersonId, LoginIP, LoginHostName, LoginMac, LoginTime, LogoutTime) VALUES(@PersonId, @LoginIP, @LoginHostName, @LoginMac, @LoginTime, @LogoutTime); SELECT @KeyId = SCOPE_IDENTITY()"; Database db = DatabaseFactory.CreateDatabase(DBLink.SysDBLink.ToString()); DbCommand command = db.GetSqlStringCommand(sql); db.AddOutParameter(command, "KeyId", DbType.Int32, sizeof(int)); db.AddInParameter(command, "PersonId", DbType.Int32, log_Login.PersonId); db.AddInParameter(command, "LoginIP", DbType.String, log_Login.LoginIP); db.AddInParameter(command, "LoginHostName", DbType.String, log_Login.LoginHostName); db.AddInParameter(command, "LoginMac", DbType.String, log_Login.LoginMac); db.AddInParameter(command, "LoginTime", DbType.DateTime, log_Login.LoginTime); db.AddInParameter(command, "LogoutTime", DbType.DateTime, log_Login.LogoutTime.HasValue ? (object)log_Login.LogoutTime : DBNull.Value); int affectedRecords = db.ExecuteNonQuery(command); if (affectedRecords < 1) { throw new ApplicationException("插入数据失败, 没有记录被插入"); } return(affectedRecords); }
/// <summary> /// 更新Log_Login记录 /// </summary> /// <param name="log_Login"> /// Log_Login对象</param> /// <returns>受影响的记录数</returns> public int UpdateLog_Login(Log_Login log_Login) { return(this._log_LoginDAO.UpdateLog_Login(log_Login)); }
/// <summary> /// 创建Log_Login记录 /// </summary> /// <param name="log_Login"> /// Log_Login对象</param> /// <returns></returns> public int CreateLog_Login(Log_Login log_Login) { return(this._log_LoginDAO.InsertLog_Login(log_Login)); }
public static async Task Log_Login(long uid, Session session, string clientVersion) { DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); ConfigComponent configCom = Game.Scene.GetComponent <ConfigComponent>(); List <Log_Login> log_Logins = await proxyComponent.QueryJson <Log_Login>( $"{{CreateTime:/^{DateTime.Now.GetCurrentDay()}/,Uid:{uid}}}"); if (log_Logins.Count == 0) { // 今天第一天登录,做一些处理 Log.Debug("今天第一天登录"); // 重置转盘次数 { List <PlayerBaseInfo> playerBaseInfos = await proxyComponent.QueryJson <PlayerBaseInfo>($"{{_id:{uid}}}"); if (playerBaseInfos.Count > 0) { playerBaseInfos[0].ZhuanPanCount = 0; if (playerBaseInfos[0].VipTime.CompareTo(CommonUtil.getCurTimeNormalFormat()) > 0) { playerBaseInfos[0].ZhuanPanCount = 1; } //重置赠送好友房钥匙 playerBaseInfos[0].IsGiveFriendKey = false; await proxyComponent.Save(playerBaseInfos[0]); } else { Log.Warning($"玩家{uid}的PlayerBaseInfo为null"); } } // 重置任务 { List <TaskProgressInfo> progressList = await proxyComponent.QueryJson <TaskProgressInfo>($"{{UId:{uid}}}"); if (progressList.Count > 0) { for (int i = 0; i < progressList.Count; ++i) { progressList[i].IsGet = false; progressList[i].IsComplete = false; progressList[i].CurProgress = 0; await proxyComponent.Save(progressList[i]); } } } //重置每天在线时长和宝箱次数 { List <GamerInfoDB> gamerInfo = await proxyComponent.QueryJson <GamerInfoDB>($"{{UId:{uid}}}"); if (gamerInfo.Count > 0) { gamerInfo[0].DailyOnlineTime = 0; gamerInfo[0].DailyTreasureCount = 0; await proxyComponent.Save(gamerInfo[0]); } } } Log_Login log_Login = ComponentFactory.CreateWithId <Log_Login>(IdGenerater.GenerateId()); log_Login.Uid = uid; log_Login.ip = session.RemoteAddress.ToString(); log_Login.clientVersion = clientVersion; await proxyComponent.Save(log_Login); }