public List<Log> GetLogs(int? id, DateTime? timestampFrom, DateTime? timestampTo, string machineName, string sessionId, string serviceName, string title, float timeTaken, string status, float? timeMin, float? timeMax, string searchText, int pageIndex, int pageSize, out int totalRowCount) { totalRowCount = 0; try { var db = new MySqlDatabase(DbConfiguration.LogDB); DataSet dataSet = db.ExecuteQuery(CommandBuilder.BuildGetLogs(id, timestampFrom, timestampTo, machineName, sessionId, serviceName, title, timeTaken, status, timeMin, timeMax, searchText, pageIndex, pageSize, db.Connection), "outtotalRowCount", out totalRowCount); return ParseLogs(dataSet); } catch (Exception ex) { var exLog = new ExceptionLog(ex, "LoggingDataProvider", "GetLogs", Severity.Normal); SaveException(exLog); } return new List<Log>(); }
public List<ExceptionLog> GetExceptions(int? exceptionId, string machineName, string source, string targetSite, string exceptionType, string appDomainName, string message, DateTime? timestampFrom, DateTime? timestampTo, int pageIndex, int pageSize, string searchText, string sessionId, out int totalRowCount) { totalRowCount = 0; try { var db = new MySqlDatabase(DbConfiguration.LogDB); DataSet dataSet = db.ExecuteQuery(CommandBuilder.BuildGetExceptions(exceptionId, machineName, source, targetSite, exceptionType, appDomainName, message, timestampFrom, timestampTo, pageIndex, pageSize, searchText, sessionId, db.Connection), "outtotalRowCount", out totalRowCount); return ParseExceptionLogs(dataSet); } catch (Exception ex) { var exLog = new ExceptionLog(ex, "LoggingDataProvider", "GetLogs", Severity.Normal); SaveException(exLog); } return new List<ExceptionLog>(); }
public static void LogException(Exception exception, string source, string method, Severity severity) { var log = new ExceptionLog(exception, source, method, severity); log.SessionId = ApplicationContext.GetSessionId(); var dataProvider = new LoggingDataProvider(); if (LoggingConfigurations.IsLogAsyncEnabled) { Task.Factory.StartNew(() => new LoggingDataProvider().SaveException(log)); } else { new LoggingDataProvider().SaveException(log); } }
public string GetRequestByLogId(int logId) { try { var db = new MySqlDatabase(DbConfiguration.LogDB); DataSet dataSet = db.ExecuteQuery(CommandBuilder.BuildGetRequestByLogId(logId, db.Connection)); return dataSet != null && dataSet.Tables.Count == 1 && dataSet.Tables[0].Rows != null && dataSet.Tables[0].Rows.Count == 1 ? dataSet.Tables[0].Rows[0][0].ToString() : "No Request Found"; } catch (Exception ex) { var exLog = new ExceptionLog(ex, "LoggingDataProvider", "GetRequestByLogId", Severity.Normal); SaveException(exLog); } return "No Request Found"; }
public void SaveLog(Log log) { try { var db = new MySqlDatabase(DbConfiguration.LogDB); db.ExecuteNonQuery(CommandBuilder.BuildSaveLog(log, db.Connection)); } catch (Exception ex) { var exLog = new ExceptionLog(ex, "LoggingDataProvider", "SaveLog", Severity.Critical); SaveException(exLog); } }
public void SaveException(ExceptionLog exception) { try { var db = new MySqlDatabase(DbConfiguration.LogDB); db.ExecuteNonQuery(CommandBuilder.BuildSaveException(exception, db.Connection)); } catch { } ; }
internal static MySqlCommand BuildSaveException(ExceptionLog exception, MySqlConnection connection) { var cmd = new MySqlCommand("spSaveException", connection) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.Add(new MySqlParameter("inAdditionalInfo", exception.AdditionalInfo)); cmd.Parameters.Add(new MySqlParameter("inAppDomainName", exception.AppDomainName)); cmd.Parameters.Add(new MySqlParameter("inInnerException", exception.InnerException)); cmd.Parameters.Add(new MySqlParameter("inMachineName", exception.MachineName)); cmd.Parameters.Add(new MySqlParameter("inMessage", exception.Message)); cmd.Parameters.Add(new MySqlParameter("inSessionId", exception.SessionId)); cmd.Parameters.Add(new MySqlParameter("inSource", exception.Source)); cmd.Parameters.Add(new MySqlParameter("inStackTrace", exception.StackTrace)); cmd.Parameters.Add(new MySqlParameter("inTargetSite", exception.TargetSite)); cmd.Parameters.Add(new MySqlParameter("inTimeStamp", DateTime.Now)); cmd.Parameters.Add(new MySqlParameter("inTitle", exception.Title)); cmd.Parameters.Add(new MySqlParameter("inType", exception.Type)); cmd.Parameters.Add(new MySqlParameter("inSeverity", exception.Severity)); return cmd; }
public void SaveExceptionTest() { var target = new LoggingDataProvider(); var exception = new ExceptionLog(new ArgumentException("Test Exception"), "Test", "TestMethod", Severity.Major, "Test Title"); target.SaveException(exception); }