Exemple #1
0
        internal static ApiLogEntry SaveApiLogEntry(ApiLogEntry apiLogEntry)
        {
            using (TeamDbContext dbContext = new TeamDbContext())
            {
                dbContext.ApiLogEntries.Add(apiLogEntry);
                dbContext.SaveChanges();

                return(apiLogEntry);
            }
        }
Exemple #2
0
        internal static void UpdateApiLogEntry(ApiLogEntry logEntry, IRestResponse restResponse)
        {
            using (TeamDbContext dbContext = new TeamDbContext())
            {
                ApiLogEntry dbEntry = dbContext.ApiLogEntries.Find(logEntry.ApiLogEntryId);
                dbEntry.ResponseHeaders     = LoggerService.SerializeHeaders(restResponse.Headers);
                dbEntry.ResponseContentType = restResponse.ContentType;
                dbEntry.ResponseContentBody = restResponse.Content;
                dbEntry.ResponseStatusCode  = (int)restResponse.StatusCode;
                dbEntry.ResponseTimestamp   = DateTime.Now;

                dbContext.SaveChanges();
            }
        }
Exemple #3
0
        internal static ApiLogEntry SaveApiLogEntry(TeamHttpContext teamContext, string fullUrl, RestRequest restRequest)
        {
            ApiLogEntry apiLogEntry = new ApiLogEntry
            {
                Application        = "core-service",
                Machine            = Environment.MachineName,
                RequestId          = teamContext.RequestId,
                RequestMethod      = restRequest.Method.ToString(),
                RequestContentBody = GetParameter(restRequest, ParameterType.RequestBody),
                RequestContentType = GetHeader(restRequest, Constants.HEADER_CONTENT_TYPE),
                RequestHeaders     = LoggerService.SerializeHeaders(restRequest.Parameters),
                RequestUri         = fullUrl
            };

            return(SaveApiLogEntry(apiLogEntry));
        }