Ejemplo n.º 1
0
        /// <summary>
        /// Handle change message
        /// </summary>
        /// <param name="message">BaseChangeMessage</param>
        public void Handle(BaseChangeMessage message)
        {
            var providerChangeMessage = message as ProviderChangeMessage;

            if (providerChangeMessage != null)
            {
                this.Handle(providerChangeMessage);
            }
            else
            {
                nextHandler.Handle(message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handle room type message
        /// </summary>
        /// <param name="message">BaseChangeMessage</param>
        public void Handle(BaseChangeMessage message)
        {
            var roomTypeChangeMessage = message as RoomTypeChangeMessage;

            if (roomTypeChangeMessage != null)
            {
                this.Handle(roomTypeChangeMessage);
            }
            else
            {
                nextHandler.Handle(message);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handle an inventory message
        /// </summary>
        /// <param name="message">BaseChangeMessage</param>
        public void Handle(BaseChangeMessage message)
        {
            var inventoryChangeMessage = message as InventoryChangeMessage;

            if (inventoryChangeMessage != null)
            {
                this.Handle(inventoryChangeMessage);
            }
            else
            {
                nextHandler.Handle(message);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handle rate plan message
        /// </summary>
        /// <param name="message">BaseChangeMessage</param>
        public void Handle(BaseChangeMessage message)
        {
   
            var ratePlanChangeMessage = message as RatePlanChangeMessage;

            if (ratePlanChangeMessage != null)
            {
                this.Handle(ratePlanChangeMessage);
            }
            else
            {
                nextHandler.Handle(message);
            }
        }
        /// <summary>
        /// Create messaging integrator service
        /// </summary>
        /// <returns>a list of messaging integrator services</returns>
        public static IEnumerable<IMessagingIntegratorService> CreateServices(BaseChangeMessage message)
        {
            var providerChangeMessage = message as ProviderChangeMessage;
            bool isOptOutMessage = providerChangeMessage != null && message.ChangeType == ChangeType.Delete && providerChangeMessage.IsFullUpdate;

            if (message.OptedInChannels.Any(c => c.PlatformCode == ChannelPlatformEnum.AIG) || isOptOutMessage)
            {
                yield return new AigIntegratorService();
            }

            if (isPpcIntegratorServiceSwitchedOn && message.OptedInChannels.Any(c => c.PlatformCode == ChannelPlatformEnum.PPC))
            {
                yield return new PPCIntegratorServices();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// This method will process an availablitiy update item and convert it into an PPC message and add it to the queue.
        /// </summary>
        /// <param name="providerSubscriberOptinLookup">ProviderSubscriberOptInsLookup</param>
        /// <param name="changeMessage">BaseChangeMessage</param>
        /// <returns>Return always True</returns>
        public bool ProcessAndQueueChangeUpdates(ProviderSubscriberOptInsLookup providerSubscriberOptinLookup, BaseChangeMessage changeMessage)
        {
            try
            {
                IMessageHandler messageHandler = MessageHandlerFactory.CreateMessageHandler();

                if (messageHandler != null)
                {
                    messageHandler.Handle(changeMessage);
                }

            }
            //We must not disturb the overall process (AIG)
            catch (Exception ex)
            {
                Logger.LogFatal("Error in PPCIntegratorServices :", null, ex);
            }

            return true;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// This method will call the base handler methods depending on the type of availbility update item.
        /// </summary>
        /// <param name="providerAndSubscriberOptInLookup">List of providers opted into AIG</param>
        /// <param name="baseChangeMessage">Availability update item to process</param>
        /// <returns>True is successful otherwise False</returns>
        private bool HandleChangeMessage(ProviderSubscriberOptInsLookup providerAndSubscriberOptInLookup, BaseChangeMessage baseChangeMessage)
        {
            //get the AIGSubscriberByOptinPriceTypeList list now or null. it could be null in a case
            //where it is a provider opt out and the list has been refreshed.
            var subscriberByOptinList = (providerAndSubscriberOptInLookup == null) ? null : providerAndSubscriberOptInLookup.GetSubscribersByProviderId(baseChangeMessage.ProviderId);

            if (subscriberByOptinList == null)
            {
                return true;
            }

            try
            {
                var inventoryChangeMessage = baseChangeMessage as InventoryChangeMessage;
                if (inventoryChangeMessage != null)
                {
                    return HandleInventoryUpdate(subscriberByOptinList, inventoryChangeMessage);
                }

                var providerChangeMessage = baseChangeMessage as ProviderChangeMessage;
                if (providerChangeMessage != null)
                {
                    return HandleProviderUpdate(subscriberByOptinList, providerChangeMessage);
                }

                var ratePlanChangeMessage = baseChangeMessage as RatePlanChangeMessage;
                if (ratePlanChangeMessage != null)
                {
                    return HandleRatePlanUpdate(subscriberByOptinList, ratePlanChangeMessage);
                }

                var roomTypeChangeMessage = baseChangeMessage as RoomTypeChangeMessage;
                if (roomTypeChangeMessage != null)
                {
                    return HandleRoomTypeUpdate(subscriberByOptinList, roomTypeChangeMessage);
                }

                var roomChangeMessage = baseChangeMessage as RoomChangeMessage;
                if (roomChangeMessage != null)
                {
                    return HandleRoomUpdate(subscriberByOptinList, roomChangeMessage);
                }

                return true;
            }
            catch (Exception ex)
            {
                //this is a catch all if anything goes wrong during the data retrieval part
                Logger.ErrorFormat("Error occured while processing {0} {1}", baseChangeMessage, ex);

                var providerErrorMessage = ProviderError.CreateProviderError(baseChangeMessage.SubscriberId.ToString(), baseChangeMessage.ProviderId.ToString(), "Unhandled exception during procesing: " + ex.Message);

                return QueueMessage(providerErrorMessage);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// This method will check to confirm that an update is required for this change message
        /// </summary>
        /// <param name="providerAndSubscriberOptInLookup">List of providers opted in to AIG</param>
        /// <param name="baseChangeMessage">Base change message to check</param>
        /// <returns>True if successful otherwise False</returns>
        private static bool IsChangeMessageRequiredUpdate(ProviderSubscriberOptInsLookup providerAndSubscriberOptInLookup, BaseChangeMessage baseChangeMessage)
        {
            if (providerAndSubscriberOptInLookup.ContainsProvider(baseChangeMessage.ProviderId))
            {
                var subscriberByOptinList = providerAndSubscriberOptInLookup.GetSubscribersByProviderId(baseChangeMessage.ProviderId);

                if (subscriberByOptinList == null)
                {
                    return false;
                }
                    
                //updates involving a businessaccount being activated/deactivated will not contain a distributor id
                if (baseChangeMessage.SubscriberId == Guid.Empty)
                {
                    return true;
                }

                if (subscriberByOptinList.ContainsSubscriber(baseChangeMessage.SubscriberId))
                {
                    return true;
                }
            }

            return false;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// This method will process an availablitiy update item and convert it into an AIG message and add it to the queue. It will however, not commit this message
        /// till the CommmitUpdates method is called. 
        /// </summary>
        /// <param name="providerSubscriberOptinLookup">List of providers opted in to AIG</param>
        /// <param name="changeMessage">Change message to process</param>
        /// <returns>True if successful otherwise False</returns>
        public bool ProcessAndQueueChangeUpdates(ProviderSubscriberOptInsLookup providerSubscriberOptinLookup, BaseChangeMessage changeMessage)
        {
            var isSuccesful = true;

            var providerId = changeMessage.ProviderId;

            using (var transactionScope = new TransactionScope(currentTransactionScope, queryTransactionOptions))
            {
                Logger.InfoFormat("Processing update for Business: {0}", providerId);

                if (IsChangeMessageRequiredUpdate(providerSubscriberOptinLookup, changeMessage))
                {
                    isSuccesful = HandleChangeMessage(providerSubscriberOptinLookup.GetProviderIdsOptedIntoSubscribers().Contains(changeMessage.ProviderId) ? providerSubscriberOptinLookup : null, changeMessage);
                }
                else
                {
                    //It will reach here is the update is for a provider not in aig subscriber list
                    Logger.Debug(string.Format("Business {0} with change message type {1} was not processed as distributor {2} is not an AIG subscriber OR the provider is not opted in", changeMessage.ProviderId, changeMessage.GetType(), changeMessage.SubscriberId));                    
                }

                Logger.InfoFormat("SUCCESSFULLY completed processing updates for Business: {0}", providerId);

                transactionScope.Complete();
            }

            return isSuccesful;
        }
Ejemplo n.º 10
0
 public IEnumerable<IMessagingIntegratorService> CreateServices(BaseChangeMessage message)
 {
     return MessagingIntegratorServiceFactory.CreateServices(message);
 }