public AddWfsLayerViewModel CreateAddWfsLayerViewModel(ModelStateDictionary modelState, string wfsUrl, string uploadUrl, string successUrl) { AddWfsLayerViewModel model; if (!string.IsNullOrEmpty(wfsUrl)) { try { var wfsCapabilities = WFSManager.GetWFSCapabilitiesAndMergeDescribeFeatureTypes(wfsUrl); var uri = new Uri(wfsUrl); var baseUrl = uri.GetLeftPart(UriPartial.Path); model = AddWfsLayerViewModel.Create(baseUrl, wfsCapabilities); } catch (Exception) { var baseUrl = new UriBuilder(wfsUrl).Uri.GetLeftPart(UriPartial.Path); modelState.AddModelError("", string.Format("The server: {0}, didn't respond correct", baseUrl)); model = AddWfsLayerViewModel.Create(baseUrl); } } else { model = new AddWfsLayerViewModel(); } model.UploadGeoJsonViewModel = new UploadGeoJsonViewModel(uploadUrl, successUrl) { FileFormatDescription = Resource.DataAddWfsLayeraFileUploadForm, FileNameRegEx = "geojson|zip", }; model.ShowFile = base.UserContext.User.PersonId != null; if (model.ShowFile) { var fileNames = MySettingsManager.GetSavedMapDataFiles(base.UserContext); if (fileNames != null) { model.Files = (from fn in fileNames select new AddWfsLayerViewModel.FileViewModel { FileName = fn, Name = fn.IndexOf(".", StringComparison.CurrentCulture) == -1 ? fn : fn.Substring(0, fn.LastIndexOf(".", StringComparison.CurrentCultureIgnoreCase - 1)) }).ToArray(); } } return(model); }
/// <summary> /// Gets all uploaded gis files. /// </summary> /// <returns>A list with the logged in users all uploaded GIS-files.</returns> public List <AddWfsLayerViewModel.FileViewModel> GetAllUploadedGisFiles() { var fileNames = MySettingsManager.GetSavedMapDataFiles(base.UserContext); if (fileNames == null) { return(new List <AddWfsLayerViewModel.FileViewModel>()); } List <AddWfsLayerViewModel.FileViewModel> files = (from fn in fileNames select new AddWfsLayerViewModel.FileViewModel { FileName = fn, Name = fn.IndexOf(".", StringComparison.CurrentCulture) == -1 ? fn : fn.Substring(0, fn.LastIndexOf(".", StringComparison.CurrentCultureIgnoreCase - 1)) }).ToList(); return(files); }