Esempio n. 1
0
        /// <summary>
        /// Insert with transaction
        /// </summary>
        public CO_SYSTEM_LOG Insert(CO_SYSTEM_LOG entity, DbTransaction transaction)
        {
            //ArgumentValidator.CheckForNullArgument(entity, "entity");
            //ArgumentValidator.CheckForNullArgument(transaction, "transaction");
            CO_SYSTEM_LOG CO_SYSTEM_LOGEntity = entity as CO_SYSTEM_LOG;

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(CO_SYSTEM_LOGDAO.SqlInsert);

                db.AddInParameter(dbCommand, "@LogGuid", DbType.Guid, CO_SYSTEM_LOGEntity.LogGuid);
                db.AddInParameter(dbCommand, "@LogSource", DbType.String, CO_SYSTEM_LOGEntity.LogSource);
                db.AddInParameter(dbCommand, "@LogType", DbType.String, CO_SYSTEM_LOGEntity.LogType);
                db.AddInParameter(dbCommand, "@LogSeverity", DbType.Int32, CO_SYSTEM_LOGEntity.LogSeverity);
                db.AddInParameter(dbCommand, "@LogContent", DbType.String, CO_SYSTEM_LOGEntity.LogContent);
                db.AddInParameter(dbCommand, "@LogDate", DbType.DateTime, CO_SYSTEM_LOGEntity.LogDate);
                db.AddInParameter(dbCommand, "@LogDateUtc", DbType.DateTime, CO_SYSTEM_LOGEntity.LogDateUtc);
                db.AddInParameter(dbCommand, "@LogOperator", DbType.String, CO_SYSTEM_LOGEntity.LogOperator);
                db.AddInParameter(dbCommand, "@HostName", DbType.String, CO_SYSTEM_LOGEntity.HostName);
                db.AddInParameter(dbCommand, "@HostIP", DbType.AnsiString, CO_SYSTEM_LOGEntity.HostIP);
                db.AddInParameter(dbCommand, "@HostMac", DbType.AnsiString, CO_SYSTEM_LOGEntity.HostMac);

                int result = db.ExecuteNonQuery(dbCommand, transaction);
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }

            return(CO_SYSTEM_LOGEntity as CO_SYSTEM_LOG);
        }
Esempio n. 2
0
        /// <summary>
        /// Get with transaction
        /// </summary>
        public CO_SYSTEM_LOG Get(object entityId, DbTransaction transaction)
        {
            //ArgumentValidator.CheckForNullArgument(entityId, "entityId");
            //ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            CO_SYSTEM_LOG CO_SYSTEM_LOGEntity = null;

            try
            {
                Database  db        = GetDatabaseInstance();
                DbCommand dbCommand = db.GetSqlStringCommand(CO_SYSTEM_LOGDAO.SqlGet);

                db.AddInParameter(dbCommand, "@LogGuid", DbType.Guid, entityId);
                using (IDataReader dataReader = db.ExecuteReader(dbCommand, transaction))
                {
                    if (dataReader.Read())
                    {
                        CO_SYSTEM_LOGEntity = ReadEntity(dataReader);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }

            return(CO_SYSTEM_LOGEntity);
        }
Esempio n. 3
0
 public static void WriteLog(CO_SYSTEM_LOG log)
 {
     if (_systemLog == false)
     {
         return;
     }
     //
     _co_SYSTEM_LOGDAO.Insert(log);
 }
Esempio n. 4
0
        public static void WriteLog(string logType, string logSource, LogSeverityEnum logSeverityEnum, string logContent, string logOperator, string hostName, string hostIP, string hostMac)
        {
            if (_systemLog == false)
            {
                return;
            }
            //
            CO_SYSTEM_LOG log = new CO_SYSTEM_LOG();

            log.LogGuid     = Guid.NewGuid();
            log.LogType     = logType;
            log.LogSource   = logSource;
            log.LogSeverity = Convert.ToInt32(logSeverityEnum);
            log.LogContent  = logContent;
            log.LogDate     = DAO.UtilDAO.GetDatabaseDatetime();
            log.LogDateUtc  = DAO.UtilDAO.GetDatabaseUtcDatetime();
            log.LogOperator = logOperator;
            log.HostName    = hostName;
            log.HostIP      = hostIP;
            log.HostMac     = hostMac;

            SSLogManager.WriteLog(log);
        }
Esempio n. 5
0
        private static CO_SYSTEM_LOG ReadEntity(IDataReader dataReader)
        {
            CO_SYSTEM_LOG CO_SYSTEM_LOGEntity = new CO_SYSTEM_LOG();
            object        value;


            value = dataReader["LogGuid"];
            if (value != DBNull.Value)
            {
                CO_SYSTEM_LOGEntity.LogGuid = (Guid?)value;
            }

            value = dataReader["LogSource"];
            if (value != DBNull.Value)
            {
                CO_SYSTEM_LOGEntity.LogSource = (String)value;
            }

            value = dataReader["LogType"];
            if (value != DBNull.Value)
            {
                CO_SYSTEM_LOGEntity.LogType = (String)value;
            }

            value = dataReader["LogSeverity"];
            if (value != DBNull.Value)
            {
                CO_SYSTEM_LOGEntity.LogSeverity = (Int32?)value;
            }

            value = dataReader["LogContent"];
            if (value != DBNull.Value)
            {
                CO_SYSTEM_LOGEntity.LogContent = (String)value;
            }

            value = dataReader["LogDate"];
            if (value != DBNull.Value)
            {
                CO_SYSTEM_LOGEntity.LogDate = (DateTime?)value;
            }

            value = dataReader["LogDateUtc"];
            if (value != DBNull.Value)
            {
                CO_SYSTEM_LOGEntity.LogDateUtc = (DateTime?)value;
            }

            value = dataReader["LogOperator"];
            if (value != DBNull.Value)
            {
                CO_SYSTEM_LOGEntity.LogOperator = (String)value;
            }

            value = dataReader["HostName"];
            if (value != DBNull.Value)
            {
                CO_SYSTEM_LOGEntity.HostName = (String)value;
            }

            value = dataReader["HostIP"];
            if (value != DBNull.Value)
            {
                CO_SYSTEM_LOGEntity.HostIP = (String)value;
            }

            value = dataReader["HostMac"];
            if (value != DBNull.Value)
            {
                CO_SYSTEM_LOGEntity.HostMac = (String)value;
            }

            return(CO_SYSTEM_LOGEntity);
        }