diff --git a/Helper/HelperGdb.cs b/Helper/HelperGdb.cs index 73e6547..0dad392 100644 --- a/Helper/HelperGdb.cs +++ b/Helper/HelperGdb.cs @@ -1904,25 +1904,48 @@ namespace OliviaAddInPro.Helper /** * Abre en el mapa la capa seleccionada, con los parámetros seleccionados */ - public static bool OpenLayer(string ftclasspath, string campValUniq, bool visible=true) + public static bool OpenLayerUniqueValue(string ftclasspath, string campValUniq, bool visible=true) { var mapView = MapView.Active; int indexNumber = mapView.Map.Layers.Count; string ftclassname = System.IO.Path.GetFileNameWithoutExtension(ftclasspath); if (mapView != null)//Check if there is a map { - System.Uri ftclass_uri = new System.Uri(ftclasspath); //creating uri for the ftclass - //mira el tipo de geometría - GeometryType tipo = GetGeomType(ftclasspath); - var task=QueuedTask.Run(() => + try { - Layer layer = LayerFactory.Instance.CreateLayer(ftclass_uri, mapView.Map, indexNumber, ftclassname); - var selectedLayer = mapView.GetSelectedLayers()[0] as FeatureLayer; - //Do something with selected layer - SetSimpleRendererPoint(selectedLayer,campValUniq,tipo); - selectedLayer.SetVisibility(visible); - }); - task.Wait(); + System.Uri ftclass_uri = new System.Uri(ftclasspath); //creating uri for the ftclass + //mira el tipo de geometría + GeometryType tipo = GetGeomType(ftclasspath); + if (tipo == GeometryType.Unknown) + return false; + var task = QueuedTask.Run(() => + { + Layer layer = null; + FeatureLayer selectedLayer = null; + try + { + layer = mapView.Map.FindLayer(ftclass_uri.ToString()); + selectedLayer = layer as FeatureLayer; + } + catch + { + layer = null; + } + if (layer == null) + { + layer = LayerFactory.Instance.CreateLayer(ftclass_uri, mapView.Map, indexNumber, ftclassname); + selectedLayer = mapView.GetSelectedLayers()[0] as FeatureLayer; + } + //Do something with selected layer + SetSimpleRendererPoint(selectedLayer, campValUniq, tipo); + selectedLayer.SetVisibility(visible); + }); + task.Wait(); + } + catch + { + return false; + } } return true; } @@ -1931,6 +1954,8 @@ namespace OliviaAddInPro.Helper */ internal static void SetSimpleRendererPoint(FeatureLayer featureLayer, string field, GeometryType tipo) { + if (featureLayer == null) + return; //QueuedTask.Run(() => //{ try diff --git a/Services/EjecServ.cs b/Services/EjecServ.cs index 573a690..a9cf1bb 100644 --- a/Services/EjecServ.cs +++ b/Services/EjecServ.cs @@ -377,14 +377,24 @@ namespace OliviaAddInPro.Services */ public Respuesta ImportSecto(string GdbFileName) { - var res = new Respuesta { Value = string.Empty }; - res = Import(GdbFileName, 0); - if (res.HasError) + var res = Import(GdbFileName, 0); + if (res.HasError || string.IsNullOrEmpty(res.Value)) + { return res; + } ////////////////////////////////////////////////// //abre las capas, pintando los sectores - - + bool mal = false; + string path_import = res.Value; + string path_lyr = path_import; + if(HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector)) + { + res.Error.Add("Error al abrir capa "+ path_lyr + " con Valor único."); + res.Value = string.Empty; + mal = true; + } + if(!mal) + res.Value = path_import; return res; } /** @@ -597,26 +607,73 @@ namespace OliviaAddInPro.Services * Realiza las funciones de importación de la planificación */ public Respuesta ImportPlanif(string GdbFileName) - { - var res = new Respuesta { Value = string.Empty }; - res = Import(GdbFileName, 1); - if (res.HasError) + { + var res = Import(GdbFileName, 1); + if (res.HasError || string.IsNullOrEmpty(res.Value)) + { + res.Value = string.Empty; return res; - //abre las capas, pintando por sectores + } + ////////////////////////////////////////////////// + //abre las capas, pintando los sectores + string path_import = res.Value; ///////////////////////////////////////////////////// //la primera capa que se añade es la de ruta, se le quita la visualización porque lo que interesa //de esa capa es poder acceder si fuera necesario a la tabla de atributos. shape + name_ruta_out + bool mal = false; + string path_lyr = path_import + NAME_RUTA_OUT; + if (!HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector,false)) + mal = true; ///////////////////////////////////////////////////// //la siguiente es la de ruta2, se le quita la visualización porque lo que interesa //de esa capa es poder acceder si fuera necesario a la tabla de atributos. shape + name_ruta2_out + if (!mal) + { + path_lyr = path_import + NAME_RUTA2_OUT; + if (!HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector, false)) + mal = true; + } ///////////////////////////////////////////////////// //se añade la capa de ruta_aux y se pinta por sectores - shape + name_ruta_out + name_aux + if (!mal) + { + path_lyr = path_import + NAME_RUTA_OUT + NAME_AUX; + if (!HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector, false)) + mal = true; + } ///////////////////////////////////////////////////// //se añade la capa de ambitos original con la secto, y se pinta por sectores - shape + if (!mal) + { + path_lyr = path_import; + if (!HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector, false)) + mal = true; + } ///////////////////////////////////////////////////// //se añade la capa de la ruta a las instalaciones, comprueba si hay configurada coordenadas de la instalación - shape + name_inst_out + if (!mal) + { + path_lyr = path_import + NAME_INSTAL_OUT; + if (!HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector, false)) + mal = true; + } //se abre la capa de puntos de control y se pintan por el sector al que pertenecen - shape + name_control_out - + if (!mal) + { + path_lyr = path_import + NAME_CONTROL_OUT; + if (!HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector, false)) + mal = true; + } + ///////////////////////////////////////////////////// + if (mal) + { + res.Value = string.Empty; + res.Error.Add("Error al abrir capa " + path_lyr + " con Valor único."); + } + else + { + res.Value = path_import; + } return res; } diff --git a/Services/FinProcServ.cs b/Services/FinProcServ.cs index 36d1570..c5ecd6d 100644 --- a/Services/FinProcServ.cs +++ b/Services/FinProcServ.cs @@ -130,6 +130,8 @@ namespace OliviaAddInPro.Services msg = Resource1.String_exito; //pone modo config2 OliviaGlob.AddFlagTipEjec(TiposEjecucion.Config2); + //actualiza la capa de la que tiene que leer ahora para planificar + inst.CapaElems = resp.Value; } } } diff --git a/ViewModel/Limpieza/DockpaneLimpiezaViewModel.cs b/ViewModel/Limpieza/DockpaneLimpiezaViewModel.cs index 814e8a6..477b626 100644 --- a/ViewModel/Limpieza/DockpaneLimpiezaViewModel.cs +++ b/ViewModel/Limpieza/DockpaneLimpiezaViewModel.cs @@ -24,7 +24,7 @@ namespace OliviaAddInPro public class DockpaneLimpiezaViewModel : DockPane { private bool firstTimeShow = true; - private static bool hideTemp = false; + private static bool hideTemp = false; private const string _dockPaneID = "OliviaAddInPro_DockpaneLimpieza"; private PaneLimpiezaViewModel _pane; public DockpaneLimpiezaViewModel() @@ -50,7 +50,7 @@ namespace OliviaAddInPro DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID); if (pane == null) return; - hideTemp = true; //avisa de que solo esconde temporalmente, no para siempre + hideTemp = true; //avisa de que es manual, no por cierre del botón pane.Hide(); } @@ -63,11 +63,11 @@ namespace OliviaAddInPro //The parameter passed to this method will be true if the Dockpane is being opened and it is false when you close the dockpane protected override void OnShow(bool isVisible) { - /*if (isVisible == false && !firstTimeShow && !hideTemp) + if (isVisible == false && !firstTimeShow && !hideTemp) { //avisa de cerrar la ventana - OliviaGlob.SetFlagTipEjec(TiposEjecucion.Ninguno); - }*/ + OliviaGlob.SetFlagTipEjec(TiposEjecucion.Ninguno); + } if (firstTimeShow) firstTimeShow = false; } diff --git a/ViewModel/Recogida/DockpaneRecogidaViewModel.cs b/ViewModel/Recogida/DockpaneRecogidaViewModel.cs index 513f754..442a550 100644 --- a/ViewModel/Recogida/DockpaneRecogidaViewModel.cs +++ b/ViewModel/Recogida/DockpaneRecogidaViewModel.cs @@ -61,11 +61,11 @@ namespace OliviaAddInPro //also false the first time protected override void OnShow(bool isVisible) { - /* if (isVisible == false && !firstTimeShow && !hideTemp) + if (isVisible == false && !firstTimeShow && !hideTemp) { //avisa de cerrar la ventana OliviaGlob.SetFlagTipEjec(TiposEjecucion.Ninguno); - }*/ + } if (firstTimeShow) firstTimeShow = false; }