Exemple #1
0
        private BackgroundService.DriverManager.location GetData(string respJsonStr)
        {
            BackgroundService.DriverManager.location location = null;
            var responseAppS = JObject.Parse(respJsonStr);
            var status       = responseAppS.Value <string>("status");

            if (status == "OK")
            {
                var stepJson = responseAppS.GetValue("results").First.Value <JToken>("geometry").Value <JToken>("location").ToString();
                location = JsonConvert.DeserializeObject <BackgroundService.DriverManager.location>(stepJson);
            }
            else
            {
            }
            return(location);
        }
Exemple #2
0
        private BackgroundService.DriverManager.location SerchMinDistance(BackgroundService.DriverManager.location locationsEndAddress, List <BackgroundService.DriverManager.location> locationsOrder)
        {
            BackgroundService.DriverManager.location tmpOrder = locationsOrder[0];
            double distance = DistanceTo(locationsEndAddress.lat, Convert.ToDouble(locationsEndAddress.lng), locationsOrder[0].lat, locationsOrder[0].lng);

            foreach (var locationOrder in locationsOrder)
            {
                double tempDistance = DistanceTo(locationsEndAddress.lat, locationsEndAddress.lng, locationOrder.lat, locationOrder.lng);
                if (tempDistance < distance)
                {
                    distance = tempDistance;
                    tmpOrder = locationOrder;
                }
            }
            return(tmpOrder);
        }
Exemple #3
0
        private async Task WorkNewOrder(int idOrderMobile, string statusOrderMobil, string token, bool isNew, bool isNewOrderAndEndOrder)
        {
            List <BackgroundService.DriverManager.location> locationsOrder = new List <BackgroundService.DriverManager.location>();
            ConnectorApiMaps connectorApiMaps = new ConnectorApiMaps();

            BackgroundService.DriverManager.location locationOrderEnd = await sqlCoommandTaxiApi.GetAddressToOrderDB(idOrderMobile);

            List <Order> orders = sqlCoommandTaxiApi.GetOrders($"{locationOrderEnd.Date} {locationOrderEnd.ApiniTime}");

            foreach (var order1 in orders)
            {
                BackgroundService.DriverManager.location locationOrder1 = connectorApiMaps.GetGetLonAndLanToAddress(order1.FromAddress);
                BackgroundService.DriverManager.location location1      = connectorApiMaps.GetGetLonAndLanToAddress(order1.ToAddress.ToString());
                if (locationOrder1 != null)
                {
                    locationOrder1.ID         = order1.ID.ToString();
                    locationOrder1.Date       = order1.Date;
                    locationOrder1.PickuoTime = order1.TimeOfPickup;
                    locationOrder1.ApiniTime  = order1.TimeOfAppointment;
                    locationOrder1.latE       = location1.lat;
                    locationOrder1.lngE       = location1.lng;
                    locationOrder1.ID         = order1.ID.ToString();
                    locationsOrder.Add(locationOrder1);
                }
            }
            if (locationsOrder.Count > 0)
            {
                BackgroundService.DriverManager.OrderForDrivers orderForDrivers      = new BackgroundService.DriverManager.OrderForDrivers();
                BackgroundService.DriverManager.location        locations            = SerchMinDistance(locationOrderEnd, locationsOrder);
                List <BackgroundService.DriverManager.location> locationsAcceptOrder = new List <BackgroundService.DriverManager.location>();
                locationsAcceptOrder.Add(locationOrderEnd);
                locationsAcceptOrder.Add(locations);
                locationsOrder.Remove(locationsAcceptOrder[1]);
                orderForDrivers.OrderOnTheWay(locationsOrder, locationsAcceptOrder, orders, sqlCoommandTaxiApi, isNew);
            }
            if (isNewOrderAndEndOrder)
            {
                await sqlCoommandTaxiApi.SetStatusMobileOrderEnd(idOrderMobile, token);
            }
        }