示例#1
0
 public static LogMail CreateMail(ExceptionLog log)
 {
     var from = new MailAddress("*****@*****.**", "Emergy");
     var to = new MailAddress("*****@*****.**", "Gabrijel Boduljak");
     return new LogMail(from, to)
     {
         Subject = "Emergy - Application Error occured!",
         Body = BuildBody(log)
     };
 }
 public async override Task OnExceptionAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)
 {
     var log = new ExceptionLog
     {
         Exception = actionExecutedContext.Exception,
         ExceptionDate = DateTime.Now
     };
     //_service.LogException(log);
     await SendMail(log).WithoutSync();
 }
 public override void OnException(HttpActionExecutedContext actionExecutedContext)
 {
     var log = new ExceptionLog
     {
         Exception = actionExecutedContext.Exception,
         ExceptionDate = DateTime.Now
     };
     //_service.LogException(log);
     _service.SendLogMail(log).RunSynchronously();
 }
示例#4
0
 private static string BuildBody(ExceptionLog log)
 {
     StringBuilder bodyBuilder = new StringBuilder();
     bodyBuilder.AppendLine("Error : \n");
     bodyBuilder.AppendLine($"Happened at : {DateTime.Now.ToShortDateString()}!\n");
     bodyBuilder.AppendLine($"Causing exception : {log.Exception.ToString()}!\n");
     bodyBuilder.AppendLine("Short description : \n");
     bodyBuilder.AppendLine($"\t Message: {log.Exception.Message} \n");
     bodyBuilder.AppendLine($"\t Data: {log.Exception.Data} \n");
     bodyBuilder.AppendLine($"\t Stack trace: {log.Exception.StackTrace} \n");
     bodyBuilder.AppendLine($"\t Inner exception: {log.GetCausingException(log.Exception).StackTrace} \n");
     return bodyBuilder.ToString();
 }
示例#5
0
 public async Task SendLogMail(ExceptionLog log)
 {
     await _emailService.SendLogMailAsync(log).WithoutSync();
 }
示例#6
0
 public void LogException(ExceptionLog log)
 {
     _loggingService.Add(log);
 }
 private async Task SendMail(ExceptionLog log)
 {
     await _service.SendLogMail(log).WithoutSync();
 }