Example #1
0
        protected void setUp()
        {
            pacific = new Voyage.Builder(new VoyageNumber("4567"), L.SHANGHAI)
                .addMovement(L.LONGBEACH, new DateTime(1), new DateTime(2))
                .build();

            transcontinental = new Voyage.Builder(new VoyageNumber("4567"), L.LONGBEACH)
                .addMovement(L.CHICAGO, new DateTime(1), new DateTime(2))
                .addMovement(L.NEWYORK, new DateTime(3), new DateTime(4))
                .build();

            atlantic = new Voyage.Builder(new VoyageNumber("4556"), L.NEWYORK)
                .addMovement(L.ROTTERDAM, new DateTime(1), new DateTime(2))
                .addMovement(L.GOTHENBURG, new DateTime(3), new DateTime(4))
                .build();

            voyage = new Voyage.Builder(new VoyageNumber("0123"), L.SHANGHAI)
                .addMovement(L.ROTTERDAM, new DateTime(1), new DateTime(2))
                .addMovement(L.GOTHENBURG, new DateTime(3), new DateTime(4))
                .build();

            wrongVoyage = new Voyage.Builder(new VoyageNumber("666"), L.NEWYORK)
                .addMovement(L.STOCKHOLM, new DateTime(1), new DateTime(2))
                .addMovement(L.HELSINKI, new DateTime(3), new DateTime(4))
                .build();
         }
Example #2
0
 /// <summary>
 /// Creates new leg instance.
 /// </summary>
 /// <param name="voyage">Voyage</param>
 /// <param name="loadLocation">Location where cargo is supposed to be loaded.</param>
 /// <param name="loadDate">Date and time when cargo is supposed to be loaded</param>
 /// <param name="unloadLocation">Location where cargo is supposed to be unloaded.</param>
 /// <param name="unloadDate">Date and time when cargo is supposed to be unloaded.</param>
 public Leg(Voyage.Voyage voyage, Location.Location loadLocation, DateTime loadDate, Location.Location unloadLocation, DateTime unloadDate)
 {
    _loadLocation = loadLocation;
    _voyage = voyage;
    _unloadDate = unloadDate;
    _unloadLocation = unloadLocation;
    _loadDate = loadDate;
 }
 public IEnumerable<Cargo> findCargosOnVoyage(Voyage voyage)
 {
     return sessionFactory.GetCurrentSession().CreateQuery(
       "select cargo from Cargo as cargo " +
         "left join cargo.Itinerary.Legs as leg " +
         "where leg.Voyage = :voyage").
       SetParameter("voyage", voyage).
       List<Cargo>();
 }
        protected void SetUp()
        {
            events = new List<HandlingEvent>();

            voyage = new Voyage.Builder(new VoyageNumber("0123"), SampleLocations.STOCKHOLM).
                AddMovement(SampleLocations.HAMBURG, DateTime.Now, DateTime.Now).
                AddMovement(SampleLocations.HONGKONG, DateTime.Now, DateTime.Now).
                AddMovement(SampleLocations.MELBOURNE, DateTime.Now, DateTime.Now).
                Build();
        }
		/// <summary>
		/// Creates an instance of <see cref="HandlingActivity"/> from the handling event type and the location.
		/// </summary>
		/// <param name="eventType">The handling event type.</param>
		/// <param name="location">The location where the handling is done.</param>
		/// <param name="voyage"></param>
		public HandlingActivity(HandlingEventType eventType, Location.Location location, Voyage.Voyage voyage)
		{
			if (location == null)
				throw new ArgumentNullException("location");
			if (voyage == null)
				throw new ArgumentNullException("voyage");

			_eventType = eventType;
			_location = location;
			_voyage = voyage;
		}
        protected void SetUp()
        {
            voyage = new Voyage.Builder(new VoyageNumber("0123"), SampleLocations.SHANGHAI).
                AddMovement(SampleLocations.ROTTERDAM, dateTime, dateTime).
                AddMovement(SampleLocations.GOTHENBURG, dateTime, dateTime).
                Build();

            wrongVoyage = new Voyage.Builder(new VoyageNumber("666"), SampleLocations.NEWYORK).
                AddMovement(SampleLocations.STOCKHOLM, dateTime, dateTime).
                AddMovement(SampleLocations.HELSINKI, dateTime, dateTime).
                Build();
        }
        public IEnumerable<Cargo> findCargosOnVoyage(Voyage voyage)
        {
            var onVoyage = new List<Cargo>();
            foreach(Cargo cargo in cargoDb.Values)
            {
                if(voyage.sameAs(cargo.CurrentVoyage))
                {
                    onVoyage.Add(cargo);
                }
            }

            return onVoyage;
        }
        protected void SetUp()
        {
            cargo = new Cargo(new TrackingId("ABC"), new RouteSpecification(SampleLocations.SHANGHAI, SampleLocations.DALLAS, DateTime.Parse("2009-04-01")));
            voyage = new Voyage.Builder(new VoyageNumber("X25"), SampleLocations.HONGKONG).
              AddMovement(SampleLocations.SHANGHAI, new DateTime(), new DateTime()).
              AddMovement(SampleLocations.DALLAS, new DateTime(), new DateTime()).
              Build();
            event1 = new HandlingEvent(cargo, DateTime.Parse("2009-03-05"), new DateTime(100), HandlingType.LOAD, SampleLocations.SHANGHAI, voyage);
            event1duplicate = new HandlingEvent(cargo, DateTime.Parse("2009-03-05"), new DateTime(200), HandlingType.LOAD, SampleLocations.SHANGHAI, voyage);
            event2 = new HandlingEvent(cargo, DateTime.Parse("2009-03-10"), new DateTime(150), HandlingType.UNLOAD, SampleLocations.DALLAS, voyage);

            handlingHistory = new HandlingHistory(new List<HandlingEvent>{event2, event1, event1duplicate});
        }
        private void AssertHandlingEvent(Cargo cargo, HandlingEvent evnt, HandlingType expectedEventType,
                                         Location expectedLocation, int completionTimeMs, int registrationTimeMs,
                                         Voyage voyage)
        {
            Assert.AreEqual(expectedEventType, evnt.Type);
            Assert.AreEqual(expectedLocation, evnt.Location);

            DateTime expectedCompletionTime = SampleDataGenerator.Offset(completionTimeMs);
            Assert.AreEqual(expectedCompletionTime, evnt.CompletionTime);

            DateTime expectedRegistrationTime = SampleDataGenerator.Offset(registrationTimeMs);
            Assert.AreEqual(expectedRegistrationTime, evnt.RegistrationTime);

            Assert.AreEqual(voyage, evnt.Voyage);
            Assert.AreEqual(cargo, evnt.Cargo);
        }
Example #10
0
        public Offhire CreateOffhire(
            long referenceNumber,
            DateTime startDateTime,
            DateTime endDateTime,
            Company introducer,
            VesselInCompany vesselInCompany,
            Voyage voyage,
            ActivityLocation offhireLocation,
            DateTime voucherDate,
            Currency voucherCurrency)
        {
            var offhire = new Offhire(
                referenceNumber,
                startDateTime,
                endDateTime,
                introducer,
                vesselInCompany,
                voyage,
                offhireLocation,
                voucherDate,
                voucherCurrency,
                this.offhireDomainService,
                this.offhireManagementSystemDomainService,
                this.vesselDomainService,
                this.voyageDomainService,
                this.companyDomainService,
                this.activityLocationDomainService,
                this.currencyDomainService);

            var init = this.workflowRepository.Single(c => c.WorkflowEntity == WorkflowEntities.Offhire && c.CurrentWorkflowStage == WorkflowStages.Initial);
            if (init == null)
                throw new ObjectNotFound("OffhireInitialStep");

            var offhireWorkflow = new OffhireWorkflowLog(offhire, WorkflowEntities.Offhire, DateTime.Now, WorkflowActions.Init,
                //TODO: Fake ActorId
                    1101, "", init.Id, true);

            offhire.ApproveWorkflows.Add(offhireWorkflow);

            offhireConfigurator.Configure(offhire);

            return offhire;
        }
Example #11
0
		/// <summary>
		/// Creates new leg instance.
		/// </summary>
		/// <param name="voyage"></param>
		/// <param name="loadLocation">Location where cargo is supposed to be loaded.</param>
		/// <param name="loadDate">Date and time when cargo is supposed to be loaded.</param>
		/// <param name="unloadLocation">Location where cargo is supposed to be unloaded.</param>
		/// <param name="unloadDate">Date and time when cargo is supposed to be unloaded.</param>
		public Leg(Voyage.Voyage voyage, Location.Location loadLocation, DateTime loadDate, Location.Location unloadLocation, DateTime unloadDate)
		{
			if (voyage == null)
				throw new ArgumentNullException("voyage", "The voyage cannot be null");
			if (loadLocation == null)
				throw new ArgumentNullException("loadLocation", "The load location cannot be null");
			if (unloadLocation == null)
				throw new ArgumentNullException("unloadLocation", "The unload location cannot be null");
			if (loadDate == default(DateTime))
				throw new ArgumentException("The load date is not correct.", "loadDate");
			if (unloadDate == default(DateTime))
				throw new ArgumentException("The unloadDate date is not correct.", "unloadDate");

			_voyage = voyage;
			_loadLocation = loadLocation;
			_unloadDate = unloadDate;
			_unloadLocation = unloadLocation;
			_loadDate = loadDate;
		}
        public void setupCargo()
        {
            TrackingIdFactoryInMem trackingIdFactory = new TrackingIdFactoryInMem();

            // Creating new voyages to avoid rescheduling shared ones, breaking other tests
            voyage1 = new Voyage(new VoyageNumber("V1"), V.HONGKONG_TO_NEW_YORK.Schedule);
            voyage2 = new Voyage(new VoyageNumber("V2"), V.NEW_YORK_TO_DALLAS.Schedule);
            voyage3 = new Voyage(new VoyageNumber("V3"), V.DALLAS_TO_HELSINKI.Schedule);

            TrackingId trackingId = trackingIdFactory.nextTrackingId();
            RouteSpecification routeSpecification = new RouteSpecification(L.HANGZOU,
                L.STOCKHOLM,
                DateTime.Parse("2008-12-23"));

            cargo = new Cargo(trackingId, routeSpecification);
            Itinerary itinerary = new Itinerary(Leg.DeriveLeg(voyage1, L.HANGZOU, L.NEWYORK),
                Leg.DeriveLeg(voyage2, L.NEWYORK, L.DALLAS),
                Leg.DeriveLeg(voyage3, L.DALLAS, L.STOCKHOLM));
            cargo.AssignToRoute(itinerary);
        }
Example #13
0
        /// <summary>
        /// retrieves brand detail
        /// </summary>
        /// <param name="voyage">brand attribute</param>
        /// <returns>Brand entity</returns>
        private static Voyage MapAsync(Entities.Voyage voyage)
        {
            var voyageData = new Voyage();
            voyageData.DebarkDate = voyage.DebarkDate;
            voyageData.Name = voyage.Name;
            voyageData.DebarkPortId = voyage.DebarkPortId;
            voyageData.DestinationId = voyage.DestinationId;
            voyageData.EmbarkDate = voyage.EmbarkDate;
            voyageData.EmbarkPortId = voyage.EmbarkPortId;
            voyageData.IsActive = voyage.IsActive;
            voyageData.AssignItineraries(voyage.Itineraries);
            voyageData.Nights = voyage.Nights;
            voyageData.Number = voyage.Number;
            voyageData.ShipId = voyage.ShipId;
            voyageData.VoyageId = voyage.VoyageId;
            var mediaItems = voyage.MediaItems.FirstOrDefault();
            voyageData.MediaItemAddress = mediaItems != null ? mediaItems.MediaItemAddress : string.Empty;

            return voyageData;
        }
        protected void setUp()
        {
            cargo = new Cargo(new TrackingId("ABC"),
                new RouteSpecification(L.SHANGHAI, L.DALLAS, DateTime.Parse("2009-04-01")));
            cargo2 = new Cargo(new TrackingId("DEF"),
                new RouteSpecification(L.SHANGHAI, L.NEWYORK, DateTime.Parse("2009-04-15")));

            voyage =
                new Voyage.Builder(new VoyageNumber("X25"), L.HONGKONG).addMovement(L.SHANGHAI,
                    new DateTime(1),
                    new DateTime(2)).addMovement(L.DALLAS, new DateTime(3), new DateTime(4)).build();
            event1 = new HandlingEvent(cargo,
                DateTime.Parse("2009-03-05"),
                DateTime.Parse("2009-03-05"),
                HandlingActivityType.LOAD,
                L.SHANGHAI,
                voyage,
                new OperatorCode("ABCDE"));
            event1duplicate = new HandlingEvent(cargo,
                DateTime.Parse("2009-03-05"),
                DateTime.Parse("2009-03-07"),
                HandlingActivityType.LOAD,
                L.SHANGHAI,
                voyage,
                new OperatorCode("ABCDE"));
            event2 = new HandlingEvent(cargo,
                DateTime.Parse("2009-03-10"),
                DateTime.Parse("2009-03-06"),
                HandlingActivityType.UNLOAD,
                L.DALLAS,
                voyage,
                new OperatorCode("ABCDE"));
            eventOfCargo2 = new HandlingEvent(cargo2,
                DateTime.Parse("2009-03-11"),
                DateTime.Parse("2009-03-08"),
                HandlingActivityType.LOAD,
                L.GOTHENBURG,
                voyage,
                new OperatorCode("ABCDE"));
        }
		/// <summary>
		/// Creates new event.
		/// </summary>
		/// <param name="eventType">Type of the event.</param>
		/// <param name="location">The location where the event took place.</param>
		/// <param name="registrationDate">Registration time, the time the message is received.</param>
		/// <param name="completionDate">Completion time, the reported time that the event actually happened (e.g. the receive took place).</param>
		/// <param name="cargo">Cargo.</param>
		/// <param name="voyage">The voyage.</param>
		public HandlingEvent(HandlingEventType eventType, Location.Location location, DateTime registrationDate, DateTime completionDate, Cargo.Cargo cargo, Voyage.Voyage voyage)
		{
			if (cargo == null)
				throw new ArgumentNullException("cargo", "Cargo is required.");
			if (location == null)
				throw new ArgumentNullException("location", "Location is required.");
			if (voyage == null)
				throw new ArgumentNullException("voyage", "Voyage is required.");
			if (registrationDate == default(DateTime))
				throw new ArgumentException("The registration date is required.", "registrationDate");
			if (completionDate == default(DateTime))
				throw new ArgumentException("The completion date is required.", "completionDate");

			if (eventType.ProhibitsVoyage())
				throw new ArgumentException("Voyage is not allowed with event type : " + eventType, "eventType");

			_eventType = eventType;
			_completionDate = completionDate;
			_registrationDate = registrationDate;
			_location = location;
			_cargo = cargo;
			_voyage = voyage;
		}
        /// <summary>
        /// Maps the voyage data.
        /// </summary>
        /// <param name="voyageData">The voyage data.</param>
        /// <returns>voyage data</returns>
        private async Task<ICollection<Voyage>> MapVoyageData(ICollection<Voyage> voyageData)
        {
            var portData = new ListResult<Port>();
            string portIds = string.Empty;

            foreach (var voyages in voyageData)
            {
                if (voyages.Itineraries != null && voyages.Itineraries.Count > 0)
                {
                    foreach (var itenarary in voyages.Itineraries)
                    {
                        if (!string.IsNullOrEmpty(itenarary.PortId))
                        {
                            portIds += itenarary.PortId + CommaSeparator;
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(portIds))
            {
                portData = await this.referenceDataRepository.ListPortAsync(portIds.Substring(0, portIds.Length - 1));
            }

            if (portData == null || portData.Items.Count == 0)
            {
                return voyageData;
            }

            var voyageResult = new List<Voyage>();

            foreach (var voyages in voyageData)
            {
                var voyage = new Voyage();
                voyage.EmbarkDate = voyages.EmbarkDate;
                voyage.IsActive = voyages.IsActive;
                voyage.Name = voyages.Name;
                voyage.Number = voyages.Number;
                voyage.VoyageId = voyages.VoyageId;
                foreach (var itenarary in voyages.Itineraries)
                {
                    var port = portData.Items.FirstOrDefault(item => item.PortId == itenarary.PortId);
                    if (port != null && !itenarary.IsSeaDay)
                    {
                        itenarary.PortName = port.Name;
                        voyage.Itineraries.Add(itenarary);
                    }
                }

                voyageResult.Add(voyage);
            }

            return voyageResult;
        }
Example #17
0
 /// <summary>
 /// Отображение рейса текущего поезда для дальнейшего редактирования
 /// </summary>
 /// <param name="window"></param>
 private void EditVoyage(TrainInfoWindow window)
 {
     if (_trainToEdit == null || String.IsNullOrEmpty(TrainNum)) return;
     var voyage = VoyageBuilder.GetVoyageOfTrain(_trainToEdit.Id);
     if (voyage == null)
     {
         var newVoyage = new Voyage();
         newVoyage.DepartureDateTime = DateTime.Now;
         newVoyage.TrainId = _trainToEdit.Id;
         ContextKeeper.Voyages.Add(newVoyage);         
     }
     var voyageEditWin = new VoyageEditWindow();
     voyageEditWin.Show();
     Messenger.Default.Send(new TrainOfVoyageMessage(_trainToEdit.Id));
     window.Close();
 }
Example #18
0
        private void SetVoyageInfo(int trainId)
        {
            this._voyage = VoyageBuilder.GetVoyageOfTrain(trainId);
            this.TrainNum = "Номер поезда: " + ContextKeeper.Trains
                .Where(train => train.Id == trainId)
                .Select(train => train.TrainNum)
                .First();
            if (this._voyage.Periodicity == null)
            {
                this.Periodicity = "0";
            }
            else
            {
                this.Periodicity = (this._voyage.Periodicity - 1).ToString();
            }

            if (this.Periodicity == null) this.Periodicity = 0.ToString();
            this.DepartureDate = (DateTime)this._voyage.DepartureDateTime.Value.Date;
            this.DepartureOffset = this.DepartureDate;
            this.ArrivalOffset = this.DepartureDate;
            RefreshRoutesOfVoyage();
        }