Example #1
0
 public static void LogFailedMessage(object messageObj)
 {
     if (LogConfig.IsLoggingEnabled)
     {
         try
         {
             //log.SessionId = ApplicationContext.GetSessionId();
             var dataProvider = new LoggingDataProvider();
             var settings = new JsonSerializerSettings()
             {
                 TypeNameHandling = TypeNameHandling.Objects,
             };
             var log = new Log()
             {
                 Name = "FailedMessageItem",
                 ServiceName = messageObj.GetType().Name,
                 Request = JsonConvert.SerializeObject(messageObj, settings),
             };
             if (LogConfig.IsLogAsyncEnabled)
             {
                 Task.Factory.StartNew(() => dataProvider.SaveLog(log));
             }
             else
             {
                 dataProvider.SaveLog(log);
             }
         }
         catch (Exception ex)
         {
             File.AppendAllText("Logs.txt", "LogMessage method failed" + ex.ToString());
         }
     }
 }
Example #2
0
        public static void LogMessage(Log log)
        {
            if (LogConfig.IsLoggingEnabled)
            {
                try
                {
                    //log.SessionId = ApplicationContext.GetSessionId();
                    var dataProvider = new LoggingDataProvider();

                    if (LogConfig.IsLogAsyncEnabled)
                    {
                        Task.Factory.StartNew(() => dataProvider.SaveLog(log));
                    }
                    else
                    {
                        dataProvider.SaveLog(log);
                    }
                }
                catch (Exception ex)
                {
                    File.AppendAllText("Logs.txt", "LogMessage method failed" + ex.ToString());
                }
            }
        }
Example #3
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());
         }
     }
 }
Example #4
0
        public string 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)
        {
            pageIndex = pageIndex < 0 ? 1 : pageIndex;
            pageSize = pageSize < 0 ? 10 : pageSize;
            var dataProvider = new LoggingDataProvider();
            List<Log> lst = dataProvider.GetLogs(id, timestampFrom, timestampTo, machineName, sessionId,
                                                              serviceName, title, timeTaken, status, timeMin, timeMax,
                                                              searchText, pageIndex, pageSize, out totalRowCount);

            var flexigridObject = new FlexigridObject
            {
                page = pageIndex,
                total = totalRowCount,
                cellNames = new List<string>
                                                          {
                                                              "LogID",
                                                              "SessionId",
                                                              "Timestamp",
                                                              "MachineName",
                                                              "ServiceName",
                                                              "Title",
                                                              "Status",
                                                              "TimeTaken",
                                                              "Request",
                                                              "Response"
                                                          }
            };
            foreach (Log x in lst)
            {
                var cell = new FlexigridRow
                {
                    id = x.LogId.ToString(),
                    cell = new List<string>
                                              {
                                                  x.LogId.ToString(),
                                                  x.SessionId,
                                                  x.TimeStamp.ToString(),
                                                  x.MachineName,
                                                  x.ServiceName,
                                                  x.Name,
                                                  x.Status.ToString(),
                                                  x.TimeTaken.ToString(),
                                                  "Click Here",
                                                  "Click Here"
                                              }
                };

                flexigridObject.rows.Add(cell);
            }

            return Serializer.JSON.Serialize(flexigridObject);
        }
Example #5
0
 public string GetResponseXml(int id)
 {
     var dataProvider = new LoggingDataProvider();
     return dataProvider.GetResponseByLogId(id);
 }
Example #6
0
 public string GetRequestXml(int id)
 {
     var dataProvider = new LoggingDataProvider();
     return dataProvider.GetRequestByLogId(id);
 }
Example #7
0
        public string 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)
        {
            pageIndex = pageIndex < 0 ? 1 : pageIndex;
            pageSize = pageSize < 0 ? 10 : pageSize;
            var dataProvider = new LoggingDataProvider();
            List<ExceptionLog> lst = dataProvider.GetExceptions(exceptionId, machineName, source,
                                                                             targetSite,
                                                                             exceptionType,
                                                                             appDomainName, message, timestampFrom,
                                                                             timestampTo,
                                                                             pageIndex,
                                                                             pageSize, searchText, sessionId,
                                                                             out totalRowCount);
            var flexigridObject = new FlexigridObject
            {
                page = pageIndex,
                total = totalRowCount,
                cellNames = new List<string>
                                                          {
                                                              "Id",
                                                              "SessionId",
                                                              "Title",
                                                              "Severity",
                                                              "Timestamp",
                                                              "MachineName",
                                                              "ExceptionType",
                                                              "Message",
                                                              "Source",
                                                              "AppDomainName",
                                                              "TargetSite",
                                                              "StackTrace",
                                                              "AdditionalInfo",
                                                              "InnerExceptions"
                                                          }
            };

            foreach (ExceptionLog x in lst)
            {
                var cell = new FlexigridRow
                {
                    id = x.ExceptionId.ToString(),
                    cell = new List<string>
                                              {
                                                  x.ExceptionId.ToString(),
                                                  x.SessionId,
                                                  x.Title,
                                                  x.Severity,
                                                  x.TimeStamp.ToString(),
                                                  x.MachineName,
                                                  x.Type,
                                                  x.Message,
                                                  x.Source,
                                                  x.AppDomainName,
                                                  x.TargetSite,
                                                  x.StackTrace,
                                                  x.AdditionalInfo,
                                                  x.InnerException
                                              },
                };

                flexigridObject.rows.Add(cell);
            }

            return Serializer.JSON.Serialize(flexigridObject);
        }