Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Alina Popa committed Apr 18, 2016
2 parents b8a0425 + 483ead1 commit ae71eb5
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .deployment
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[config]
project=src/MobileAppService/MyDrivingService/MyDrivingService.csproj
4 changes: 3 additions & 1 deletion scripts/ARM/scenario_complete.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
/* Mobile App settings */
"mobileAppName": "[concat(variables('baseName'), '-', uniquestring(resourceGroup().id))]",
"mobileAppRepositoryBranch": "master",
"mobileAppProject": "src/MobileAppService/MyDrivingService/MyDrivingService.csproj",
/* App Insights settings */
"appInsightsName": "[concat(variables('baseName'), 'API', '-', uniquestring(resourceGroup().id))]",
"appInsightsLocation": "centralus", /* App Insights is currently only available in Central US */
Expand Down Expand Up @@ -550,7 +551,8 @@
"[resourceId('Microsoft.Web/Sites', variables('mobileAppName'))]"
],
"properties": {
"IoTHubConnectionString": "[concat('HostName=', variables('iotHubName'), '.azure-devices.net;SharedAccessKeyName=', variables('iotHubKeyName'), ';SharedAccessKey=', listKeys(resourceId('Microsoft.Devices/IotHubs/Iothubkeys', variables('iotHubName'), variables('iotHubKeyName')), '2016-02-03').primaryKey)]"
"IoTHubConnectionString": "[concat('HostName=', variables('iotHubName'), '.azure-devices.net;SharedAccessKeyName=', variables('iotHubKeyName'), ';SharedAccessKey=', listKeys(resourceId('Microsoft.Devices/IotHubs/Iothubkeys', variables('iotHubName'), variables('iotHubKeyName')), '2016-02-03').primaryKey)]",
"Project": "[variables('mobileAppProject')]"
}
},
{
Expand Down
4 changes: 3 additions & 1 deletion scripts/ARM/scenario_complete.nocomments.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"hostingPlanName": "[concat(variables('baseName'), 'Plan', '-', uniquestring(resourceGroup().id))]",
"mobileAppName": "[concat(variables('baseName'), '-', uniquestring(resourceGroup().id))]",
"mobileAppRepositoryBranch": "master",
"mobileAppProject": "src/MobileAppService/MyDrivingService/MyDrivingService.csproj",
"appInsightsName": "[concat(variables('baseName'), 'API', '-', uniquestring(resourceGroup().id))]",
"appInsightsLocation": "centralus",
"dataFactoryName": "[concat(variables('baseName'), '-df', uniquestring(resourceGroup().id))]",
Expand Down Expand Up @@ -521,7 +522,8 @@
"[resourceId('Microsoft.Web/Sites', variables('mobileAppName'))]"
],
"properties": {
"IoTHubConnectionString": "[concat('HostName=', variables('iotHubName'), '.azure-devices.net;SharedAccessKeyName=', variables('iotHubKeyName'), ';SharedAccessKey=', listKeys(resourceId('Microsoft.Devices/IotHubs/Iothubkeys', variables('iotHubName'), variables('iotHubKeyName')), '2016-02-03').primaryKey)]"
"IoTHubConnectionString": "[concat('HostName=', variables('iotHubName'), '.azure-devices.net;SharedAccessKeyName=', variables('iotHubKeyName'), ';SharedAccessKey=', listKeys(resourceId('Microsoft.Devices/IotHubs/Iothubkeys', variables('iotHubName'), variables('iotHubKeyName')), '2016-02-03').primaryKey)]",
"Project": "[variables('mobileAppProject')]"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@
<SDKReference Include="Microsoft.VCLibs, Version=14.0">
<Name>Visual C++ 2015 Runtime for Universal Windows Platform Apps</Name>
</SDKReference>
<SDKReference Include="SQLite.UWP.2015, Version=3.11.1">
<SDKReference Include="SQLite.UWP.2015, Version=3.12.1">
<Name>SQLite for Universal Windows Platform</Name>
</SDKReference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,28 +184,38 @@ private async Task BeginExtendedExecution()

ClearExtendedExecution();

var newSession = new ExtendedExecutionSession
try
{
Reason = ExtendedExecutionReason.LocationTracking,
Description = "Tracking your location"
};
newSession.Revoked += SessionRevoked;
ExtendedExecutionResult result = await newSession.RequestExtensionAsync();
switch (result)
{
case ExtendedExecutionResult.Allowed:
session = newSession;
ViewModel.Geolocator.AllowsBackgroundUpdates = true;
ViewModel.StartTrackingTripCommand.Execute(null);
var newSession = new ExtendedExecutionSession
{
Reason = ExtendedExecutionReason.LocationTracking,
Description = "Tracking your location"
};
newSession.Revoked += SessionRevoked;
ExtendedExecutionResult result = await newSession.RequestExtensionAsync();
switch (result)
{
case ExtendedExecutionResult.Allowed:
session = newSession;
ViewModel.Geolocator.AllowsBackgroundUpdates = true;
ViewModel.StartTrackingTripCommand.Execute(null);

break;
break;

default:
Acr.UserDialogs.UserDialogs.Instance.Alert("Unable to execute app in the background.",
"Background execution denied.", "OK");
default:
Acr.UserDialogs.UserDialogs.Instance.Alert("Unable to execute app in the background.",
"Background execution denied.", "OK");

newSession.Dispose();
break;
newSession.Dispose();
break;
}
}
catch (Exception ex)
{
// Sometimes while creating ExtendedExecution session you get Resource not ready exception.
Logger.Instance.Report(ex);
Acr.UserDialogs.UserDialogs.Instance.Alert("Will not be able to execute app in the background.",
"Background execution session failed.", "OK");
}
}

Expand Down Expand Up @@ -371,7 +381,7 @@ await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>

private async void DrawPath(BasicGeoposition basicGeoposition)
{
if (!ViewModel.IsRecording || ViewModel.CurrentTrip.Points.Count == 0)
if (!ViewModel.IsRecording || ViewModel.CurrentTrip?.Points?.Count == 0)
return;

await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
Expand All @@ -383,8 +393,12 @@ await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
Locations =
new List<BasicGeoposition>(
ViewModel.CurrentTrip.Points.Select(
ViewModel.CurrentTrip?.Points?.Select(
s => new BasicGeoposition() { Latitude = s.Latitude, Longitude = s.Longitude }));

// If the viewmodel still has not added this point, then add it locally to the Locations collection.
if (Locations.Count == 0)
Locations.Add(basicGeoposition);
}
else
Locations.Add(basicGeoposition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,19 @@ public async Task<bool> StopRecordingTrip()
Logger.Instance.Report(ex);
}

List<POI> poiList = new List<POI>(await StoreManager.POIStore.GetItemsAsync(CurrentTrip.Id));
List<POI> poiList = new List<POI>();
try
{
poiList = new List<POI>(await StoreManager.POIStore.GetItemsAsync(CurrentTrip.Id));
}
catch (Exception ex)
{
//Intermittently, Sqlite will cause a crash for WinPhone saying "unable to set temporary directory"
//If this call fails, simply use an empty list of POIs
Logger.Instance.WriteLine("Unable to get POI Store Items.");
Logger.Instance.Report(ex);
}

CurrentTrip.HardStops = poiList.Where(p => p.POIType == POIType.HardBrake).Count();
CurrentTrip.HardAccelerations = poiList.Where(p => p.POIType == POIType.HardAcceleration).Count();

Expand Down

0 comments on commit ae71eb5

Please sign in to comment.