/// <summary>
        /// Checks whether provided event is expected according to this itinerary specification.
        /// </summary>
        /// <param name="event">A handling event.</param>
        /// <returns>True, if it is expected. Otherwise - false. 
        /// If itinerary is empty, returns false.</returns>
        public Boolean IsExpected(HandlingEvent @event)
        {
            if (IsEmpty)
            {
                return false;
            }

            if (@event.EventType == HandlingEventType.Receive)
            {
                Leg firstLeg = m_legs.First();
                return firstLeg.LoadLocation == @event.Location;
            }

            if (@event.EventType == HandlingEventType.Claim)
            {
                Leg lastLeg = m_legs.Last();
                return lastLeg.UnloadLocation == @event.Location;
            }

            if (@event.EventType == HandlingEventType.Load)
            {
                return m_legs.Any(x => x.LoadLocation == @event.Location);
            }

            if (@event.EventType == HandlingEventType.Unload)
            {
                return m_legs.Any(x => x.UnloadLocation == @event.Location);
            }

            //@event.EventType == HandlingEventType.Customs
            return true;
        }
Esempio n. 2
0
        private Delivery(HandlingEvent lastHandlingEvent, Itinerary itinerary,
            RouteSpecification specification)
        {
            m_calculatedAt = DateTime.Now;
            m_lastEvent = lastHandlingEvent;

            m_misdirected = CalculateMisdirectionStatus(itinerary);
            m_routingStatus = CalculateRoutingStatus(itinerary, specification);
            m_transportStatus = CalculateTransportStatus();
            m_lastKnownLocation = CalculateLastKnownLocation();
            m_eta = CalculateEta(itinerary);
            m_nextExpectedActivity = CalculateNextExpectedActivity(specification, itinerary);
            m_isUnloadedAtDestination = CalculateUnloadedAtDestination(specification);
        }
Esempio n. 3
0
 /// <summary>
 /// Creates a new delivery snapshot based on the complete handling history of a cargo, as well 
 /// as its route specification and itinerary.
 /// </summary>
 /// <param name="specification">Current route specification.</param>
 /// <param name="itinerary">Current itinerary.</param>
 /// <param name="lastHandlingEvent">Most recent handling event.</param>
 /// <returns>Delivery status description.</returns>
 public static Delivery DerivedFrom(
     RouteSpecification specification,
     Itinerary itinerary,
     HandlingEvent lastHandlingEvent)
 {
     return new Delivery(lastHandlingEvent, itinerary, specification);
 }
Esempio n. 4
0
        /// <summary>
        /// Updates delivery progress information according to handling history.
        /// </summary>
        /// <param name="lastHandlingEvent">Most recent handling event.</param>
        public void DeriveDeliveryProgress(HandlingEvent lastHandlingEvent)
        {
            Delivery = Delivery.DerivedFrom(RouteSpecification, Itinerary, lastHandlingEvent);

            if (Delivery.IsMisdirected)
            {
                m_eventAggegator.Publish<CargoWasMisdirectedEvent>(
                    new CargoWasMisdirectedEvent(this));
            }
            else if (Delivery.IsUnloadedAtDestination)
            {
                m_eventAggegator.Publish<CargoHasArrivedEvent>(
                    new CargoHasArrivedEvent(this));
            }
        }