Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
VaijanathB committed Apr 25, 2016
2 parents 236499e + fae8a21 commit e467a4a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 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
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,26 @@ private DeviceProvisionHandler()
private string GenerateDeviceId()
{
string id = CrossDeviceInfo.Current.Id;

if (id == null)
return id;

int limit = 128;
//remove unaccepted characters - see https://azure.microsoft.com/en-us/documentation/articles/iot-hub-devguide/#device-identity-registry for accepted characters
//remove unaccepted characters - see https://azure.microsoft.com/en-us/documentation/articles/iot-hub-devguide/#device-identity-registry
//Note due to bug in Microsoft.Azure.Devices.Client.PCL some characters such as '+' in DeviceID still cause trouble

StringBuilder sb = new StringBuilder(id.Length);

foreach (char c in id)
{
if (IsAcceptedChar(c))
if (Char.IsLetterOrDigit(c))
sb.Append(c);
if (sb.Length >= limit)
break;
}
return sb.ToString();
}

private bool IsAcceptedChar(char c)
{
List<char> accepted = new List<char>() { '-', ':', '.', '+', '%', '_', '#', '*', '?', '!', '(', ')', ',', '=', '@', ';', '$', '\'' };
if (Char.IsLetterOrDigit(c))
return true;
else if (accepted.Contains(c))
return true;
return false;
}

public string DeviceId { get; private set; }

public string HostName { get; private set; }
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 e467a4a

Please sign in to comment.