private static IDictionary<int, Route> getRoutes()
        {
            Company company = new Company() { Name = "NZPost" };
            RouteNode origin = new DistributionCentre("Wellington");

            var routes = new Dictionary<int, Route>();

            // route1
            Route route1 = new Route{Company = company, TransportType = TransportType.Air, Origin = origin, Destination = new DistributionCentre("Auckland")};
            route1.AddDepartureTime(new WeeklyTime(DayOfWeek.Friday, 15, 0));
            route1.AddDepartureTime(new WeeklyTime(DayOfWeek.Wednesday, 5, 50));
            route1.ID = 1;
            routes[1] = route1;

            // route2
            Route route2 = new Route { Company = company, TransportType = TransportType.Land, Origin = origin, Destination = new DistributionCentre("Christchurch") };
            route2.AddDepartureTime(new WeeklyTime(DayOfWeek.Monday, 15, 0));
            route2.ID = 2;
            routes[2] = route2;

            return routes;
        }
예제 #2
0
        private Route getRoute()
        {
            Company company = new Company() {Name = "NZPost"};
            TransportType transportType = TransportType.Land;
            RouteNode origin = new DistributionCentre("Wellington");
            RouteNode destination = new DistributionCentre("Auckland");
            Route target = new Route{Company = company, TransportType = transportType, Origin = origin, Destination = destination};

            target.AddDepartureTime(new WeeklyTime(DayOfWeek.Friday, 15, 0));
            target.AddDepartureTime(new WeeklyTime(DayOfWeek.Wednesday, 5, 50));

            return target;
        }
예제 #3
0
        private Route getRoute2()
        {
            Company company = new Company() { Name = "NZPost" };
            TransportType transportType = TransportType.Sea;
            RouteNode origin = new DistributionCentre("Wellington");
            RouteNode destination = new DistributionCentre("Christchurch");
            Route target = new Route { Company = company, TransportType = transportType, Origin = origin, Destination = destination };

            target.AddDepartureTime(new WeeklyTime(DayOfWeek.Monday, 15, 0));

            return target;
        }
예제 #4
0
        private void BenDBTests(CountryService countryService, RouteService routeService)
        {
            try
            {

                CountryDataHelper cdh = new CountryDataHelper();

                // create country if doesn't exist
                Country country = new Country { ID = 1, Name = "Wellington", Code = "WLG" };
                if (!countryService.Exists(country))
                {
                    country = countryService.Create("Wellington", "WLG");
                }

                country = countryService.Update(country.ID, "WLN");
                country = countryService.Update(country.ID, "BEN");

                // get latest version
                Country loadedCountry = countryService.Get(country.ID);

                cdh.LoadAll(DateTime.Now);

                // create new zealand
                country = new Country { Name = "New Zealand", Code = "NZ" };
                if (!countryService.Exists(country))
                {
                    country = countryService.Create(country.Name, country.Code);
                }

                // create australia
                country = new Country { Name = "Australia", Code = "AUS" };
                if (!countryService.Exists(country))
                {
                    country = countryService.Create(country.Name, country.Code);
                }

                // load all countries
                var allCountries = countryService.GetAll();

                // create christchurch depot
                RouteNode routeNode = new DistributionCentre("Christchurch");
                if (!locationService.Exists(routeNode))
                {
                    routeNode = locationService.CreateDistributionCentre("Christchurch");
                }

                // wellington depot
                routeNode = new DistributionCentre("Wellington");
                if (!locationService.Exists(routeNode))
                {
                    routeNode = locationService.CreateDistributionCentre("Wellington");
                }

                // australia port
                country = countryService.GetAll().AsQueryable().First(t => t.Name == "Australia");
                var destination = new InternationalPort(country);
                if (!locationService.Exists(destination))
                {
                    destination = locationService.CreateInternationalPort(country.ID);
                }

                // get a company
                var company = new Company() { Name = "NZ Post" };
                if (!companyService.Exists(company))
                {
                    company = companyService.Create(company.Name);
                }

                // create a new route
                Route route = new Route()
                    {
                        Origin = routeNode,
                        Destination = destination,
                        Company = company,
                        Duration = 300,
                        MaxVolume = 5000,
                        MaxWeight = 5000,
                        CostPerCm3 = 3,
                        CostPerGram = 5,
                        TransportType = TransportType.Air,
                        DepartureTimes = new List<WeeklyTime> { new WeeklyTime(DayOfWeek.Monday, 5, 30) }
                    };

                var routeDataHelper = new RouteDataHelper();

                int id = routeDataHelper.GetId(route);
                Logger.WriteLine("Route id is: " + id);
                if (id == 0)
                {
                    routeDataHelper.Create(route);
                }

                //route = routeDataHelper.Load(1);

                // edit departure times
                route.DepartureTimes.Add(new WeeklyTime(DayOfWeek.Wednesday, 14, 35));

                // update
                //routeDataHelper.Update(route);

                // delete
                routeDataHelper.Delete(route.ID);

                var routes = routeDataHelper.LoadAll();

                var delivery = new Delivery { Origin = routeNode, Destination = destination, Priority = Priority.Air, WeightInGrams = 200, VolumeInCm3 = 2000, TotalPrice = 2500, TotalCost = 1000, TimeOfRequest = DateTime.UtcNow, TimeOfDelivery = DateTime.UtcNow.AddHours(5.5), Routes = new List<RouteInstance> { new RouteInstance(route, DateTime.UtcNow)} };

                var deliveryDataHelper = new DeliveryDataHelper();

                deliveryDataHelper.Create(delivery);

                deliveryDataHelper.Load(delivery.ID);

                deliveryDataHelper.LoadAll();

                var price = new Price { Origin = routeNode, Destination = destination, Priority = Priority.Air, PricePerCm3 = 3, PricePerGram = 5 };
                var priceDataHelper = new PriceDataHelper();
                //priceDataHelper.Create(price);

                price.PricePerGram = 10;
                price.ID = 1;

                Logger.WriteLine(price.ToString());

            }
            catch (Exception e)
            {
                Logger.WriteLine(e.Message);
                Logger.Write(e.StackTrace);
            }
        }
예제 #5
0
        private void SetUpDatabaseWithData()
        {
            var countryDataHelper = new CountryDataHelper();

            // countries
            var newZealand = new Country { Name = "New Zealand", Code = "NZ"};
            countryDataHelper.Create(newZealand);

            var australia = new Country { Name = "Australia", Code = "AUS" };
            countryDataHelper.Create(australia);

            var japan = new Country { Name = "Japan", Code = "JAP" };
            countryDataHelper.Create(japan);

            var routeNodeDataHelper = new RouteNodeDataHelper();
            // international ports
            var australiaP = new InternationalPort(australia);
            routeNodeDataHelper.Create(australiaP);

            var japanP = new InternationalPort(japan);
            routeNodeDataHelper.Create(japanP);

            // distribution centres
            var auckland = new DistributionCentre("Auckland");
            routeNodeDataHelper.Create(auckland);
            var wellington = new DistributionCentre("Wellington");
            routeNodeDataHelper.Create(wellington);
            var christchurch = new DistributionCentre("Christchurch");
            routeNodeDataHelper.Create(christchurch);
            var hamilton = new DistributionCentre("Hamilton");
            routeNodeDataHelper.Create(hamilton);
            var rotorua = new DistributionCentre("Rotorua");
            routeNodeDataHelper.Create(rotorua);
            var palmerstonNorth = new DistributionCentre("Palmerston North");
            routeNodeDataHelper.Create(palmerstonNorth);
            var dunedin = new DistributionCentre("Dunedin");
            routeNodeDataHelper.Create(dunedin);

            // company
            var companyDataHelper = new CompanyDataHelper();
            var nzPost = new Company{ Name = "NZ Post" };
            companyDataHelper.Create(nzPost);
            var quantas = new Company{ Name = "Quantas" };
            companyDataHelper.Create(quantas);
            var airNZ = new Company { Name = "Air New Zealand" };
            companyDataHelper.Create(airNZ);

            // routes
            var routeDataHelper = new RouteDataHelper();
            var wellToAuckLand = new Route { Origin = wellington, Destination = auckland, Company = nzPost, TransportType = TransportType.Land, CostPerCm3 = 2, CostPerGram = 2, MaxVolume = 10000, MaxWeight = 5000, Duration = 480, DepartureTimes = new List<WeeklyTime> { new WeeklyTime(DayOfWeek.Monday, 8, 0), new WeeklyTime(DayOfWeek.Tuesday, 8, 0), new WeeklyTime(DayOfWeek.Wednesday, 8, 0), new WeeklyTime(DayOfWeek.Thursday, 8, 0), new WeeklyTime(DayOfWeek.Friday, 8, 0) } };
            routeDataHelper.Create(wellToAuckLand);

            var wellToAuckAir = new Route { Origin = wellington, Destination = auckland, Company = airNZ, TransportType = TransportType.Air, CostPerCm3 = 8, CostPerGram = 10, MaxVolume = 10000, MaxWeight = 5000, Duration = 100, DepartureTimes = new List<WeeklyTime> { new WeeklyTime(DayOfWeek.Monday, 8, 0), new WeeklyTime(DayOfWeek.Tuesday, 8, 0), new WeeklyTime(DayOfWeek.Wednesday, 8, 0), new WeeklyTime(DayOfWeek.Thursday, 8, 0), new WeeklyTime(DayOfWeek.Friday, 8, 0) } };
            routeDataHelper.Create(wellToAuckAir);

            var auckToAusAir = new Route { Origin = auckland, Destination = australiaP, Company = airNZ, TransportType = TransportType.Air, CostPerCm3 = 10, CostPerGram = 12, MaxVolume = 8000, MaxWeight = 3000, Duration = 150, DepartureTimes = new List<WeeklyTime> { new WeeklyTime(DayOfWeek.Monday, 11, 0), new WeeklyTime(DayOfWeek.Tuesday, 11, 0), new WeeklyTime(DayOfWeek.Wednesday, 11, 0), new WeeklyTime(DayOfWeek.Thursday, 11, 0), new WeeklyTime(DayOfWeek.Friday, 11, 0) } };
            routeDataHelper.Create(auckToAusAir);

            // prices
            var priceDataHelper = new PriceDataHelper();
            var wellToAuckStandardPrice = new Price { Origin = wellington, Destination = auckland, Priority = Priority.Standard, PricePerCm3 = 4, PricePerGram = 4 };
            priceDataHelper.Create(wellToAuckStandardPrice);

            var wellToAuckAirPrice = new Price { Origin = wellington, Destination = auckland, Priority = Priority.Air, PricePerCm3 = 12, PricePerGram = 12 };
            priceDataHelper.Create(wellToAuckAirPrice);

            var auckToAusAirPrice = new Price { Origin = auckland, Destination = australiaP, Priority = Priority.Air, PricePerCm3 = 15, PricePerGram = 15 };
            priceDataHelper.Create(auckToAusAirPrice);
        }
예제 #6
0
 protected bool Equals(Company other)
 {
     return string.Equals(Name, other.Name);
 }
예제 #7
0
        /// <summary>
        /// This is where the initialisation of the routes collection happens.
        /// </summary>
        /// <returns></returns>
        private static IDictionary<int, Route> getRoutes(List<RouteNode> routeNodes)
        {
            Company company = new Company() { Name = "NZPost" };

            var routes = new Dictionary<int, Route>();

            Route airChchWell = new Route { Company = company, TransportType = TransportType.Air, Origin = routeNodes[0], Destination = routeNodes[1] };
            airChchWell.AddDepartureTime(new WeeklyTime(DayOfWeek.Monday, 12, 0));
            airChchWell.Duration = 60;
            airChchWell.CostPerCm3 = 0;
            airChchWell.CostPerGram = 2;
            airChchWell.ID = 0;
            routes[0] = airChchWell;

            Route landChchWell = new Route { Company = company, TransportType = TransportType.Land, Origin = routeNodes[0], Destination = routeNodes[1] };
            landChchWell.AddDepartureTime(new WeeklyTime(DayOfWeek.Tuesday, 12, 0));
            landChchWell.Duration = 60;
            landChchWell.CostPerCm3 = 0;
            landChchWell.CostPerGram = 1;
            landChchWell.ID = 1;
            routes[1] = landChchWell;

            Route airWellAuck = new Route { Company = company, TransportType = TransportType.Air, Origin = routeNodes[1], Destination = routeNodes[2] };
            airWellAuck.AddDepartureTime(new WeeklyTime(DayOfWeek.Thursday, 12, 0));
            airWellAuck.Duration = 60;
            airWellAuck.CostPerCm3 = 0;
            airWellAuck.CostPerGram = 3;
            airWellAuck.ID = 2;
            routes[2] = airWellAuck;

            Route landWellAuck = new Route { Company = company, TransportType = TransportType.Land, Origin = routeNodes[1], Destination = routeNodes[2] };
            landWellAuck.AddDepartureTime(new WeeklyTime(DayOfWeek.Wednesday, 12, 0));
            landWellAuck.Duration = 60;
            landWellAuck.CostPerCm3 = 0;
            landWellAuck.CostPerGram = 4;
            landWellAuck.ID = 3;
            routes[3] = landWellAuck;

            return routes;
        }
예제 #8
0
 public void SaveCompany(Company company)
 {
     companies[company.ID] = company;
 }