Ejemplo n.º 1
0
        // ReSharper disable once UnusedMember.Global
        public void Post(ErrorLogCreateRequest request)
        {
            Guard.AgainstEmpty(request.Application);
            Guard.AgainstEmpty(request.Provider);
            Guard.AgainstEmpty(request.ProviderId);
            Guard.IsTrue(r => string.IsNullOrWhiteSpace(r.ErrorMessage) == false || string.IsNullOrWhiteSpace(r.StackTrace), request);

            var existingUser = UserHelpers.GetExistingUser(request, UserRepository);

            ErrorLogRepository.Add(new ErrorLog
            {
                Application = request.Application,
                Message     = request.ErrorMessage,
                StackTrace  = request.StackTrace,
                Provider    = existingUser.Provider,
                ProviderId  = existingUser.ProviderId
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="log"></param>
        /// <returns></returns>
        public string Save(ErrorLogModel log)
        {
            if (log == null)
            {
#if DEBUG
                log = new ErrorLogModel();
#else
                return("null");
#endif
            }

            var logId     = log?.Id ?? string.Empty;
            var emptyGuid = Guid.Empty.ToString();

            if (string.IsNullOrWhiteSpace(logId) ||
                logId == emptyGuid ||
                logId == emptyGuid.Replace("-", string.Empty))
            {
                log.Id = Guid.NewGuid().ToString();
            }

            if (!log.LogTime.HasValue)
            {
                log.LogTime = DateTime.Now;
                log.LogTimeUnixTimestamp = log.LogTime.Value.Ticks;
            }

            log.CreatedOn = DateTime.Now;
            log.CreatedOnUnixTimestamp = log.CreatedOn.Ticks;
            var entity = SimpleMapper.Map <ErrorLogModel, ErrorLogEntity>(log);

            using (var repo = new ErrorLogRepository <ErrorLogEntity>())
            {
                repo.Add(entity);
                repo.SaveChanges();
            }

            return(entity.Id);
        }
Ejemplo n.º 3
0
        public void Add(ErrorLogModel errorLogModel)
        {
            IErrorLogRepository errorLogRepo = new ErrorLogRepository();

            errorLogRepo.Add(MappingExtensions.MapTo <ErrorLogModel, ErrorLog>(errorLogModel));
        }