Exemple #1
0
        public (string, string, string, string) FindPassengerNameMismatch(logevent @event)
        {
            var content = @event.Message;

            try
            {
                if (!content.StartsWith("Output for passenger search for Givenname"))
                {
                    return(Empty);
                }

                var surname = new Regex("Surname\\: [A-Z\\s]+\\,").Match(content);
                if (!surname.Success)
                {
                    return(Empty);
                }

                var firstSurname = surname.Value?
                                   .Replace("Surname: ", "")?
                                   .TrimEnd(',')
                                   .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)?
                                   .Last()
                                   .ToUpperInvariant();

                var onePassengerRecord = new Regex(@"Basic search Retrieved one passenger record for [A-Z\s]+").Match(content);
                if (!onePassengerRecord.Success)
                {
                    return(Empty);
                }

                var secondSurname = onePassengerRecord.Value
                                    .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)?
                                    .Last()
                                    ?.ToUpperInvariant();

                if (secondSurname == null)
                {
                    return(Empty);
                }

                if (secondSurname != firstSurname)
                {
                    return(firstSurname, secondSurname, @event.Timestamp, @event.CorrelationId);
                }
            }
            catch (Exception e)
            {
                _logger.Error(e);
            }

            return(Empty);
        }
Exemple #2
0
        public void Must_Return_True_On_Names_Mixup()
        {
            var parser = new PaxDocumentParser();

            using (var stream = File.OpenText("mixed-names-message.txt"))
            {
                var text   = stream.ReadToEnd();
                var @event = new logevent {
                    Timestamp = DateTime.Now.ToString(), CorrelationId = Guid.Empty.ToString(), Message = text
                };
                parser.FindPassengerNameMismatch(@event).Item2.Should().Be("MGEE");
            }
        }