Cambios ventana intermedia para elegir nombre de FeatureClass. sin probar.

Gerardo/Compilacion.net
Elena 2022-10-26 12:32:30 +02:00
parent 23cd733c9b
commit 8081d00bbe
5 changed files with 82 additions and 19 deletions

View File

@ -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,

View File

@ -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<bool> DeleteFeatureClass(string gdbPath, string featureClassPath)
public static Respuesta<bool> DeleteFeatureClassSync(string gdbPath, string featureClassName)
{
var res = new Respuesta<bool> { 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<bool> resp = new Respuesta<bool> { 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<bool> DeleteFeatureClass(string gdbPath, string featureClassName)
{
var res = new Respuesta<bool> { 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<bool>>)(() =>
{
Respuesta<bool> resp = new Respuesta<bool> { Value = false };

View File

@ -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; }

View File

@ -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;

View File

@ -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)
{