コード例 #1
0
        /// <summary>
        /// Load and execute engine rules
        /// </summary>
        public void EngineRulesExecution(OSUSR_UUK_BAGMSGS bag, OSUSR_UUK_BAGINTEG bagIntegraty, OSUSR_UUK_FLT_INFO flightInfoI, OSUSR_UUK_FLT_INFO flightInfoF, String hub, ISessionFactory factory)
        {
            BagTMLog.LogDebug("BagTM Engine Rules Execution Start", this);

            ISession session = factory.CreateSession();

            try
            {
                bagIntegraty.IATD = (flightInfoI != null && flightInfoI.ATD != null) ? flightInfoI.ATD :
                                    (flightInfoI != null && flightInfoI.ETD != null) ? flightInfoI.ETD :
                                    (flightInfoI != null && flightInfoI.STD != null) ? flightInfoI.STD : null;
                bagIntegraty.FATD = (flightInfoF != null && flightInfoF.ATD != null) ? flightInfoF.ATD :
                                    (flightInfoF != null && flightInfoF.ETD != null) ? flightInfoF.ETD :
                                    (flightInfoF != null && flightInfoF.STD != null) ? flightInfoF.STD : null;

                session.Insert(hub);

                //Insert facts into rules engine's memory
                session.Insert(bag);
                session.Insert(bagIntegraty);

                //Start match/resolve/act cycle
                session.Fire();
            }
            catch (Exception e)
            {
                BagTMLog.LogError("BagTM Engine Error Processing Rules", this, e);

                throw e;
            }

            BagTMLog.LogDebug("BagTM Engine Rules Execution Ending", this);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            try
            {
                BagTMLog.LogDebug("BagTM Command Line Start", args);

                BagTMLog.LogDebug("BagTM Queue Processing Debug Starting", null);

                IExecutionQueueProcessing queueProcess = new ExecutionDataflowQueueProcessing();

                queueProcess.QueueProcessingDebug();

                BagTMLog.LogDebug("BagTM Queue Processing Debug Ended", null);

                BagTMLog.LogDebug("BagTM Engine Processing Debug Starting", null);

                IExecutionEngineProcessing engineProcess = new ExecutionDataflowEngineProcessing();

                engineProcess.EngineProcessingDebug();

                BagTMLog.LogDebug("BagTM Command Line Debug Ends", null);

                BagTMLog.LogDebug("BagTM Command Line Ending", null);
            }
            catch (ConfigurationErrorsException cee)
            {
                BagTMLog.LogError("BagTM Command Line Ends", args, cee);
            }
        }
コード例 #3
0
        /// <summary>
        /// Engine processing for debug
        /// </summary>
        public void EngineProcess(int n)
        {
            BagTMLog.LogDebug(
                String.Format("BagTM Engine Debug Processing Queue Process Start"), this);

            object[] messages = null;
            try
            {
                this.RefreshRefLists();

                messages = this.ReadQueue(n, QUEUEENGINE);

                if (messages == null)
                {
                    return;
                }

                if (messages[0].GetType().Equals(typeof(OSUSR_UUK_BAGMSGS)))
                {
                    this.bagIntergityProcessing.ProcessBaggageTTYEngine(messages[0], n);
                    Message messageSucess = new Message(messages[0]);
                    messageSucess.Label = "Bag Msgs: " + ((OSUSR_UUK_BAGMSGS)messages[0]).ID;
                    this.SendMessage(messageSucess, n, QUEUESUCESS);
                }
                else if (messages[0].GetType().Equals(typeof(OSUSR_UUK_PAXMSGS)))
                {
                    this.ptmH2HProcessing.ProcessPTMTTYEngine(messages[0], n);
                    Message messageSucess = new Message(messages[0]);
                    messageSucess.Label = "Pax Msgs: " + ((OSUSR_UUK_PAXMSGS)messages[0]).ID;
                    this.SendMessage(messageSucess, n, QUEUESUCESS);
                }
                else if (messages[0].GetType().Equals(typeof(OSUSR_UUK_FLT_INFO)))
                {
                    this.fltInfoProcessing.ProcessFLTINFOEngine(messages[0], n);
                    Message messageSucess = new Message(messages[0]);
                    messageSucess.Label = "Flt Msgs: " + ((OSUSR_UUK_FLT_INFO)messages[0]).ID;
                    this.SendMessage(messageSucess, n, QUEUESUCESS);
                }
                else
                {
                    BagTMLog.LogDebug(
                        String.Format("BagTM Engine Processing Task Process Message read task {0} with message {1} no engine to process message", n, messages[0].GetType()), this);
                    ((Message)messages[1]).Label = String.Format("BagTM Engine Processing Task Process Message read task {0} with message {1} no engine to process message", n, messages[0].GetType()).Substring(0, 120);
                    this.SendMessage(messages[1], n, QUEUEERROR);
                }
            }
            catch (Exception e)
            {
                String message = BagTMLog.LogError(
                    String.Format("BagTM Engine Processing Task {0} Message", n), this, e);
                if (messages != null && messages[0] != null)
                {
                    ((Message)messages[1]).Label = message.Substring(0, 120);
                    this.SendMessage(messages[1], n, QUEUEERROR);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Constructor to create logger and tasks and queue parametrization
        /// </summary>
        public ExecutionDataflowQueueProcessing()
        {
            BagTMLog.LogDebug("BagTM Queue Processing Constructor", this);

            //Get the application configuration file.
            config =
                ConfigurationManager.OpenExeConfiguration(
                    ConfigurationUserLevel.None) as Configuration;

            this.hub = this.GetAppSetting(config, "hub");

            String timeSpanParameter = this.GetAppSetting(config, "timeSpan");
            int    timeSpanNumber    = 0;

            if (!int.TryParse(timeSpanParameter, out timeSpanNumber))
            {
                throw new QueueProcessingException("Parameter TimeSpan incorrectly configured");
            }

            this.timeSpan = new TimeSpan((Int64)(timeSpanNumber * TimeSpan.TicksPerSecond));

            BagTMLog.LogDebug("BagTM Queue Processing Timespan " + timeSpanParameter, timeSpan);

            String parallelismCounterParameter = this.GetAppSetting(config, "parallelismCounter");

            if (!int.TryParse(parallelismCounterParameter, out this.parallelismCounter))
            {
                throw new QueueProcessingException("Parameter ParallelismCounter incorrectly configured");
            }

            BagTMLog.LogDebug("BagTM Queue Processing ParallelismCounter " + parallelismCounter, parallelismCounter);

            TTYMessagesSection ttyMsg = ConfigurationManager.GetSection("TTYMessagesSection") as TTYMessagesSection;

            BagTMLog.LogDebug(String.Format("BagTM Queue Processing TTY Parser Collection {0} {1}",
                                            ttyMsg.ttyCollection.GetNumberOfItems(),
                                            ttyMsg.ttyCollection.Describe())
                              , this);

            try
            {
                this.messageFormater = new TTYMessageFormatter(ttyMsg.ttyCollection, new BaggageEntities(), hub);

                BagTMLog.LogDebug("BagTM Queue Processing MessageFormater", messageFormater);

                queueIn       = this.CreateMessageQueue(QUEUEIN);
                queueInSucess = this.CreateMessageQueue(QUEUESUCESS);
                queueInError  = this.CreateMessageQueue(QUEUEERROR);
                queueEngine   = this.CreateMessageQueue(QUEUEENGINE);
                BagTMLog.LogDebug("BagTM Queue Processing QueueEngine", queueEngine);
                BagTMLog.LogDebug("BagTM Queue Processing Constructor Ending", this);
            }
            catch (Exception e)
            {
                BagTMLog.LogError("BagTM Queue Processing Constructor Error ", this, e);
            }
        }
コード例 #5
0
        protected object[] ReadQueue(int n)
        {
            object message = null;

            object[] messages = new object[2];

            BagTMLog.LogDebug(
                String.Format("BagTM Queue Read Task Message Start {0}", n), this);
            Message msg = null;

            try
            {
                if (queueIn.Peek() != null)
                {
                    msg         = queueIn.Receive();
                    messages[1] = msg;

                    if (msg != null)
                    {
                        BagTMLog.LogDebug(
                            String.Format("BagTM Queue Read Task {0} for Message Body Type: {1}", n, msg.BodyType), this);

                        message     = (object)msg.Body;
                        messages[0] = message;

                        BagTMLog.LogInfo(
                            String.Format("BagTM Queue Message Parsed {0}", message), this);

                        BagTMLog.LogDebug(
                            String.Format("BagTM Queue Read Task {0} with Message {1}", n, msg.Id), this);
                    }
                }
            }
            catch (Exception e)
            {
                String messageError = BagTMLog.LogError(
                    String.Format("BagTM Queue Read Task {0} with Error", n), this, e);

                if (msg != null)
                {
                    msg.Label = messageError.Substring(0, 120);
                    this.SendMessage(msg, n, QUEUEERROR);
                }
                throw e;
            }

            BagTMLog.LogDebug(
                String.Format("BagTM Queue Read Task Message End {0}", n), this);


            return(messages);
        }
コード例 #6
0
        public void QueueProcess(int n)
        {
            BagTMLog.LogDebug(
                String.Format("BagTM Queue Debug Processing Queue Process Start"), this);

            object[] messages = null;
            try
            {
                messages = this.ReadQueue(n);
                Message messageEngine = new Message(messages[0]);
                if (messages[0].GetType().Equals(typeof(OSUSR_UUK_BAGMSGS)))
                {
                    messageEngine.Label = "Bag Msgs: " + ((OSUSR_UUK_BAGMSGS)messages[0]).ID;
                }
                else if (messages[0].GetType().Equals(typeof(OSUSR_UUK_PAXMSGS)))
                {
                    messageEngine.Label = "Pax Msgs: " + ((OSUSR_UUK_PAXMSGS)messages[0]).ID;
                }
                this.SendMessage(messageEngine, n, QUEUEENGINE);
                Message messageSucess = (Message)messages[1];
                if (messages[0].GetType().Equals(typeof(OSUSR_UUK_BAGMSGS)))
                {
                    messageSucess.Label = "Bag Msgs: " + ((OSUSR_UUK_BAGMSGS)messages[0]).ID;
                }
                else if (messages[0].GetType().Equals(typeof(OSUSR_UUK_PAXMSGS)))
                {
                    messageSucess.Label = "Pax Msgs: " + ((OSUSR_UUK_PAXMSGS)messages[0]).ID;
                }
                this.SendMessage(messageSucess, n, QUEUESUCESS);
            }
            catch (Exception e)
            {
                String message = BagTMLog.LogError(
                    String.Format("BagTM Queue Processing Error with no TTY message", n), this, e);
                if (messages != null && messages[0] != null)
                {
                    ((Message)messages[1]).Label = message.Substring(0, 120);
                    this.SendMessage(messages[1], n, QUEUEERROR);
                }
                else
                {
                    BagTMLog.LogError(
                        String.Format("BagTM Queue Processing Error with no TTY message", n), this, e);
                }
            }

            BagTMLog.LogDebug(
                String.Format("BagTM Queue Debug Processing Queue Process End"), this);
        }
コード例 #7
0
        /// <summary>
        /// Load and execute engine rules
        /// </summary>
        public void ProcessBoardBaggageTTY(OSUSR_UUK_BAGMSGS bag, OSUSR_UUK_BAGINTEG bagIntegraty, OSUSR_UUK_FLT_INFO flightInfoI, OSUSR_UUK_FLT_INFO flightInfoF, String hub, ISessionFactory factory)
        {
            BagTMLog.LogDebug("BagTM Engine Process Board Baggage Start", this);

            try
            {
                List <OSUSR_UUK_BAGMSGS> listOfBagBoarded = this.SearchBaggageMsgsByFlightandSeatNumber(bag);

                foreach (OSUSR_UUK_BAGMSGS boardBag in listOfBagBoarded)
                {
                    OSUSR_UUK_BAGINTEG boardBagInteg = this.SearchBaggageIntegratyByBagIdentifier(boardBag.NBAGTAG + boardBag.NNRTAGS);

                    if (boardBagInteg == null)
                    {
                        boardBagInteg = new OSUSR_UUK_BAGINTEG();
                    }

                    var inst = bag.GetType().GetMethod("MemberwiseClone", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                    OSUSR_UUK_BAGMSGS bagClone = (OSUSR_UUK_BAGMSGS)inst.Invoke(bag, null);

                    bagClone.NNRTAGS = boardBag.NNRTAGS;
                    bagClone.NBAGTAG = boardBag.NBAGTAG;

                    BagTMLog.LogDebug("BagTM Board Baggage Engine Rules Execution", this);
                    // Run engine process rules
                    this.EngineRulesExecution(bagClone, boardBagInteg, flightInfoI, flightInfoF, hub, factory);
                }
            }
            catch (Exception e)
            {
                BagTMLog.LogError("BagTM Engine Error Process Board Baggage", this, e);

                throw e;
            }

            BagTMLog.LogDebug("BagTM Engine Process Board Baggage Ending", this);
        }
コード例 #8
0
        public Object parse(String messageString, BaggageEntities db)
        {
            BagTMLog.LogDebug(
                String.Format("BagTM Queue Message Parsing PTM TTY {0}", messageString), this);

            Match flight;
            MatchCollection outbounds;
            IPTMTTYTable messageObject = null;
            String methodName;
            String parameter = null;
            String messageStripped;

            // At this stage formatter alredy removed headers
            messageStripped = this.RemoveHeaders(messageString);
            flight = Regex.Match(messageString, matchFlights);
            outbounds = Regex.Matches(messageString.Remove(0, flight.Length), matchOutbounds);

            try
            {
                BagTMLog.LogDebug(
                    String.Format("BagTM Queue Message Parsing PTM TTY Message flight {0}", flight.Value), this);

                PTMTTYTable paxmsgs = new PTMTTYTable();

                TTYComponentConfigElement configFlight = ttyCollection.GetTTYElement("PTM").ttyElements.GetTTYElementElement("default").ttycomponents.GetTTYElementElement("Flight");
                
                if (!flight.Success)
                    throw new PTMParsingException("No flight information impossible to process PTM message.");

                DateTime messageTimestamp = DateTime.Now;

                if (outbounds.Count > 0)
                {
                    foreach (Match outbound in outbounds)
                    {

                        messageObject = (IPTMTTYTable)Activator.CreateInstance(Type.GetType(ttyCollection.GetTTYElement("PTM").entityName));

                        BagTMLog.LogDebug(
                                String.Format("BagTM Queue Message Parsing PTM TTY Message flight {0}", flight.Value), this);

                        parameter = flight.Value.Substring(4, flight.Length - 10);
                        methodName = configFlight.methodName;
                        // Not necessary if parameter is null since no change to object
                        if (parameter != null) messageObject.SetValue(methodName, parameter);

                        TTYComponentConfigElement configOutbound = ttyCollection.GetTTYElement("PTM").ttyElements.GetTTYElementElement("default").ttycomponents.GetTTYElementElement("Outbounds");

                        BagTMLog.LogDebug(
                            String.Format("BagTM Queue Message Parsing PTM TTY Message flight {0} and outbound {1}", flight.Value, outbound.Value), this);
                        parameter = outbound.Value;
                        methodName = configOutbound.methodName;
                        // Not necessary if parameter is null since no change to object
                        if (parameter != null) messageObject.SetValue(methodName, parameter);

                        // Create timestamp message identifier
                        messageObject.SetValue("Stamp", messageTimestamp.ToString());

                        // Se o objeto estiver instanciado então foi preenchido e deve ser guardado em base de dados
                        if (messageObject != null)
                        {
                            BagTMLog.LogInfo(
                                    String.Format("BagTM Queue Message PTM Message Outbound Parsed {0}", messageObject), this);
                            messageObject.Save(db, hub);
                        }
                    }

                }
                else
                {
                    messageObject = (IPTMTTYTable)Activator.CreateInstance(Type.GetType(ttyCollection.GetTTYElement("PTM").entityName));

                    BagTMLog.LogDebug(
                            String.Format("BagTM Queue Message Parsing PTM TTY Message flight {0}", flight.Value), this);

                    parameter = flight.Value.Substring(4, flight.Length - 10);
                    methodName = configFlight.methodName;
                    // Not necessary if parameter is null since no change to object
                    if (parameter != null) messageObject.SetValue(methodName, parameter);

                    // Se o objeto estiver instanciado então foi preenchido e deve ser guardado em base de dados
                    if (messageObject != null)
                    {
                        BagTMLog.LogInfo(
                                String.Format("BagTM Queue Message PTM Message Parsed {0}", messageObject), this);
                        messageObject.Save(db, hub);
                    }
                }

                return ((PTMTTYTable)messageObject).getOSUSR_UUK_PAXMSGS();

            } catch (Exception e)
            {
                BagTMLog.LogError("BagTM Queue Message Parsing PTM TTY Parser Error", this, e);
                
                throw e;
            }
            
        }
コード例 #9
0
        /// <summary>
        /// Read queue
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        protected object[] ReadQueue(int n, int queueType)
        {
            object message = null;

            object[] messages = new object[2];

            BagTMLog.LogDebug(
                String.Format("BagTM Engine Read Task Message Start {0}", n), this);

            Message msg = null;

            try
            {
                MessageQueue queueUse = this.CreateMessageQueue(queueType);

                try
                {
                    msg         = queueUse.Receive(this.timeSpan);
                    messages[1] = msg;
                }
                catch (Exception e)
                {
                    if (e.Message.Contains("Timeout"))
                    {
                        return(null);
                    }
                    queueUse = this.CreateMessageQueue(queueType);

                    msg         = queueUse.Receive(this.timeSpan);
                    messages[1] = msg;
                }

                if (msg != null)
                {
                    BagTMLog.LogDebug(
                        String.Format("BagTM Engine Read Task {0} for Message Body Type: {1}", n, msg.BodyType), this);

                    message     = (Object)msg.Body;
                    messages[0] = message;

                    BagTMLog.LogInfo("BagTM Engine TTY Message: " + message, this);

                    BagTMLog.LogDebug(
                        String.Format("BagTM Engine Read Task {0} with Message {1}", n, msg.Id), this);
                }
            }
            catch (Exception e)
            {
                BagTMLog.LogError(
                    String.Format("BagTM Engine Read Task {0} with Error", n), this, e);

                if (msg != null)
                {
                    this.SendMessage(msg, n, QUEUEERROR);
                }

                throw e;
            }

            BagTMLog.LogDebug(
                String.Format("BagTM Engine Read Task Message End {0}", n), this);

            return(messages);
        }
コード例 #10
0
        /// <summary>
        /// Update H2H table based on flight information
        /// </summary>
        public void EngineUpdatePTMH2H(OSUSR_UUK_FLT_INFO flightInfoI, DateTime stampPTM)
        {
            BagTMLog.LogDebug("BagTM Engine Update PTM H2H Start", this);
            int i = 0;

            BaggageEntities db = new BaggageEntities();

            try
            {
                BagTMLog.LogDebug("BagTM Engine Update PTM H2H FlightInfoI", flightInfoI);
                BagTMLog.LogDebug("BagTM Engine Update PTM H2H Hub", hub);

                BagTMLog.LogDebug("BagTM Engine Update Search PTM H2H", this);

                String iFLTNR = (flightInfoI != null) ?
                                CommonFunctions.FormatFlightNumber(flightInfoI.OPERATOR + flightInfoI.FLT_NR) : null;
                System.Nullable <DateTime> iDATE = (flightInfoI != null) ? flightInfoI.STD : null;
                String iORIGIN = (flightInfoI != null) ? flightInfoI.FROM_IATA : null;
                String iDEST   = (flightInfoI != null) ? flightInfoI.TO_IATA : null;
                System.Nullable <DateTime> stamp = stampPTM;

                List <OSUSR_UUK_PTM_H2H> h2hList = this.SearchPTMH2HInformation(
                    iFLTNR, iDATE, iORIGIN);

                List <OSUSR_UUK_PTMREFS2G>        refStandGateTimes = this.SearchRefStandGateTimes();
                List <OSUSR_UUK_PTM_REF_SEC_TIME> secTimes          = this.SearchSecTimes();


                BagTMLog.LogDebug("BagTM Engine Update PTM H2H List", h2hList);


                var ptmQuery = from s in db.OSUSR_UUK_PAXMSGS
                               where s.TIMESTAMP == stamp
                               select s;

                var ptmList = ptmQuery.Where(s => s.IFLTNR == iFLTNR &&
                                             s.IDATE == ((DateTime)iDATE).Date &&
                                             s.IORIGIN == iORIGIN &&
                                             s.TIMESTAMP == stamp)
                              .Select(x => new
                {
                    x.IFLTNR,
                    x.IDATE,
                    x.IORIGIN,
                    x.OFLTNR,
                    x.ODATE,
                    x.ODEST,
                    x.RESERVATIONSTATUS
                })
                              .Distinct()
                              .ToList();

                BagTMLog.LogDebug("BagTM Engine Update Obtain PTM TTY list", ptmList);

                OSUSR_UUK_FLT_INFO flightInfoF;
                foreach (OSUSR_UUK_PTM_H2H h2h in h2hList)
                {
                    flightInfoF = null;

                    BagTMLog.LogDebug("BagTM Engine Update PTM H2H Flight Process", h2h);
                    i++;
                    var ptmListH2H = ptmList.Where(s => s.IFLTNR == h2h.IFLTNR &&
                                                   s.IDATE == h2h.IDATE &&
                                                   s.IORIGIN == h2h.IORIGIN &&
                                                   s.OFLTNR == h2h.OFLTNR &&
                                                   s.ODATE == h2h.ODATE &&
                                                   s.ODEST == h2h.ODEST &&
                                                   s.RESERVATIONSTATUS == h2h.STATUS)
                                     .ToList();

                    var h2hExists = ptmListH2H.FirstOrDefault();

                    BagTMLog.LogDebug("BagTM Engine Update Calculate PTMH2H PAX Count", ptmListH2H);

                    var PAXCalculate = ptmQuery.Where(s => s.IFLTNR == h2h.IFLTNR &&
                                                      s.IDATE == h2h.IDATE &&
                                                      s.IORIGIN == h2h.IORIGIN &&
                                                      s.OFLTNR == h2h.OFLTNR &&
                                                      s.ODATE == h2h.ODATE &&
                                                      s.ODEST == h2h.ODEST &&
                                                      s.RESERVATIONSTATUS == h2h.STATUS)
                                       .GroupBy(x => new
                    {
                        x.IFLTNR,
                        x.IDATE,
                        x.IORIGIN,
                        x.OFLTNR,
                        x.ODATE,
                        x.ODEST,
                        x.RESERVATIONSTATUS
                    })
                                       .Select(x => new
                    {
                        IFLTNR            = x.Key.IFLTNR,
                        IDATE             = x.Key.IDATE,
                        IORIGIN           = x.Key.IORIGIN,
                        OFLTNR            = x.Key.OFLTNR,
                        ODATE             = x.Key.ODATE,
                        ODEST             = x.Key.ODEST,
                        RESERVATIONSTATUS = x.Key.RESERVATIONSTATUS,
                        SumFIRST          = x.Sum(z => z.FIRST),
                        SumBUSINESS       = x.Sum(z => z.BUSINESS),
                        SumECONOMY        = x.Sum(z => z.ECONOMY)
                    }
                                               ).FirstOrDefault();

                    BagTMLog.LogDebug("BagTM Engine Update H2H Exist", PAXCalculate);

                    if (h2h.OFLTNR != null && h2h.ODATE != null)
                    {
                        flightInfoF = this.SearchFlightInfo(h2h.OFLTNR, h2h.ODATE, hub, h2h.ODEST);
                    }
                    else
                    {
                        flightInfoF = new OSUSR_UUK_FLT_INFO();
                    }
                    BagTMLog.LogDebug("BagTM Engine Search FlightInfoF", flightInfoF);

                    if (PAXCalculate != null && PAXCalculate.IFLTNR != null)
                    {
                        // To update inbound NRBAGS count for Hub messages
                        h2h.FIRST    = PAXCalculate.SumFIRST;
                        h2h.BUSINESS = PAXCalculate.SumBUSINESS;
                        h2h.ECONOMY  = PAXCalculate.SumECONOMY;

                        h2h.ETA = (flightInfoI != null && flightInfoI.DOOROPEN != null && flightInfoI.DOOROPEN.Value.Year != 1900) ? flightInfoI.DOOROPEN :
                                  (flightInfoI != null && flightInfoI.ATA != null && flightInfoI.ATA.Value.Year != 1900) ? flightInfoI.ATA :
                                  (flightInfoI != null && flightInfoI.ETA != null && flightInfoI.ETA.Value.Year != 1900) ? flightInfoI.ETA : null;
                        h2h.GATE = (flightInfoF != null && flightInfoF.FROM_GATE != null) ? flightInfoF.FROM_GATE : null;
                        h2h.ETD  = (flightInfoF != null && flightInfoF.DOORCLOSED != null && flightInfoF.DOORCLOSED.Value.Year != 1900) ? flightInfoF.DOORCLOSED :
                                   (flightInfoF != null && flightInfoF.ATD != null && flightInfoF.ATD.Value.Year != 1900) ? flightInfoF.ATD :
                                   (flightInfoF != null && flightInfoF.ETD != null && flightInfoF.ETD.Value.Year != 1900) ? flightInfoF.ETD :
                                   (flightInfoF != null && flightInfoF.STD != null && flightInfoF.STD.Value.Year != 1900) ? flightInfoF.STD : null;
                        h2h.STAND      = (flightInfoI != null && flightInfoI.TO_STAND != null) ? flightInfoI.TO_STAND : null;
                        h2h.STATUS     = PAXCalculate.RESERVATIONSTATUS;
                        h2h.IFLTINFOID = (flightInfoI != null) ? (System.Nullable <int>)flightInfoI.ID : null;
                        h2h.OFLTINFOID = (flightInfoF != null) ? (System.Nullable <int>)flightInfoF.ID : null;

                        System.Nullable <DateTime> etg = null;
                        if (flightInfoI != null)
                        {
                            if (flightInfoI.DOOROPEN != null)
                            {
                                etg = flightInfoI.DOOROPEN;
                            }
                            else if (flightInfoI.ATA != null)
                            {
                                etg = flightInfoI.ATA;
                            }
                            else if (flightInfoI.ETA != null)
                            {
                                etg = flightInfoI.ETA;
                            }
                        }

                        // Obtain security times from table
                        OSUSR_UUK_PTMREFS2G refStandGateTime = refStandGateTimes.Where(
                            s => s.GATE == h2h.GATE &&
                            s.STAND == h2h.STAND).FirstOrDefault();

                        int standGateMinutes = (refStandGateTime != null && refStandGateTime.MINUTES != null) ? (int)refStandGateTime.MINUTES / 2 : 0;

                        if (refStandGateTime != null && SEC_Y.Equals(refStandGateTime.SEC))
                        {
                            OSUSR_UUK_PTM_REF_SEC_TIME secTime = secTimes.Where(
                                s => s.WEEK == ((DateTime)h2h.IDATE).DayOfWeek.ToString() &&
                                s.FROM_TIME > ((DateTime)etg).AddMinutes(standGateMinutes))
                                                                 .FirstOrDefault();
                            h2h.SEC = (secTime != null && secTime.TIME != null) ? standGateMinutes + (int)secTime.TIME : standGateMinutes;
                        }
                        else
                        {
                            h2h.SEC = standGateMinutes;
                        }
                        if (h2h.ETD != null)
                        {
                            h2h.ETCG = h2h.ETD;
                            h2h.ETCG.Value.AddMinutes(-1 * etcg);
                        }
                        h2h.ETG = h2h.ETA;
                        h2h.ETG = (h2h.ETG != null) ? (System.Nullable <DateTime>)((DateTime)h2h.ETG).AddMinutes(
                            Math.Min((h2h.SEC != null) ? (int)h2h.SEC : 0, this.maxPaxTurnaround)) : null;
                        h2h.HUB = (h2h.ETD != null && h2h.ETG != null) ? (System.Nullable <int>)((TimeSpan)(h2h.ETD - h2h.ETG)).TotalMinutes : null;

                        BagTMLog.LogInfo("BagTM Engine H2H Update: " + h2h.ID, this);
                    }
                    else
                    {
                        // To update inbound NRBAGS count for Hub messages
                        h2h.FIRST    = 0;
                        h2h.BUSINESS = 0;
                        h2h.ECONOMY  = 0;

                        h2h.ETA    = (flightInfoI != null && flightInfoI.ETA != null) ? flightInfoI.ETA : null;
                        h2h.GATE   = (flightInfoF != null && flightInfoF.FROM_GATE != null) ? flightInfoF.FROM_GATE : null;
                        h2h.ETD    = (flightInfoF != null && flightInfoF.ETD != null) ? flightInfoF.ETD : null;
                        h2h.STAND  = (flightInfoI != null && flightInfoI.TO_STAND != null) ? flightInfoI.TO_STAND : null;
                        h2h.STATUS = null;

                        h2h.SEC  = 0;
                        h2h.ETG  = null;
                        h2h.ETCG = null;
                        h2h.HUB  = null;
                    }

                    db.OSUSR_UUK_PTM_H2H.Attach(h2h);
                    db.Entry(h2h).State = EntityState.Modified;
                    BagTMLog.LogInfo("BagTM Engine PTM H2H Update: " + h2h.ID, this);

                    ptmList.Remove(h2hExists);
                }

                OSUSR_UUK_PTM_H2H newH2H = null;
                foreach (var ptmNotIn in ptmList)
                {
                    flightInfoF = null;

                    // Verify if passengers in connection with a FI flight
                    if (ptmNotIn.OFLTNR != null && !ptmNotIn.OFLTNR.StartsWith(this.airline))
                    {
                        continue;
                    }

                    newH2H = new OSUSR_UUK_PTM_H2H();

                    var PAXCalculate = ptmQuery.Where(s => s.IFLTNR == ptmNotIn.IFLTNR &&
                                                      s.IDATE == ptmNotIn.IDATE &&
                                                      s.IORIGIN == ptmNotIn.IORIGIN &&
                                                      s.OFLTNR == ptmNotIn.OFLTNR &&
                                                      s.ODATE == ptmNotIn.ODATE &&
                                                      s.ODEST == ptmNotIn.ODEST &&
                                                      s.RESERVATIONSTATUS == ptmNotIn.RESERVATIONSTATUS)
                                       .GroupBy(x => new
                    {
                        x.IFLTNR,
                        x.IDATE,
                        x.IORIGIN,
                        x.OFLTNR,
                        x.ODATE,
                        x.ODEST,
                        x.RESERVATIONSTATUS
                    })
                                       .Select(x => new
                    {
                        IFLTNR            = x.Key.IFLTNR,
                        IDATE             = x.Key.IDATE,
                        IORIGIN           = x.Key.IORIGIN,
                        OFLTNR            = x.Key.OFLTNR,
                        ODATE             = x.Key.ODATE,
                        ODEST             = x.Key.ODEST,
                        RESERVATIONSTATUS = x.Key.RESERVATIONSTATUS,
                        SumFIRST          = x.Sum(z => z.FIRST),
                        SumBUSINESS       = x.Sum(z => z.BUSINESS),
                        SumECONOMY        = x.Sum(z => z.ECONOMY)
                    }
                                               ).FirstOrDefault();

                    BagTMLog.LogDebug("BagTM Engine Update H2H Don't Exist", PAXCalculate);

                    if (PAXCalculate != null && PAXCalculate.IFLTNR != null)
                    {
                        // To update inbound NRBAGS count for Hub messages
                        newH2H.FIRST    = PAXCalculate.SumFIRST;
                        newH2H.BUSINESS = PAXCalculate.SumBUSINESS;
                        newH2H.ECONOMY  = PAXCalculate.SumECONOMY;
                    }
                    else
                    {
                        newH2H.FIRST    = 0;
                        newH2H.BUSINESS = 0;
                        newH2H.ECONOMY  = 0;
                    }

                    if (ptmNotIn.OFLTNR != null && ptmNotIn.ODATE != null)
                    {
                        flightInfoF = this.SearchFlightInfo(ptmNotIn.OFLTNR, ptmNotIn.ODATE, hub, ptmNotIn.ODEST);
                    }
                    else
                    {
                        flightInfoF = new OSUSR_UUK_FLT_INFO();
                    }
                    BagTMLog.LogDebug("BagTM Engine Search FlightInfoF", flightInfoF);

                    newH2H.IFLTNR  = ptmNotIn.IFLTNR;
                    newH2H.IDATE   = ptmNotIn.IDATE;
                    newH2H.IORIGIN = ptmNotIn.IORIGIN;
                    newH2H.OFLTNR  = ptmNotIn.OFLTNR;
                    newH2H.ODATE   = ptmNotIn.ODATE;
                    newH2H.ODEST   = ptmNotIn.ODEST;

                    newH2H.ETA = (flightInfoI != null && flightInfoI.DOOROPEN != null && flightInfoI.DOOROPEN.Value.Year != 1900) ? flightInfoI.DOOROPEN :
                                 (flightInfoI != null && flightInfoI.ATA != null && flightInfoI.ATA.Value.Year != 1900) ? flightInfoI.ATA :
                                 (flightInfoI != null && flightInfoI.ETA != null && flightInfoI.ETA.Value.Year != 1900) ? flightInfoI.ETA : null;
                    newH2H.GATE = (flightInfoF != null && flightInfoF.FROM_GATE != null) ? flightInfoF.FROM_GATE : null;
                    newH2H.ETD  = (flightInfoF != null && flightInfoF.DOORCLOSED != null && flightInfoF.DOORCLOSED.Value.Year != 1900) ? flightInfoF.DOORCLOSED :
                                  (flightInfoF != null && flightInfoF.ATD != null && flightInfoF.ATD.Value.Year != 1900) ? flightInfoF.ATD :
                                  (flightInfoF != null && flightInfoF.ETD != null && flightInfoF.ETD.Value.Year != 1900) ? flightInfoF.ETD :
                                  (flightInfoF != null && flightInfoF.STD != null && flightInfoF.STD.Value.Year != 1900) ? flightInfoF.STD : null;
                    newH2H.STAND      = (flightInfoI != null && flightInfoI.TO_STAND != null) ? flightInfoI.TO_STAND : null;
                    newH2H.STATUS     = ptmNotIn.RESERVATIONSTATUS;
                    newH2H.IFLTINFOID = (flightInfoI != null) ? (System.Nullable <int>)flightInfoI.ID : null;
                    newH2H.OFLTINFOID = (flightInfoF != null) ? (System.Nullable <int>)flightInfoF.ID : null;

                    System.Nullable <DateTime> etcg = null;
                    if (flightInfoI != null)
                    {
                        if (flightInfoI.DOOROPEN != null && flightInfoI.DOOROPEN.Value.Year != 1900)
                        {
                            etcg = flightInfoI.DOOROPEN;
                        }
                        else if (flightInfoI.ATA != null && flightInfoI.ATA.Value.Year != 1900)
                        {
                            etcg = flightInfoI.ATA;
                        }
                        else if (flightInfoI.ETA != null && flightInfoI.ETA.Value.Year != 1900)
                        {
                            etcg = flightInfoI.ETA;
                        }
                    }

                    // Obtain security times from table
                    OSUSR_UUK_PTMREFS2G refStandGateTime = refStandGateTimes.Where(
                        s => s.GATE == newH2H.GATE &&
                        s.STAND == newH2H.STAND).FirstOrDefault();

                    int standGateMinutes = (refStandGateTime != null && refStandGateTime.MINUTES != null) ? (int)refStandGateTime.MINUTES / 2 : 0;

                    if (refStandGateTime != null && SEC_Y.Equals(refStandGateTime.SEC))
                    {
                        OSUSR_UUK_PTM_REF_SEC_TIME secTime = secTimes.Where(
                            s => s.WEEK == ((DateTime)newH2H.IDATE).DayOfWeek.ToString() &&
                            s.FROM_TIME > ((DateTime)flightInfoF.ETA).AddMinutes(standGateMinutes)).FirstOrDefault();
                        newH2H.SEC = (secTime != null && secTime.TIME != null) ? standGateMinutes + (int)secTime.TIME : standGateMinutes;
                    }
                    else
                    {
                        newH2H.SEC = standGateMinutes;
                    }
                    newH2H.ETG = newH2H.ETA;
                    newH2H.ETG = (newH2H.ETG != null) ? (System.Nullable <DateTime>)((DateTime)newH2H.ETG).AddMinutes(
                        Math.Min((newH2H.SEC != null) ? (int)newH2H.SEC : 0, this.maxPaxTurnaround)) : null;
                    newH2H.HUB = (newH2H.ETD != null && newH2H.ETG != null) ? (System.Nullable <int>)((TimeSpan)(newH2H.ETD - newH2H.ETG)).TotalMinutes : null;

                    try
                    {
                        db.OSUSR_UUK_PTM_H2H.Add(newH2H);
                        BagTMLog.LogInfo("BagTM Engine PTM H2H Create: " + newH2H.ID, this);
                    }
                    catch (DbEntityValidationException ex)
                    {
                        db.OSUSR_UUK_PTM_H2H.Remove(newH2H);
                        // Retrieve the error messages as a list of strings.
                        var errorMessages = ex.EntityValidationErrors
                                            .SelectMany(x => x.ValidationErrors)
                                            .Select(x => x.ErrorMessage);

                        // Join the list to a single string.
                        var fullErrorMessage = string.Join("; ", errorMessages);

                        // Combine the original exception message with the new one.
                        var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);

                        // Throw a new DbEntityValidationException with the improved exception message.
                        throw new EngineProcessingException(exceptionMessage);
                    }
                }

                try
                {
                    db.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                    // Retrieve the error messages as a list of strings.
                    var errorMessages = ex.EntityValidationErrors
                                        .SelectMany(x => x.ValidationErrors)
                                        .Select(x => x.ErrorMessage);

                    // Join the list to a single string.
                    var fullErrorMessage = string.Join("; ", errorMessages);

                    // Combine the original exception message with the new one.
                    var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);

                    // Throw a new DbEntityValidationException with the improved exception message.
                    throw new EngineProcessingException(exceptionMessage);
                }
            }
            catch (Exception e)
            {
                BagTMLog.LogError("BagTM Engine Error updating PTM H2H Table", this, e);

                throw e;
            }

            BagTMLog.LogDebug("BagTM Engine Update PTM H2H End", this);
        }
コード例 #11
0
        /// <summary>
        /// Process engine rules
        /// </summary>
        /// <param name="messageObject"></param>
        /// <param name="n"></param>
        public void ProcessBaggageTTYEngine(Object messageObject, int n)
        {
            BagTMLog.LogDebug("BagTM Engine Baggage TTY", this);

            // Only process message if is a baggage message
            if (messageObject.GetType() != typeof(OSUSR_UUK_BAGMSGS))
            {
                throw new EngineProcessingException("Not a baggage message.");
            }

            OSUSR_UUK_BAGMSGS bag = (OSUSR_UUK_BAGMSGS)messageObject;

            int nrtag = 0;

            try
            {
                nrtag = Convert.ToInt32(bag.NNRTAGS);
            }
            catch (Exception e)
            {
                BagTMLog.LogError("Bag NNRTAG is not an number.", bag, e);
            }
            if (nrtag > 1)
            {
                for (int i = 0; i < nrtag; i++)
                {
                    var inst = bag.GetType().GetMethod("MemberwiseClone", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                    OSUSR_UUK_BAGMSGS bagClone = (OSUSR_UUK_BAGMSGS)inst.Invoke(bag, null);

                    bagClone.NNRTAGS = "001";
                    bagClone.NBAGTAG = (Convert.ToDecimal(bagClone.NBAGTAG) + i).ToString("0000000000");
                    ProcessBaggageTTYEngine(bagClone, n);
                }
            }

            BagTMLog.LogDebug("BagTM Engine Search BaggageIntegraty", bag);
            // Obtain baggage from Baggage Integraty table
            OSUSR_UUK_BAGINTEG bagIntegraty = this.SearchBaggageIntegratyByBagIdentifier(bag.NBAGTAG + bag.NNRTAGS);

            if (bagIntegraty == null)
            {
                bagIntegraty = new OSUSR_UUK_BAGINTEG();
            }
            BagTMLog.LogDebug("BagTM Engine Search BaggageIntegraty Found ", bagIntegraty);
            BagTMLog.LogDebug("BagTM Engine Search FlightInfoI and FlightInfoF", this);
            OSUSR_UUK_FLT_INFO flightInfoI = null;
            OSUSR_UUK_FLT_INFO flightInfoF = null;

            bool isHub              = false;
            bool isLocalTTYforHub   = false;
            bool isLocalEndingInHub = false;

            if ((BagTMRulesActions.hubBagParameter.Equals(bag.VBAGSOURCIND) &&
                 this.hub.Equals(bag.VCITY)) ||
                (BagTMRulesActions.localBagParameter.Equals(bag.VBAGSOURCIND) &&
                 this.hub.Equals(bag.FDEST)))
            {
                isHub = true;
            }
            if (isHub && BagTMRulesActions.localBagParameter.Equals(bag.VBAGSOURCIND))
            {
                isLocalTTYforHub = true;
            }
            if (isHub && isLocalTTYforHub && (bag.OFLTNR == null || !bag.OFLTNR.StartsWith(this.airline)))
            {
                isLocalEndingInHub = true;
            }
            if (isHub && !isLocalTTYforHub && bag.IFLTNR != null)
            {
                isLocalEndingInHub = true;
            }

            // Obtain list of message from Baggage table
            if (isHub)
            {
                if (!isLocalEndingInHub)
                {
                    if (bag.FFLTNR != null && bag.FDATE != null && bag.FFLTNR.StartsWith(this.airline))
                    {
                        flightInfoI = this.SearchFlightInfo(bag.FFLTNR, bag.FDATE, bag.VCITY, bag.FDEST);
                    }
                    else
                    {
                        flightInfoI = new OSUSR_UUK_FLT_INFO();
                    }
                    if (bag.OFLTNR != null && bag.ODATE != null && bag.OFLTNR.StartsWith(this.airline))
                    {
                        flightInfoF = this.SearchFlightInfo(bag.OFLTNR, bag.ODATE, hub, bag.ODEST);
                    }
                    else
                    {
                        flightInfoF = new OSUSR_UUK_FLT_INFO();
                    }
                }
                else
                {
                    if (bag.IFLTNR != null && bag.IDATE != null && bag.IFLTNR.StartsWith(this.airline))
                    {
                        flightInfoI = this.SearchFlightInfo(bag.IFLTNR, bag.IDATE, bag.IORIGIN, bag.VCITY);
                    }
                    else
                    {
                        flightInfoI = new OSUSR_UUK_FLT_INFO();
                    }
                    if (bag.FFLTNR != null && bag.FDATE != null && bag.FFLTNR.StartsWith(this.airline))
                    {
                        flightInfoF = this.SearchFlightInfo(bag.FFLTNR, bag.FDATE, bag.VCITY, bag.FDEST);
                    }
                    else
                    {
                        flightInfoF = new OSUSR_UUK_FLT_INFO();
                    }
                }
            }
            else
            {
                if (bag.FFLTNR != null && bag.FDATE != null && bag.FFLTNR.StartsWith(this.airline))
                {
                    flightInfoF = this.SearchFlightInfo(bag.FFLTNR, bag.FDATE, bag.VCITY, bag.FDEST);
                }
                else
                {
                    flightInfoF = new OSUSR_UUK_FLT_INFO();
                }

                flightInfoI = new OSUSR_UUK_FLT_INFO();
            }

            BagTMLog.LogDebug("BagTM Engine Search FlightInfoI", flightInfoI);
            BagTMLog.LogDebug("BagTM Engine Search FlightInfoF", flightInfoF);
            BagTMLog.LogDebug("BagTM Engine Rules Execution", this);
            // Run engine process rules
            this.EngineRulesExecution(bag, bagIntegraty, flightInfoI, flightInfoF, hub, factory);

            // Verify if is a baggage board
            if (BagTMRulesActions.PAX_BOARDED_STATUS.Equals(bag.SPAXCK))
            {
                BagTMLog.LogDebug("BagTM Engine Boaded Pax", this);

                this.ProcessBoardBaggageTTY(bag, bagIntegraty, flightInfoI, flightInfoF, hub, factory);
            }

            if (flightInfoF == null || flightInfoF.FLT_NR == null || flightInfoI == null)
            {
                BagTMLog.LogDebug("No update to H2H since no flight information, please check flight in FLT_INFO table.", this);
            }
            else
            {
                // Reprocess Hull 2 Hull table for selected flight
                if (isHub || (hub.Equals(bag.VCITY) && BagTMRulesActions.localBagParameter.Equals(bag.VBAGSOURCIND)))
                {
                    this.h2hProcessing.EngineUpdateH2H(flightInfoI, flightInfoF, isHub);
                }
            }
            BagTMLog.LogDebug("BagTM Engine Baggage TTY End", this);
        }
コード例 #12
0
        public Object parse(String messageString, BaggageEntities db)
        {
            BagTMLog.LogDebug(
                String.Format("BagTM Queue Message Parsing TTY {0}", messageString), this);

            String[]         elements;
            String[]         components;
            String           keyTTY;
            String           keyElement;
            IBaggageTTYTable messageObject = null;
            String           methodName;
            String           parameter = null;
            String           messageStripped;

            // At this stage formatter alredy removed headers
            messageStripped = this.RemoveHeaders(messageString);
            elements        = Regex.Split(messageStripped, matchElements);

            try
            {
                BagTMLog.LogDebug(
                    String.Format("BagTM Queue Message Parsing TTY Message element[0] {0} element[0].lenght {1}",
                                  elements[0], elements[0].Length), this);

                if (elements[0] != null && elements[0].Length > 2 && ttyCollection.HasTTY(elements[0].Substring(0, 3)))
                {
                    keyTTY = elements[0].Substring(0, 3);

                    BagTMLog.LogDebug(
                        String.Format("BagTM Queue Message Parsing TTY Message with Key {0} Processing by EntityName {1} and Type {2}",
                                      keyTTY, ttyCollection.GetTTYElement(keyTTY).entityName,
                                      Type.GetType(ttyCollection.GetTTYElement(keyTTY).entityName)), this);

                    messageObject = (IBaggageTTYTable)Activator.CreateInstance(Type.GetType(ttyCollection.GetTTYElement(keyTTY).entityName));
                    messageObject.Clean();

                    foreach (string element in elements)
                    {
                        components = Regex.Split(element, matchComponents);

                        keyElement = (!element.Equals(elements[0])) ? components[0] : "default";

                        BagTMLog.LogDebug(
                            String.Format("BagTM Queue Message Parsing TTY Message with Key {0} Processing KeyElement {1} for Element {2} and Components[0] {3} ",
                                          keyTTY, keyElement, element, components[0]), this);

                        if (components[0] != null && ttyCollection.HasTTYElement(keyTTY, keyElement))
                        {
                            foreach (TTYComponentConfigElement config in ttyCollection.GetTTYElement(keyTTY).ttyElements.GetTTYElementElement(keyElement).ttycomponents)
                            {
                                BagTMLog.LogDebug(
                                    String.Format("BagTM Queue Message Parsing TTY Message with Config Size {0}", ttyCollection.GetTTYElement(keyTTY).ttyElements.GetTTYElementElement(keyElement).ttycomponents.Count), this);

                                BagTMLog.LogDebug(
                                    String.Format("BagTM Queue Message Parsing TTY Message key {0}, keyElement {1}, position {2} and substring {3} from components {4}",
                                                  keyTTY, keyElement, config.GetPositionInt(), config.substring, components.Length), this);

                                parameter  = null;
                                methodName = config.methodName;

                                // To process all components based on XML configuration
                                if (config.GetPositionInt() < 0)
                                {
                                    // If position = 0 then all components in the same attribute
                                    // Also remove . and /
                                    parameter = element.Substring(components[0].Length + 1);
                                }
                                else if (config.GetPositionInt() < components.Length)
                                {
                                    if (config.substring != null && config.substring.Length > 0)
                                    {
                                        if (components[config.GetPositionInt()].Length >= config.StartSubString() + config.LenghtSubString())
                                        {
                                            parameter = components[config.GetPositionInt()].
                                                        Substring(config.StartSubString(), config.LenghtSubString());
                                        }
                                        else
                                        {
                                            parameter = null;
                                        }
                                    }
                                    else
                                    {
                                        parameter = components[config.GetPositionInt()];
                                    }
                                }

                                if (config.GetPositionInt() < components.Length)
                                {
                                    BagTMLog.LogDebug(
                                        String.Format("BagTM Queue Message Parsing TTY Message key {0} and keyElement {1} position {2} to method {3} with parameters {4}",
                                                      keyTTY, keyElement, config.position, methodName, parameter), this);

                                    // Not necessary if parameter is null since no change to object
                                    if (parameter != null)
                                    {
                                        messageObject.SetValue(methodName, parameter);
                                    }

                                    BagTMLog.LogDebug(
                                        String.Format("BagTM Queue Message Parsing TTY Message key {0} and keyElement {1} position {2} stored object {3}",
                                                      keyTTY, keyElement, config.position, messageObject.ToString()), this);
                                }
                            }
                        }
                        else
                        {
                            BagTMLog.LogDebug(
                                String.Format("BagTM Queue Message Parsing TTY Message key {0} and keyElement {1} does not process in element {2}",
                                              keyTTY, keyElement, element), this);
                        }
                    }
                }
                else
                {
                    BagTMLog.LogDebug(
                        String.Format("BagTM Queue Message Parsing TTY Message key {0} does not process {1}", elements[0], messageString), this);
                }
            } catch (Exception e)
            {
                BagTMLog.LogError("BagTM Queue Message Parsing TTY Parser Error", this, e);

                throw e;
            }

            BagTMLog.LogDebug(
                String.Format("BagTM Queue Message Parsing TTY Parser Collection {0}", messageString), this);

            // Se o objeto estiver instanciado então foi preenchido e deve ser guardado em base de dados
            if (messageObject != null)
            {
                BagTMLog.LogInfo(
                    String.Format("BagTM Queue Message Message Parsed {0}", messageObject), this);
                return(messageObject.Save(db));
            }
            else
            {
                return(null);
            }
        }