Exemplo n.º 1
0
        private async void ProcessRecord(StreamRequestContext context, KinesisEvent.KinesisEventRecord record)
        {
            var correlationId = string.Empty;

            try
            {
                var customerNotifications = StreamUtils.GetStreamRecord <CustomerNotificationDTO>(record.Kinesis.Data);

                _logger.LogInfo($"Call Type: {customerNotifications.Event.RequestType} number: {customerNotifications.Customer.NotificationNumber} status:{customerNotifications.Event.RequestStatus}", context);
                if (customerNotifications.Event.RequestType == "Digital" && customerNotifications.Event.RequestStatus == "REQUEST CONFIRMED")
                {
                    HttpClient client = new HttpClient();

                    var caseId = customerNotifications.CaseData != null?customerNotifications.CaseData.CaseId.ToString() : "";

                    var clientId = customerNotifications.CaseData != null?customerNotifications.CaseData.ClientId.ToString() : "";

                    var callbackRefNumber = customerNotifications.Customer != null?customerNotifications.Customer.CallbackRefNumber.ToString() : "";

                    var notificationNumber = customerNotifications.Customer != null?customerNotifications.Customer.NotificationNumber.ToString() : "";

                    var values = new Dictionary <string, string>
                    {
                        { "CallbackRefNumber", callbackRefNumber }
                    };

                    var content  = new FormUrlEncodedContent(values);
                    var response = await client.PostAsync("", content);

                    var responseString = await response.Content.ReadAsStringAsync();
                }
            }


            catch (BatchProcessingException processingException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public static string BuildLogMessage(
            StreamRequestContext context,
            LogTypes logType,
            string message,
            object applicationData = null)
        {
            context = context ?? new StreamRequestContext
            {
                AppName           = $"{AssemblyName}-UnknownEnvironment",
                Version           = string.Empty,
                SystemInformation = null
            };

            return(JsonConvert.SerializeObject(new LogEvent()
            {
                LogType = logType.ToString(),
                Message = message,
                ApplicationName = context.AppName,
                ApplicationVersion = context.Version,
                ApplicationData = applicationData,
                SystemInformation = context.SystemInformation
            }));
        }
 public static void LogError(this ILogger logger, string logMessage, StreamRequestContext context, object appData = null)
 {
     logger.LogError(LoggingUtils.BuildLogMessage(context, LogTypes.ERROR, logMessage, appData));
 }
 public static void LogInfo(this ILogger logger, string logMessage, StreamRequestContext context, object appData = null)
 {
     logger.LogInformation(LoggingUtils.BuildLogMessage(context, LogTypes.INFO, logMessage, appData));
 }