示例#1
0
        public async Task <IActionResult> Log(LogAddressModel model)
        {
            var appid    = _tokenManager.ValidateAccessToken(model.AccessToken);
            var appLocal = await _dbContext.StatusApps.SingleOrDefaultAsync(t => t.AppId == appid);

            if (appLocal == null)
            {
                appLocal = new StatusApp
                {
                    AppId = appid
                };
                _dbContext.StatusApps.Add(appLocal);
                await _dbContext.SaveChangesAsync();
            }
            var newEvent = new ErrorLog
            {
                AppId      = appid,
                Message    = model.Message,
                StackTrace = model.StackTrace,
                EventLevel = model.EventLevel
            };

            _dbContext.ErrorLogs.Add(newEvent);
            await _dbContext.SaveChangesAsync();

            return(this.Protocol(ErrorType.Success, $"Successfully logged your event."));
        }
示例#2
0
        public IActionResult Log(LogAddressModel model)
        {
            var appid = _tokenManager.ValidateAccessToken(model.AccessToken);

            _cannon.QueueWithDependency <ObserverDbContext>(async dbContext =>
            {
                var newEvent = new ErrorLog
                {
                    AppId      = appid,
                    Message    = model.Message,
                    StackTrace = model.StackTrace,
                    EventLevel = model.EventLevel,
                    Path       = model.Path
                };
                dbContext.ErrorLogs.Add(newEvent);
                await dbContext.SaveChangesAsync();
            });

            return(this.Protocol(ErrorType.Success, "Successfully logged your event."));
        }