예제 #1
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());
        }
예제 #2
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());
        }