Merge branch 'develop' of https://www.narvaling.com/Bonobo.Git.Server/OliviaAddInPro into develop
commit
a728cf770f
|
|
@ -38,7 +38,7 @@
|
|||
<tooltip heading="OLIVIA - Recogida de Residuos">
|
||||
Add-In de ArcGIS Pro para la herramienta de optimización de la limpieza viaria, OLIVIA<disabledText /></tooltip>
|
||||
</button>
|
||||
<button id="OliviaAddInPro_ButtonConfig" caption="Configuración" className="ButtonConfig" loadOnClick="true" largeImage="Images/config2.png">
|
||||
<button id="OliviaAddInPro_ButtonConfig" caption="Configuración" className="ButtonConfig" loadOnClick="true" largeImage="Images/config2_olv.png">
|
||||
<tooltip heading="OLIVIA - Configuración">
|
||||
Add-In de ArcGIS Pro para la herramienta de optimización de la limpieza viaria, OLIVIA<disabledText /></tooltip>
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -562,7 +562,7 @@ namespace OliviaAddInPro.Helper
|
|||
return ftclss;
|
||||
}
|
||||
//devuelve el campo dado el nombre
|
||||
private static ArcGIS.Core.Data.Field GetFieldByNameSinc(FeatureClass ftClss, string fieldName)
|
||||
private static ArcGIS.Core.Data.Field GetFieldByNameSync(FeatureClass ftClss, string fieldName)
|
||||
{
|
||||
FeatureClassDefinition ftcldef = ftClss.GetDefinition();
|
||||
ReiniciaOutStr();
|
||||
|
|
@ -739,9 +739,10 @@ namespace OliviaAddInPro.Helper
|
|||
if (!fields.Contains(field))
|
||||
{
|
||||
HelperGdb.OutStr = "No se encuentra el campo " + field;
|
||||
Free(fc);
|
||||
return false;
|
||||
}
|
||||
|
||||
Free(fc);
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
|
|
@ -757,13 +758,14 @@ namespace OliviaAddInPro.Helper
|
|||
}
|
||||
|
||||
ObservableCollection<string> fields = GetFieldsSync(fc);
|
||||
bool encuentra = true;
|
||||
if (!fields.Contains(field))
|
||||
{
|
||||
HelperGdb.OutStr = "No se encuentra el campo " + field;
|
||||
return false;
|
||||
encuentra= false;
|
||||
}
|
||||
|
||||
return true;
|
||||
Free(fc);
|
||||
return encuentra;
|
||||
}
|
||||
/*
|
||||
* Lee la capa que se ha seleccionzdo de recogida y se comprueba que contiene los campos necesarios
|
||||
|
|
@ -1946,12 +1948,27 @@ namespace OliviaAddInPro.Helper
|
|||
if (brwsFilt != null)
|
||||
dlg.BrowseFilter = brwsFilt;
|
||||
|
||||
bool? ok = dlg.ShowDialog();
|
||||
try
|
||||
{
|
||||
bool? ok = dlg.ShowDialog();
|
||||
|
||||
if ((ok ?? true) && dlg.FilePath.Length > 0)
|
||||
return dlg.FilePath;
|
||||
else
|
||||
if ((ok ?? true) && dlg.FilePath.Length > 0)
|
||||
return dlg.FilePath;
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saca diálogo para elegir directorio
|
||||
*/
|
||||
public static string FolderBrowseDlg(string title_, string initloc_)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2391,5 +2408,113 @@ namespace OliviaAddInPro.Helper
|
|||
Free(ftcl);
|
||||
return tipo;
|
||||
}
|
||||
|
||||
/*
|
||||
* Renombra un campo de la feature class dada
|
||||
*/
|
||||
public static bool RenameFieldSync(string fcname, string oldFieldName, string newFieldName, string newFieldAlias)
|
||||
{
|
||||
bool res = false;
|
||||
string[] args = { fcname, oldFieldName, newFieldName,newFieldAlias };
|
||||
// execute the tool
|
||||
try
|
||||
{
|
||||
var gpres = Geoprocessing.ExecuteToolAsync("management.AlterField", args);
|
||||
if (gpres.Result.IsFailed)
|
||||
{
|
||||
var gpResult = gpres.Result;
|
||||
string msg;
|
||||
if (gpResult.ErrorMessages != null)
|
||||
msg = gpResult.ErrorMessages.First().Text;
|
||||
else
|
||||
msg = "Errores al renombrar campo "+newFieldName;
|
||||
}
|
||||
else
|
||||
res= true; //ha ido bien
|
||||
return res;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
public struct FieldToAdd
|
||||
{
|
||||
public string Name;
|
||||
public string Tipo; //LONG, TEXT, ...
|
||||
public string Alias;
|
||||
public int Length;
|
||||
|
||||
public FieldToAdd(string nomb, string tip, string al, int len)
|
||||
{
|
||||
Name = nomb; //obligatorio
|
||||
Tipo = tip; //obligatorio
|
||||
Alias = al;
|
||||
Length = len;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Renombra un campo de la feature class dada
|
||||
*/
|
||||
public static bool AddFieldsSync(string fcname, FieldToAdd[] fields)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
// set up the arguments
|
||||
string fields_str = "";
|
||||
int camps = 0;
|
||||
for(int i=0;i<fields.Length;i++)
|
||||
{
|
||||
if (CheckFieldSync(fcname, fields[i].Name))
|
||||
continue;
|
||||
camps++;
|
||||
|
||||
fields_str += fields[i].Name + " " + fields[i].Tipo + " ";
|
||||
if (!string.IsNullOrEmpty(fields[i].Alias))
|
||||
fields_str += fields[i].Alias;
|
||||
else
|
||||
fields_str += "#";
|
||||
|
||||
fields_str += " ";
|
||||
if (fields[i].Length != 0)
|
||||
fields_str += fields[i].Length;
|
||||
else
|
||||
fields_str += "#";
|
||||
fields_str += " #"; //def value siempre #
|
||||
|
||||
if (i < fields.Length - 1)
|
||||
fields_str += ";";
|
||||
}
|
||||
if (camps == 0)
|
||||
return true;//no tiene que añadir ningún campo porque los tiene
|
||||
|
||||
//var f1 = "field1 long field1 # #;field2 Text # 255 myDefaultValue"; //los # son opciones sin rellenar el orden es: Nombre Tipo Alias Longitud Valor Defecto
|
||||
|
||||
var args = Geoprocessing.MakeValueArray(fcname, fields_str);
|
||||
|
||||
// run the tool
|
||||
try
|
||||
{
|
||||
var gpres = Geoprocessing.ExecuteToolAsync("management.AddFields", args);
|
||||
if (gpres.Result.IsFailed)
|
||||
{
|
||||
var gpResult = gpres.Result;
|
||||
string msg;
|
||||
if (gpResult.ErrorMessages != null)
|
||||
msg = gpResult.ErrorMessages.First().Text;
|
||||
else
|
||||
msg = "Errores al añadir campos";
|
||||
}
|
||||
else
|
||||
res = true; //ha ido bien
|
||||
return res;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
|
|
@ -66,9 +66,12 @@ namespace OliviaAddInPro.Model
|
|||
/////
|
||||
///DEBUG
|
||||
///
|
||||
/*Respuesta<TiposEjecucion> res1 = new Respuesta<TiposEjecucion> { Value = TiposEjecucion.FinEjecOk };
|
||||
HelperGdb.OpenLayer(@"C:\Users\Elena\Documents\ArcGIS\Projects\MyProject3\MyProject3.gdb\Barrido_man\BarMan_AceM_AceNM_20220529_134336", "SECTOR", true);
|
||||
return res1;*/
|
||||
//Respuesta<TiposEjecucion> res1 = new Respuesta<TiposEjecucion> { Value = TiposEjecucion.FinEjecOk };
|
||||
//HelperGdb.OpenLayer(@"C:\Users\Elena\Documents\ArcGIS\Projects\MyProject3\MyProject3.gdb\Barrido_man\BarMan_AceM_AceNM_20220529_134336", "SECTOR", true);
|
||||
//Serv.ActualizaSecto(@"D:\Proyectos\Olivia\Instal2.0\data\data_T00_A0405_20220628_214902.shp", @"C:\\Users\\Elena\\Documents\\ArcGIS\\Projects\\MyProject3\\MyProject3.gdb\\Barrido_man\\BarMan_AceM_AceNM_20220628_214613");
|
||||
//return res1;
|
||||
|
||||
//////////////////
|
||||
/////////////////////////////
|
||||
|
||||
Respuesta<bool> res = new Respuesta<bool> { Value=false};
|
||||
|
|
@ -144,5 +147,20 @@ namespace OliviaAddInPro.Model
|
|||
ambitos = ambitos + shapefile.Substring(aux);
|
||||
|
||||
}
|
||||
/**
|
||||
* Restaura el nombre original del campo si se ha truncado a 10 car al exportar a shp
|
||||
*/
|
||||
public override string[] GetCamposRestaura()
|
||||
{
|
||||
string[] camps = {
|
||||
LimpiezaDef.Campos.consulta_entidad,
|
||||
LimpiezaDef.Campos.consulta_mecan,
|
||||
LimpiezaDef.Campos.consulta_observ,
|
||||
LimpiezaDef.Campos.consulta_anch_tip,
|
||||
LimpiezaDef.Campos.consulta_tipolo,
|
||||
/*LimpiezaDef.Campos.consulta_sector,
|
||||
LimpiezaDef.Campos.consulta_secuen */};
|
||||
return camps;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ namespace OliviaAddInPro.Model
|
|||
if (sh)
|
||||
{
|
||||
DockpaneLimpiezaViewModel.Show();
|
||||
SetFlagTipEjec(TiposEjecucion.Limp);
|
||||
//SetFlagTipEjec(TiposEjecucion.Limp);
|
||||
ViewSetFlagTipEjec(TiposEjecucion.Limp);
|
||||
}
|
||||
else
|
||||
|
|
@ -226,7 +226,7 @@ namespace OliviaAddInPro.Model
|
|||
if (sh)
|
||||
{
|
||||
DockpaneRecogidaViewModel.Show();
|
||||
SetFlagTipEjec(TiposEjecucion.Reco);
|
||||
//SetFlagTipEjec(TiposEjecucion.Reco);
|
||||
ViewSetFlagTipEjec(TiposEjecucion.Reco);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -155,5 +155,42 @@ namespace OliviaAddInPro.Model
|
|||
//concatena el timestamp
|
||||
carga = carga + shapefile.Substring(aux);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restaura el nombre original del campo si se ha truncado a 10 car al exportar a shp
|
||||
*/
|
||||
public override string[] GetCamposRestaura()
|
||||
{
|
||||
string[] camps = {
|
||||
RecogidaDef.campos_def.cons_id,
|
||||
RecogidaDef.campos_def.cons_nomrec,
|
||||
RecogidaDef.campos_def.cons_lateral ,
|
||||
RecogidaDef.campos_def.cons_fracc,
|
||||
RecogidaDef.campos_def.cons_capac,
|
||||
RecogidaDef.campos_def.cons_uds,
|
||||
RecogidaDef.campos_def.cons_kgrec };
|
||||
return camps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rellena el array de filtros en base a la config
|
||||
*/
|
||||
public void RellenaFiltrosReco()
|
||||
{
|
||||
//se rellena el array de filtros
|
||||
RecogidaDef.filtro_str = new string[RecogidaDef.tipos_fracc_str.Length + RecogidaDef.tipos_carg_str.Length];
|
||||
for (int i = 0; i < RecogidaDef.tipos_fracc_str.Length; i++)
|
||||
{
|
||||
//se comprueba que tipo de fracción se ha seleccionado. Si se ha seleccionado una fracción sin nombre (el campo en la capa es NULL, y en el comboBox de fracciiones aparece como "-") hay que modificar el filtro
|
||||
if (RecogidaDef.tipos_fracc_str[i] == "-")
|
||||
RecogidaDef.filtro_str[i] = RecogidaDef.campos_def.cons_fracc + " IS NULL";
|
||||
else
|
||||
RecogidaDef.filtro_str[i] = RecogidaDef.campos_def.cons_fracc + "= '" + RecogidaDef.tipos_fracc_str[i] + "'";
|
||||
}
|
||||
for (int i = RecogidaDef.tipos_fracc_str.Length; i < RecogidaDef.filtro_str.Length; i++)
|
||||
{
|
||||
RecogidaDef.filtro_str[i] = RecogidaDef.campos_def.cons_nomrec + "= '" + RecogidaDef.tipos_carg_str[i - RecogidaDef.tipos_fracc_str.Length] + "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ using OliviaAddInPro.Helper;
|
|||
using OliviaAddInPro.Model.contract;
|
||||
using OliviaAddInPro.Services;
|
||||
using static OliviaAddInPro.Model.ComunDef;
|
||||
using ArcGIS.Core.CIM;
|
||||
using ArcGIS.Core.Data;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace OliviaAddInPro.Model
|
||||
{
|
||||
|
|
@ -191,5 +194,62 @@ namespace OliviaAddInPro.Model
|
|||
tratamiento = string.Empty;
|
||||
ambitos = string.Empty;
|
||||
}
|
||||
/**
|
||||
* Restaura el nombre original del campo si se ha truncado a 10 car al exportar a shp
|
||||
*/
|
||||
public virtual string[] GetCamposRestaura()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restaura el nombre original del campo si se ha truncado a 10 car al exportar a shp
|
||||
*/
|
||||
public Respuesta<bool> RestauraNomCampos(string nombFtClass)
|
||||
{
|
||||
int LENGTHCAMPSHP = 10;
|
||||
Respuesta<bool> resp = new Respuesta<bool> { Value = false };
|
||||
FeatureClass fc = HelperGdb.GetFtClassSync(nombFtClass);
|
||||
if (fc == null)
|
||||
return resp;
|
||||
////////////////////////////////////////////////////////
|
||||
string[] camps = GetCamposRestaura();
|
||||
|
||||
ObservableCollection<string> fields = HelperGdb.GetFieldsSync(fc);
|
||||
HelperGdb.Free(fc);
|
||||
if (fields == null)
|
||||
return resp;
|
||||
try
|
||||
{
|
||||
int i = 0;
|
||||
int indx;
|
||||
string campTrunc = string.Empty;
|
||||
for (i = 0; i < camps.Length; i++)
|
||||
{
|
||||
if (camps[i].Length <= LENGTHCAMPSHP)
|
||||
continue;
|
||||
campTrunc = camps[i].Substring(0, LENGTHCAMPSHP);
|
||||
//si tiene más de 10 caracteres, lo ha truncado al exportar
|
||||
//busca el nombre actual del campo en la fc
|
||||
indx = fields.IndexOf(campTrunc);
|
||||
if (indx < 0)
|
||||
break;
|
||||
if (!HelperGdb.RenameFieldSync(nombFtClass, campTrunc, camps[i],camps[i]))
|
||||
break;
|
||||
}
|
||||
if (i < camps.Length)
|
||||
{
|
||||
resp.Error.Add("Error en el campo " + camps[i]);
|
||||
}
|
||||
else
|
||||
resp.Value = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<WarningLevel>0</WarningLevel>
|
||||
<StartAction>Program</StartAction>
|
||||
<StartProgram>$(ArcGISFolder)\bin\ArcGISPro.exe</StartProgram>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
|
|
@ -357,6 +357,9 @@
|
|||
<ItemGroup>
|
||||
<AddInContent Include="Images\carrito2.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AddInContent Include="Images\config2_olv.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!--
|
||||
PackageAction can be:
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ namespace OliviaAddInPro.Services
|
|||
{
|
||||
ErrStr = string.Empty;
|
||||
try
|
||||
{
|
||||
{
|
||||
com.ProgrSrc.Init("Exportando datos");
|
||||
//Comprueba que tiene las columnas necesarias para planificar
|
||||
if ((modo == ModosEjec.Planifica) && !CompruebaPlanif())
|
||||
|
|
@ -122,6 +122,8 @@ namespace OliviaAddInPro.Services
|
|||
//ahora si está en modo planificación y la capa no tiene esa columna, exporta la sectorización
|
||||
if (modo==ModosEjec.Planifica && !string.IsNullOrEmpty(com.CapaPlanif))
|
||||
{
|
||||
string capa_principal = System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathData);
|
||||
HelperGdb.CloseLayer(capa_principal);
|
||||
if (!ActualizaSecto(OliviaGlob.Paths.PathData, com.CapaPlanif))
|
||||
{
|
||||
ErrStr = "Error al exportar campos de SECTOR y/o SECUENCIA de la capa " + com.CapaPlanif;
|
||||
|
|
@ -280,7 +282,136 @@ namespace OliviaAddInPro.Services
|
|||
*/
|
||||
public bool ActualizaSecto(string path_shp, string path_secto)
|
||||
{
|
||||
return false;
|
||||
//Añade al shp exportado la columna de sector y secuencia
|
||||
HelperGdb.FieldToAdd[] fields = new HelperGdb.FieldToAdd[2];
|
||||
//campo SECTOR
|
||||
fields[0].Name = LimpiezaDef.Campos.consulta_sector;
|
||||
fields[0].Alias = LimpiezaDef.Campos.consulta_sector;
|
||||
fields[0].Tipo = "LONG";
|
||||
fields[0].Length = 0;
|
||||
//campo SECUENCIA
|
||||
fields[1].Name = LimpiezaDef.Campos.consulta_secuen;
|
||||
fields[1].Alias = LimpiezaDef.Campos.consulta_secuen;
|
||||
fields[1].Tipo = "LONG";
|
||||
fields[1].Length = 0;
|
||||
|
||||
if (!HelperGdb.AddFieldsSync(path_shp, fields))
|
||||
return false;
|
||||
//vuelve a cerrar la capa
|
||||
string capa_principal = System.IO.Path.GetFileNameWithoutExtension(path_shp);
|
||||
HelperGdb.CloseLayer(capa_principal);
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
//ahora rellena las columnas
|
||||
using (FeatureClass fc_secto = HelperGdb.GetFtClassSync(path_secto))
|
||||
{
|
||||
using (FeatureClass fc_shp = HelperGdb.GetFtClassSync(path_shp))
|
||||
{
|
||||
if (fc_secto == null || fc_shp == null)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
using (RowCursor rc_shp = fc_shp.Search())
|
||||
{
|
||||
using (RowCursor rc_secto = fc_secto.Search())
|
||||
{
|
||||
if (rc_shp == null || rc_secto == null)
|
||||
return false;
|
||||
|
||||
var modifyOp = new ArcGIS.Desktop.Editing.EditOperation();
|
||||
modifyOp.Name = "Actualiza SECTOR y SECUENCIA";
|
||||
bool ex = false;
|
||||
//modifyOp.Callback((context) =>
|
||||
//{
|
||||
while (rc_shp.MoveNext() && rc_secto.MoveNext())
|
||||
{
|
||||
using (Row rowsecto = rc_secto.Current)
|
||||
{
|
||||
using (Row rowshp = rc_shp.Current)
|
||||
{
|
||||
//context.Invalidate(rowshp);
|
||||
// modify and execute
|
||||
modifyOp.Modify(rowshp, LimpiezaDef.Campos.consulta_sector, rowsecto[LimpiezaDef.Campos.consulta_sector]);
|
||||
modifyOp.Modify(rowshp, LimpiezaDef.Campos.consulta_secuen, rowsecto[LimpiezaDef.Campos.consulta_secuen]);
|
||||
rowshp.Store();
|
||||
//context.Invalidate(rowshp);
|
||||
}
|
||||
}
|
||||
}
|
||||
//}, fc_shp);
|
||||
ex = modifyOp.Execute();
|
||||
ArcGIS.Desktop.Core.Project.Current.SaveEditsAsync();
|
||||
if (ex && modifyOp.IsDone)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
var modifyOp = new ArcGIS.Desktop.Editing.EditOperation();
|
||||
modifyOp.Name = "Actualiza SECTOR y SECUENCIA";
|
||||
bool ex=false;
|
||||
modifyOp.Callback((context) =>
|
||||
{
|
||||
using (RowCursor rc_shp = fc_shp.Search())
|
||||
{
|
||||
using (RowCursor rc_secto = fc_secto.Search())
|
||||
{
|
||||
|
||||
if (rc_shp != null && rc_secto != null)
|
||||
{
|
||||
while (rc_shp.MoveNext() && rc_secto.MoveNext())
|
||||
{
|
||||
using (Row rowsecto = rc_secto.Current)
|
||||
{
|
||||
using (Row rowshp = rc_shp.Current)
|
||||
{
|
||||
context.Invalidate(rowshp);
|
||||
// modify and execute
|
||||
modifyOp.Modify(rowshp, LimpiezaDef.Campos.consulta_sector, rowsecto[LimpiezaDef.Campos.consulta_sector]);
|
||||
modifyOp.Modify(rowshp, LimpiezaDef.Campos.consulta_secuen, rowsecto[LimpiezaDef.Campos.consulta_secuen]);
|
||||
rowshp.Store();
|
||||
context.Invalidate(rowshp);
|
||||
}
|
||||
}
|
||||
}
|
||||
bien = true;
|
||||
rc_secto.Dispose();
|
||||
rc_shp.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, fc_shp);
|
||||
ex = modifyOp.Execute();
|
||||
if (bien && ex && modifyOp.IsDone)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
fc_secto.Dispose();
|
||||
fc_shp.Dispose();
|
||||
HelperGdb.Free(fc_secto);
|
||||
HelperGdb.Free(fc_shp);
|
||||
|
||||
}
|
||||
return false;*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -390,7 +521,7 @@ namespace OliviaAddInPro.Services
|
|||
|
||||
//si ha importado seguro que las tiene
|
||||
if (OliviaGlob.IsConfig2() && !string.IsNullOrEmpty(com.CapaPlanif))
|
||||
return true;
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -437,22 +568,28 @@ namespace OliviaAddInPro.Services
|
|||
//abre las capas, pintando los sectores
|
||||
string path_import = res.Value;
|
||||
int NOPEN = 6;
|
||||
int nopen_ = 4;
|
||||
string[] path_lyr_arr = new string[NOPEN];
|
||||
//se añade la capa de ambitos original con la secto, y se pinta por sectores - shape
|
||||
path_lyr_arr[0] = path_import;
|
||||
//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
|
||||
path_lyr_arr[0]= path_import + NAME_RUTA_OUT;
|
||||
//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
|
||||
path_lyr_arr[1] = path_import + NAME_RUTA2_OUT;
|
||||
path_lyr_arr[1]= path_import + NAME_RUTA_OUT;
|
||||
//se añade la capa de ruta_aux y se pinta por sectores - shape + name_ruta_out + name_aux
|
||||
path_lyr_arr[2] = path_import + NAME_RUTA_OUT + NAME_AUX;
|
||||
//se añade la capa de ambitos original con la secto, y se pinta por sectores - shape
|
||||
path_lyr_arr[3] = path_import;
|
||||
//se añade la capa de la ruta a las instalaciones, comprueba si hay configurada coordenadas de la instalación - shape + name_inst_out
|
||||
path_lyr_arr[4] = path_import + NAME_INSTAL_OUT;
|
||||
//se abre la capa de puntos de control y se pintan por el sector al que pertenecen - shape + name_control_out
|
||||
path_lyr_arr[5] = path_import + NAME_CONTROL_OUT;
|
||||
bool[] visible_arr = {false,false,true,true,false,false };
|
||||
path_lyr_arr[3] = path_import + NAME_CONTROL_OUT;
|
||||
|
||||
//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 (System.IO.File.Exists(path_import + NAME_RUTA2_OUT))
|
||||
path_lyr_arr[nopen_++] = path_import + NAME_RUTA2_OUT;
|
||||
//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 (System.IO.File.Exists(path_import + NAME_INSTAL_OUT))
|
||||
path_lyr_arr[nopen_++] = path_import + NAME_INSTAL_OUT;
|
||||
|
||||
NOPEN = nopen_;
|
||||
bool[] visible_arr = {true,false,true,false,false,false };
|
||||
int i;
|
||||
var resb = new Respuesta<bool>();
|
||||
for(i =0;i<NOPEN;i++)
|
||||
|
|
@ -491,15 +628,7 @@ namespace OliviaAddInPro.Services
|
|||
string tratamiento = string.Empty;
|
||||
string ambitos = string.Empty;
|
||||
com.decode_gdb(shapefile, out tratamiento, out ambitos); //supsuestamente distingue si es limpieza o recogida
|
||||
/*
|
||||
if (prefijo == "T")
|
||||
{
|
||||
com.decode_gdb(shapefile, out tratamiento, out ambitos);
|
||||
}
|
||||
else if (prefijo == "F")
|
||||
{
|
||||
com.decode_gdb(shapefile, out tratamiento, out ambitos);
|
||||
}*/
|
||||
|
||||
if(string.IsNullOrEmpty(tratamiento) || string.IsNullOrEmpty(ambitos))
|
||||
{
|
||||
res.Error.Add(string.Format("Nombre del archivo a importar erróneo. No se reconoce el prefijo introducido: {0}", prefijo));
|
||||
|
|
@ -527,49 +656,7 @@ namespace OliviaAddInPro.Services
|
|||
HelperGlobal.ponMsg(err_spatref +", se ha creado un nuevo dataset "+ datasetNameOut );
|
||||
tratamiento = datasetNameOut;
|
||||
}
|
||||
string dataset = tratamiento;
|
||||
|
||||
/*
|
||||
* //YA NO hace falta preguntar ni comprobar el ftclass porque pone el timestamp y el nombre es único
|
||||
/////////////////////////////////////////
|
||||
//pregunta a ver si se quiere ese nombre u otro
|
||||
bool replace = false;
|
||||
string dataset = tratamiento;
|
||||
bool sal = true;
|
||||
string ambitos_aux;
|
||||
//repite por si se ha equivocado hasta que elige el nombre de clase
|
||||
do
|
||||
{
|
||||
sal = true;
|
||||
ambitos_aux = HelperGdb.SaveFileDlg("Guardar Feature Class como...", GdbFileName + "\\" + tratamiento, null, null,
|
||||
ArcGIS.Desktop.Core.BrowseProjectFilter.GetFilter("esri_browseDialogFilters_featureClasses_all"));
|
||||
if (string.IsNullOrEmpty(ambitos_aux))
|
||||
sal = HelperGlobal.ponMsg("¿Desea cancelar el proceso de imporación?",
|
||||
MessageBoxImage.Question, "OLIVIA", MessageBoxButton.YesNo);
|
||||
} while (!sal);
|
||||
if (!string.IsNullOrEmpty(ambitos_aux))
|
||||
{
|
||||
//sustituye los ámbitos por los elegidos
|
||||
ambitos = System.IO.Path.GetFileNameWithoutExtension(ambitos_aux);
|
||||
replace = System.IO.File.Exists(ambitos_aux);
|
||||
dataset = System.IO.Path.GetFileNameWithoutExtension(System.IO.Path.GetDirectoryName(ambitos_aux)) ;
|
||||
}
|
||||
else {
|
||||
res.Error.Add("Se ha cancelado la importación de resultados. Se cancela la elección de nombre de la Feature Class.");
|
||||
return res;
|
||||
}
|
||||
//comprueba si la proyección es la misma la del dataset que la que llega
|
||||
if (!dataset.Equals(tratamiento))
|
||||
{
|
||||
//ha cambiado de dataset al elegir
|
||||
//comprueba las proyecciones
|
||||
if (!HelperGdb.GetSpatRef(GdbFileName, dataset).Equals(spatRefData))
|
||||
{
|
||||
//avisa
|
||||
HelperGlobal.ponMsg(err_spatref);
|
||||
}
|
||||
}
|
||||
*/
|
||||
string dataset = tratamiento;
|
||||
|
||||
/////////////////////////////////////////
|
||||
//todo ok, se pone a importar
|
||||
|
|
@ -636,19 +723,7 @@ 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 (replace)
|
||||
{
|
||||
resp2 = HelperGdb.DeleteFeatureClass(GdbFileName, noms_gdb[i]);
|
||||
if (!resp2.Value)
|
||||
{
|
||||
err_st = "Error al sobreescribir la capa " + noms_gdb[i];
|
||||
if (resp2.HasError)
|
||||
err_st += " " + resp2.Error.First();
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
{
|
||||
resp2 = HelperGdb.ImportShp(dir_shp + "\\" + noms_shp[i] + HelperGdb.SHP_EXT, GdbFileName + "\\" + dataset, noms_gdb[i]);
|
||||
if (!resp2.Value)
|
||||
{
|
||||
|
|
@ -657,13 +732,23 @@ namespace OliviaAddInPro.Services
|
|||
err_st += " " + resp2.Error.First();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (i < NIMPORT)
|
||||
{
|
||||
res.Error.Add("Errores en la importación: "+err_st);
|
||||
return res;
|
||||
}
|
||||
//cambia el nombre de los campos que había truncado a 10 caracteres al exportar a shp
|
||||
//solo para la capa original
|
||||
resp2 = com.RestauraNomCampos(GdbFileName + "\\" + dataset + "\\" + noms_gdb[0]);
|
||||
if (!resp2.Value)
|
||||
{
|
||||
err_st = "Error al renombrar campos " + noms_gdb[i];
|
||||
if (resp2.HasError)
|
||||
err_st += " " + resp2.Error.First();
|
||||
res.Error.Add("Errores en la importación: " + err_st);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -676,8 +761,7 @@ namespace OliviaAddInPro.Services
|
|||
}
|
||||
res.Value = path_import;
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Cierra del mapa las capas de trabajo después de la exportación
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -16,105 +16,8 @@ namespace OliviaAddInPro.Services
|
|||
{
|
||||
Application.Current.Dispatcher.BeginInvoke(new Action<Respuesta<TiposEjecucion>, TratamientoComun>((p, v) => finEjecuta2(p, v)),res,inst);
|
||||
|
||||
//borra los archivos que le toca borrar
|
||||
//BorraFiles();
|
||||
}
|
||||
public void finEjecuta2_old(Respuesta<TiposEjecucion> res, TratamientoComun inst)
|
||||
{
|
||||
String msg = string.Empty;
|
||||
String msg_err = "Errores en el proceso de importación de resultados";
|
||||
bool mal = false;
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
//gestiona los flags, el estado de finok o finnok va en res.Vale
|
||||
if (res.HasError)
|
||||
{
|
||||
msg = res.Error.First();
|
||||
//actualiza los flags
|
||||
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.FinEjecNOk);
|
||||
}
|
||||
else
|
||||
{
|
||||
//actualiza los flags
|
||||
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.FinEjecOk);
|
||||
//importa resultados
|
||||
var resp = IniImport();
|
||||
if (resp.HasError)
|
||||
{
|
||||
msg = resp.Error.First();
|
||||
mal = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
string GdbFileName = resp.Value;
|
||||
var resp2 = new Respuesta<string> { Value = string.Empty };
|
||||
if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecSecto)) //Ha terminado bien la sectorización
|
||||
{
|
||||
//actualiza los flags
|
||||
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.EjecSecto);
|
||||
//acciones de importación
|
||||
resp2 = inst.ServCom.ImportSecto(GdbFileName);
|
||||
}
|
||||
else if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecPlanif)) //Ha terminado bien la planificación
|
||||
{
|
||||
//actualiza los flags
|
||||
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.EjecPlanif);
|
||||
//guarda csv
|
||||
GuardaCsv(inst);
|
||||
//acciones de importación
|
||||
resp2 = inst.ServCom.ImportPlanif(GdbFileName);
|
||||
|
||||
}
|
||||
if (string.IsNullOrEmpty(resp2.Value))
|
||||
{
|
||||
if (resp2.HasError)
|
||||
{
|
||||
msg = resp2.Error.First();
|
||||
}
|
||||
else
|
||||
msg = msg_err;
|
||||
mal = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
msg = msg_err + ": " + msg + ": " + ex.Message;
|
||||
mal = true;
|
||||
}
|
||||
if (mal)
|
||||
{
|
||||
//reinicia flags
|
||||
if (OliviaGlob.IsLimp())
|
||||
OliviaGlob.SetFlagTipEjec(TiposEjecucion.Limp);
|
||||
else if (OliviaGlob.IsReco())
|
||||
OliviaGlob.SetFlagTipEjec(TiposEjecucion.Reco);
|
||||
|
||||
}
|
||||
HelperGlobal.ponMsg(msg);
|
||||
OliviaGlob.progrDialog.Hide();
|
||||
//muestra la ventana
|
||||
OliviaGlob.ShowHidePane(true);
|
||||
var task = ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
|
||||
{
|
||||
//borra los archivos que le toca borrar
|
||||
BorraFiles();
|
||||
});
|
||||
//task.Wait();
|
||||
//borra los archivos que le toca borrar
|
||||
//BorraFiles();
|
||||
}
|
||||
|
||||
public void finEjecuta2(Respuesta<TiposEjecucion> res, TratamientoComun inst)
|
||||
{
|
||||
String msg = string.Empty;
|
||||
|
|
@ -153,16 +56,16 @@ namespace OliviaAddInPro.Services
|
|||
if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecSecto)) //Ha terminado bien la sectorización
|
||||
{
|
||||
//actualiza los flags
|
||||
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.EjecSecto);
|
||||
//OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.EjecSecto);
|
||||
//acciones de importación
|
||||
resp2 = inst.ServCom.ImportSecto(GdbFileName);
|
||||
}
|
||||
else if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecPlanif)) //Ha terminado bien la planificación
|
||||
{
|
||||
//actualiza los flags
|
||||
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.EjecPlanif);
|
||||
//OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.EjecPlanif);
|
||||
//guarda csv
|
||||
GuardaCsv(inst);
|
||||
//GuardaCsv(inst); en finEjecuta3
|
||||
//acciones de importación
|
||||
resp2 = inst.ServCom.ImportPlanif(GdbFileName);
|
||||
|
||||
|
|
@ -218,11 +121,15 @@ namespace OliviaAddInPro.Services
|
|||
}
|
||||
else
|
||||
{
|
||||
msg = Resource1.String_exito;
|
||||
//pone modo config2
|
||||
OliviaGlob.AddFlagTipEjec(TiposEjecucion.Config2);
|
||||
//actualiza la capa de la que tiene que leer ahora para planificar
|
||||
inst.CapaPlanif = resp2.Value;
|
||||
if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecPlanif)) //Ha terminado bien la planificación
|
||||
{
|
||||
//guarda csv
|
||||
GuardaCsv(inst);
|
||||
}
|
||||
msg = Resource1.String_exito;
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -231,7 +138,7 @@ namespace OliviaAddInPro.Services
|
|||
mal = true;
|
||||
}
|
||||
}
|
||||
if (mal)
|
||||
/*if (mal)
|
||||
{
|
||||
//reinicia flags
|
||||
if (OliviaGlob.IsLimp())
|
||||
|
|
@ -239,7 +146,13 @@ namespace OliviaAddInPro.Services
|
|||
else if (OliviaGlob.IsReco())
|
||||
OliviaGlob.SetFlagTipEjec(TiposEjecucion.Reco);
|
||||
|
||||
}
|
||||
}*/
|
||||
//actualiza los flags
|
||||
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.EjecPlanif);
|
||||
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.EjecSecto);
|
||||
//pone modo config2
|
||||
OliviaGlob.AddFlagTipEjec(TiposEjecucion.Config2);
|
||||
///////////////////////////////////////////////////
|
||||
HelperGlobal.ponMsg(msg);
|
||||
OliviaGlob.progrDialog.Hide();
|
||||
//muestra la ventana
|
||||
|
|
@ -304,16 +217,15 @@ namespace OliviaAddInPro.Services
|
|||
nameDokL = Directory.GetFiles(DirData,
|
||||
System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathData) + inst.ServCom.NAME_CSV + ".*");
|
||||
|
||||
string Title = "Guardar Secuencia de la Planificación";
|
||||
string Title = "Directorio para guardar Secuencia de la Planificación";
|
||||
string Filter = "Secuencia en formato CSV (*.csv)|*.csv";
|
||||
inst.decode_gdb(System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathData),
|
||||
out auxi, out nombre);
|
||||
string InitialDirectory = System.IO.Path.Combine(DirData, nombre);
|
||||
|
||||
|
||||
string FileName = HelperGdb.SaveFileDlg(Title, InitialDirectory, inst.ServCom.EXT_CSV, Filter);
|
||||
//string Path = HelperGdb.SaveFileDlg(Title, DirData, inst.ServCom.EXT_CSV, Filter);
|
||||
string Path = HelperGdb.SaveFileDlg(Title, DirData, null, ArcGIS.Desktop.Catalog.ItemFilters.folders);
|
||||
|
||||
if (string.IsNullOrEmpty(FileName) || FileName.Length == 0)
|
||||
if (string.IsNullOrEmpty(Path) || Path.Length == 0)
|
||||
{
|
||||
bool ok = HelperGlobal.ponMsg("Se va a perder el archivo que contiene la secuencia en planificación, ¿está seguro?",
|
||||
MessageBoxImage.Question,"OLIVIA",MessageBoxButton.YesNo);
|
||||
|
|
@ -322,6 +234,8 @@ namespace OliviaAddInPro.Services
|
|||
}
|
||||
else
|
||||
{
|
||||
var FileName = System.IO.Path.Combine(Path, nombre);
|
||||
FileName += inst.ServCom.EXT_CSV;
|
||||
if (File.Exists(FileName))
|
||||
File.Delete(FileName);
|
||||
File.Move(nameDokL[0], FileName);
|
||||
|
|
@ -343,7 +257,7 @@ namespace OliviaAddInPro.Services
|
|||
//repite por si se ha equivocado hasta que elige la gdb
|
||||
GdbFileName = HelperGdb.OpenFileDialog(HelperGdb.TiposOpenFileDlg.OpenGdb,"", "Seleccionar GDB a la que importar los resultados");
|
||||
if(string.IsNullOrEmpty(GdbFileName))
|
||||
sal= HelperGlobal.ponMsg("¿Desea cancelar el proceso de imporación?",
|
||||
sal= HelperGlobal.ponMsg("¿Desea cancelar el proceso de importación?",
|
||||
MessageBoxImage.Question, "OLIVIA", MessageBoxButton.YesNo);
|
||||
} while (!sal);
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ namespace OliviaAddInPro.Services
|
|||
{
|
||||
//NO SE USA AQUÍ, ESTÁ EN EJECSERV
|
||||
//si ha importado no hace falta que compruebe, seguro que las tiene
|
||||
if (OliviaGlob.IsConfig2() && ComprCamposPlanif(limp.CapaPlanif))
|
||||
if (OliviaGlob.IsConfig2() && ComprCamposPlanif(limp.CapaElems))
|
||||
return true;
|
||||
//no ha importado, comprueba capa
|
||||
if (ComprCamposPlanif(limp.CapaElems))
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ namespace OliviaAddInPro.Services
|
|||
public RecogidaServ(Recogida _reco)
|
||||
{
|
||||
reco = _reco;
|
||||
RellenaFiltrosReco();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -95,7 +94,7 @@ namespace OliviaAddInPro.Services
|
|||
|
||||
//cierra las capas que se han abierto durante la exportación
|
||||
CierraCapas();
|
||||
|
||||
res.Value = true;
|
||||
return res;
|
||||
|
||||
}
|
||||
|
|
@ -145,27 +144,7 @@ namespace OliviaAddInPro.Services
|
|||
consulta = "";
|
||||
}
|
||||
return consulta;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rellena el array de filtros en base a la config
|
||||
*/
|
||||
public void RellenaFiltrosReco()
|
||||
{
|
||||
//se rellena el array de filtros
|
||||
RecogidaDef.filtro_str = new string[RecogidaDef.tipos_fracc_str.Length + RecogidaDef.tipos_carg_str.Length];
|
||||
for (int i = 0; i < RecogidaDef.tipos_fracc_str.Length; i++)
|
||||
{
|
||||
//se comprueba que tipo de fracción se ha seleccionado. Si se ha seleccionado una fracción sin nombre (el campo en la capa es NULL, y en el comboBox de fracciiones aparece como "-") hay que modificar el filtro
|
||||
if (RecogidaDef.tipos_fracc_str[i] == "-")
|
||||
RecogidaDef.filtro_str[i] = RecogidaDef.campos_def.cons_fracc + " IS NULL";
|
||||
else
|
||||
RecogidaDef.filtro_str[i] = RecogidaDef.campos_def.cons_fracc + "= '" + RecogidaDef.tipos_fracc_str[i] + "'";
|
||||
}
|
||||
for (int i = RecogidaDef.tipos_fracc_str.Length; i < RecogidaDef.filtro_str.Length; i++)
|
||||
{
|
||||
RecogidaDef.filtro_str[i] = RecogidaDef.campos_def.cons_nomrec + "= '" + RecogidaDef.tipos_carg_str[i - RecogidaDef.tipos_fracc_str.Length] + "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace OliviaAddInPro
|
|||
}
|
||||
else if (DataContext is PaneRecogidaViewModel modrec)
|
||||
{
|
||||
modrec.Ejecuta(OliviaAddInPro.Services.ModosEjec.Planifica);
|
||||
modrec.Ejecuta(OliviaAddInPro.Services.ModosEjec.SoloPlanifica);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,6 +94,9 @@ namespace OliviaAddInPro
|
|||
err_str = "";
|
||||
try
|
||||
{
|
||||
//Rellena el array de filtros
|
||||
reco.RellenaFiltrosReco();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
///Lee el panel 1
|
||||
if (!_subPanel1ViewModel.CapaAbierta || string.IsNullOrEmpty(_subPanel1ViewModel.CapaElems))
|
||||
|
|
|
|||
Loading…
Reference in New Issue