Esempio n. 1
0
        public static LegActivityMatch Match(Leg leg, HandlingActivity handlingActivity, Itinerary itinerary)
        {
            switch (handlingActivity.Type)
            {
            case HandlingActivityType.RECEIVE:
            case HandlingActivityType.LOAD:
                return(new LegActivityMatch(leg, LegEnd.LoadEnd, handlingActivity, itinerary));

            case HandlingActivityType.UNLOAD:
            case HandlingActivityType.CLAIM:
            case HandlingActivityType.CUSTOMS:
                return(new LegActivityMatch(leg, LegEnd.UnloadEnd, handlingActivity, itinerary));

            default:
                return(NoMatch(handlingActivity, itinerary));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Merges the current <see cref="Freight.Itinerary"/> with the provided <see cref="Freight.Itinerary"/>
        /// </summary>
        /// <param name="other">itinerary</param>
        /// <returns>A merge between the current itinerary and the provided itinerary
        /// that describes a continuous route even if the cargo is currently misdirected.</returns>
        public virtual Itinerary ItineraryMergedWith(Itinerary other)
        {
            if (RoutingStatus == RoutingStatus.NOT_ROUTED)
            {
                return(other);
            }

            if (IsMisdirected && TransportStatus == TransportStatus.ONBOARD_CARRIER)
            {
                var currentLeg = Leg.DeriveLeg(CurrentVoyage, LastKnownLocation,
                                               CurrentVoyage.ArrivalLocationWhenDepartedFrom(LastKnownLocation));

                return(Itinerary.TruncatedAfter(LastKnownLocation).WithLeg(currentLeg).AppendBy(other));
            }

            return(Itinerary.TruncatedAfter(EarliestReroutingLocation).AppendBy(other));
        }
Esempio n. 3
0
        internal Itinerary TruncatedAfter(Location location)
        {
            var newLegs = new List <Leg>();

            foreach (var leg in Legs)
            {
                if (leg.Voyage.Locations.Contains(location))
                {
                    newLegs.Add(Leg.DeriveLeg(leg.Voyage, leg.LoadLocation, location));
                    break;
                }
                else
                {
                    newLegs.Add(leg);
                    if (leg.UnloadLocation.sameAs(location))
                    {
                        break;
                    }
                }
            }

            return(new Itinerary(newLegs));
        }
Esempio n. 4
0
 private HandlingActivity DeriveFromNextLeg(Leg nextLeg)
 {
     return(nextLeg == null?HandlingActivity.ClaimIn(LastLeg.UnloadLocation) : nextLeg.DeriveLoadActivity());
 }
Esempio n. 5
0
 private HandlingActivity DeriveFromMatchingLeg(HandlingActivity handlingActivity, Leg matchingLeg)
 {
     if (matchingLeg == null)
     {
         return(null);
     }
     if (handlingActivity.Type == HandlingActivityType.LOAD)
     {
         return(matchingLeg.DeriveUnloadActivity());
     }
     else if (handlingActivity.Type == HandlingActivityType.UNLOAD)
     {
         return(DeriveFromNextLeg(NextLeg(matchingLeg)));
     }
     else
     {
         // Will only derive from load and unload within the itinerary context
         return(null);
     }
 }