From 8081d00bbea47d1b986b082f94c9bca2a453f69e Mon Sep 17 00:00:00 2001 From: Elena Date: Wed, 26 Oct 2022 12:32:30 +0200 Subject: [PATCH] Cambios ventana intermedia para elegir nombre de FeatureClass. sin probar. --- Button/ButtonLimp.cs | 3 +-- Helper/HelperGdb.cs | 53 +++++++++++++++++++++++++++++++++++++++--- Model/OliviaConf.cs | 14 +++++------ Services/ConfigServ.cs | 2 +- Services/EjecServ.cs | 29 ++++++++++++++++++----- 5 files changed, 82 insertions(+), 19 deletions(-) diff --git a/Button/ButtonLimp.cs b/Button/ButtonLimp.cs index 48f2c19..8810a7a 100644 --- a/Button/ButtonLimp.cs +++ b/Button/ButtonLimp.cs @@ -29,8 +29,7 @@ namespace OliviaAddInPro if (OliviaGlob.TipoView == TiposEjecucion.Ninguno) { - ///Comprueba que existe la red navegable configurada - + ///Comprueba que existe la red navegable configurada if (!OliviaGlob.CompruebaNwYCampos()) { HelperGlobal.ponMsg("No se encuentra red navegable, cambie Configuración: " + HelperGdb.OutStr, diff --git a/Helper/HelperGdb.cs b/Helper/HelperGdb.cs index 07e9123..caf894b 100644 --- a/Helper/HelperGdb.cs +++ b/Helper/HelperGdb.cs @@ -2013,7 +2013,6 @@ namespace OliviaAddInPro.Helper try { bool? ok = dlg.ShowDialog(); - if ((ok ?? true) && dlg.FilePath.Length > 0) return dlg.FilePath; else @@ -2318,16 +2317,64 @@ namespace OliviaAddInPro.Helper /** * Borrar una feature class de un dataset */ - public static Respuesta DeleteFeatureClass(string gdbPath, string featureClassPath) + public static Respuesta DeleteFeatureClassSync(string gdbPath, string featureClassName) { var res = new Respuesta { Value = false }; - FeatureClass ftclss = GetFtClass(featureClassPath); + + Geodatabase gdb = GetGdbSync(gdbPath); + if (gdb == null) + return res; + + FeatureClass ftclss = GetFtClassSync(featureClassName, gdb); if (ftclss == null) return res; + + Respuesta resp = new Respuesta { Value = false }; + SchemaBuilder schemaBuilder = null; + try + { + // Create a FeatureClassDescription object + FeatureClassDescription featureClassDescription = new FeatureClassDescription(ftclss.GetDefinition()); + // Create a SchemaBuilder object + schemaBuilder = new SchemaBuilder(gdb); + // Add the deletion fo the feature class to our list of DDL tasks + schemaBuilder.Delete(featureClassDescription); + // Execute the DDL + resp.Value = schemaBuilder.Build(); + if (!resp.Value && schemaBuilder.ErrorMessages.Count > 0) + resp.Error.Add(schemaBuilder.ErrorMessages.FirstOrDefault()); + } + catch + { + resp.Error.Add(schemaBuilder.ErrorMessages.FirstOrDefault()); + } + + if (resp.Value) + res.Value = true; + else + { + res.Error.Add(resp.Error.FirstOrDefault()); + } + Free(gdb); + Free(ftclss); + return res; + } + + /** + * Borrar una feature class de un dataset + */ + public static Respuesta DeleteFeatureClass(string gdbPath, string featureClassName) + { + var res = new Respuesta { Value = false }; + Geodatabase gdb = GetGdb(gdbPath).Result; if (gdb == null) return res; + FeatureClass ftclss = GetFtClass(featureClassName,gdb).Result; + if (ftclss == null) + return res; + var task = ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func>)(() => { Respuesta resp = new Respuesta { Value = false }; diff --git a/Model/OliviaConf.cs b/Model/OliviaConf.cs index 23215ba..b1def84 100644 --- a/Model/OliviaConf.cs +++ b/Model/OliviaConf.cs @@ -1069,37 +1069,37 @@ namespace OliviaAddInPro.Model #endregion #region 12TiemposRecoAvanz - [Category("Tiempos de Tratamiento Recogida (min) - Avanzadas")]//OCULTAR + [Category("Tiempos de Tratamiento Recogida (seg) - Avanzadas")]//OCULTAR [DisplayName("Carga Trasera")] [Description("")] public int t_vaci_trasera { get; set; } - [Category("Tiempos de Tratamiento Recogida (min) - Avanzadas")]//OCULTAR + [Category("Tiempos de Tratamiento Recogida (seg) - Avanzadas")]//OCULTAR [DisplayName("Carga Lateral")] [Description("")] public int t_vaci_lateral { get; set; } - [Category("Tiempos de Tratamiento Recogida (min) - Avanzadas")]//OCULTAR + [Category("Tiempos de Tratamiento Recogida (seg) - Avanzadas")]//OCULTAR [DisplayName("Carga superior")] [Description("")] public int t_vaci_superior { get; set; } - [Category("Tiempos de Tratamiento Recogida (min) - Avanzadas")]//OCULTAR + [Category("Tiempos de Tratamiento Recogida (seg) - Avanzadas")]//OCULTAR [DisplayName("Carga Bilateral")] [Description("")] public int t_vaci_bilateral { get; set; } - [Category("Tiempos de Tratamiento Recogida (min) - Avanzadas")]//OCULTAR + [Category("Tiempos de Tratamiento Recogida (seg) - Avanzadas")]//OCULTAR [DisplayName("Bolseo")] [Description("")] public int t_vaci_bolseo { get; set; } - [Category("Tiempos de Tratamiento Recogida (min) - Avanzadas")]//OCULTAR + [Category("Tiempos de Tratamiento Recogida (seg) - Avanzadas")]//OCULTAR [DisplayName("Lavado")] [Description("")] public int t_vaci_lavado { get; set; } - [Category("Tiempos de Tratamiento Recogida (min) - Avanzadas")]//OCULTAR + [Category("Tiempos de Tratamiento Recogida (seg) - Avanzadas")]//OCULTAR [DisplayName("Otro tipo de carga")] [Description("")] public int t_vaci_otra { get; set; } diff --git a/Services/ConfigServ.cs b/Services/ConfigServ.cs index e6c9df8..4218f48 100644 --- a/Services/ConfigServ.cs +++ b/Services/ConfigServ.cs @@ -356,7 +356,7 @@ namespace OliviaAddInPro.Services c.t_vaci_lateral=90; c.t_vaci_superior=180; c.t_vaci_bilateral=100; - c.t_vaci_bolseo=5; + c.t_vaci_bolseo=5*60; c.t_vaci_lavado=60; c.t_vaci_otra=60; c.kgmax_max=20000; diff --git a/Services/EjecServ.cs b/Services/EjecServ.cs index c8a6567..bfaf59f 100644 --- a/Services/EjecServ.cs +++ b/Services/EjecServ.cs @@ -734,6 +734,8 @@ namespace OliviaAddInPro.Services ///////////////////////////////////////// /////mira a ver si tiene configurado Dataset string msg_avisa = string.Empty; + string amb_aux = string.Empty; + bool sobreescribe = false; if (!string.IsNullOrEmpty(OliviaGlob.Paths.PathDatasetImport)) { var datname = new System.IO.DirectoryInfo(OliviaGlob.Paths.PathDatasetImport).Name; @@ -753,10 +755,17 @@ namespace OliviaAddInPro.Services ///////////////////////////////////////// //no tiene un dataset configurado, saca ventana para elegir uno //saca ventana para elegir Dataset, si se cancela, se guarda en el nombre por defecto en función del tratamiento y los ámbitos - //HelperGlobal.ponMsg("A continuación, seleccione nombre de Feature Class para importación. Si cancela el proceso, se establecerán el nombre y Dataset por defecto en función de los ámbitos y el tratamiento"); - string path_aux = HelperGdb.SaveFileDlg("Seleccione Dataset donde importar", GdbFileName, null, ArcGIS.Desktop.Catalog.ItemFilters.featureDatasets_all); + HelperGlobal.ponMsg("A continuación, introduzca nombre de Feature Class y ubicación (Dataset) para importación. Si cancela el proceso, se establecerán el nombre y Dataset por defecto en función de los ámbitos y el tratamiento"); + string path_aux = HelperGdb.SaveFileDlg("Introduzca nombre de Feature Class a importar", GdbFileName, null, ArcGIS.Desktop.Catalog.ItemFilters.featureClasses_all); if (!string.IsNullOrEmpty(path_aux)) + { tratamiento = System.IO.Path.GetDirectoryName(path_aux); + amb_aux = System.IO.Path.GetFileNameWithoutExtension(path_aux); + //comprueba si ya existe ese ft class + FeatureClass ft = HelperGdb.GetFtClass(path_aux); + if (ft != null) + sobreescribe = true; + } } //crea el dataset o comprueba si existe string datasetNameOut = string.Empty; @@ -783,9 +792,6 @@ namespace OliviaAddInPro.Services } string dataset = tratamiento; ///////////////////////////////////////// - //saca ventana para elegir nombre - ShowProWindowSaveFileName wndFileName = new ShowProWindowSaveFileName(ambitos); - string amb_aux = wndFileName.GetName(); if (!string.IsNullOrEmpty(amb_aux)) ambitos = amb_aux; ///////////////////////////////////////// @@ -852,7 +858,18 @@ namespace OliviaAddInPro.Services ///////////////////////////////////////// //se embucla para hacer todas las importaciones necesarias for (i = 0; i < NIMPORT; i++) - { + { + //mira a ver si hay que borrar para reemplazar + if (sobreescribe) + { + resp2 = HelperGdb.DeleteFeatureClassSync(GdbFileName, noms_gdb[i]); + if (!resp2.Value) + { + err_st = "Error al sobreescribir la capa " + noms_gdb[i]; + break; + } + } + resp2 = HelperGdb.ImportShp(dir_shp + "\\" + noms_shp[i] + HelperGdb.SHP_EXT, GdbFileName + "\\" + dataset, noms_gdb[i]); if (!resp2.Value) {