Beispiel #1
0
 public SimulationThread(TripThruCore.Partner partner, PartnerConfiguration configuration)
 {
     this._partner       = partner;
     this._configuration = configuration;
     _worker             = new Thread(StartSimulation);
     _worker.Start();
 }
Beispiel #2
0
        public object Any(IReturn <InitPartner> request)
        {
            MapTools.SetGeodataFilenames("~/App_Data/Geo-Location-Names.csv".MapHostAbsolutePath(), "~/App_Data/Geo-Routes.csv".MapHostAbsolutePath(), "~/App_Data/Geo-Location-Addresses.csv".MapHostAbsolutePath());
            MapTools.LoadGeoData();
            MapTools.WriteGeoData();
            PartnerConfiguration configuration = TripThruCore.Partner.LoadPartnerConfigurationFromJsonFile("~/PartnerConfiguration.txt".MapHostAbsolutePath());

            TripThruCore.Partner partner = new TripThruCore.Partner(configuration.Partner.ClientId, configuration.Partner.Name, new GatewayClient("TripThru", "TripThru", configuration.Partner.AccessToken, configuration.TripThruUrl ?? configuration.TripThruUrlMono), configuration.partnerFleets);

            GatewayService.gateway = partner;

            MapTools.WriteGeoData();

            var sim = new SimulationThread(partner, configuration);

            return(new InitPartnerResponse());
        }
Beispiel #3
0
 public Test_TripLifeCycle_Base(
     string filename,
     Gateway tripthru,
     TimeSpan? maxLateness = null,
     PartnerTrip.Origination? origination = null,
     PartnerTrip.Origination? service = null,
     double? locationVerificationTolerance = null)
 {
     this.filename = filename;
     this.tripthru = tripthru;
     if (maxLateness != null)
         this.maxLateness = (TimeSpan)maxLateness;
     if (origination != null)
         this.origination = origination;
     if (service != null)
         this.service = service;
     if (locationVerificationTolerance != null)
         this.locationVerificationTolerance = (double)locationVerificationTolerance;
     PartnerConfiguration configuration = Partner.LoadPartnerConfigurationFromJsonFile(filename);
     partner = new Partner(configuration.Partner.ClientId, configuration.Partner.Name, new GatewayClientMock(tripthru), configuration.partnerFleets);
     partner.tripthru.RegisterPartner(partner);
 }
Beispiel #4
0
        public object Any(IReturn <InitPartner> request)
        {
            MapTools.SetGeodataFilenames("~/App_Data/Geo-Location-Names.txt".MapHostAbsolutePath(), "~/App_Data/Geo-Routes.txt".MapHostAbsolutePath(), "~/App_Data/Geo-Location-Addresses.txt".MapHostAbsolutePath());
            MapTools.LoadGeoData();
            MapTools.WriteGeoData();
            PartnerConfiguration configuration = TripThruCore.Partner.LoadPartnerConfigurationFromJsonFile("~/PartnerConfiguration.txt".MapHostAbsolutePath());

            if (configuration.host.debug)
            {
                //StorageManager.OpenStorage(new SqliteStorage("~/../../Db/db.sqlite".MapHostAbsolutePath()));
                StorageManager.OpenStorage(new MongoDbStorage("mongodb://192.168.0.104:27017/", configuration.Partner.ClientId));
            }
            else
            {
                StorageManager.OpenStorage(new MongoDbStorage("mongodb://SG-TripThru-3328.servers.mongodirector.com:27017/", configuration.Partner.ClientId));
            }

            var account = StorageManager.GetPartnerAccountByClientId(configuration.Partner.ClientId);

            if (account != null)
            {
                configuration.Partner.AccessToken = account.AccessToken;
                configuration.Partner.Name        = account.PartnerName;
                TripThruCore.Partner partner = new TripThruCore.Partner(configuration.Partner.ClientId, configuration.Partner.Name, new GatewayClient("TripThru", "TripThru", configuration.TripThruUrl ?? configuration.TripThruUrlMono, configuration.Partner.AccessToken), configuration.partnerFleets);

                GatewayService.gateway = partner;

                MapTools.WriteGeoData();

                var sim = new SimulationThread(partner, configuration);
            }
            else
            {
                Console.WriteLine("Can not init partner, account not found");
            }
            return(new InitPartnerResponse());
        }
        public PartnerFleet(string name, Location location, List<Zone> coverage, List<Driver> drivers, List<VehicleType> vehicleTypes,
            List<Pair<Location, Location>> possibleTrips, double costPerMile, double baseCost, double tripsPerHour, List<Passenger> passengers, Partner partner = null)
            : base(name)
        {
            this.coverage = coverage;
            this.partner = partner;
            this.location = location;
            foreach (Passenger p in passengers)
                p.PartnerFleet = this;
            random = new Random();

            this.passengers = passengers.ToArray();
            this.possibleTrips = possibleTrips.ToArray();

            List<Pair<Location, Location>> coveredTrips = new List<Pair<Location, Location>>();
            foreach (Pair<Location, Location> trip in possibleTrips)
            {
                if (FleetServesLocation(trip.First))
                    coveredTrips.Add(trip);
            }

            this.tripsPerHour = tripsPerHour;
            this.costPerMile = costPerMile;
            this.baseCost = baseCost;

            this.queue = new LinkedList<PartnerTrip>();

            this.drivers = new Dictionary<string, Driver>();
            availableDrivers = new LinkedList<Driver>();
            returningDrivers = new LinkedList<Driver>();
            this.vehicleTypes = new List<VehicleType>(vehicleTypes);
            if (drivers != null)
            {
                foreach (Driver d in drivers)
                    AddDriver(d);
            }
            if (partner != null)
                partner.AddPartnerFleet(this);
        }
 public PartnerTrip(Partner partner, string ID, Origination origination, Location pickupLocation, DateTime pickupTime, PaymentMethod? paymentMethod = null, string passengerID = null, string passengerName = null, Location dropoffLocation = null,
    DateTime? dropoffTime = null, List<Location> waypoints = null, VehicleType? vehicleType = null, double? maxPrice = null, int? minRating = null, PartnerFleet fleet = null, Driver driver = null, TimeSpan? duration = null, TimeSpan? driverRouteDuration = null, double? price = null)
 {
     this.ID = ID;
     this.origination = origination;
     this.service = Origination.Local;
     this.partner = partner;
     this.passengerID = passengerID;
     this.passengerName = passengerName;
     this.pickupLocation = pickupLocation;
     this.pickupTime = pickupTime;
     this.duration = duration;
     this.dropoffLocation = dropoffLocation;
     this.dropoffTime = dropoffTime;
     this.waypoints = waypoints;
     this.paymentMethod = paymentMethod;
     this.vehicleType = vehicleType;
     this.maxPrice = maxPrice;
     this.minRating = minRating;
     this.PartnerFleet = fleet;
     this.driver = driver;
     this.price = price;
     this.UpdateTripStatus(notifyPartner: false, status: Status.New);
 }
 public PartnerTrip(PartnerTrip t)
 {
     this.ID = t.ID;
     this.passengerID = t.passengerID;
     this.passengerName = t.passengerName;
     this.origination = t.origination;
     this.service = t.service;
     this.luggage = t.luggage;
     this.persons = t.persons;
     this.pickupLocation = t.pickupLocation;
     this.pickupTime = t.pickupTime;
     this.duration = t.duration;
     this.dropoffLocation = t.dropoffLocation;
     this.dropoffTime = t.dropoffTime;
     this.waypoints = t.waypoints;
     this.paymentMethod = t.paymentMethod;
     this.vehicleType = t.vehicleType;
     this.price = t.price;
     this.maxPrice = t.maxPrice;
     this.minRating = t.minRating;
     this.PartnerFleet = t.PartnerFleet;
     this.driver = t.driver;
     this.lastUpdate = t.lastUpdate;
     this._status = t._status;
     this.partner = t.partner;
     this.lastDispatchAttempt = DateTime.MinValue;
 }