예제 #1
0
        public IBSSettingContainer GetSettingContainer(string companyKey)
        {
            if (!companyKey.HasValue())
            {
                return(_serverSettings.ServerData.IBS);
            }

            // Switched companies or external market
            if (!_ibsSettings.ContainsKey(companyKey))
            {
                // Get all fleets available to dispatch to company
                var networkFleet = _taxiHailNetworkService.GetNetworkFleet(_serverSettings.ServerData.TaxiHail.ApplicationKey);

                _ibsSettings.Clear();

                foreach (var networkFleetResponse in networkFleet)
                {
                    var settingContainer = new IBSSettingContainer
                    {
                        RestApiUrl          = networkFleetResponse.RestApiUrl,
                        RestApiUser         = networkFleetResponse.RestApiUser,
                        RestApiSecret       = networkFleetResponse.RestApiSecret,
                        WebServicesUrl      = networkFleetResponse.IbsUrl,
                        WebServicesPassword = networkFleetResponse.IbsPassword,
                        WebServicesUserName = networkFleetResponse.IbsUserName,
                        TimeDifference      = networkFleetResponse.IbsTimeDifference
                    };

                    _ibsSettings.Add(networkFleetResponse.CompanyKey, settingContainer);
                }
            }

            return(_ibsSettings[companyKey]);
        }
예제 #2
0
        public object Get(NetworkFleetsRequest request)
        {
            var networkFleet = _taxiHailNetworkServiceClient.GetNetworkFleet(null);

            return(networkFleet.Select(f => new NetworkFleet
            {
                CompanyKey = f.CompanyKey,
                CompanyName = f.CompanyName
            }));
        }
예제 #3
0
        internal BestAvailableCompany FindSpecificCompany(string market, CreateReportOrder createReportOrder, string orderCompanyKey = null, int?orderFleetId = null, double?latitude = null, double?longitude = null)
        {
            if (!orderCompanyKey.HasValue() && !orderFleetId.HasValue)
            {
                Exception createOrderException = new ArgumentNullException("You must at least provide a value for orderCompanyKey or orderFleetId");
                createReportOrder.Error = createOrderException.ToString();
                _commandBus.Send(createReportOrder);
                throw createOrderException;
            }

            var homeCompanyKey = _serverSettings.ServerData.TaxiHail.ApplicationKey;

            var fleets = market.HasValue()
                ? _taxiHailNetworkServiceClient.GetMarketFleets(homeCompanyKey, market).ToArray()
                : _taxiHailNetworkServiceClient.GetNetworkFleet(homeCompanyKey, latitude, longitude).ToArray();

            if (orderCompanyKey.HasValue())
            {
                var match = fleets.FirstOrDefault(f => f.CompanyKey == orderCompanyKey);
                if (match != null)
                {
                    return(new BestAvailableCompany
                    {
                        CompanyKey = match.CompanyKey,
                        CompanyName = match.CompanyName,
                        FleetId = match.FleetId
                    });
                }
            }

            if (orderFleetId.HasValue)
            {
                var match = fleets.FirstOrDefault(f => f.FleetId == orderFleetId.Value);
                if (match != null)
                {
                    return(new BestAvailableCompany
                    {
                        CompanyKey = match.CompanyKey,
                        CompanyName = match.CompanyName,
                        FleetId = match.FleetId
                    });
                }
            }

            // Nothing found
            return(new BestAvailableCompany());
        }