/// <summary>
        /// Inserts a log item
        /// </summary>
        /// <param name="logTypeId">Log item type identifier</param>
        /// <param name="severity">The severity</param>
        /// <param name="message">The short message</param>
        /// <param name="exception">The full exception</param>
        /// <param name="ipAddress">The IP address</param>
        /// <param name="customerId">The customer identifier</param>
        /// <param name="pageUrl">The page URL</param>
        /// <param name="referrerUrl">The referrer URL</param>
        /// <param name="createdOn">The date and time of instance creationL</param>
        /// <returns>Log item</returns>
        public override DBLog InsertLog(int logTypeId, int severity, string message,
                                        string exception, string ipAddress, int customerId,
                                        string pageUrl, string referrerUrl, DateTime createdOn)
        {
            DBLog     item      = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_LogInsert");

            db.AddOutParameter(dbCommand, "LogID", DbType.Int32, 0);
            db.AddInParameter(dbCommand, "LogTypeID", DbType.Int32, logTypeId);
            db.AddInParameter(dbCommand, "Severity", DbType.Int32, severity);
            db.AddInParameter(dbCommand, "Message", DbType.String, message);
            db.AddInParameter(dbCommand, "Exception", DbType.String, exception);
            db.AddInParameter(dbCommand, "IPAddress", DbType.String, ipAddress);
            db.AddInParameter(dbCommand, "CustomerID", DbType.Int32, customerId);
            db.AddInParameter(dbCommand, "PageURL", DbType.String, pageUrl);
            db.AddInParameter(dbCommand, "ReferrerURL", DbType.String, referrerUrl);
            db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, createdOn);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                int logId = Convert.ToInt32(db.GetParameterValue(dbCommand, "@LogID"));
                item = GetLogById(logId);
            }
            return(item);
        }
Exemple #2
0
        private DBLog GetLogFromReader(IDataReader dataReader)
        {
            DBLog log = new DBLog();

            log.LogID      = NopSqlDataHelper.GetInt(dataReader, "LogID");
            log.LogTypeID  = NopSqlDataHelper.GetInt(dataReader, "LogTypeID");
            log.Severity   = NopSqlDataHelper.GetInt(dataReader, "Severity");
            log.Message    = NopSqlDataHelper.GetString(dataReader, "Message");
            log.Exception  = NopSqlDataHelper.GetString(dataReader, "Exception");
            log.IPAddress  = NopSqlDataHelper.GetString(dataReader, "IPAddress");
            log.CustomerID = NopSqlDataHelper.GetInt(dataReader, "CustomerID");
            log.PageURL    = NopSqlDataHelper.GetString(dataReader, "PageURL");
            log.CreatedOn  = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn");
            return(log);
        }
Exemple #3
0
        /// <summary>
        /// Gets a log item
        /// </summary>
        /// <param name="LogID">Log item identifier</param>
        /// <returns>Log item</returns>
        public override DBLog GetLogByID(int LogID)
        {
            DBLog     log       = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_LogLoadByPrimaryKey");

            db.AddInParameter(dbCommand, "LogID", DbType.Int32, LogID);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    log = GetLogFromReader(dataReader);
                }
            }
            return(log);
        }
        private DBLog GetLogFromReader(IDataReader dataReader)
        {
            var item = new DBLog();

            item.LogId       = NopSqlDataHelper.GetInt(dataReader, "LogID");
            item.LogTypeId   = NopSqlDataHelper.GetInt(dataReader, "LogTypeID");
            item.Severity    = NopSqlDataHelper.GetInt(dataReader, "Severity");
            item.Message     = NopSqlDataHelper.GetString(dataReader, "Message");
            item.Exception   = NopSqlDataHelper.GetString(dataReader, "Exception");
            item.IPAddress   = NopSqlDataHelper.GetString(dataReader, "IPAddress");
            item.CustomerId  = NopSqlDataHelper.GetInt(dataReader, "CustomerID");
            item.PageUrl     = NopSqlDataHelper.GetString(dataReader, "PageURL");
            item.ReferrerUrl = NopSqlDataHelper.GetString(dataReader, "ReferrerURL");
            item.CreatedOn   = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn");
            return(item);
        }
Exemple #5
0
        /// <summary>
        /// Gets all log items
        /// </summary>
        /// <returns>Log item collection</returns>
        public override DBLogCollection GetAllLogs()
        {
            DBLogCollection logCollection = new DBLogCollection();
            Database        db            = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand       dbCommand     = db.GetStoredProcCommand("Nop_LogLoadAll");

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBLog log = GetLogFromReader(dataReader);
                    logCollection.Add(log);
                }
            }

            return(logCollection);
        }
Exemple #6
0
        /// <summary>
        /// Inserts a log item
        /// </summary>
        /// <param name="LogTypeID">Log item type identifier</param>
        /// <param name="Severity">The severity</param>
        /// <param name="Message">The short message</param>
        /// <param name="Exception">The full exception</param>
        /// <param name="IPAddress">The IP address</param>
        /// <param name="CustomerID">The customer identifier</param>
        /// <param name="PageURL">The page URL</param>
        /// <param name="CreatedOn">The date and time of instance creationL</param>
        /// <returns>Log item</returns>
        public override DBLog InsertLog(int LogTypeID, int Severity, string Message,
                                        string Exception, string IPAddress, int CustomerID, string PageURL, DateTime CreatedOn)
        {
            DBLog     log       = null;
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_LogInsert");

            db.AddOutParameter(dbCommand, "LogID", DbType.Int32, 0);
            db.AddInParameter(dbCommand, "LogTypeID", DbType.Int32, LogTypeID);
            db.AddInParameter(dbCommand, "Severity", DbType.Int32, Severity);
            db.AddInParameter(dbCommand, "Message", DbType.String, Message);
            db.AddInParameter(dbCommand, "Exception", DbType.String, Exception);
            db.AddInParameter(dbCommand, "IPAddress", DbType.String, IPAddress);
            db.AddInParameter(dbCommand, "CustomerID", DbType.Int32, CustomerID);
            db.AddInParameter(dbCommand, "PageURL", DbType.String, PageURL);
            db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, CreatedOn);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                int LogID = Convert.ToInt32(db.GetParameterValue(dbCommand, "@LogID"));
                log = GetLogByID(LogID);
            }
            return(log);
        }