示例#1
0
        /// <summary>
        /// 写操作日志
        ///
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public virtual bool WriteOperateLog(OperateLogEventData data, int level)
        {
            //根据日志级别,过滤日志: 从配置中获取或者从logger获取
            if (level < this.Level)
            {
                return(true);
            }

            //从日志工厂获取日志logger: 共有四个日志logger,分别是内存、oracle、文件、系统日志
            LoggerCollectionEnumerator enumerator = (LoggerCollectionEnumerator)cacheLogger["OperateLog"];

            if (enumerator == null)
            {
                throw new ApplicationException("操作日志Logger为空,请检查系统配置文件");
            }

            //调用logger写操作日志接口:分别写入内存或者oracle、或者文件、或者系统日志
            enumerator.Reset();
            while (enumerator.MoveNext())
            {
                //写日志
                ILogger logger = enumerator.Current;
                logger.WriteOperateLog(data, level);
            }
            return(true);
        }
示例#2
0
        /// <summary>
        /// 写操作日志
        /// </summary>
        /// <param name="data">日志内容</param>
        /// <param name="level">日志级别</param>
        /// <returns>true:成功;false:失败</returns>
        public override bool WriteOperateLog(OperateLogEventData data, int level)
        {
            if (level < this.logLevel)
            {
                return(true);
            }

            appender.WriteLog("Operate", data.ToString());
            return(true);
        }
示例#3
0
        /// <summary>
        /// 写操作日志
        /// </summary>
        /// <param name="data">日志内容</param>
        /// <param name="level">日志级别</param>
        /// <returns>true:成功;false:失败</returns>
        public override bool WriteOperateLog(OperateLogEventData data, int level)
        {
            if (level < this.logLevel)
            {
                return(true);
            }

            data.StationID = this.StationID;
            data.SystemID  = this.SystemID;

            return(RollingFileAppender.SimpleFileLog(PrepareFileName("", LogCategory.Operate), data.ToString()));
        }
示例#4
0
        /// <summary>
        /// 写操作日志
        /// </summary>
        /// <param name="data">日志内容</param>
        /// <param name="level">日志级别</param>
        /// <returns>true:成功;false:失败</returns>
        public override bool WriteOperateLog(OperateLogEventData data, int level)
        {
            if (level < this.logLevel)
            {
                return(true);
            }

            data.StationID = this.StationID;
            data.SystemID  = this.SystemID;
            string commandText = string.Format("INSERT INTO LOG_OPERATE(APPID,OPERATEUSER,OPERATEDATE,MESSAGE,OPERATELEVEL,OPERATERESULT,OPERATECATEGORY,RECORDLEVEL,CREATEDATE,STATIONID,SYSTEMID)" +
                                               "VALUES('{0}','{1}',to_date('{2}','yyyy-MM-dd HH24:mi:ss'),{3},'{4}',{5},'{6}',{7},to_date('{8}','yyyy-MM-dd HH24:mi:ss'),{9},{10}) ",
                                               StringHelper.GetSubStr(data.AppID, 30),
                                               StringHelper.GetSubStr(data.Operator, 50),
                                               data.RecordDate.ToString("yyyy-MM-dd HH:mm:ss"),
                                               ":prmMessage",
                                               StringHelper.GetSubStr(data.OperateLevel.ToString(), 30),
                                               ":prmOperateResult",
                                               StringHelper.GetSubStr(data.OperateCategory, 30),
                                               data.Level,
                                               System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                                               ":prmStationID",
                                               ":prmSystemID");

            #region 定义参数
            OracleParameter[] para = new OracleParameter[4];

            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);

            para[3]               = new OracleParameter();
            para[3].Direction     = ParameterDirection.Input;
            para[3].OracleType    = OracleType.VarChar;
            para[3].ParameterName = "prmOperateResult";
            para[3].Value         = StringHelper.GetSubStr(data.OperateResult, 30);
            #endregion

            return(OracleAppender.ExecuteNonQuery(connectionString, commandText, para) > 0);
        }
示例#5
0
        /// <summary>
        /// 写操作日志
        /// </summary>
        /// <param name="logLevel">日志级别</param>
        /// <param name="operateLevel">操作级别</param>
        /// <param name="appID">应用ID</param>
        /// <param name="operatorUser">操作员</param>
        /// <param name="operateDT">操作时间</param>
        /// <param name="operateDesc">操作描述</param>
        /// <param name="operateResult">操作结果</param>
        /// <param name="message">备注</param>
        /// <param name="operateCategory">操作归类</param>
        /// <returns>true:成功;false:失败</returns>
        public virtual bool WriteOperateLog(int logLevel, int operateLevel, string appID, string operatorUser,
                                            DateTime operateDT, string operateDesc, string operateResult,
                                            string message, string operateCategory)
        {
            OperateLogEventData data = new OperateLogEventData(logLevel, operateLevel, appID, operatorUser,
                                                               operateDT, operateResult, message, operateCategory);

            data.StationID = StationID;
            data.SystemID  = SystemID;

            return(WriteOperateLog(data, logLevel));
        }
示例#6
0
        /// <summary>
        /// 写操作日志
        /// </summary>
        /// <param name="data">日志内容</param>
        /// <param name="level">日志级别</param>
        /// <returns>true:成功;false:失败</returns>
        public override bool WriteOperateLog(OperateLogEventData data, int level)
        {
            if (level < this.logLevel)
            {
                return(true);
            }

            data.SN = ++operateLogMaxSN;

            data.StationID = this.StationID;
            data.SystemID  = this.SystemID;

            operateLog.AddTail <OperateLogEventData>(data);
            return(true);
        }
示例#7
0
 /// <summary>
 /// 写操作日志
 /// </summary>
 /// <param name="data">操作日志数据</param>
 /// <param name="level">日志级别</param>
 /// <returns>true:成功;false:失败</returns>
 public abstract bool WriteOperateLog(OperateLogEventData data, int level);