From 24a96b2c2de14cbe2184f56a896dca5f28f580b1 Mon Sep 17 00:00:00 2001 From: Hualiang Xie Date: Mon, 29 Jul 2019 13:28:55 +0800 Subject: [PATCH] POI returns no route for not covered areas (#1960) --- .../Dialogs/RouteDialog.cs | 2 +- .../Responses/Shared/POISharedResponses.cs | 1 + .../Shared/POISharedResponses.de.json | Bin 21574 -> 22058 bytes .../Shared/POISharedResponses.es.json | Bin 19944 -> 20384 bytes .../Shared/POISharedResponses.fr.json | Bin 21210 -> 21650 bytes .../Shared/POISharedResponses.it.json | Bin 20190 -> 20638 bytes .../Responses/Shared/POISharedResponses.json | 9 +++++++++ .../Shared/POISharedResponses.zh.json | 9 +++++++++ .../Services/AzureMapsGeoSpatialService.cs | 11 +++++++++-- 9 files changed, 29 insertions(+), 3 deletions(-) diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/RouteDialog.cs b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/RouteDialog.cs index 8f04475950..5e0c8d8432 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/RouteDialog.cs +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/RouteDialog.cs @@ -241,7 +241,7 @@ public async Task RouteToFindPointOfInterestBeforeRouteDialog( if (cards.Count() == 0) { - var replyMessage = ResponseManager.GetResponse(POISharedResponses.NoLocationsFound); + var replyMessage = ResponseManager.GetResponse(POISharedResponses.NoRouteFound); await sc.Context.SendActivityAsync(replyMessage); } else if (cards.Count() == 1) diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.cs b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.cs index 31a2ed7412..f64341c127 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.cs +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.cs @@ -25,6 +25,7 @@ public class POISharedResponses : IResponseIdCollection public const string NoLocationsFound = "NoLocationsFound"; public const string MultipleRoutesFound = "MultipleRoutesFound"; public const string SingleRouteFound = "SingleRouteFound"; + public const string NoRouteFound = "NoRouteFound"; public const string PointOfInterestSelection = "PointOfInterestSelection"; public const string CurrentLocationMultipleSelection = "CurrentLocationMultipleSelection"; public const string CurrentLocationSingleSelection = "CurrentLocationSingleSelection"; diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.de.json b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.de.json index e33dea24626190b6b05d53d2fdaef20e9c6ebddd..339807fc8c58a934e09f52fe1704b7e81e1721ae 100644 GIT binary patch delta 94 zcmX@Mf^pRv#tn~zc>Ngi8G?Ygl%a$nb@D}J#mNPl7K}QR83ke|Cs?pe-oTH2IN@*yLY^I-B`~EgS*C#UA(o delta 26 icmZ3rhVj@6#tn~zCf_sGnf!}CWby?8mCaeA2OI#Zm<#j( diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.es.json b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.es.json index 78063102c2efc07a9570adebfad97b3a7326b886..89d4a467fc946e7bd46420c0537046861fadffef 100644 GIT binary patch delta 124 zcmaDcn{mN>#tpXwnEe>?C;RegPhKD^HQ7N;j!|cFqqFa1J$oI=RE9i;WQKeoS;A1n w@RC6R$jSub^vQ+-!jr#nN=;6%(<7uxRcZ1iU8l)Bc4?Cp1cWx%31-;<0O)%oy#N3J delta 18 acmZ25pYg?P#tpXwCNI#}*}PBakqrP-cL?CwmHLPyWC!HM!17j!|c_p|J1d56%XYX9@GMCNh*VBu@?$ l5}o|bLu#@Buh8Ty7KzCL&Kzj6ViHP|g*?PI{}Z}n4*;Qq9i9LH delta 34 scmV+-0NwwRsR7!h0kHlOlZrDeldKkoliU?7lL{;-lm0Xyv)mQ7J`NHN@&Et; diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.it.json b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.it.json index ed63559d71e508d9bb1bca4bfa1644ec2654c4bf..f2470fde865811dfa028caedda4dab10e6c2d579 100644 GIT binary patch delta 96 zcmcaNmvP=g#tokYnEe>?C%f`#PoAJBHQ7x~j!|cFB46xeEf$%{3+x5h^B7VYiW!P0 nzZVmqti&oaIe}ATvJQ(BhTIkdmB~tSVw3Ob>1>u0JYWj|!ml0# delta 18 acmbQYkn!GJ#tokYCeJg_*?dpvfGq%2Hwc^n diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.json b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.json index 1247e92fb2..746c5d45e3 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.json +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.json @@ -216,6 +216,15 @@ ], "inputHint": "expectingInput" }, + "NoRouteFound": { + "replies": [ + { + "text": "Sorry, I didn't find any route.", + "speak": "Sorry, I didn't find any route." + } + ], + "inputHint": "acceptingInput" + }, "PointOfInterestSelection": { "replies": [ { diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.zh.json b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.zh.json index 786a26e0aa..9407ff63dd 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.zh.json +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.zh.json @@ -226,6 +226,15 @@ ], "inputHint": "expectingInput" }, + "NoRouteFound": { + "inputHint": "acceptingInput", + "replies": [ + { + "text": "对不起,我找不到任何路线。", + "speak": "对不起,我找不到任何路线。" + } + ] + }, "CurrentLocationSingleSelection": { "replies": [ { diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Services/AzureMapsGeoSpatialService.cs b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Services/AzureMapsGeoSpatialService.cs index 6097a720e9..8c98bd6f63 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Services/AzureMapsGeoSpatialService.cs +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Services/AzureMapsGeoSpatialService.cs @@ -265,9 +265,16 @@ void AddPoint(double longitude, double latitude) /// RouteDirections. private async Task GetRouteDirectionsAsync(string url) { - var response = await httpClient.GetStringAsync(url); + var response = await httpClient.GetAsync(url); + + var apiResponse = new RouteDirections(); - var apiResponse = JsonConvert.DeserializeObject(response); + // TODO when it returns 400 for uncovered areas, we return no route instead. For other unsuccessful codes, exception is thrown as usual + if (response.StatusCode != System.Net.HttpStatusCode.BadRequest) + { + response = response.EnsureSuccessStatusCode(); + apiResponse = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + } apiResponse.Provider = PointOfInterestModel.AzureMaps;