public override List <LogEntity> GetExceptionLog()
        {
            List <LogEntity> list   = new List <LogEntity>();
            string           strSql = "SELECT * FROM " + TableName + " WHERE LOG_STATE=2 AND LOG_TYPE=1 ORDER BY LOG_TIME DESC";
            DataSet          ds     = DataAccess.SelectDataSet(strSql);

            if (ds == null || ds.Tables.Count == 0)
            {
                return(list);
            }

            DataTable dt = ds.Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow row = dt.Rows[i];

                LogEntity entity = new LogEntity();
                entity.Time             = row["LOG_TIME"].ToString();
                entity.Category         = Convert.ToInt32(row["LOG_STATE"]);
                entity.JobCode          = row["JOB_NAME"].ToString();
                entity.Description      = row["DESCRIPTION"].ToString();
                entity.ExceptionType    = row["EXCEPTION_TYPE"].ToString();
                entity.ExceptionMessage = row["EXCEPTION_MESSAGE"].ToString();
                entity.ThreadName       = row["THREAD_Name"].ToString();

                list.Add(entity);
            }

            using (DataAccessBroker broker = DataAccessFactory.Instance())
            {
                broker.ExecuteSQL("UPDATE " + TableName + " SET LOG_TYPE=2 WHERE LOG_STATE=2 AND LOG_TYPE=1 ");
            }

            return(list);
        }
Exemplo n.º 2
0
        ///// <summary>
        ///// 获得日志
        ///// </summary>
        ///// <param name="logCategory"></param>
        ///// <returns></returns>
        //public override List<LogEntity> GetLogs(int logCategory)
        //{
        //    List<LogEntity> entityList = new List<LogEntity>();

        //    string sqlString = "";

        //    if (logCategory == -1)
        //    {
        //        sqlString = "select top 500 * from " + this.TableName + " where LOG_TIME > SYSDATE-3 order by LOG_TIME desc,SN desc";
        //    }
        //    else
        //    {
        //        sqlString = "select top 500 * from " + this.TableName
        //            + " where LOG_STATE=" + logCategory
        //            + " and LOG_TIME >SYSDATE-3 order by LOG_TIME desc,SN desc";
        //    }


        //    DataSet ds = DataAccess.SelectDataSet(sqlString);
        //    if (ds == null || ds.Tables.Count == 0)
        //        return entityList;

        //    DataTable dt = ds.Tables[0];
        //    for (int i = 0; i < dt.Rows.Count; i++)
        //    {
        //        DataRow row = dt.Rows[i];

        //        LogEntity entity = new LogEntity();
        //        entity.Time = row["LOG_TIME"].ToString();
        //        entity.Category = Convert.ToInt32(row["LOG_STATE"]);
        //        entity.JobCode = row["JOB_NAME"].ToString();
        //        entity.Description = row["DESCRIPTION"].ToString();
        //        entity.ExceptionType = row["EXCEPTION_TYPE"].ToString();
        //        entity.ExceptionMessage = row["EXCEPTION_MESSAGE"].ToString();

        //        entityList.Add(entity);
        //    }

        //    return entityList;
        //}

        /// <summary>
        /// 获得日志
        /// </summary>
        /// <param name="logCategory"></param>
        /// <returns></returns>
        public override List <LogEntity> GetLogs(int logCategory, string jobCode)
        {
            List <LogEntity> entityList = new List <LogEntity>();

            string whereSql = "";

            if (logCategory != -1)
            {
                whereSql = " LOG_STATE = " + logCategory;
            }
            if (jobCode != "")
            {
                if (whereSql != "")
                {
                    whereSql += " and ";
                }
                whereSql += " JOB_NAME like '%" + jobCode + "%'";
            }
            if (whereSql != "")
            {
                whereSql = " where " + whereSql;
            }

            // 只取前3天的日志
            if (whereSql == "")
            {
                whereSql += " where";
            }
            whereSql += " log_time>SYSDATE-3";


            string sqlString = "select * from " + this.TableName
                               + whereSql
                               + " order by LOG_TIME desc,SN desc";

            DataSet ds = DataAccess.SelectDataSet(sqlString);

            if (ds == null || ds.Tables.Count == 0)
            {
                return(entityList);
            }

            DataTable dt = ds.Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow row = dt.Rows[i];

                LogEntity entity = new LogEntity();
                entity.Time             = row["LOG_TIME"].ToString();
                entity.Category         = Convert.ToInt32(row["LOG_STATE"]);
                entity.JobCode          = row["JOB_NAME"].ToString();
                entity.Description      = row["DESCRIPTION"].ToString();
                entity.ExceptionType    = row["EXCEPTION_TYPE"].ToString();
                entity.ExceptionMessage = row["EXCEPTION_MESSAGE"].ToString();
                entity.ThreadName       = row["THREAD_Name"].ToString();

                entityList.Add(entity);
            }

            return(entityList);
        }