From a514a601b31dd4e9ab8455e62dbeb3f8d026ec20 Mon Sep 17 00:00:00 2001 From: Zack Allen Date: Fri, 26 Jun 2020 13:57:14 -0700 Subject: [PATCH] Improved error messages for local server samples (#805) --- .../LocalServerFeatureLayer.xaml.cs | 9 +++++++-- .../LocalServerFeatureLayer/readme.md | 2 +- .../LocalServerGeoprocessing.xaml.cs | 9 +++++++-- .../LocalServerGeoprocessing/readme.md | 2 +- .../LocalServerMapImageLayer.xaml.cs | 9 +++++++-- .../LocalServerMapImageLayer/readme.md | 2 +- .../LocalServerServices.xaml.cs | 20 +++++++++++++------ .../LocalServerServices/readme.md | 2 +- 8 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerFeatureLayer/LocalServerFeatureLayer.xaml.cs b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerFeatureLayer/LocalServerFeatureLayer.xaml.cs index 06850ab590..0011ba87a4 100644 --- a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerFeatureLayer/LocalServerFeatureLayer.xaml.cs +++ b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerFeatureLayer/LocalServerFeatureLayer.xaml.cs @@ -12,7 +12,9 @@ using Esri.ArcGISRuntime.LocalServices; using Esri.ArcGISRuntime.Mapping; using System; +using System.Diagnostics; using System.IO; +using System.Reflection; using System.Windows; namespace ArcGISRuntime.WPF.Samples.LocalServerFeatureLayer @@ -23,7 +25,7 @@ namespace ArcGISRuntime.WPF.Samples.LocalServerFeatureLayer description: "Start a local feature service and display its features in a map.", instructions: "A Local Server and Local Feature Service will automatically be started. Once started then a `FeatureLayer` will be created and added to the map.", tags: new[] { "feature service", "local", "offline", "server", "service" })] - [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("4e94fec734434d1288e6ebe36c3c461f")] + [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("4e94fec734434d1288e6ebe36c3c461f")] public partial class LocalServerFeatureLayer { // Hold a reference to the local feature service; the ServiceFeatureTable will be loaded from this service @@ -62,7 +64,10 @@ private async void Initialize() } catch (Exception ex) { - MessageBox.Show(String.Format("Please ensure that local server is installed prior to using the sample. See instructions in readme.md. Message: {0}", ex.Message), "Local Server failed to start"); + var localServerTypeInfo = typeof(LocalMapService).GetTypeInfo(); + var localServerVersion = FileVersionInfo.GetVersionInfo(localServerTypeInfo.Assembly.Location); + + MessageBox.Show($"Please ensure that local server {localServerVersion.FileVersion} is installed prior to using the sample. The download link is in the description. Message: {ex.Message}", "Local Server failed to start"); return; } diff --git a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerFeatureLayer/readme.md b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerFeatureLayer/readme.md index 1cbe10cd99..fd74bb535b 100644 --- a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerFeatureLayer/readme.md +++ b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerFeatureLayer/readme.md @@ -43,7 +43,7 @@ This sample downloads the following items from ArcGIS Online automatically: ## Additional information -Local Server can be downloaded for Windows and Linux platforms. Local Server is not supported on macOS. +Local Server can be downloaded for Windows and Linux platforms from the [developers website](https://developers.arcgis.com/downloads/apis-and-sdks?product=local-server#arcgis-runtime-local-server). Local Server is not supported on macOS. ## Tags diff --git a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerGeoprocessing/LocalServerGeoprocessing.xaml.cs b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerGeoprocessing/LocalServerGeoprocessing.xaml.cs index ec82869b1a..78ecadee1a 100644 --- a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerGeoprocessing/LocalServerGeoprocessing.xaml.cs +++ b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerGeoprocessing/LocalServerGeoprocessing.xaml.cs @@ -13,7 +13,9 @@ using Esri.ArcGISRuntime.Tasks; using Esri.ArcGISRuntime.Tasks.Geoprocessing; using System; +using System.Diagnostics; using System.IO; +using System.Reflection; using System.Windows; using System.Windows.Controls; @@ -25,7 +27,7 @@ namespace ArcGISRuntime.WPF.Samples.LocalServerGeoprocessing description: "Create contour lines from local raster data using a local geoprocessing package `.gpk` and the contour geoprocessing tool.", instructions: "Contour Line Controls (Top Left):", tags: new[] { "geoprocessing", "local", "offline", "parameters", "processing", "service" })] - [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("f7c7b4a30fb9415896ba0d1921fe014b", "da9e565a52ca41c1937cff1a01017068")] + [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("f7c7b4a30fb9415896ba0d1921fe014b", "da9e565a52ca41c1937cff1a01017068")] public partial class LocalServerGeoprocessing { // Hold a reference to the local geoprocessing service @@ -98,7 +100,10 @@ private async void Initialize() } catch (Exception ex) { - MessageBox.Show(String.Format("Please ensure that local server is installed prior to using the sample. See instructions in readme.md. Message: {0}", ex.Message), "Local Server failed to start"); + var localServerTypeInfo = typeof(LocalMapService).GetTypeInfo(); + var localServerVersion = FileVersionInfo.GetVersionInfo(localServerTypeInfo.Assembly.Location); + + MessageBox.Show($"Please ensure that local server {localServerVersion.FileVersion} is installed prior to using the sample. The download link is in the description. Message: {ex.Message}", "Local Server failed to start"); return; } diff --git a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerGeoprocessing/readme.md b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerGeoprocessing/readme.md index 39cec823a5..d521a73634 100644 --- a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerGeoprocessing/readme.md +++ b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerGeoprocessing/readme.md @@ -56,7 +56,7 @@ This sample downloads the following items from ArcGIS Online automatically: ## Additional information -Local Server can be downloaded for Windows and Linux platforms. Local Server is not supported on macOS. +Local Server can be downloaded for Windows and Linux platforms from the [developers website](https://developers.arcgis.com/downloads/apis-and-sdks?product=local-server#arcgis-runtime-local-server). Local Server is not supported on macOS. ## Tags diff --git a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerMapImageLayer/LocalServerMapImageLayer.xaml.cs b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerMapImageLayer/LocalServerMapImageLayer.xaml.cs index f13332fe1a..32b6cc6dee 100644 --- a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerMapImageLayer/LocalServerMapImageLayer.xaml.cs +++ b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerMapImageLayer/LocalServerMapImageLayer.xaml.cs @@ -11,7 +11,9 @@ using Esri.ArcGISRuntime.LocalServices; using Esri.ArcGISRuntime.Mapping; using System; +using System.Diagnostics; using System.IO; +using System.Reflection; using System.Windows; namespace ArcGISRuntime.WPF.Samples.LocalServerMapImageLayer @@ -22,7 +24,7 @@ namespace ArcGISRuntime.WPF.Samples.LocalServerMapImageLayer description: "Start the Local Server and Local Map Service, create an ArcGIS Map Image Layer from the Local Map Service, and add it to a map.", instructions: "The Local Server and local map service will automatically be started and, once running, a map image layer will be created and added to the map.", tags: new[] { "image", "layer", "local", "offline", "server" })] - [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("dee5d8060a6048a4b063484199a9546b")] + [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("dee5d8060a6048a4b063484199a9546b")] public partial class LocalServerMapImageLayer { // Hold a reference to the local map service @@ -85,7 +87,10 @@ private async void Initialize() } catch (Exception ex) { - MessageBox.Show(string.Format("Please ensure that local server is installed prior to using the sample. See instructions in readme.md. Message: {0}", ex.Message), "Local Server failed to start"); + var localServerTypeInfo = typeof(LocalMapService).GetTypeInfo(); + var localServerVersion = FileVersionInfo.GetVersionInfo(localServerTypeInfo.Assembly.Location); + + MessageBox.Show($"Please ensure that local server {localServerVersion.FileVersion} is installed prior to using the sample. The download link is in the description. Message: {ex.Message}", "Local Server failed to start"); } } diff --git a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerMapImageLayer/readme.md b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerMapImageLayer/readme.md index 7a9d771870..5436ddc21f 100644 --- a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerMapImageLayer/readme.md +++ b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerMapImageLayer/readme.md @@ -40,7 +40,7 @@ This sample downloads the following items from ArcGIS Online automatically: ## Additional information -Local Server can be downloaded for Windows and Linux platforms. Local Server is not supported on macOS. +Local Server can be downloaded for Windows and Linux platforms from the [developers website](https://developers.arcgis.com/downloads/apis-and-sdks?product=local-server#arcgis-runtime-local-server). Local Server is not supported on macOS. ## Tags diff --git a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerServices/LocalServerServices.xaml.cs b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerServices/LocalServerServices.xaml.cs index 1fc289bb14..867e650572 100644 --- a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerServices/LocalServerServices.xaml.cs +++ b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerServices/LocalServerServices.xaml.cs @@ -10,8 +10,10 @@ using ArcGISRuntime.Samples.Managers; using Esri.ArcGISRuntime.LocalServices; using System; +using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; using System.Windows; using System.Windows.Controls; @@ -23,7 +25,7 @@ namespace ArcGISRuntime.WPF.Samples.LocalServerServices description: "Demonstrates how to start and stop the Local Server and start and stop a local map, feature, and geoprocessing service running on the Local Server.", instructions: "Click `Start Local Server` to start the Local Server. Click `Stop Local Server` to stop the Local Server.", tags: new[] { "feature", "geoprocessing", "local services", "map", "server", "service" })] - [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("dee5d8060a6048a4b063484199a9546b", "4e94fec734434d1288e6ebe36c3c461f", "da9e565a52ca41c1937cff1a01017068")] + [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("dee5d8060a6048a4b063484199a9546b", "4e94fec734434d1288e6ebe36c3c461f", "da9e565a52ca41c1937cff1a01017068")] public partial class LocalServerServices { // Hold references to the individual services @@ -54,7 +56,10 @@ private void Initialize() } catch (Exception ex) { - MessageBox.Show(String.Format("Please ensure that local server is installed prior to using the sample. See instructions in readme.md. Message: {0}", ex.Message), "Local Server failed to start"); + var localServerTypeInfo = typeof(LocalMapService).GetTypeInfo(); + var localServerVersion = FileVersionInfo.GetVersionInfo(localServerTypeInfo.Assembly.Location); + + MessageBox.Show($"Please ensure that local server {localServerVersion.FileVersion} is installed prior to using the sample. The download link is in the description. Message: {ex.Message}", "Local Server failed to start"); } } @@ -213,7 +218,7 @@ private async void StartServerButtonClicked(object sender, RoutedEventArgs e) string tempDataPath = Path.Combine(tempDataPathRoot, "EsriSamples", "AppData"); Directory.CreateDirectory(tempDataPath); // CreateDirectory won't overwrite if it already exists. LocalServer.Instance.AppDataPath = tempDataPath; - + // Start the server await LocalServer.Instance.StartAsync(); @@ -222,7 +227,10 @@ private async void StartServerButtonClicked(object sender, RoutedEventArgs e) } catch (Exception ex) { - MessageBox.Show(ex.Message, "Local Server Failed to start"); + var localServerTypeInfo = typeof(LocalMapService).GetTypeInfo(); + var localServerVersion = FileVersionInfo.GetVersionInfo(localServerTypeInfo.Assembly.Location); + + MessageBox.Show($"Please ensure that local server {localServerVersion.FileVersion} is installed prior to using the sample. The download link is in the description. Message: {ex.Message}", "Local Server failed to start"); } // Update the UI @@ -264,7 +272,7 @@ private void NavigateButtonClicked(object sender, RoutedEventArgs e) string serviceUri = strFullName.Split(splitChars, 2)[1].Trim(); // Navigate to the service - System.Diagnostics.Process.Start(serviceUri); + Process.Start(serviceUri); } catch (Exception ex) { @@ -272,4 +280,4 @@ private void NavigateButtonClicked(object sender, RoutedEventArgs e) } } } -} +} \ No newline at end of file diff --git a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerServices/readme.md b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerServices/readme.md index 7d3c5deff0..1a6e7d788c 100644 --- a/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerServices/readme.md +++ b/src/WPF/ArcGISRuntime.WPF.Viewer/Samples/Local Server/LocalServerServices/readme.md @@ -45,7 +45,7 @@ To start a `LocalServer` and attach a `LocalService`: ## Additional information -Local Server can be downloaded for Windows and Linux platforms. Local Server is not supported on macOS. +Local Server can be downloaded for Windows and Linux platforms from the [developers website](https://developers.arcgis.com/downloads/apis-and-sdks?product=local-server#arcgis-runtime-local-server). Local Server is not supported on macOS. ## Tags