/// <summary> /// 写登陆日志 /// </summary> /// <param name="data"></param> /// <returns></returns> public virtual bool WriteLoginLog(LoginLogEventData data, int level) { //根据日志级别,过滤日志: 从配置中获取或者从logger获取 if (level < this.Level) { return(true); } //从日志工厂获取日志logger: 共有四个日志logger,分别是内存、oracle、文件、系统日志 LoggerCollectionEnumerator enumerator = (LoggerCollectionEnumerator)cacheLogger["LoginLog"]; if (enumerator == null) { throw new ApplicationException("登陆日志Logger为空,请检查系统配置文件"); } //调用logger写操作日志接口:分别写入内存或者oracle、或者文件、或者系统日志 enumerator.Reset(); while (enumerator.MoveNext()) { //写日志 ILogger logger = enumerator.Current; logger.WriteLoginLog(data, level); } return(true); }
/// <summary> /// 写登陆日志 /// </summary> /// <param name="data">日志内容</param> /// <param name="level">日志级别</param> /// <returns>true:成功;false:失败</returns> public override bool WriteLoginLog(LoginLogEventData data, int level) { if (level < this.logLevel) { return(true); } appender.WriteLog("Login", data.ToString()); return(true); }
/// <summary> /// 写登陆日志 /// </summary> /// <param name="data">日志内容</param> /// <param name="level">日志级别</param> /// <returns>true:成功;false:失败</returns> public override bool WriteLoginLog(LoginLogEventData data, int level) { if (level < this.logLevel) { return(true); } data.StationID = this.StationID; data.SystemID = this.SystemID; return(RollingFileAppender.SimpleFileLog(PrepareFileName("", LogCategory.Login), data.ToString())); }
/// <summary> /// 写登陆日志 /// </summary> /// <param name="logLevel">日志级别</param> /// <param name="appID">应用名称</param> /// <param name="userCode">登陆用户</param> /// <param name="message">登陆信息</param> /// <param name="loginDate">登陆时间</param> /// <param name="logIP">登陆IP</param> /// <param name="loginType">登陆类型</param> /// <param name="isWarn">是否报警</param> /// <returns>true:成功;false:失败</returns> public virtual bool WriteLoginLog(int logLevel, string appID, string userCode, string message, DateTime loginDate, string logIP, int loginType, bool isWarn) { LoginLogEventData eventData = new LoginLogEventData(logLevel, appID, userCode, message, loginDate, logIP, loginType, isWarn); eventData.StationID = StationID; eventData.SystemID = SystemID; return(WriteLoginLog(eventData, logLevel)); }
/// <summary> /// 写登陆日志 /// </summary> /// <param name="data">日志内容</param> /// <param name="level">日志级别</param> /// <returns>true:成功;false:失败</returns> public override bool WriteLoginLog(LoginLogEventData data, int level) { if (level < this.logLevel) { return(true); } data.SN = ++loginLogMaxSN; data.StationID = this.StationID; data.SystemID = this.SystemID; loginLog.AddTail <LoginLogEventData>(data); return(true); }
/// <summary> /// 写登陆日志 /// </summary> /// <param name="data">日志内容</param> /// <param name="level">日志级别</param> /// <returns>true:成功;false:失败</returns> public override bool WriteLoginLog(LoginLogEventData data, int level) { if (level < this.logLevel) { return(true); } data.StationID = this.StationID; data.SystemID = this.SystemID; string commandText = string.Format("INSERT INTO LOG_LOGIN(APPID,USERCODE,MESSAGE,LOGINDATE,IP,ISWARN,LOGINTYPE,RECORDLEVEL,CREATEDATE,STATIONID,SYSTEMID)" + "VALUES('{0}','{1}',{2},to_date('{3}','yyyy-MM-dd HH24:mi:ss'),'{4}',{5},{6},{7},to_date('{8}','yyyy-MM-dd HH24:mi:ss'),{9},{10}) ", StringHelper.GetSubStr(data.AppID, 30), StringHelper.GetSubStr(data.UserCode, 30), ":prmMessage", data.LoginDate.ToString("yyyy-MM-dd HH:mm:ss"), StringHelper.GetSubStr(data.IP, 32), data.IsWarn == true ? 1 : 0, data.LoginType, data.Level, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), ":prmStationID", ":prmSystemID"); #region 定义参数 OracleParameter[] para = new OracleParameter[3]; para[0] = new OracleParameter(); para[0].Direction = ParameterDirection.Input; para[0].OracleType = OracleType.VarChar; para[0].ParameterName = "prmSystemID"; para[0].Value = StringHelper.GetSubStr(data.SystemID, 30); para[1] = new OracleParameter(); para[1].Direction = ParameterDirection.Input; para[1].OracleType = OracleType.VarChar; para[1].ParameterName = "prmStationID"; para[1].Value = StringHelper.GetSubStr(data.StationID, 30); para[2] = new OracleParameter(); para[2].Direction = ParameterDirection.Input; para[2].OracleType = OracleType.VarChar; para[2].ParameterName = "prmMessage"; para[2].Value = StringHelper.GetSubStr(data.Message, 2000); #endregion return(OracleAppender.ExecuteNonQuery(connectionString, commandText, para) > 0); }
/// <summary> /// 写登陆日志 /// </summary> /// <param name="data">登陆日志数据</param> /// <param name="level">日志级别</param> /// <returns>true:成功;false:失败</returns> public abstract bool WriteLoginLog(LoginLogEventData data, int level);