public void AddCacheSettings() { try { var dlgService = new ArcgisServiceDialog(); dlgService.Owner = View; dlgService.ShowDialog(); if (dlgService.DialogResult == true) { var service = dlgService.ViewModel.Service; var dlgCache = new EditCacheDialog(); dlgCache.Owner = View; dlgCache.ViewModel.MapService = service; dlgCache.ShowDialog(); if (dlgCache.DialogResult == true) { Configuration.MapServices.Add(dlgCache.ViewModel.Configuration); } } } catch (Exception ex) { ErrorHelper.OnError(MethodBase.GetCurrentMethod().DeclaringType.Name, "Error adding cache settings", ex); } }
private void ServiceInfo_RetrieveFeatureInfoCompleted(object sender, RetrieveFeatureInfoEventArgs e) { try { ArcGisServiceInfo.ServiceInfo.RetrieveFeatureInfoCompleted -= ServiceInfo_RetrieveFeatureInfoCompleted; if (e.Error != null) { ErrorHelper.OnError(MethodBase.GetCurrentMethod().DeclaringType.Name, "Error pulling service info", e.Error); return; } if (_pollObject is CacheSettings) { var cache = _pollObject as CacheSettings; var index = Configuration.MapServices.IndexOf(cache); var name = cache.Name; Application.Current.Dispatcher.BeginInvoke((Action)(() => { var dlgCache = new EditCacheDialog(); dlgCache.ViewModel.Configuration = cache; dlgCache.ViewModel.MapService = e.FeatureData; dlgCache.ShowDialog(); if (dlgCache.DialogResult == true) { Configuration.MapServices[index] = dlgCache.ViewModel.Configuration; foreach (var gcdr in Configuration.Geocoders.Where(gcdr => gcdr.CacheName == name)) { gcdr.CacheName = Configuration.MapServices[index].Name; } foreach (var stint in Configuration.StreetList.Where(stint => stint.CacheName == name)) { stint.CacheName = Configuration.MapServices[index].Name; } } })); } else if (_pollObject is GeocoderSettings) { var geocoder = _pollObject as GeocoderSettings; var index = Configuration.Geocoders.IndexOf(geocoder); var cache = Configuration.MapServices.FirstOrDefault(cach => cach.Name == geocoder.CacheName); var layer = e.FeatureData.Layers.FirstOrDefault(lyr => lyr.Name == geocoder.LayerName); Application.Current.Dispatcher.BeginInvoke((Action)(() => { var dlgCache = new EditGeocoderDialog(); dlgCache.ViewModel.LayerInfo = layer; dlgCache.ViewModel.Configuration = geocoder; dlgCache.ShowDialog(); if (dlgCache.DialogResult == true) { Configuration.Geocoders[index] = dlgCache.ViewModel.Configuration; } })); } else { ErrorHelper.OnMessage("Service polled for unknown object"); } } catch (Exception ex) { ErrorHelper.OnError(MethodBase.GetCurrentMethod().DeclaringType.Name, "Error editing cache settings", ex); } }