Пример #1
0
        private void DisplayRoute(TripMessage tripMessage)
        {
            RouteMap.MapElements.Clear();

            if (tripMessage.Trip.BoundingBoxBottomRight != null && tripMessage.Trip.BoundingBoxTopLeft != null)
            {
                RouteMap.SetView(LocationRectangle.CreateBoundingRectangle(tripMessage.Trip.BoundingBoxBottomRight.GeoCoordinate, tripMessage.Trip.BoundingBoxTopLeft.GeoCoordinate));
            }
           
            foreach (TripRoute tripRoute in tripMessage.Trip.TripRoutes)
            {
                if (tripRoute.Coordinates.Count() >= 2)
                {
                    MapPolyline route = new MapPolyline();

                    route.StrokeColor = ThemeColourConverter.GetBrushFromHex(tripRoute.Colour).Color;
                    route.StrokeThickness = 9;

                    MapPolyline routeBlack = new MapPolyline();

                    routeBlack.StrokeColor = ThemeColourConverter.GetBrushFromHex(ThemeColourConverter.Black).Color;
                    routeBlack.StrokeThickness = 11;

                    foreach (Coordinate coordinate in tripRoute.Coordinates)
                    {
                        route.Path.Add(coordinate.GeoCoordinate);
                        routeBlack.Path.Add(coordinate.GeoCoordinate);
                    }

                    RouteMap.MapElements.Add(routeBlack);
                    RouteMap.MapElements.Add(route);
                }
            }
        }
Пример #2
0
        private static void ValidateTripMessage(TripMessage tripMessage)
        {
            tripMessage.Validate();
            var trip = TripDal.GetTrip(tripMessage.TripId);

            if (TripEvent.Begin == tripMessage.Event)
            {
                if (trip != null)
                {
                    throw new TripAlreadyExistsException(
                              "Trip with ID {0} already exists, therefore a begin message cannot be saved.",
                              tripMessage.TripId);
                }
            }
            else
            {
                if (null == trip)
                {
                    throw new TripDoesNotExistException(
                              "Trip with ID {0} does not exist, therefore a non begin message cannot be saved.",
                              tripMessage.TripId);
                }
                if (trip.LastMessageEpoch >= tripMessage.Epoch)
                {
                    throw new TripAlreadyHasMessageAfterEpochException(
                              "Trip with ID {0} already has an update after the messages epoch, therefore a non begin message cannot be saved.",
                              tripMessage.TripId);
                }
                if (trip.EndEpoch.HasValue)
                {
                    throw new TripAlreadyEndedException(
                              "Trip with ID {0} has already ended, therefore a message can not be saved.", tripMessage.TripId);
                }
            }
        }
Пример #3
0
        private void DisplayRoute(TripMessage tripMessage)
        {
            RouteMap.MapElements.Clear();

            if (tripMessage.Trip.BoundingBoxBottomRight != null && tripMessage.Trip.BoundingBoxTopLeft != null)
            {
                RouteMap.SetView(LocationRectangle.CreateBoundingRectangle(tripMessage.Trip.BoundingBoxBottomRight.GeoCoordinate, tripMessage.Trip.BoundingBoxTopLeft.GeoCoordinate));
            }

            foreach (TripRoute tripRoute in tripMessage.Trip.TripRoutes)
            {
                if (tripRoute.Coordinates.Count() >= 2)
                {
                    MapPolyline route = new MapPolyline();

                    route.StrokeColor     = ThemeColourConverter.GetBrushFromHex(tripRoute.Colour).Color;
                    route.StrokeThickness = 9;

                    MapPolyline routeBlack = new MapPolyline();

                    routeBlack.StrokeColor     = ThemeColourConverter.GetBrushFromHex(ThemeColourConverter.Black).Color;
                    routeBlack.StrokeThickness = 11;

                    foreach (Coordinate coordinate in tripRoute.Coordinates)
                    {
                        route.Path.Add(coordinate.GeoCoordinate);
                        routeBlack.Path.Add(coordinate.GeoCoordinate);
                    }

                    RouteMap.MapElements.Add(routeBlack);
                    RouteMap.MapElements.Add(route);
                }
            }
        }
        private static TripMessage InsertUpdateMessage()
        {
            var tripMessage = new TripMessage
            {
                Epoch     = 1392864673040,
                Event     = TripEvent.Update,
                Latitude  = 37.79947m,
                Longitude = 122.51163m,
                TripId    = 432
            };

            TripMessageBl.InsertTripMessage(tripMessage);
            return(tripMessage);
        }
        private static void InsertBeginTripMessageThatAlreadyExists()
        {
            var tripMessage = new TripMessage
            {
                Event     = TripEvent.Begin,
                Epoch     = 1392864673030,
                Latitude  = 37.79947m,
                Longitude = 122.51163m,
                TripId    = 432
            };

            TripMessageBl.InsertTripMessage(tripMessage);
            TripMessageBl.InsertTripMessage(tripMessage);
        }
Пример #6
0
        private void PopulateTrip(Guid id)
        {
            if (SelectedPathOption.Trip != null)
            {
                TripMessage.Send(SelectedPathOption.Trip);
                return;
            }

            Action getTrip = async() =>
            {
                LoadingBarMessage.Send(LoadingBarMessageReason.Show);

                try
                {
                    if (cancellationTokenSource == null)
                    {
                        cancellationTokenSource = new CancellationTokenSource();
                    }
                    else
                    {
                        cancellationTokenSource.Cancel();
                        cancellationTokenSource = new CancellationTokenSource();
                    }
                    Trip trip = await BumbleApi.Trip(cancellationTokenSource.Token, user, id);

                    cancellationTokenSource = null;

                    PathOptions.Where(x => x.TripId == id).FirstOrDefault().Trip = trip;

                    SimpleIoc.Default.Unregister <PathResultsModel>();

                    SimpleIoc.Default.Register <PathResultsModel>(() =>
                    {
                        return(this);
                    });

                    TripMessage.Send(trip);
                }
                catch (Exception)
                {
                }

                cancellationTokenSource = null;

                LoadingBarMessage.Send(LoadingBarMessageReason.Hide);
            };

            DispatcherHelper.CheckBeginInvokeOnUI(getTrip);
        }
        private static void InsertTripMessageThatAlreadyHasMessageAfterEpoch()
        {
            var tripMessage = new TripMessage
            {
                Event     = TripEvent.Begin,
                Epoch     = 1392864673030,
                Latitude  = 37.79947m,
                Longitude = 122.51163m,
                TripId    = 432
            };

            TripMessageBl.InsertTripMessage(tripMessage);
            tripMessage.Epoch = 1392864673020;
            tripMessage.Event = TripEvent.Update;
            TripMessageBl.InsertTripMessage(tripMessage);
        }
Пример #8
0
 public static void InsertTripMessage(TripMessage tripMessage)
 {
     using (var dbConnection = new MySqlConnection(ConnectionString))
     {
         dbConnection.Open();
         dbConnection.Execute("sp_insert_trip_message",
                              new
         {
             EventId = (int)tripMessage.Event.Value,
             tripMessage.TripId,
             tripMessage.Latitude,
             tripMessage.Longitude,
             tripMessage.Epoch,
             tripMessage.Fare
         }, commandType: CommandType.StoredProcedure);
     }
 }
Пример #9
0
        private void DisplayRoute(TripMessage tripMessage)
        {
            try
            {
                foreach (MapPolyline line in routes)
                {
                    Map.Children.Remove(line);
                }
            }
            catch (Exception) { }

            if (tripMessage.Trip.BoundingBoxBottomRight != null && tripMessage.Trip.BoundingBoxTopLeft != null)
            {
                Map.SetView(LocationRect.CreateLocationRect(tripMessage.Trip.BoundingBoxBottomRight.GeoCoordinate, tripMessage.Trip.BoundingBoxTopLeft.GeoCoordinate));
            }
            var trips = tripMessage.Trip.TripRoutes.ToList();

            foreach (TripRoute tripRoute in tripMessage.Trip.TripRoutes)
            {
                if (tripRoute.Coordinates.Count() >= 2)
                {
                    MapPolyline route = new MapPolyline();
                    routes.Add(route);
                    route.Stroke          = ThemeColourConverter.GetBrushFromHex(tripRoute.Colour);
                    route.StrokeThickness = 9;
                    route.Locations       = new LocationCollection();

                    MapPolyline routeBlack = new MapPolyline();
                    routes.Add(routeBlack);
                    routeBlack.Stroke          = ThemeColourConverter.GetBrushFromHex(ThemeColourConverter.Black);
                    routeBlack.StrokeThickness = 11;
                    routeBlack.Locations       = new LocationCollection();

                    foreach (Coordinate coordinate in tripRoute.Coordinates)
                    {
                        route.Locations.Add(coordinate.GeoCoordinate);
                        routeBlack.Locations.Add(coordinate.GeoCoordinate);
                    }

                    Map.Children.Insert(0, route);
                    Map.Children.Insert(0, routeBlack);
                }
            }
        }
Пример #10
0
        private void DisplayRoute(TripMessage tripMessage)
        {
            try
            {
                foreach (MapPolyline line in routes)
                    Map.Children.Remove(line);
            }
            catch (Exception) { }

            if (tripMessage.Trip.BoundingBoxBottomRight != null && tripMessage.Trip.BoundingBoxTopLeft != null)
            {
                Map.SetView(LocationRect.CreateLocationRect(tripMessage.Trip.BoundingBoxBottomRight.GeoCoordinate, tripMessage.Trip.BoundingBoxTopLeft.GeoCoordinate));
            }
            var trips = tripMessage.Trip.TripRoutes.ToList();
            foreach (TripRoute tripRoute in tripMessage.Trip.TripRoutes)
            {
                if (tripRoute.Coordinates.Count() >= 2)
                {
                    MapPolyline route = new MapPolyline();
                    routes.Add(route);
                    route.Stroke = ThemeColourConverter.GetBrushFromHex(tripRoute.Colour);
                    route.StrokeThickness = 9;
                    route.Locations = new LocationCollection();

                    MapPolyline routeBlack = new MapPolyline();
                    routes.Add(routeBlack);
                    routeBlack.Stroke = ThemeColourConverter.GetBrushFromHex(ThemeColourConverter.Black);
                    routeBlack.StrokeThickness = 11;
                    routeBlack.Locations = new LocationCollection();

                    foreach (Coordinate coordinate in tripRoute.Coordinates)
                    {
                        route.Locations.Add(coordinate.GeoCoordinate);
                        routeBlack.Locations.Add(coordinate.GeoCoordinate);
                    }

                    Map.Children.Insert(0, route);
                    Map.Children.Insert(0, routeBlack);
                }
            }
        }
        private static void InsertTripMessageThatAlreadyEnded()
        {
            var tripMessage = new TripMessage
            {
                Event     = TripEvent.Begin,
                Epoch     = 1392864673030,
                Latitude  = 37.79947m,
                Longitude = 122.51163m,
                TripId    = 432
            };

            TripMessageBl.InsertTripMessage(tripMessage);
            tripMessage.Epoch = 1392864673070;
            tripMessage.Fare  = 25;
            tripMessage.Event = TripEvent.End;
            TripMessageBl.InsertTripMessage(tripMessage);
            tripMessage.Epoch = 1392864673080;
            tripMessage.Event = TripEvent.Update;
            tripMessage.Fare  = null;
            TripMessageBl.InsertTripMessage(tripMessage);
        }
Пример #12
0
 public static void InsertTripMessage(TripMessage tripMessage)
 {
     ValidateTripMessage(tripMessage);
     TripMessageDal.InsertTripMessage(tripMessage);
 }