コード例 #1
0
        public RequestDelivery(ClientController clientCon, ClientState clientState)
        {
            InitializeComponent();
            var state = new CurrentState();
            var routeService = new RouteService(state);
            _pathFinder = new PathFinder(routeService);
            _clientState = clientState;
            _pathfindService = new DeliveryService(state, _pathFinder);
            _clientController = clientCon;

            foreach (var routeNode in clientState.GetAllRouteNodes())
            {
                ComboBoxItem cbi = new ComboBoxItem();
                if (routeNode is DistributionCentre)
                    cbi.Content = ((DistributionCentre)routeNode).Name;
                else if (routeNode is InternationalPort)
                    cbi.Content = routeNode.Country.Name;
                cbi.Tag = routeNode.ID;
                this.origin.Items.Add(cbi);

                ComboBoxItem cbi2 = new ComboBoxItem();
                if (routeNode is DistributionCentre)
                    cbi2.Content = ((DistributionCentre)routeNode).Name;
                else if (routeNode is InternationalPort)
                    cbi2.Content = routeNode.Country.Name;
                cbi2.Tag = routeNode.ID;
                this.destination.Items.Add(cbi2);
            }

            _clientController.OptionsReceived += new ClientController.DeliveryOptionsDelegate(DeliveryOptions_Returned);
            _clientController.DeliveryOK+= new ClientController.DeliveryConfirmedDelegate(DeliveryConfirmed);
        }
コード例 #2
0
        public static void MyClassInitialize(TestContext testContext)
        {
            // initialise state
            CurrentState state = new CurrentState();
            routeNodes = new List<RouteNode>();
            routeNodes.Add(new DistributionCentre("Christchurch"));
            routeNodes.Add(new DistributionCentre("Wellington"));
            routeNodes.Add(new DistributionCentre("Auckland"));

            routes = getRoutes(routeNodes);

            state.InitialiseRoutes(getRoutes(routeNodes));

            // initialise routeService
            var routeService = new RouteService(state);

            // initialise pathfinder
            pathFinder = new PathFinder(routeService);
        }
コード例 #3
0
 public TimeEvaluator(PathFinder outer)
     : base(outer)
 {
 }
コード例 #4
0
 public RouteExcluder(PathFinder outer)
 {
     this.outer = outer;
 }
コード例 #5
0
 public NullExcluder(PathFinder outer)
     : base(outer)
 {
 }
コード例 #6
0
 public NodeEvaluator(PathFinder outer)
 {
     this.outer = outer;
 }
コード例 #7
0
 public CostEvaluator(PathFinder outer)
     : base(outer)
 {
 }
コード例 #8
0
 public AirOnlyExcluder(PathFinder outer)
     : base(outer)
 {
 }
コード例 #9
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // initialise logger
            Logger.Instance.SetOutput(logBox);
            Logger.WriteLine("Server starting..");

            // initialise database
            Database.Instance.Connect();

            // initialise the state object
            currentState = new CurrentState();

            // initialise all the services (they set up the state themselves) and pathfinder
            countryService = new CountryService(currentState);
            companyService = new CompanyService(currentState);
            routeService = new RouteService(currentState);
            var pathFinder = new PathFinder(routeService); // pathfinder needs the RouteService and state
            deliveryService = new DeliveryService(currentState, pathFinder); // DeliveryService needs the PathFinder
            priceService = new PriceService(currentState);
            locationService = new LocationService(currentState);
            eventService = new EventService(currentState);
            statisticsService = new StatisticsService();

            // initialise network
            Network.Network network = Network.Network.Instance;
            network.Start();
            network.Open();

            // create controller
            var controller = new Controller(countryService, companyService, deliveryService, priceService, routeService,
                                            locationService, statisticsService, eventService);

            //BenDBTests(countryService, routeService);
            //SetUpDatabaseWithData();

            /*try
            {
                var priceDH = new PriceDataHelper();

                var standardPrice = new DomesticPrice(Priority.Standard) { PricePerGram = 3, PricePerCm3 = 5 };
                //standardPrice = priceService.CreateDomesticPrice(standardPrice.Priority, standardPrice.PricePerGram, standardPrice.PricePerCm3);

                standardPrice.PricePerCm3 = 8;
                //standardPrice = priceService.UpdateDomesticPrice(standardPrice.ID, standardPrice.Priority, standardPrice.PricePerGram, standardPrice.PricePerCm3);

                var loadedPrice = priceService.GetDomesticPrice(1);
                var prices = priceService.GetAllDomesticPrices();

                var normalPrices = priceService.GetAll();
            }
            catch (DatabaseException er) {
                Logger.WriteLine(er.Message);
                Logger.Write(er.StackTrace);
            }*/
        }