Пример #1
0
        public ExceptionLogDTO GetExceptionLogOfCorrespondentLog(int logId)
        {
            LogRepository   rep       = new LogRepository();
            ExceptionLog    excLog    = rep.GetExceptionLog(logId);
            ExceptionLogDTO excLogDto = null;

            if (excLog != null)
            {
                excLogDto = new ExceptionLogDTO
                {
                    Id            = excLog.Id,
                    Message       = excLog.Message,
                    Source        = excLog.Source,
                    ParentId      = excLog.Id,
                    StackTrace    = excLog.StackTrace,
                    ExceptionType = excLog.ExceptionType,
                    HasChildren   = rep.HasAnyChildren(logId)
                };
                return(excLogDto);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        public void LogException(object sender, EventArgs eventArgs)
        {
            var log = new ExceptionLogDTO()
            {
                Code       = "UI_SilverLight_Exp",
                ClassName  = "",
                LogLevel   = LogLevel.Error.ToString(),
                Id         = new Guid(),
                LogDate    = DateTime.Now,
                Title      = eventArgs.GetType().ToString(),
                MethodName = ""
            };

            if (CurrentUser != null && !string.IsNullOrEmpty(CurrentUser.Username))
            {
                log.UserName = CurrentUser.Username;
            }

            if (eventArgs is ApplicationUnhandledExceptionEventArgs)
            {
                log.Title    = (eventArgs as ApplicationUnhandledExceptionEventArgs).ExceptionObject.Message;
                log.Messages = (eventArgs as ApplicationUnhandledExceptionEventArgs).ExceptionObject.StackTrace;
            }

            logService.AddLog((res, exp) =>
            {
            }, log);
        }
Пример #3
0
 /// <summary>
 /// Save exception log.
 /// </summary>
 /// <param name="log">Exception log object</param>
 public void CreateExeptionLog(ExceptionLogDTO log)
 {
     try
     {
         var newLog = _logMapperDTO.ToExceptionLog.Map <ExceptionLogDTO, ExceptionLog>(log);
         _logUnitOfWork.ExceptionLogger.Create(newLog);
         _logUnitOfWork.Save();
     }
     catch
     {
     }
 }
Пример #4
0
        /// <summary>
        /// Save exception log to database.
        /// </summary>
        /// <param name="e">Exception</param>
        /// <param name="className">Exception class</param>
        /// <param name="actionName">Exception action</param>
        protected void CreateLog(Exception e, string className, string actionName)
        {
            ExceptionLogDTO log = new ExceptionLogDTO()
            {
                ActionName      = actionName,
                ClassName       = className,
                ExeptionMessage = e.Message,
                StackTrace      = e.StackTrace,
                Time            = DateTime.Now
            };

            LogService.CreateExeptionLog(log);
        }
Пример #5
0
        public LogDTO AddExceptionLog(ExceptionLogDTO logDto)
        {
            User user = null;

            //this check must be move to domain servi
            if (!string.IsNullOrWhiteSpace(logDto.UserName))
            {
                user = userRep.GetUserById(new PartyId(logDto.UserName));
            }
            var log = logService.AddExceptionLog(logDto.Code, LogLevel.FromDisplayName <LogLevel>(logDto.LogLevel),
                                                 user, logDto.ClassName, logDto.MethodName, logDto.Title, logDto.Messages);

            return(logDTOMapper.MapToModel(log));
        }
        /// <summary>
        /// Log exception
        /// </summary>
        /// <param name="filterContext">Exception context</param>
        public void OnException(ExceptionContext filterContext)
        {
            _logService = (ILogService)DependencyResolver.Current.GetService(typeof(ILogService));
            ExceptionLogDTO exceptionLogDTO = new ExceptionLogDTO()
            {
                ExeptionMessage = filterContext.Exception.Message,
                StackTrace      = filterContext.Exception.StackTrace,
                ClassName       = filterContext.RouteData.Values["controller"].ToString(),
                ActionName      = filterContext.RouteData.Values["action"].ToString(),
                Time            = DateTime.Now
            };

            _logService.CreateExeptionLog(exceptionLogDTO);
            filterContext.ExceptionHandled = true;
            filterContext.Result           = new ViewResult()
            {
                ViewName = "CustomError"
            };
        }
Пример #7
0
        public override LogDTO MapToModel(Log entity)
        {
            LogDTO res;

            if (entity is ExceptionLog)
            {
                res = new ExceptionLogDTO();
            }
            else
            {
                res = new EventLogDTO();
            }

            res.Id         = entity.Id.Guid;
            res.ClassName  = entity.ClassName;
            res.Code       = entity.Code;
            res.LogDate    = entity.LogDate;
            res.LogLevel   = entity.LogLevel.ToString();
            res.Messages   = entity.Messages;
            res.Title      = entity.Title;
            res.MethodName = entity.MethodName;
            res.UserName   = (entity.PartyId != null) ? entity.PartyId.PartyName : "";
            return(res);
        }