Exemplo n.º 1
0
        /// <summary>
        /// 获取日志类型
        /// </summary>
        /// <param name="systemID">子系统编号</param>
        /// <returns>日志类型集合,保含ID、Name</returns>
        public DataSet GetLogTypeBySystemID(int systemID)
        {
            string commandText = string.Format("SELECT ID AS ID ,NAME AS NAME FROM LOG_TYPE WHERE SYSTEMID={0} ORDER BY SORTID",
                                               systemID);

            return(OracleAppender.ExecuteQuery(connectionString, commandText));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 写通用日志
        /// </summary>
        /// <param name="message">日志内容</param>
        /// <param name="level">日志级别</param>
        /// <param name="fileName">日志文件名</param>
        /// <returns>true:成功;false:失败</returns>
        public override bool WriteLog(string message, int level, string fileName)
        {
            if (level < this.logLevel)
            {
                return(true);
            }

            string commandText = string.Format("INSERT INTO LOG_COMMON(MESSAGE,RECORDLEVEL,CREATEDATE,STATIONID,SYSTEMID) VALUES({0},'{1}',to_date('{2}','yyyy-MM-dd HH24:mi:ss'),{3},{4}) ",
                                               ":prmMessage", 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(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(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(message, 2000);
            #endregion

            return(OracleAppender.ExecuteNonQuery(connectionString, commandText, para) > 0);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 写异常日志
        /// </summary>
        /// <param name="data">日志内容</param>
        /// <param name="level">日志级别</param>
        /// <returns>true:成功;false:失败</returns>
        public override bool WriteExceptionLog(ExceptionLogEventData data, int level)
        {
            if (level < this.logLevel)
            {
                return(true);
            }

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

            string commandText = string.Format("INSERT INTO LOG_EXCEPTION(APPID,EXCEPTIONSOURCE,EXCEPTIONTYPE,MESSAGE,EXCEPTIONSTACKTRACE,RECORDLEVEL,CREATEDATE,STATIONID,SYSTEMID)" +
                                               "VALUES('{0}',{1},'{2}',{3},{4},{5},to_date('{6}','yyyy-MM-dd HH24:mi:ss'),{7},{8}) ",
                                               StringHelper.GetSubStr(data.AppID, 30),
                                               ":prmSource",
                                               StringHelper.GetSubStr(data.Type, 30),
                                               ":prmMessage",
                                               ":prmStackTrace",
                                               data.Level,
                                               System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                                               ":prmStationID",
                                               ":prmSystemID");

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

            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 = "prmStackTrace";
            para[3].Value         = StringHelper.GetSubStr(data.StackTrace, 1000);

            para[4]               = new OracleParameter();
            para[4].Direction     = ParameterDirection.Input;
            para[4].OracleType    = OracleType.VarChar;
            para[4].ParameterName = "prmSource";
            para[4].Value         = StringHelper.GetSubStr(data.Source, 30);
            #endregion
            return(OracleAppender.ExecuteNonQuery(connectionString, commandText, para) > 0);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取指定系统指定类型的记录数
        /// </summary>
        /// <param name="systemID">子系统编号</param>
        /// <param name="logType">日志类型</param>
        /// <param name="beginDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        /// <returns>记录个数</returns>
        public int GetCount(int systemID, int logType, DateTime beginDate, DateTime endDate)
        {
            string commandText = string.Format("SELECT COUNT(1) FROM LOG_OPERATION " +
                                               " WHERE CREATEDATE BETWEEN TO_DATE('{0}','yyyy-MM-dd HH24:mi:ss') AND TO_DATE('{1}','yyyy-MM-dd HH24:mi:ss') " +
                                               " AND SYSTEMID={2} AND LOGTYPE={3} ",
                                               beginDate.ToString("yyyy-MM-dd HH:mm:ss"), endDate.ToString("yyyy-MM-dd HH:mm:ss"), systemID, logType);

            Object obj = OracleAppender.ExecuteScalar(connectionString, commandText);

            return(Int32.Parse(obj.ToString()));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取指定日期、指定类型的子系统日志
        ///
        /// 分页数据
        /// </summary>
        /// <param name="systemID">子系统ID</param>
        /// <param name="logType">日志类型</param>
        /// <param name="beginDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <returns>日志记录集合</returns>
        public DataSet GetLog(int systemID, int logType, DateTime beginDate, DateTime endDate)
        {
            string commandText = string.Format("SELECT ID as ID ,EmpCode as Empcode ,OutID as OutID,Name as Name,Message as Message,CreateDate as CreateDate" +
                                               " FROM LOG_OPERATION " +
                                               " WHERE CREATEDATE BETWEEN TO_DATE('{0}','yyyy-MM-dd HH24:mi:ss') AND TO_DATE('{1}','yyyy-MM-dd HH24:mi:ss') " +
                                               " AND SYSTEMID={2} AND LOGTYPE={3} " +
                                               " Order by CreateDate",
                                               beginDate.ToString("yyyy-MM-dd HH:mm:ss"), endDate.ToString("yyyy-MM-dd HH:mm:ss"), systemID, logType);

            return(OracleAppender.ExecuteQuery(connectionString, commandText));
        }
Exemplo n.º 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.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);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 写应用日志
        /// </summary>
        /// <param name="data">日志内容</param>
        /// <param name="level">日志级别</param>
        /// <returns>true:成功;false:失败</returns>
        public override bool WriteApplicationLog(ApplicationEventData data, int level)
        {
            if (level < this.logLevel)
            {
                return(true);
            }

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

            string commandText = string.Format("INSERT INTO LOG_APPLICATION(APPID,COMPONENTNAME,ERRTYPE,Message,MessagePOSITION,RECORDLEVEL,CREATEDATE,STATIONID,SYSTEMID)" +
                                               "VALUES( '{0}','{1}','{2}',{3}, {4},{5},to_date('{6}','yyyy-MM-dd HH24:mi:ss'),{7},{8}) ",
                                               StringHelper.GetSubStr(data.AppID, 30),
                                               StringHelper.GetSubStr(data.ComponentName, 30),
                                               StringHelper.GetSubStr(data.ErrType, 30),
                                               ":prmMessage",
                                               ":prmMessagePosition",

                                               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 = "prmMessagePosition";
            para[3].Value         = StringHelper.GetSubStr(data.MessagePosition, 50);
            #endregion

            return(OracleAppender.ExecuteNonQuery(connectionString, commandText, para) > 0);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 写客户反馈
        /// </summary>
        /// <param name="data">日志内容</param>
        /// <param name="level">日志级别</param>
        /// <returns>true:成功;false:失败</returns>
        public override bool WriteFeedbackLog(FeedbackEventData data, int level)
        {
            if (level < this.logLevel)
            {
                return(true);
            }

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

            string commandText = string.Format("INSERT INTO LOG_FEEDBACK(APPID,FEEDTYPE,Message,FEEDBACKDESC,FEEDBACKUSER,RECORDLEVEL,CREATEDATE,STATIONID,SYSTEMID)" +
                                               "VALUES('{0}','{1}',{2},{3},'{4}',{5},to_date('{6}','yyyy-MM-dd HH24:mi:ss'),{7},{8}) ",
                                               StringHelper.GetSubStr(data.AppID, 30),
                                               StringHelper.GetSubStr(data.FeedbackType, 30),
                                               ":prmMessage",
                                               ":prmFeedbackDesc",
                                               StringHelper.GetSubStr(data.FeedbackUser, 32),
                                               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 = "prmFeedbackDesc";
            para[3].Value         = StringHelper.GetSubStr(data.FeedbackDesc, 32);
            #endregion

            return(OracleAppender.ExecuteNonQuery(connectionString, commandText, para) > 0);
        }
Exemplo n.º 9
0
        /// <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);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 获取指定日期、指定类型的子系统日志
        ///
        /// 分页数据
        /// </summary>
        /// <param name="systemID">子系统ID</param>
        /// <param name="logType">日志类型</param>
        /// <param name="beginDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <param name="pageSize">每页容量</param>
        /// <param name="pageNo">页号</param>
        /// <returns>日志记录集合</returns>
        public DataSet GetLog(int systemID, int logType, DateTime beginDate, DateTime endDate, int pageSize, int pageNo)
        {
            int maxRowNum = pageNo * pageSize;
            int minRowNum = maxRowNum - pageSize + 1;

            string commandText = string.Format("SELECT rn,ID as ID ,EmpCode as Empcode ,OutID as OutID,Name as Name,Message as Message,CreateDate as CreateDate" +
                                               " FROM ( select A.* ,rownum as rn from LOG_OPERATION A " +
                                               " WHERE CREATEDATE BETWEEN TO_DATE('{0}','yyyy-MM-dd HH24:mi:ss') AND TO_DATE('{1}','yyyy-MM-dd HH24:mi:ss') " +
                                               " AND SYSTEMID={2} AND LOGTYPE={3} " +
                                               " Order by CreateDate)" +
                                               " Where rn <={4} and rn >={5}",
                                               beginDate.ToString("yyyy-MM-dd HH:mm:ss"), endDate.ToString("yyyy-MM-dd HH:mm:ss"), systemID, logType, maxRowNum, minRowNum);

            return(OracleAppender.ExecuteQuery(connectionString, commandText));
        }
Exemplo n.º 11
0
        /// <summary>
        /// 写业务日志数据
        /// </summary>
        /// <param name="systemID">子系统编号</param>
        /// <param name="stationID">工作站编号</param>
        /// <param name="empCode">职员代码</param>
        /// <param name="outid">学工号</param>
        /// <param name="name">姓名</param>
        /// <param name="message">消息</param>
        /// <param name="logType">日志类型</param>
        /// <returns></returns>
        public bool WriteLog(string systemID, string stationID, int empID, string outid, int Customerid, int Cardsn, long Cardno,
                             string name, string message, int logType)
        {
            string commandText = string.Format(" INSERT INTO LOG_OPERATION (SYSTEMID,STATIONID ,EMPID  ,CUSTOMERID, CARDNO, CARDSN, OUTID  ,NAME ,MESSAGE ,LOGTYPE)" +
                                               " VALUES({0},{1},{2}, {3},{4},{5},{6},{7},{8},{9})",
                                               ":prmSystemID", ":prmStationID", empID, Customerid, Cardno, Cardsn,
                                               ":PrmOutid", ":PrmName", ":prmMessage",
                                               logType);

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

            para[0]               = new OracleParameter();
            para[0].Direction     = ParameterDirection.Input;
            para[0].OracleType    = OracleType.VarChar;
            para[0].ParameterName = "prmSystemID";
            para[0].Value         = StringHelper.GetSubStr(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(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(message, 2000);


            para[3]               = new OracleParameter();
            para[3].Direction     = ParameterDirection.Input;
            para[3].OracleType    = OracleType.VarChar;
            para[3].ParameterName = "PrmOutid";
            para[3].Value         = StringHelper.GetSubStr(outid, 20);


            para[4]               = new OracleParameter();
            para[4].Direction     = ParameterDirection.Input;
            para[4].OracleType    = OracleType.VarChar;
            para[4].ParameterName = "PrmName";
            para[4].Value         = StringHelper.GetSubStr(name, 20);
            #endregion

            return(OracleAppender.ExecuteNonQuery(connectionString, commandText, para) > 0);
        }