本文整理汇总了C#中Cargo.DeriveDeliveryProgress方法的典型用法代码示例。如果您正苦于以下问题:C# Cargo.DeriveDeliveryProgress方法的具体用法?C# Cargo.DeriveDeliveryProgress怎么用?C# Cargo.DeriveDeliveryProgress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cargo
的用法示例。
在下文中一共展示了Cargo.DeriveDeliveryProgress方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createCargoWithDeliveryHistory
public static Cargo createCargoWithDeliveryHistory(TrackingId trackingId,
Location origin,
Location destination,
HandlingHistory handlingHistory)
{
RouteSpecification routeSpecification = new RouteSpecification(origin, destination, new DateTime());
Cargo cargo = new Cargo(trackingId, routeSpecification);
cargo.DeriveDeliveryProgress(handlingHistory);
return cargo;
}
示例2: CanCreateTest
public void CanCreateTest()
{
var cargo = new Cargo(new TrackingId("XYZ"),
new RouteSpecification(SampleLocations.HANGZOU, SampleLocations.HELSINKI,
DateTime.Now));
var events = new List<HandlingEvent>
{
new HandlingEvent(cargo, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2), HandlingType.RECEIVE,
SampleLocations.HANGZOU),
new HandlingEvent(cargo, DateTime.Now.AddDays(3), DateTime.Now.AddDays(4), HandlingType.LOAD,
SampleLocations.HANGZOU, SampleVoyages.CM001),
new HandlingEvent(cargo, DateTime.Now.AddDays(5), DateTime.Now.AddDays(6), HandlingType.UNLOAD,
SampleLocations.HELSINKI, SampleVoyages.CM001)
};
cargo.DeriveDeliveryProgress(new HandlingHistory(events));
var adapter = new CargoTrackingViewAdapter(cargo, events);
Assert.AreEqual("XYZ", adapter.TrackingId);
Assert.AreEqual("Hangzhou", adapter.Origin);
Assert.AreEqual("Helsinki", adapter.Destination);
Assert.AreEqual("In port Helsinki", adapter.GetStatusText());
IEnumerator<HandlingEventViewAdapter> it = adapter.Events.GetEnumerator();
it.MoveNext();
HandlingEventViewAdapter evnt = it.Current;
Assert.AreEqual("RECEIVE", evnt.Type);
Assert.AreEqual("Hangzhou", evnt.Location);
Assert.AreEqual(GetDateFormated(1), evnt.Time);
Assert.AreEqual("", evnt.VoyageNumber);
Assert.IsTrue(evnt.IsExpected);
it.MoveNext();
evnt = it.Current;
Assert.AreEqual("LOAD", evnt.Type);
Assert.AreEqual("Hangzhou", evnt.Location);
Assert.AreEqual(GetDateFormated(3), evnt.Time);
Assert.AreEqual("CM001", evnt.VoyageNumber);
Assert.IsTrue(evnt.IsExpected);
it.MoveNext();
evnt = it.Current;
Assert.AreEqual("UNLOAD", evnt.Type);
Assert.AreEqual("Helsinki", evnt.Location);
Assert.AreEqual(GetDateFormated(5), evnt.Time);
Assert.AreEqual("CM001", evnt.VoyageNumber);
Assert.IsTrue(evnt.IsExpected);
}
示例3: TestIsMisdirected
public void TestIsMisdirected()
{
//A cargo with no itinerary is not misdirected
Cargo cargo = new Cargo(new TrackingId("TRKID"),
new RouteSpecification(SampleLocations.SHANGHAI, SampleLocations.GOTHENBURG,
DateTime.Now));
Assert.IsFalse(cargo.Delivery.IsMisdirected);
cargo = SetUpCargoWithItinerary(SampleLocations.SHANGHAI, SampleLocations.ROTTERDAM,
SampleLocations.GOTHENBURG);
//A cargo with no handling events is not misdirected
Assert.IsFalse(cargo.Delivery.IsMisdirected);
var handlingEvents = new Collection<HandlingEvent>
{
new HandlingEvent(cargo, new DateTime(10), new DateTime(20),
HandlingType.RECEIVE, SampleLocations.SHANGHAI),
new HandlingEvent(cargo, new DateTime(30), new DateTime(40),
HandlingType.LOAD, SampleLocations.SHANGHAI, voyage),
new HandlingEvent(cargo, new DateTime(50), new DateTime(60),
HandlingType.UNLOAD, SampleLocations.ROTTERDAM, voyage),
new HandlingEvent(cargo, new DateTime(70), new DateTime(80),
HandlingType.LOAD, SampleLocations.ROTTERDAM, voyage),
new HandlingEvent(cargo, new DateTime(90), new DateTime(100),
HandlingType.UNLOAD, SampleLocations.GOTHENBURG, voyage),
new HandlingEvent(cargo, new DateTime(110), new DateTime(120),
HandlingType.CLAIM, SampleLocations.GOTHENBURG),
new HandlingEvent(cargo, new DateTime(130), new DateTime(140),
HandlingType.CUSTOMS, SampleLocations.GOTHENBURG)
};
//Happy path
events.AddRange(handlingEvents);
cargo.DeriveDeliveryProgress(new HandlingHistory(events));
Assert.IsFalse(cargo.Delivery.IsMisdirected);
//Try a couple of failing ones
cargo = SetUpCargoWithItinerary(SampleLocations.SHANGHAI, SampleLocations.ROTTERDAM,
SampleLocations.GOTHENBURG);
handlingEvents = new Collection<HandlingEvent>
{
new HandlingEvent(cargo, DateTime.Now, DateTime.Now, HandlingType.RECEIVE,
SampleLocations.HANGZOU)
};
events.AddRange(handlingEvents);
cargo.DeriveDeliveryProgress(new HandlingHistory(events));
Assert.IsTrue(cargo.Delivery.IsMisdirected);
cargo = SetUpCargoWithItinerary(SampleLocations.SHANGHAI, SampleLocations.ROTTERDAM,
SampleLocations.GOTHENBURG);
handlingEvents = new Collection<HandlingEvent>
{
new HandlingEvent(cargo, new DateTime(10), new DateTime(20),
HandlingType.RECEIVE,
SampleLocations.SHANGHAI),
new HandlingEvent(cargo, new DateTime(30), new DateTime(40),
HandlingType.LOAD,
SampleLocations.SHANGHAI, voyage),
new HandlingEvent(cargo, new DateTime(50), new DateTime(60),
HandlingType.UNLOAD,
SampleLocations.ROTTERDAM, voyage),
new HandlingEvent(cargo, new DateTime(70), new DateTime(80),
HandlingType.LOAD,
SampleLocations.ROTTERDAM, voyage)
};
events.AddRange(handlingEvents);
cargo.DeriveDeliveryProgress(new HandlingHistory(events));
Assert.IsTrue(cargo.Delivery.IsMisdirected);
cargo = SetUpCargoWithItinerary(SampleLocations.SHANGHAI, SampleLocations.ROTTERDAM,
SampleLocations.GOTHENBURG);
handlingEvents = new Collection<HandlingEvent>
{
new HandlingEvent(cargo, new DateTime(10), new DateTime(20),
HandlingType.RECEIVE,
SampleLocations.SHANGHAI),
new HandlingEvent(cargo, new DateTime(30), new DateTime(40),
HandlingType.LOAD,
SampleLocations.SHANGHAI, voyage),
new HandlingEvent(cargo, new DateTime(50), new DateTime(60),
HandlingType.UNLOAD,
SampleLocations.ROTTERDAM, voyage),
new HandlingEvent(cargo, DateTime.Now, DateTime.Now, HandlingType.CLAIM,
SampleLocations.ROTTERDAM)
};
//.........这里部分代码省略.........
示例4: PopulateCargoOffMelbourne
private Cargo PopulateCargoOffMelbourne()
{
Cargo cargo = new Cargo(new TrackingId("XYZ"),
new RouteSpecification(SampleLocations.STOCKHOLM, SampleLocations.MELBOURNE,
DateTime.Now));
events.Add(new HandlingEvent(cargo, GetDate("2007-12-01"), DateTime.Now, HandlingType.LOAD,
SampleLocations.STOCKHOLM, voyage));
events.Add(new HandlingEvent(cargo, GetDate("2007-12-02"), DateTime.Now, HandlingType.UNLOAD,
SampleLocations.HAMBURG, voyage));
events.Add(new HandlingEvent(cargo, GetDate("2007-12-03"), DateTime.Now, HandlingType.LOAD,
SampleLocations.HAMBURG, voyage));
events.Add(new HandlingEvent(cargo, GetDate("2007-12-04"), DateTime.Now, HandlingType.UNLOAD,
SampleLocations.HONGKONG, voyage));
events.Add(new HandlingEvent(cargo, GetDate("2007-12-05"), DateTime.Now, HandlingType.LOAD,
SampleLocations.HONGKONG, voyage));
events.Add(new HandlingEvent(cargo, GetDate("2007-12-07"), DateTime.Now, HandlingType.UNLOAD,
SampleLocations.MELBOURNE, voyage));
cargo.DeriveDeliveryProgress(new HandlingHistory(events));
return cargo;
}
示例5: PopulateCargoReceivedStockholm
// TODO: Generate test data some better way
private Cargo PopulateCargoReceivedStockholm()
{
Cargo cargo = new Cargo(new TrackingId("XYZ"),
new RouteSpecification(SampleLocations.STOCKHOLM, SampleLocations.MELBOURNE,
DateTime.Now));
HandlingEvent he = new HandlingEvent(cargo, GetDate("2007-12-01"), DateTime.Now, HandlingType.RECEIVE,
SampleLocations.STOCKHOLM);
events.Add(he);
cargo.DeriveDeliveryProgress(new HandlingHistory(events));
return cargo;
}
示例6: 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);
//.........这里部分代码省略.........
示例7: LoadMongoData
//.........这里部分代码省略.........
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;
if (!jkl567exists)
{
var routeSpecification1 = new RouteSpecification(SampleLocations.HANGZOU,
SampleLocations.STOCKHOLM,
DateUtil.ToDate("2009-03-18"));
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);
cargo.Insert(jkl567);
HandlingEvent event21 = handlingEventFactory.CreateHandlingEvent(
new DateTime(), DateUtil.ToDate("2009-03-01"), trackingId1, null, SampleLocations.HANGZOU.UnLocode,
HandlingType.RECEIVE);
handlingEvents.Insert(event21);
HandlingEvent event22 = handlingEventFactory.CreateHandlingEvent(
new DateTime(), DateUtil.ToDate("2009-03-03"), trackingId1,
SampleVoyages.HONGKONG_TO_NEW_YORK.voyageNumber, SampleLocations.HANGZOU.UnLocode,
HandlingType.LOAD
);
handlingEvents.Insert(event22);
HandlingEvent event23 = handlingEventFactory.CreateHandlingEvent(
new DateTime(), DateUtil.ToDate("2009-03-05"), trackingId1,
SampleVoyages.HONGKONG_TO_NEW_YORK.voyageNumber, SampleLocations.NEWYORK.UnLocode,
HandlingType.UNLOAD
);
handlingEvents.Insert(event23);
HandlingEvent event24 = handlingEventFactory.CreateHandlingEvent(
new DateTime(), DateUtil.ToDate("2009-03-06"), trackingId1,
SampleVoyages.HONGKONG_TO_NEW_YORK.voyageNumber, SampleLocations.NEWYORK.UnLocode,
HandlingType.LOAD
);
handlingEvents.Insert(event24);
HandlingHistory handlingHistory1 = handlingEventRepository.LookupHandlingHistoryOfCargo(trackingId1);
jkl567.DeriveDeliveryProgress(handlingHistory1);
cargo.Save(jkl567);
}
}