Ejemplo n.º 1
0
        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(LogConfig.LogDB);
                DataSet dataSet =
                    db.ExecuteQuery(LogDbCommandBuilder.BuildGetLogs(id, timestampFrom, timestampTo, machineName,
                                                                sessionId, serviceName, title, timeTaken, status,
                                                                timeMin,
                                                                timeMax, searchText, pageIndex, pageSize, db.Connection),
                                    "outtotalRowCount", out totalRowCount);
                return ParseLogs(dataSet).OrderByDescending(e => e.TimeStamp).ToList();
            }
            catch (Exception ex)
            {
                var exLog = new ExceptionLog(ex, "LoggingDataProvider", "GetLogs", Severity.Normal);
                SaveException(exLog);
            }
            return new List<Log>();
        }
Ejemplo n.º 2
0
        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(LogConfig.LogDB);
                DataSet dataSet =
                    db.ExecuteQuery(LogDbCommandBuilder.BuildGetExceptions(exceptionId, machineName, source, targetSite,
                                                                      exceptionType, appDomainName, message,
                                                                      timestampFrom, timestampTo,
                                                                      pageIndex, pageSize, searchText, sessionId,
                                                                      db.Connection), "outtotalRowCount",
                                    out totalRowCount);
                var exceptions = ParseExceptionLogs(dataSet).OrderByDescending(e => e.TimeStamp).ToList();
                return exceptions;
            }
            catch (Exception ex)
            {
                var exLog = new ExceptionLog(ex, "LoggingDataProvider", "GetExceptions", Severity.Normal);
                SaveException(exLog);
            }
            return new List<ExceptionLog>();
        }
Ejemplo n.º 3
0
        public string GetRequestByLogId(int logId)
        {
            try
            {
                var db = new MySqlDatabase(LogConfig.LogDB);
                DataSet dataSet = db.ExecuteQuery(LogDbCommandBuilder.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";
        }
Ejemplo n.º 4
0
 public static void LogException(Exception exception, string source, string method, Severity severity, string sessionId = "")
 {
     if (LogConfig.IsLoggingEnabled)
     {
         try
         {
             var log = new ExceptionLog(exception, source, method, severity);
             log.SessionId = sessionId;
             var dataProvider = new LoggingDataProvider();
             if (LogConfig.IsLogAsyncEnabled)
             {
                 Task.Factory.StartNew(() => dataProvider.SaveException(log));
             }
             else
             {
                 dataProvider.SaveException(log);
             }
         }
         catch (Exception ex)
         {
             File.AppendAllText("Logs.txt","LogException method failed" + ex.ToString());
         }
     }
 }
Ejemplo n.º 5
0
 public void SaveLog(Log log)
 {
     try
     {
         var db = new MySqlDatabase(LogConfig.LogDB);
         db.ExecuteNonQuery(LogDbCommandBuilder.BuildSaveLog(log, db.Connection));
     }
     catch (Exception ex)
     {
         var exLog = new ExceptionLog(ex, "LoggingDataProvider", "SaveLog", Severity.Critical);
         SaveException(exLog);
     }
 }
Ejemplo n.º 6
0
 public void SaveException(ExceptionLog exception)
 {
     try
     {
         var db = new MySqlDatabase(LogConfig.LogDB);
         db.ExecuteNonQuery(LogDbCommandBuilder.BuildSaveException(exception, db.Connection));
     }
     catch
     {
     }
 }
Ejemplo n.º 7
0
 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;
 }