示例#1
0
        public Controller(CountryService countryService, CompanyService companyService, DeliveryService deliveryService, PriceService priceService, RouteService routeService, LocationService locationService, StatisticsService statisticsService, EventService eventService)
        {
            this.countryService = countryService;
            this.companyService = companyService;
            this.deliveryService = deliveryService;
            this.priceService = priceService;
            this.routeService = routeService;
            this.locationService = locationService;
            this.statisticsService = statisticsService;
            this.eventService = eventService;

            Network.Instance.MessageReceived += new Network.MessageReceivedDelegate(OnReceived);
        }
示例#2
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);
            }*/
        }