From 9887f626ba4ab95fdfcb90a0f1a473aa6678144d Mon Sep 17 00:00:00 2001 From: Alina Popa Date: Fri, 1 Apr 2016 17:38:17 -0700 Subject: [PATCH 1/3] Trim characters from DeviceID that are not letter or digit. --- .../DeviceProvisionHandler.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/MobileApps/MyDriving/MyDriving.AzureClient/DeviceProvisionHandler.cs b/src/MobileApps/MyDriving/MyDriving.AzureClient/DeviceProvisionHandler.cs index 084f81f6..56b9394b 100644 --- a/src/MobileApps/MyDriving/MyDriving.AzureClient/DeviceProvisionHandler.cs +++ b/src/MobileApps/MyDriving/MyDriving.AzureClient/DeviceProvisionHandler.cs @@ -48,14 +48,19 @@ 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; @@ -63,16 +68,6 @@ private string GenerateDeviceId() return sb.ToString(); } - private bool IsAcceptedChar(char c) - { - List accepted = new List() { '-', ':', '.', '+', '%', '_', '#', '*', '?', '!', '(', ')', ',', '=', '@', ';', '$', '\'' }; - 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; } From 337acdeada708ad3e0c3f923bbb6c5dc1646f04f Mon Sep 17 00:00:00 2001 From: HaishiBai Date: Sun, 10 Apr 2016 19:10:46 -0700 Subject: [PATCH 2/3] added .deployment file for deploying web app --- .deployment | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .deployment diff --git a/.deployment b/.deployment new file mode 100644 index 00000000..45ccc160 --- /dev/null +++ b/.deployment @@ -0,0 +1,2 @@ +[config] +project=src/MobileAppService/MyDrivingService/MyDrivingService.csproj \ No newline at end of file From ced5ceb2d706df616307200660e3c48cfd051136 Mon Sep 17 00:00:00 2001 From: Nicole Haugen Date: Mon, 11 Apr 2016 16:35:02 -0500 Subject: [PATCH 3/3] Checking if getting items from the POIStore results in exception --- .../MyDriving/ViewModel/CurrentTripViewModel.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/MobileApps/MyDriving/MyDriving/ViewModel/CurrentTripViewModel.cs b/src/MobileApps/MyDriving/MyDriving/ViewModel/CurrentTripViewModel.cs index c4ee26ac..8e53d827 100644 --- a/src/MobileApps/MyDriving/MyDriving/ViewModel/CurrentTripViewModel.cs +++ b/src/MobileApps/MyDriving/MyDriving/ViewModel/CurrentTripViewModel.cs @@ -291,7 +291,19 @@ public async Task StopRecordingTrip() Logger.Instance.Report(ex); } - List poiList = new List(await StoreManager.POIStore.GetItemsAsync(CurrentTrip.Id)); + List poiList = new List(); + try + { + poiList = new List(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();