Beispiel #1
0
 private void _calcIsMishandled(Itinerary itinerary, HandlingEvent @event)
 {
     if (@event == null || itinerary == null)
     {
         IsMishandled = false;
     }
     else
     {
         IsMishandled = itinerary.IsExpected(@event);
     }
 }
Beispiel #2
0
 private void _calcIsUnloadedAtDestination(RouteSpecification routeSpec, HandlingEvent @event)
 {
     if (@event == null)
     {
         IsUnloadedAtDestination = false;
     }
     else
     {
         IsUnloadedAtDestination = routeSpec.Destination.Equals(@event.Location);
     }
 }
Beispiel #3
0
 private void _calcCurrentVoyage(HandlingEvent @event)
 {
     if (@event != null)
     {
         CurrentVoyage = @event.Voyage;
     }
     else
     {
         CurrentVoyage = null;
     }
 }
Beispiel #4
0
 private void _calcLastKnownLocation(HandlingEvent @event)
 {
     if (@event != null)
     {
         LastKnownLocation = @event.Location;
     }
     else
     {
         LastKnownLocation = null;
     }
 }
Beispiel #5
0
        public Delivery(
            RouteSpecification routeSpec,
            Itinerary itinerary,
            HandlingEvent lastHandlingEvent
            )
        {
            RouteSpec         = routeSpec ?? throw new ArgumentNullException(nameof(routeSpec));
            Itinerary         = itinerary;
            LastHandlingEvent = lastHandlingEvent;

            _calcTransportStatus(lastHandlingEvent);
            _calcLastKnownLocation(lastHandlingEvent);
            _calcCurrentVoyage(lastHandlingEvent);
            _calcNextExpectedHandlingActivity(routeSpec, itinerary, lastHandlingEvent);
            _calcIsUnloadedAtDestination(routeSpec, lastHandlingEvent);
            _calcRoutingStatus(routeSpec, itinerary);
            _calcIsMishandled(itinerary, lastHandlingEvent);
        }
Beispiel #6
0
        public bool IsExpected(HandlingEvent @event)
        {
            if (@event == null)
            {
                return(true);
            }

            // receive at the first leg's load location
            switch (@event.Type)
            {
            case HandlingType.Receive:
                return(this.FirstLoadLocation.Equals(@event.Location));

            case HandlingType.Load:
                foreach (var leg in Legs)
                {
                    if (leg.LoadLocation.Equals(@event.Location))
                    {
                        return(true);
                    }
                }
                return(false);

            case HandlingType.Unload:
                foreach (var leg in Legs)
                {
                    if (leg.UnloadLocation.Equals(@event.Location))
                    {
                        return(true);
                    }
                }
                return(false);

            case HandlingType.Claim:
            case HandlingType.Customs:
                return(this.LastUnloadLocation.Equals(@event.Location));
            }

            return(false);
        }
Beispiel #7
0
        // rehydration ctor
        public Cargo(TrackingId trackingId, RouteSpecification routeSpec, Itinerary itinerary, Delivery delivery, HandlingEvent lastHandlingEvent)
        {
            TrackingId        = trackingId;
            RouteSpec         = routeSpec;
            Itinerary         = itinerary;
            LastHandlingEvent = lastHandlingEvent;

            Delivery = new Delivery(RouteSpec, Itinerary, LastHandlingEvent);
        }
Beispiel #8
0
        private void _calcNextExpectedHandlingActivity(RouteSpecification routeSpec, Itinerary itinerary, HandlingEvent @event)
        {
            // can't derive next handling activity if there is no itinerary
            if (itinerary == null)
            {
                NextExpectedHandlingActivity = null;
                return;
            }

            // can't derive the next handling activity if the cargo is misrouted
            _calcRoutingStatus(routeSpec, itinerary);
            if (RoutingStatus == RoutingStatus.MisRouted)
            {
                NextExpectedHandlingActivity = null;
                return;
            }

            // no handling event so far; next one should be receive at itinerary's first leg unload location
            if (@event == null)
            {
                NextExpectedHandlingActivity = new HandlingActivity(HandlingType.Receive, itinerary.FirstLoadLocation, null);
                return;
            }

            switch (@event.Type)
            {
            // last handling event = received => next handling activity = load at itinerary's first leg unload location and voyage
            case HandlingType.Receive:

                NextExpectedHandlingActivity = new HandlingActivity(HandlingType.Load, itinerary.FirstLoadLocation, itinerary.FirstYoyage);

                return;

            // last handling event = load => next handling activity = unload at itinerary's next leg unload location
            case HandlingType.Load:
                var leg = itinerary.Of(@event.Location);

                NextExpectedHandlingActivity = new HandlingActivity(HandlingType.Unload, leg.UnloadLocation, leg.Voyage);

                return;

            // last handling event = unload => next handling activity =
            // a. load at itinerary's next leg load location and voyage, if that leg is not the final one
            // b. customs at itinerarys's final unload location
            case HandlingType.Unload:

                if (@event.Location.Equals(itinerary.LastUnloadLocation))
                {
                    NextExpectedHandlingActivity = new HandlingActivity(HandlingType.Customs, itinerary.LastUnloadLocation, null);
                    return;
                }

                var nextLeg = itinerary.NextOf(@event.Location);
                NextExpectedHandlingActivity = new HandlingActivity(HandlingType.Load, nextLeg.LoadLocation, nextLeg.Voyage);
                return;

            // last handling event = customs => next handling activity = claim
            case HandlingType.Customs:
                NextExpectedHandlingActivity = new HandlingActivity(HandlingType.Claim, itinerary.LastUnloadLocation, null);
                return;

            // last handling event = claim => next handling activity = none
            case HandlingType.Claim:
            default:
                NextExpectedHandlingActivity = null;
                return;
            }
        }