Ejemplo n.º 1
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            if (request.RequestUri.ToString().Contains("swagger"))
            {
                return(await base.SendAsync(request, cancellationToken));
            }

            var logMetadata = BuildRequestMetadata(request);

            //First Log Created

            logProcess = new LoggingProcess(_conHelper);

            await logProcess.TransactionLogAdded(logMetadata.RequestUri + " " + logMetadata.RequestMethod,
                                                 ErrorMessageCode.Transaction, ProjectNames.Other, ApplicationType.Windows, logMetadata.RequestTimestamp, "İşlem Başladı...", 1, 1);

            //---------------

            var response = await base.SendAsync(request, cancellationToken);

            if (response.StatusCode == HttpStatusCode.NotFound)
            {
                await logProcess.TransactionLogAdded(logMetadata.RequestUri + " " + logMetadata.RequestMethod,
                                                     ErrorMessageCode.NotFound, ProjectNames.Other, ApplicationType.Windows, logMetadata.ResponseTimestamp, "Yanlış Adres bilgisi.", 1, 1);

                await logProcess.ApplicationLogAdded(logMetadata.RequestUri + " " + logMetadata.RequestMethod,
                                                     ErrorMessageCode.NotFound, ProjectNames.Other, ApplicationType.Windows, logMetadata.ResponseTimestamp, "Yanlış Adres bilgisi.", 1, 1);
            }

            else
            {
                string jsonContent      = response.Content.ReadAsStringAsync().Result;
                BusinessLayerResult res = JsonConvert.DeserializeObject <BusinessLayerResult>(jsonContent);
                logMetadata.Errors = res.Errors;
                logMetadata.Result = res.Result;

                logMetadata = BuildResponseMetadata(logMetadata, response);
                await SendToLog(logMetadata);
            }

            //Eng Log Created
            await logProcess.TransactionLogAdded(logMetadata.RequestUri + " " + logMetadata.RequestMethod,
                                                 ErrorMessageCode.Transaction, ProjectNames.Other, ApplicationType.Windows, logMetadata.ResponseTimestamp, "İşlem Tamamlandı...", 1, 1);

            //---------------

            return(response);
        }
Ejemplo n.º 2
0
        private async Task <bool> SendToLog(LogMetadata logMetadata)
        {
            logProcess = new LoggingProcess(_conHelper);

            if (!logMetadata.Result && (logMetadata.Errors.Count > 0 | logMetadata.Errors != null))
            {
                foreach (ErrorMessageObj item in logMetadata.Errors)
                {
                    await logProcess.TransactionLogAdded(logMetadata.RequestUri + " " + logMetadata.RequestMethod + " " + logMetadata.ResponseStatusCode.ToString(),
                                                         item.Code, ProjectNames.Other, ApplicationType.Windows, logMetadata.ResponseTimestamp, item.Message, 1, 1);

                    await logProcess.ApplicationLogAdded(logMetadata.RequestUri + " " + logMetadata.RequestMethod + " " + logMetadata.ResponseStatusCode.ToString(),
                                                         item.Code, ProjectNames.Other, ApplicationType.Windows, logMetadata.ResponseTimestamp, item.Message, 1, 1);
                }
            }
            return(true);
        }