Example #1
0
        internal void FinishTrip()
        {
            TripDebugLog.EndBikeTrip();

            SetLocationUpdateEnabled(false);

            // Do we have a trip?
            if (lastLocation != null && currentDistance > MinimumDistanceForTrip && currentFix > startFix)
            {
                var trip = new BikeTrip {
                    Distance  = currentDistance,
                    StartTime = Epoch + TimeSpan.FromMilliseconds(startFix),
                    EndTime   = Epoch + TimeSpan.FromMilliseconds(currentFix)
                };
                var dataApi = DataApi.Obtain(this);
                dataApi.AddTrip(trip).Wait();

                TripDebugLog.LogNewTrip(trip.EndTime - trip.StartTime, trip.Distance);
            }

            lastLocation    = null;
            currentDistance = startFix = currentFix = 0;

            var oldState = currentBikingState;

            currentBikingState = BikingState.NotBiking;
            OnBikingStateChanged(oldState, currentBikingState);

            TripDebugLog.CommitTripLog();
            StopSelf();
        }
Example #2
0
		public async Task AddTrip (BikeTrip trip)
		{
			// Sanitize trip date information
			if (trip.CommitTime == DateTime.MinValue)
				trip.CommitTime = DateTime.UtcNow;
			else if (trip.CommitTime.Kind != DateTimeKind.Utc)
				trip.CommitTime = trip.CommitTime.ToUniversalTime ();
			if (trip.StartTime.Kind != DateTimeKind.Utc)
				trip.StartTime = trip.StartTime.ToUniversalTime ();
			if (trip.EndTime.Kind != DateTimeKind.Utc)
				trip.EndTime = trip.EndTime.ToUniversalTime ();

			using (var connection = await GrabConnection ().ConfigureAwait (false))
				await Task.Run (() => connection.Insert (trip)).ConfigureAwait (false);
		}
Example #3
0
        public async Task AddTrip(BikeTrip trip)
        {
            // Sanitize trip date information
            if (trip.CommitTime == DateTime.MinValue)
            {
                trip.CommitTime = DateTime.UtcNow;
            }
            else if (trip.CommitTime.Kind != DateTimeKind.Utc)
            {
                trip.CommitTime = trip.CommitTime.ToUniversalTime();
            }
            if (trip.StartTime.Kind != DateTimeKind.Utc)
            {
                trip.StartTime = trip.StartTime.ToUniversalTime();
            }
            if (trip.EndTime.Kind != DateTimeKind.Utc)
            {
                trip.EndTime = trip.EndTime.ToUniversalTime();
            }

            using (var connection = await GrabConnection().ConfigureAwait(false))
                await Task.Run(() => connection.Insert(trip)).ConfigureAwait(false);
        }
Example #4
0
        internal void FinishTrip()
        {
            TripDebugLog.EndBikeTrip ();

            SetLocationUpdateEnabled (false);

            // Do we have a trip?
            if (lastLocation != null && currentDistance > 0 && currentFix > startFix) {
                var trip = new BikeTrip {
                    Distance = currentDistance,
                    StartTime = Epoch + TimeSpan.FromMilliseconds (startFix),
                    EndTime = Epoch + TimeSpan.FromMilliseconds (currentFix)
                };
                var dataApi = DataApi.Obtain (this);
                dataApi.AddTrip (trip).Wait ();

                TripDebugLog.LogNewTrip (trip.EndTime - trip.StartTime, trip.Distance);
            }

            lastLocation = null;
            currentDistance = startFix = currentFix = 0;

            var oldState = currentBikingState;
            currentBikingState = BikingState.NotBiking;
            OnBikingStateChanged (oldState, currentBikingState);

            TripDebugLog.CommitTripLog ();
            StopSelf ();
        }
Example #5
0
		public async Task AddTrip (BikeTrip trip)
		{
			trip.CommitTime = DateTime.UtcNow;
			using (var connection = await GrabConnection ().ConfigureAwait (false))
				await Task.Run (() => connection.Insert (trip)).ConfigureAwait (false);
		}