Пример #1
0
 public InPortCargo(CargoState previousState, UnLocode portLocation, DateTime arrivalDate)
     : base(previousState)
 {
     _lastKnownLocation = portLocation;
     _date          = arrivalDate;
     _customCleared = false;
 }
Пример #2
0
 protected Cargo(CargoState state)
 {
     if (null == state)
     {
         throw new ArgumentNullException("state");
     }
     CurrentState = state;
 }
Пример #3
0
        public override bool Equals(CargoState other)
        {
            InPortCargo cargo = other as InPortCargo;

            if (null != cargo && !_customCleared.Equals(cargo._customCleared))
            {
                return(false);
            }
            return(base.Equals(other));
        }
Пример #4
0
 public OnboardCarrierCargo(CargoState previousState, IVoyage voyage, DateTime loadDate)
     : base(previousState)
 {
     if (null == voyage)
     {
         throw new ArgumentNullException("voyage");
     }
     _voyage            = voyage.Number;
     _date              = loadDate;
     _lastKnownLocation = voyage.LastKnownLocation;
 }
Пример #5
0
 public ClaimedCargo(CargoState previousState, DateTime claimDate)
     : base(previousState)
 {
     if (previousState.RoutingStatus == RoutingStatus.Misrouted)
     {
         throw new ArgumentException(string.Format("Can not claim the misrouted cargo {0}.", Identifier));
     }
     if (previousState.RoutingStatus == RoutingStatus.NotRouted)
     {
         throw new ArgumentException(string.Format("Can not claim the cargo {0} since it is not routed.", Identifier));
     }
     if (previousState.TransportStatus != TransportStatus.InPort)
     {
         throw new ArgumentException(string.Format("Can not claim the cargo {0} since it is not yet in port.", Identifier));
     }
     if (!previousState.IsUnloadedAtDestination)
     {
         throw new ArgumentException(string.Format("Can not claim the cargo {0} since it is not yet been unloaded at destination.", Identifier));
     }
     _claimDate = claimDate;
 }
Пример #6
0
        public void AssignToRoute(IItinerary itinerary)
        {
            // Thread safe, lock free sincronization
            CargoState stateBeforeTransition;
            CargoState previousState = CurrentState;

            do
            {
                stateBeforeTransition = previousState;
                CargoState newValue = stateBeforeTransition.AssignToRoute(itinerary);
                previousState = Interlocked.CompareExchange <CargoState>(ref this.CurrentState, newValue, stateBeforeTransition);
            }while (previousState != stateBeforeTransition);

            if (!previousState.Equals(this.CurrentState))
            {
                ChangeEventArgs <IItinerary> args = new ChangeEventArgs <IItinerary>(previousState.Itinerary, CurrentState.Itinerary);

                EventHandler <ChangeEventArgs <IItinerary> > handler = ItineraryChanged;
                if (null != handler)
                {
                    handler(this, args);
                }
            }
        }
Пример #7
0
        public void SpecifyNewRoute(IRouteSpecification routeSpecification)
        {
            // Thread safe, lock free sincronization
            CargoState stateBeforeTransition;
            CargoState previousState = CurrentState;

            do
            {
                stateBeforeTransition = previousState;
                CargoState newValue = stateBeforeTransition.SpecifyNewRoute(routeSpecification);
                previousState = Interlocked.CompareExchange <CargoState>(ref this.CurrentState, newValue, stateBeforeTransition);
            }while (previousState != stateBeforeTransition);

            if (!previousState.Equals(this.CurrentState))
            {
                ChangeEventArgs <IRouteSpecification> args = new ChangeEventArgs <IRouteSpecification>(previousState.RouteSpecification, CurrentState.RouteSpecification);

                EventHandler <ChangeEventArgs <IRouteSpecification> > handler = NewRouteSpecified;
                if (null != handler)
                {
                    handler(this, args);
                }
            }
        }
Пример #8
0
        public void Unload(Voyage.IVoyage voyage, DateTime date)
        {
            // Thread safe, lock free sincronization
            CargoState stateBeforeTransition;
            CargoState previousState = CurrentState;

            do
            {
                stateBeforeTransition = previousState;
                CargoState newValue = stateBeforeTransition.Unload(voyage, date);
                previousState = Interlocked.CompareExchange <CargoState>(ref this.CurrentState, newValue, stateBeforeTransition);
            }while (previousState != stateBeforeTransition);

            if (!previousState.Equals(this.CurrentState))
            {
                HandlingEventArgs args = new HandlingEventArgs(CurrentState, CurrentState.CalculationDate);

                EventHandler <HandlingEventArgs> handler = Unloaded;
                if (null != handler)
                {
                    handler(this, args);
                }
            }
        }
Пример #9
0
 protected NewCargo(CargoState previousState, IItinerary newItinerary)
     : base(previousState, newItinerary)
 {
 }
Пример #10
0
 protected NewCargo(CargoState previousState, IRouteSpecification newRoute)
     : base(previousState, newRoute)
 {
 }