Esempio n. 1
0
        /// <summary>
        /// Clears log messages between a date range and for specified log levels
        /// </summary>
        /// <param name="start">start date</param>
        /// <param name="end">end date</param>
        /// <param name="logLevels">string array of log levels</param>
        public void ClearLog(DateTime start, DateTime end, string[] logLevels)
        {
            string logLevelList = "";

            foreach (string logLevel in logLevels)
            {
                logLevelList += ",'" + logLevel + "'";
            }
            if (logLevelList.Length > 0)
            {
                logLevelList = logLevelList.Substring(1);
            }

            string commandText = "delete from [NLog_Record] WHERE time_stamp >= @p0 and time_stamp <= @p1 and level in (@p2)";

            SqlParameter paramStartDate = new SqlParameter {
                ParameterName = "p0", Value = start.ToUniversalTime(), DbType = System.Data.DbType.DateTime
            };
            SqlParameter paramEndDate = new SqlParameter {
                ParameterName = "p1", Value = end.ToUniversalTime(), DbType = System.Data.DbType.DateTime
            };
            SqlParameter paramLogLevelList = new SqlParameter {
                ParameterName = "p2", Value = logLevelList
            };

            _context.ExecuteStoreCommand(commandText, paramStartDate, paramEndDate, paramLogLevelList);
        }
Esempio n. 2
0
        /// <summary>
        /// Clears log messages between a date range and for specified log levels
        /// </summary>
        /// <param name="start">start date</param>
        /// <param name="end">end date</param>
        /// <param name="logLevels">string array of log levels</param>
        public void ClearLog(DateTime start, DateTime end, string[] logLevels)
        {
            string commandText = "delete from [ELMAH_Error] WHERE TimeUtc >= @p0 and TimeUtc <= @p1";

            SqlParameter paramStartDate = new SqlParameter {
                ParameterName = "p0", Value = start.ToUniversalTime(), DbType = System.Data.DbType.DateTime
            };
            SqlParameter paramEndDate = new SqlParameter {
                ParameterName = "p1", Value = end.ToUniversalTime(), DbType = System.Data.DbType.DateTime
            };

            _context.ExecuteStoreCommand(commandText, paramStartDate, paramEndDate);
        }
Esempio n. 3
0
        /// <summary>
        /// Clears log messages between a date range and for specified log levels
        /// </summary>
        /// <param name="start">start date</param>
        /// <param name="end">end date</param>
        /// <param name="logLevels">string array of log levels</param>
        public void ClearLog(DateTime start, DateTime end, string[] logLevels)
        {
            string logLevelList = "";

            foreach (string logLevel in logLevels)
            {
                logLevelList += ",'" + logLevel + "'";
            }
            if (logLevelList.Length > 0)
            {
                logLevelList = logLevelList.Substring(1);
            }

            string commandText = "";

            commandText += "DELETE ";
            commandText += "FROM ";
            commandText += "	aspnet_WebEvent_Events ";
            commandText += "WHERE";
            commandText += "	EventId IN	";
            commandText += "(SELECT EventId	";
            commandText += " FROM vw_aspnet_WebEvents_extended ";
            commandText += " WHERE ";
            commandText += "	[EventTimeUtc] >= @p0";
            commandText += " AND [EventTimeUtc] <= @p1";
            commandText += " AND [Level] IN (@p2)"; // eg:  AND [Level] IN ('Info','Debug')
            commandText += " )";

            SqlParameter paramStartDate = new SqlParameter {
                ParameterName = "p0", Value = start.ToUniversalTime(), DbType = System.Data.DbType.DateTime
            };
            SqlParameter paramEndDate = new SqlParameter {
                ParameterName = "p1", Value = end.ToUniversalTime(), DbType = System.Data.DbType.DateTime
            };
            SqlParameter paramLogLevelList = new SqlParameter {
                ParameterName = "p2", Value = logLevelList
            };

            _context.ExecuteStoreCommand(commandText, paramStartDate, paramEndDate, paramLogLevelList);
        }