Exemplo n.º 1
0
        /// <summary>
        /// Deletes the selected uploaded gis layers.
        /// </summary>
        /// <param name="filenames">The filenames.</param>
        /// <returns></returns>
        public JsonNetResult DeleteUploadedGisLayers(string[] filenames)
        {
            JsonModel jsonModel;

            try
            {
                jsonModel = JsonModel.CreateSuccess("Ok");

                foreach (string filename in filenames)
                {
                    if (!MySettingsManager.DeleteMapDataFile(GetCurrentUser(), filename))
                    {
                        jsonModel = JsonModel.CreateFailure("Deleting file failed.");
                    }

                    //Check if file layer is in use, if so, remove it
                    var viewManager = new WfsLayersViewManager(GetCurrentUser(), SessionHandler.MySettings);
                    var layer       = viewManager.GetWfsLayers().FirstOrDefault(l => l.Name == GetLayerName(filename));

                    if (layer != null)
                    {
                        viewManager.RemoveWfsLayer(layer.Id);
                    }
                }

                return(new JsonNetResult(jsonModel));
            }
            catch (Exception ex)
            {
                jsonModel = JsonModel.CreateFailure(ex.Message);
            }

            return(new JsonNetResult(jsonModel));
        }
Exemplo n.º 2
0
        public JsonNetResult DeleteMapDataFile(string fileName)
        {
            var jsonModel = JsonModel.CreateSuccess("Ok");

            if (!MySettingsManager.DeleteMapDataFile(GetCurrentUser(), fileName))
            {
                jsonModel = JsonModel.CreateFailure("Deleting file failed.");
            }

            //Check if file layer is in use, if so, remove it
            var viewManager = new WfsLayersViewManager(GetCurrentUser(), SessionHandler.MySettings);
            var layer       = viewManager.GetWfsLayers().FirstOrDefault(l => l.Name == GetLayerName(fileName));

            if (layer != null)
            {
                viewManager.RemoveWfsLayer(layer.Id);
            }

            return(new JsonNetResult(jsonModel));
        }