protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { this.log.Debug("Sending request ..."); var response = await base.SendAsync(request, cancellationToken); try { this.log.Debug("Saving the request details into the database..."); var logEntry = new WebRequestLog { Url = request.RequestUri.ToString(), Method = request.Method.ToString(), Timestamp = this.timeProvider.Now, RequestBody = request.Content?.ReadAsStringAsync().Result, Request = request.ToString(), ResponseBody = response.Content?.ReadAsStringAsync().Result, Response = response.ToString(), ResponseCode = (int)response.StatusCode }; using (var tx = this.repository.BeginTransaction()) { this.repository.Add(logEntry); tx.Commit(); } this.log.Debug("Request logged"); } catch (Exception ex) { this.log.Error($"Unable to save the request: {ex}"); } return(response); }
/// <summary> /// Logs the error to Sql Server through the WebRequestLog /// </summary> /// <param name="ConnectionString"></param> /// <param name="LogAsString"></param> /// <returns></returns> public bool LogErrorToSql(string ConnectionString) { if (!IsParsed) { Parse(); } WebRequestLog.LogCustomMessage(ConnectionString, WebRequestLogMessageTypes.Error, ToString()); return(true); }
public void NextTuple(Dictionary <string, object> parms) { lastseqid++; //Get a random WebRequestLog var json = WebRequestLog.GetRandomWebRequestLogAsJson(); if (ackEnabled) { //Add to the spout cache so that the tuple can be re-emitted on fail spoutCache.Add(lastseqid, json); } this.context.Emit(Constants.DEFAULT_STREAM_ID, new Values(json), lastseqid); global_emit_count++; if (global_emit_count % 5000 == 0) { Context.Logger.Info("Last emitted tuple: SeqId = {0} Value = {1}", lastseqid, json); Context.Logger.Info("Total tuples emitted: {0} ({1} tuples/sec)", global_emit_count, global_emit_count / globalstopwatch.Elapsed.TotalSeconds); } }