当前位置: 首页>>代码示例>>C#>>正文


C# Cargo.AssignToRoute方法代码示例

本文整理汇总了C#中Cargo.AssignToRoute方法的典型用法代码示例。如果您正苦于以下问题:C# Cargo.AssignToRoute方法的具体用法?C# Cargo.AssignToRoute怎么用?C# Cargo.AssignToRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cargo的用法示例。


在下文中一共展示了Cargo.AssignToRoute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: toCargoRoutingDTO

        public void toCargoRoutingDTO()
        {
            var origin = L.HONGKONG;
            var destination = L.LONGBEACH;
            var cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(origin, destination, DateTime.Now));

            var itinerary = new Itinerary(
                Leg.DeriveLeg(SampleVoyages.pacific1, L.HONGKONG, L.TOKYO),
                Leg.DeriveLeg(SampleVoyages.pacific1, L.TOKYO, L.LONGBEACH)
                );

            cargo.AssignToRoute(itinerary);

            var dto = DTOAssembler.toDTO(cargo);

            Assert.AreEqual(2, dto.getLegs().Count());

            LegDTO legDTO = dto.getLegs().ElementAt(0);
            Assert.AreEqual("PAC1", legDTO.getVoyageNumber());
            Assert.AreEqual("CNHKG", legDTO.getFrom());
            Assert.AreEqual("JNTKO", legDTO.getTo());

            legDTO = dto.getLegs().ElementAt(1);
            Assert.AreEqual("PAC1", legDTO.getVoyageNumber());
            Assert.AreEqual("JNTKO", legDTO.getFrom());
            Assert.AreEqual("USLBG", legDTO.getTo());
        }
开发者ID:awhatley,项目名称:dddsample.net,代码行数:27,代码来源:DTOAssemblerTest.cs

示例2: testRoutingStatus

        public void testRoutingStatus()
        {
            Cargo cargo = new Cargo(new TrackingId("XYZ"),
                new RouteSpecification(L.STOCKHOLM, L.MELBOURNE, DateTime.Now));
            Itinerary good = new Itinerary(Leg.DeriveLeg(northernRail, L.SEATTLE, L.NEWYORK));
            Itinerary bad = new Itinerary(Leg.DeriveLeg(crazyVoyage, L.HAMBURG, L.HONGKONG));
            RouteSpecification acceptOnlyGood = new RouteSpecification(L.SEATTLE, L.NEWYORK, DateTime.Now);

            cargo.SpecifyNewRoute(acceptOnlyGood);
            Assert.AreEqual(RoutingStatus.NOT_ROUTED, cargo.RoutingStatus);

            cargo.AssignToRoute(bad);
            Assert.AreEqual(RoutingStatus.MISROUTED, cargo.RoutingStatus);

            cargo.AssignToRoute(good);
            Assert.AreEqual(RoutingStatus.ROUTED, cargo.RoutingStatus);
        }
开发者ID:awhatley,项目名称:dddsample.net,代码行数:17,代码来源:CargoTest.cs

示例3: TestRoutingStatus

        public void TestRoutingStatus()
        {       
            Cargo cargo = new Cargo(new TrackingId("XYZ"),
                                    new RouteSpecification(SampleLocations.STOCKHOLM, SampleLocations.MELBOURNE,
                                                           DateTime.Now));
            var good = new Itinerary();
            var bad = new Itinerary();

            RouteSpecification acceptOnlyGood = new RouteSpecificationStub(cargo.Origin,
                                                                           cargo.RouteSpecification.Destination,
                                                                           DateTime.Now, good);             
            cargo.SpecifyNewRoute(acceptOnlyGood);

            Assert.AreEqual(RoutingStatus.NOT_ROUTED, cargo.Delivery.RoutingStatus);

            cargo.AssignToRoute(bad);
            Assert.AreEqual(RoutingStatus.MISROUTED, cargo.Delivery.RoutingStatus);

            cargo.AssignToRoute(good);
            Assert.AreEqual(RoutingStatus.ROUTED, cargo.Delivery.RoutingStatus);
        }
开发者ID:colourblendcreative,项目名称:ndddsample,代码行数:21,代码来源:CargoTest.cs

示例4: setupCargo

        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);
        }
开发者ID:awhatley,项目名称:dddsample.net,代码行数:20,代码来源:VoyageRescheduledScenarioTest.cs

示例5: setUpCargoWithItinerary

        private Cargo setUpCargoWithItinerary(Location origin, Location midpoint, Location destination)
        {
            Cargo cargo = new Cargo(new TrackingId("CARGO1"), new RouteSpecification(origin, destination, DateTime.Now));

            Itinerary itinerary = new Itinerary(Leg.DeriveLeg(crazyVoyage, origin, midpoint),
                Leg.DeriveLeg(crazyVoyage, midpoint, destination));

            cargo.AssignToRoute(itinerary);
            return cargo;
        }
开发者ID:awhatley,项目名称:dddsample.net,代码行数:10,代码来源:CargoTest.cs

示例6: shanghaiSeattleChicagoOnPacific2AndContinental3

        private Cargo shanghaiSeattleChicagoOnPacific2AndContinental3()
        {
            Cargo cargo = new Cargo(new TrackingId("CARGO1"),
                new RouteSpecification(L.SHANGHAI, L.CHICAGO, DateTime.Parse("2009-12-24")));

            // A cargo with no itinerary is not misdirected
            Assert.IsFalse(cargo.IsMisdirected);

            Itinerary itinerary = new Itinerary(Leg.DeriveLeg(V.pacific2, L.SHANGHAI, L.SEATTLE),
                Leg.DeriveLeg(V.continental3, L.SEATTLE, L.CHICAGO));
            cargo.AssignToRoute(itinerary);
            return cargo;
        }
开发者ID:awhatley,项目名称:dddsample.net,代码行数:13,代码来源:CargoTest.cs

示例7: testCustomsClearancePoint

        public void testCustomsClearancePoint()
        {
            //cargo destination NYC
            Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(L.SHANGHAI, L.NEWYORK, DateTime.Now));

            Assert.That(cargo.CustomsClearancePoint, Is.EqualTo(Location.None));

            //SHA-LGB-NYC
            cargo.AssignToRoute(new Itinerary(Leg.DeriveLeg(pacific, L.SHANGHAI, L.LONGBEACH),
                Leg.DeriveLeg(transcontinental, L.LONGBEACH, L.NEWYORK)));
            Assert.AreEqual(L.LONGBEACH, cargo.CustomsClearancePoint);

            //SHA-SEA-NYC
            cargo.AssignToRoute(new Itinerary(Leg.DeriveLeg(pacific, L.SHANGHAI, L.SEATTLE),
                Leg.DeriveLeg(northernRail, L.SEATTLE, L.NEWYORK)));
            Assert.AreEqual(L.SEATTLE, cargo.CustomsClearancePoint);

            //cargo destination LGB
            //SHA-LGB
            cargo.SpecifyNewRoute(new RouteSpecification(L.SHANGHAI, L.LONGBEACH, DateTime.Now));
            cargo.AssignToRoute(new Itinerary(Leg.DeriveLeg(pacific, L.SHANGHAI, L.LONGBEACH)));
            Assert.AreEqual(L.LONGBEACH, cargo.CustomsClearancePoint);

            //Cargo destination HAMBURG
            //SHA-LGB-NYC This itinerary does not take
            // the cargo into its CustomsZone, so no clearancePoint.
            cargo.SpecifyNewRoute(new RouteSpecification(L.SHANGHAI, L.HAMBURG, DateTime.Now));
            cargo.AssignToRoute(new Itinerary(Leg.DeriveLeg(pacific, L.SHANGHAI, L.LONGBEACH),
                Leg.DeriveLeg(transcontinental, L.LONGBEACH, L.NEWYORK)));
            Assert.IsNull(cargo.CustomsClearancePoint);

            //Cargo destination NEWYORK on SHA-LGB-CHI
            //This itinerary does not take the cargo to its destination,
            //but it does enter the CustomsZone, so it has a clearancePoint.
            cargo.SpecifyNewRoute(new RouteSpecification(L.SHANGHAI, L.NEWYORK, DateTime.Now));
            cargo.AssignToRoute(new Itinerary(Leg.DeriveLeg(pacific, L.SHANGHAI, L.LONGBEACH),
                Leg.DeriveLeg(transcontinental, L.LONGBEACH, L.CHICAGO)));
            Assert.AreEqual(L.LONGBEACH, cargo.CustomsClearancePoint);
        }
开发者ID:awhatley,项目名称:dddsample.net,代码行数:39,代码来源:CargoTest.cs

示例8: testIsReadyToClaimWithDestinationSameAsCustomsClearancePoint

        public void testIsReadyToClaimWithDestinationSameAsCustomsClearancePoint()
        {
            Cargo cargo = new Cargo(new TrackingId("CARGO1"),
                new RouteSpecification(L.SHANGHAI, L.SEATTLE, DateTime.Parse("2009-12-24")));
            Itinerary itinerary = new Itinerary(Leg.DeriveLeg(V.pacific2, L.SHANGHAI, L.SEATTLE));
            cargo.AssignToRoute(itinerary);
            Assert.IsTrue(cargo.RouteSpecification.Destination.sameAs(cargo.CustomsClearancePoint));
            Assert.IsFalse(cargo.IsReadyToClaim);

            cargo.Handled(HandlingActivity.UnloadOff(V.pacific2).In(L.SEATTLE));
            Assert.IsFalse(cargo.IsReadyToClaim);

            cargo.Handled(HandlingActivity.CustomsIn(L.SEATTLE));
            Assert.IsTrue(cargo.IsReadyToClaim);

            cargo.Handled(HandlingActivity.ClaimIn(L.SEATTLE));
            Assert.IsFalse(cargo.IsReadyToClaim);
        }
开发者ID:awhatley,项目名称:dddsample.net,代码行数:18,代码来源:CargoTest.cs

示例9: testIsReadyToClaimWithDestinationDifferentFromCustomsClearancePoint

        public void testIsReadyToClaimWithDestinationDifferentFromCustomsClearancePoint()
        {
            Cargo cargo = new Cargo(new TrackingId("CARGO1"),
                new RouteSpecification(L.HONGKONG, L.NEWYORK, DateTime.Parse("2009-12-24")));
            Itinerary itinerary = new Itinerary(Leg.DeriveLeg(V.pacific1, L.HONGKONG, L.LONGBEACH),
                Leg.DeriveLeg(V.continental2, L.LONGBEACH, L.NEWYORK));
            cargo.AssignToRoute(itinerary);
            Assert.IsFalse(cargo.RouteSpecification.Destination.sameAs(cargo.CustomsClearancePoint));
            Assert.IsFalse(cargo.IsReadyToClaim);

            cargo.Handled(HandlingActivity.UnloadOff(V.pacific1).In(L.LONGBEACH));
            Assert.IsFalse(cargo.IsReadyToClaim);

            cargo.Handled(HandlingActivity.LoadOnto(V.continental2).In(L.LONGBEACH));
            Assert.IsFalse(cargo.IsReadyToClaim);

            cargo.Handled(HandlingActivity.UnloadOff(V.continental2).In(L.NEWYORK));
            Assert.IsTrue(cargo.IsReadyToClaim);
        }
开发者ID:awhatley,项目名称:dddsample.net,代码行数:19,代码来源:CargoTest.cs

示例10: Save

        public void Save()
        {
            //TODO: atrosin make the method transactional because it modifies data
            TrackingId trackingId = new TrackingId("AAA");
            Location origin = locationRepository.Find(SampleLocations.STOCKHOLM.UnLocode);
            Location destination = locationRepository.Find(SampleLocations.MELBOURNE.UnLocode);

            Cargo cargo = new Cargo(trackingId, new RouteSpecification(origin, destination, new DateTime()));
            cargoRepository.Store(cargo);

            cargo.AssignToRoute(new Itinerary(
                                    new List<Leg>
                                        {
                                            new Leg(
                                                voyageRepository.Find(new VoyageNumber("0101")),
                                                locationRepository.Find(SampleLocations.STOCKHOLM.UnLocode),
                                                locationRepository.Find(SampleLocations.MELBOURNE.UnLocode),
                                                new DateTime(), new DateTime())
                                        }));

            Flush();

            IList cargoListFromDb = GetPlainCargoListFromDbByTrackId(trackingId);

            Assert.AreEqual("AAA", cargoListFromDb[0] /*TRACKING_ID*/);

            int originId = GetIntId(origin);
            Assert.AreEqual(originId, cargoListFromDb[1] /*SPEC_ORIGIN_ID*/);

            int destinationId = GetIntId(destination);
            Assert.AreEqual(destinationId, cargoListFromDb[2] /*SPEC_DESTINATION_ID*/);

            UnitOfWork.CurrentSession.Clear();

            Cargo loadedCargo = cargoRepository.Find(trackingId);
            Assert.AreEqual(1, loadedCargo.Itinerary.Legs.Count);
        }
开发者ID:chandmk,项目名称:esddd,代码行数:37,代码来源:CargoRepositoryTest.cs

示例11: SetUpCargoWithItinerary

        private Cargo SetUpCargoWithItinerary(Location origin, Location midpoint, Location destination)
        {
            var cargo = new Cargo(new TrackingId("CARGO1"), new RouteSpecification(origin, destination, DateTime.Now));

            var itinerary = new Itinerary(
                new List<Leg>
                    {
                        new Leg(voyage, origin, midpoint, DateTime.Now, DateTime.Now),
                        new Leg(voyage, midpoint, destination, DateTime.Now, DateTime.Now)
                    });

            cargo.AssignToRoute(itinerary);
            return cargo;
        }
开发者ID:colourblendcreative,项目名称:ndddsample,代码行数:14,代码来源:CargoTest.cs

示例12: testSave

        public void testSave()
        {
            TrackingId trackingId = new TrackingId("AAA");
            Location origin = locationRepository.find(SampleLocations.STOCKHOLM.UnLocode);
            Location destination = locationRepository.find(SampleLocations.MELBOURNE.UnLocode);

            Cargo cargo = new Cargo(trackingId, new RouteSpecification(origin, destination, DateTime.Now));
            cargoRepository.store(cargo);

            getSession().Flush();
            getSession().Clear();

            cargo = cargoRepository.find(trackingId);
            Assert.IsNull(cargo.Itinerary);

            cargo.AssignToRoute(
                new Itinerary(Leg.DeriveLeg(voyageRepository.find(new VoyageNumber("0101")),
                    locationRepository.find(SampleLocations.STOCKHOLM.UnLocode),
                    locationRepository.find(SampleLocations.MELBOURNE.UnLocode))));

            flush();

            var map = GenericTemplate.QueryForObjectDelegate(CommandType.Text,
                String.Format("select * from Cargo where tracking_id = '{0}'", trackingId.Value),
                (r, i) => new {TRACKING_ID = r["TRACKING_ID"]});

            Assert.AreEqual("AAA", map.TRACKING_ID);

            long originId = (long) getSession().GetIdentifier(cargo);
            //Assert.AreEqual(originId, map.get("SPEC_ORIGIN_ID"));

            long destinationId = (long) getSession().GetIdentifier(cargo);
            //Assert.AreEqual(destinationId, map.get("SPEC_DESTINATION_ID"));

            getSession().Clear();

            Cargo loadedCargo = cargoRepository.find(trackingId);
            Assert.AreEqual(1, loadedCargo.Itinerary.Legs.Count());
        }
开发者ID:awhatley,项目名称:dddsample.net,代码行数:39,代码来源:CargoRepositoryTest.cs

示例13: LoadHibernateData

        //TODO:atrosin Revise where and how is used the method
        public static void LoadHibernateData(ISession session, HandlingEventFactory handlingEventFactory,
                                             IHandlingEventRepository handlingEventRepository)
        {
            Console.WriteLine("*** Loading Hibernate data ***");           

            foreach (Location location  in SampleLocations.GetAll())
            {
                session.Save(location);
            }

            foreach (Voyage voyage in SampleVoyages.GetAll())
            {
                session.Save(voyage);
            }

            /*session.Save(SampleVoyages.HONGKONG_TO_NEW_YORK);
            session.Save(SampleVoyages.NEW_YORK_TO_DALLAS);
            session.Save(SampleVoyages.DALLAS_TO_HELSINKI);
            session.Save(SampleVoyages.HELSINKI_TO_HONGKONG);
            session.Save(SampleVoyages.DALLAS_TO_HELSINKI_ALT);*/
             
            var routeSpecification = new RouteSpecification(SampleLocations.HONGKONG,
                                                            SampleLocations.HELSINKI,
                                                            DateUtil.ToDate("2009-03-15"));
            var trackingId = new TrackingId("ABC123");
            var abc123 = new Cargo(trackingId, routeSpecification);

            var itinerary = new Itinerary(
                new List<Leg>
                    {
                        new Leg(SampleVoyages.HONGKONG_TO_NEW_YORK, SampleLocations.HONGKONG, SampleLocations.NEWYORK,
                                DateUtil.ToDate("2009-03-02"), DateUtil.ToDate("2009-03-05")),
                        new Leg(SampleVoyages.NEW_YORK_TO_DALLAS, SampleLocations.NEWYORK, SampleLocations.DALLAS,
                                DateUtil.ToDate("2009-03-06"), DateUtil.ToDate("2009-03-08")),
                        new Leg(SampleVoyages.DALLAS_TO_HELSINKI, SampleLocations.DALLAS, SampleLocations.HELSINKI,
                                DateUtil.ToDate("2009-03-09"), DateUtil.ToDate("2009-03-12"))
                    });
            abc123.AssignToRoute(itinerary);

            session.Save(abc123);


            HandlingEvent event1 = handlingEventFactory.CreateHandlingEvent(
                new DateTime(), DateUtil.ToDate("2009-03-01"), trackingId, null, SampleLocations.HONGKONG.UnLocode,
                HandlingType.RECEIVE
                );
            session.Save(event1);

            HandlingEvent event2 = handlingEventFactory.CreateHandlingEvent(
                new DateTime(), DateUtil.ToDate("2009-03-02"), trackingId,
                SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber, SampleLocations.HONGKONG.UnLocode,
                HandlingType.LOAD
                );
            session.Save(event2);

            HandlingEvent event3 = handlingEventFactory.CreateHandlingEvent(
                new DateTime(), DateUtil.ToDate("2009-03-05"), trackingId,
                SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber, SampleLocations.NEWYORK.UnLocode,
                HandlingType.UNLOAD
                );
            session.Save(event3);


            HandlingHistory handlingHistory = handlingEventRepository.LookupHandlingHistoryOfCargo(trackingId);
            abc123.DeriveDeliveryProgress(handlingHistory);

            session.Update(abc123);

            // Cargo JKL567

            var routeSpecification1 = new RouteSpecification(SampleLocations.HANGZOU,
                                                             SampleLocations.STOCKHOLM,
                                                             DateUtil.ToDate("2009-03-18"));
            var trackingId1 = new TrackingId("JKL567");
            var jkl567 = new Cargo(trackingId1, routeSpecification1);

            var itinerary1 = new Itinerary(new List<Leg>
                                               {
                                                   new Leg(SampleVoyages.HONGKONG_TO_NEW_YORK,
                                                           SampleLocations.HANGZOU, SampleLocations.NEWYORK,
                                                           DateUtil.ToDate("2009-03-03"),
                                                           DateUtil.ToDate("2009-03-05")),
                                                   new Leg(SampleVoyages.NEW_YORK_TO_DALLAS,
                                                           SampleLocations.NEWYORK, SampleLocations.DALLAS,
                                                           DateUtil.ToDate("2009-03-06"),
                                                           DateUtil.ToDate("2009-03-08")),
                                                   new Leg(SampleVoyages.DALLAS_TO_HELSINKI,
                                                           SampleLocations.DALLAS, SampleLocations.STOCKHOLM,
                                                           DateUtil.ToDate("2009-03-09"),
                                                           DateUtil.ToDate("2009-03-11"))
                                               });
            jkl567.AssignToRoute(itinerary1);

            session.Save(jkl567);


            HandlingEvent event21 = handlingEventFactory.CreateHandlingEvent(
                new DateTime(), DateUtil.ToDate("2009-03-01"), trackingId1, null, SampleLocations.HANGZOU.UnLocode,
                HandlingType.RECEIVE);
//.........这里部分代码省略.........
开发者ID:colourblendcreative,项目名称:ndddsample,代码行数:101,代码来源:SampleDataGenerator.cs

示例14: LoadHibernateData

        public void LoadHibernateData()
        {
            var tt = new TransactionTemplate(transactionManager);
            tt.Execute(ts => {
                var session = SessionFactory.GetCurrentSession();

                foreach(var location in SampleLocations.getAll())
                {
                    session.Save(location);
                }

                session.Save(SampleVoyages.HONGKONG_TO_NEW_YORK);
                session.Save(SampleVoyages.NEW_YORK_TO_DALLAS);
                session.Save(SampleVoyages.DALLAS_TO_HELSINKI);
                session.Save(SampleVoyages.HELSINKI_TO_HONGKONG);
                session.Save(SampleVoyages.DALLAS_TO_HELSINKI_ALT);

                var routeSpecification = new RouteSpecification(
                    SampleLocations.HONGKONG,
                    SampleLocations.HELSINKI,
                    DateTime.Parse("2009-03-15"));
                var trackingId = new TrackingId("ABC123");
                var abc123 = new Cargo(trackingId, routeSpecification);

                var itinerary = new Itinerary(new[] {
                    Leg.DeriveLeg(SampleVoyages.HONGKONG_TO_NEW_YORK, SampleLocations.HONGKONG, SampleLocations.NEWYORK),
                    Leg.DeriveLeg(SampleVoyages.NEW_YORK_TO_DALLAS, SampleLocations.NEWYORK, SampleLocations.DALLAS),
                    Leg.DeriveLeg(SampleVoyages.DALLAS_TO_HELSINKI, SampleLocations.DALLAS, SampleLocations.HELSINKI),
                });

                abc123.AssignToRoute(itinerary);

                session.Save(abc123);

                var event01 = HandlingEventFactory.createHandlingEvent(
                    DateTime.Parse("2009-03-01"),
                    trackingId,
                    null,
                    SampleLocations.HONGKONG.UnLocode,
                    HandlingActivityType.RECEIVE,
                    new OperatorCode("ABCDE")
                    );
                session.Save(event01);

                var event02 = HandlingEventFactory.createHandlingEvent(
                    DateTime.Parse("2009-03-02"),
                    trackingId,
                    SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber,
                    SampleLocations.HONGKONG.UnLocode,
                    HandlingActivityType.LOAD,
                    new OperatorCode("ABCDE")
                    );
                session.Save(event02);

                var event03 = HandlingEventFactory.createHandlingEvent(
                    DateTime.Parse("2009-03-05"),
                    trackingId,
                    SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber,
                    SampleLocations.NEWYORK.UnLocode,
                    HandlingActivityType.UNLOAD,
                    new OperatorCode("ABCDE")
                    );
                session.Save(event03);

                var handlingEvent = HandlingEventRepository.mostRecentHandling(abc123);
                abc123.Handled(handlingEvent.Activity);
                session.Update(abc123);

                // Cargo JKL567

                var routeSpecification1 = new RouteSpecification(
                    SampleLocations.HANGZOU,
                    SampleLocations.STOCKHOLM,
                    DateTime.Parse("2009-03-18"));
                var trackingId1 = new TrackingId("JKL567");
                var jkl567 = new Cargo(trackingId1, routeSpecification1);

                var itinerary1 = new Itinerary(new[] {
                    Leg.DeriveLeg(SampleVoyages.HONGKONG_TO_NEW_YORK, SampleLocations.HANGZOU, SampleLocations.NEWYORK),
                    Leg.DeriveLeg(SampleVoyages.NEW_YORK_TO_DALLAS, SampleLocations.NEWYORK, SampleLocations.DALLAS),
                    Leg.DeriveLeg(SampleVoyages.DALLAS_TO_HELSINKI, SampleLocations.DALLAS, SampleLocations.STOCKHOLM),
                });
                jkl567.AssignToRoute(itinerary1);

                session.Save(jkl567);

                var event1 = HandlingEventFactory.createHandlingEvent(
                    DateTime.Parse("2009-03-01"),
                    trackingId1,
                    null,
                    SampleLocations.HANGZOU.UnLocode,
                    HandlingActivityType.RECEIVE,
                    new OperatorCode("ABCDE")
                    );
                session.Save(event1);

                var event2 = HandlingEventFactory.createHandlingEvent(
                    DateTime.Parse("2009-03-03"),
                    trackingId1,
                    SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber,
//.........这里部分代码省略.........
开发者ID:awhatley,项目名称:dddsample.net,代码行数:101,代码来源:PopulateDatabase.cs

示例15: LoadMongoData


//.........这里部分代码省略.........
            }
            var voyages = db.GetCollection<Location>("voyages");

            try
            {
                voyages.InsertBatch(SampleVoyages.GetAll(), mongoInsertOptions);
            }
            catch (WriteConcernException ex)
            {
            }

            var cargo = db.GetCollection<Cargo>("cargo");

            var routeSpecification = new RouteSpecification(SampleLocations.HONGKONG,
                                                            SampleLocations.HELSINKI,
                                                            DateUtil.ToDate("2009-03-15"));
            var trackingId = new TrackingId("ABC123");
            var abc123exists = new CargoRepositoryMongo(db).Find(trackingId) != null;
            var handlingEvents = db.GetCollection<HandlingEvent>("handlingEvents");
            if (!abc123exists)
            {
                var abc123 = new Cargo(trackingId, routeSpecification);
                var itinerary = new Itinerary(
                    new List<Leg>
                        {
                            new Leg(SampleVoyages.HONGKONG_TO_NEW_YORK, SampleLocations.HONGKONG,
                                    SampleLocations.NEWYORK,
                                    DateUtil.ToDate("2009-03-02"), DateUtil.ToDate("2009-03-05")),
                            new Leg(SampleVoyages.NEW_YORK_TO_DALLAS, SampleLocations.NEWYORK, SampleLocations.DALLAS,
                                    DateUtil.ToDate("2009-03-06"), DateUtil.ToDate("2009-03-08")),
                            new Leg(SampleVoyages.DALLAS_TO_HELSINKI, SampleLocations.DALLAS, SampleLocations.HELSINKI,
                                    DateUtil.ToDate("2009-03-09"), DateUtil.ToDate("2009-03-12"))
                        });
                abc123.AssignToRoute(itinerary);

                cargo.Insert(abc123);

                HandlingEvent event1 = handlingEventFactory.CreateHandlingEvent(
                    new DateTime(), DateUtil.ToDate("2009-03-01"), trackingId, null, SampleLocations.HONGKONG.UnLocode,
                    HandlingType.RECEIVE
                    );

                handlingEvents.Insert(event1);

                HandlingEvent event2 = handlingEventFactory.CreateHandlingEvent(
                    new DateTime(), DateUtil.ToDate("2009-03-02"), trackingId,
                    SampleVoyages.HONGKONG_TO_NEW_YORK.voyageNumber, SampleLocations.HONGKONG.UnLocode,
                    HandlingType.LOAD
                    );
                handlingEvents.Insert(event2);

                HandlingEvent event3 = handlingEventFactory.CreateHandlingEvent(
                    new DateTime(), DateUtil.ToDate("2009-03-05"), trackingId,
                    SampleVoyages.HONGKONG_TO_NEW_YORK.voyageNumber, SampleLocations.NEWYORK.UnLocode,
                    HandlingType.UNLOAD
                    );
                handlingEvents.Insert(event3);

                HandlingHistory handlingHistory = handlingEventRepository.LookupHandlingHistoryOfCargo(trackingId);
                abc123.DeriveDeliveryProgress(handlingHistory);
                cargo.Save(abc123);

            }

            var trackingId1 = new TrackingId("JKL567");
            var jkl567exists = new CargoRepositoryMongo(db).Find(trackingId) != null;
开发者ID:chandmk,项目名称:esddd,代码行数:67,代码来源:SampleDataGenerator.cs


注:本文中的Cargo.AssignToRoute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。