Avances en planificación de limpieza. Ya se hace si la capa tiene columna de sector y secuencia, está en camnio de hacerse cuando no la tiene
parent
8de6d7682e
commit
663e6f058f
|
|
@ -2388,7 +2388,10 @@ namespace OliviaAddInPro.Helper
|
||||||
return tipo;
|
return tipo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool RenameField(string fcname, string oldFieldName, string newFieldName, string newFieldAlias)
|
/*
|
||||||
|
* Renombra un campo de la feature class dada
|
||||||
|
*/
|
||||||
|
public static bool RenameFieldSync(string fcname, string oldFieldName, string newFieldName, string newFieldAlias)
|
||||||
{
|
{
|
||||||
bool res = false;
|
bool res = false;
|
||||||
string[] args = { fcname, oldFieldName, newFieldName,newFieldAlias };
|
string[] args = { fcname, oldFieldName, newFieldName,newFieldAlias };
|
||||||
|
|
@ -2413,6 +2416,75 @@ namespace OliviaAddInPro.Helper
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 = "";
|
||||||
|
for(int i=0;i<fields.Length;i++)
|
||||||
|
{
|
||||||
|
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 += ";";
|
||||||
|
}
|
||||||
|
//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;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,7 @@ namespace OliviaAddInPro.Model
|
||||||
if (sh)
|
if (sh)
|
||||||
{
|
{
|
||||||
DockpaneLimpiezaViewModel.Show();
|
DockpaneLimpiezaViewModel.Show();
|
||||||
SetFlagTipEjec(TiposEjecucion.Limp);
|
//SetFlagTipEjec(TiposEjecucion.Limp);
|
||||||
ViewSetFlagTipEjec(TiposEjecucion.Limp);
|
ViewSetFlagTipEjec(TiposEjecucion.Limp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -226,7 +226,7 @@ namespace OliviaAddInPro.Model
|
||||||
if (sh)
|
if (sh)
|
||||||
{
|
{
|
||||||
DockpaneRecogidaViewModel.Show();
|
DockpaneRecogidaViewModel.Show();
|
||||||
SetFlagTipEjec(TiposEjecucion.Reco);
|
//SetFlagTipEjec(TiposEjecucion.Reco);
|
||||||
ViewSetFlagTipEjec(TiposEjecucion.Reco);
|
ViewSetFlagTipEjec(TiposEjecucion.Reco);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ namespace OliviaAddInPro.Model
|
||||||
indx = fields.IndexOf(campTrunc);
|
indx = fields.IndexOf(campTrunc);
|
||||||
if (indx < 0)
|
if (indx < 0)
|
||||||
break;
|
break;
|
||||||
if (!HelperGdb.RenameField(nombFtClass, campTrunc, camps[i],camps[i]))
|
if (!HelperGdb.RenameFieldSync(nombFtClass, campTrunc, camps[i],camps[i]))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i < camps.Length)
|
if (i < camps.Length)
|
||||||
|
|
|
||||||
|
|
@ -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
|
//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))
|
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))
|
if (!ActualizaSecto(OliviaGlob.Paths.PathData, com.CapaPlanif))
|
||||||
{
|
{
|
||||||
ErrStr = "Error al exportar campos de SECTOR y/o SECUENCIA de la capa " + com.CapaPlanif;
|
ErrStr = "Error al exportar campos de SECTOR y/o SECUENCIA de la capa " + com.CapaPlanif;
|
||||||
|
|
@ -280,6 +282,87 @@ namespace OliviaAddInPro.Services
|
||||||
*/
|
*/
|
||||||
public bool ActualizaSecto(string path_shp, string path_secto)
|
public bool ActualizaSecto(string path_shp, string path_secto)
|
||||||
{
|
{
|
||||||
|
//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(OliviaGlob.Paths.PathData);
|
||||||
|
HelperGdb.CloseLayer(capa_principal);
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
|
RowCursor rc_shp = null;
|
||||||
|
RowCursor rc_secto = null;
|
||||||
|
Row rowshp = null;
|
||||||
|
Row rowsecto = null;
|
||||||
|
FeatureClass fc_secto = null;
|
||||||
|
FeatureClass fc_shp = null;
|
||||||
|
bool bien = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//ahora rellena las columnas
|
||||||
|
fc_secto = HelperGdb.GetFtClassSync(path_secto);
|
||||||
|
fc_shp = HelperGdb.GetFtClassSync(path_shp);
|
||||||
|
if (fc_secto == null || fc_shp == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var modifyOp = new ArcGIS.Desktop.Editing.EditOperation();
|
||||||
|
modifyOp.Name = "Actualiza SECTOR y SECUENCIA";
|
||||||
|
//modifyOp.Callback((context) =>
|
||||||
|
//{
|
||||||
|
rc_shp = fc_shp.Search();
|
||||||
|
rc_secto = fc_secto.Search();
|
||||||
|
|
||||||
|
if (rc_shp == null || rc_secto == null)
|
||||||
|
{
|
||||||
|
HelperGdb.Free(rc_shp);
|
||||||
|
HelperGdb.Free(rc_secto);
|
||||||
|
HelperGdb.Free(fc_secto);
|
||||||
|
HelperGdb.Free(fc_shp);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (rc_shp.MoveNext() && rc_secto.MoveNext())
|
||||||
|
{
|
||||||
|
rowsecto = rc_secto.Current;
|
||||||
|
rowshp = rc_shp.Current;
|
||||||
|
// 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]);
|
||||||
|
}
|
||||||
|
bien = true;
|
||||||
|
//}, fc_shp.GetFeatureDataset());
|
||||||
|
|
||||||
|
modifyOp.Execute();
|
||||||
|
if (bien)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
HelperGdb.Free(rowsecto);
|
||||||
|
HelperGdb.Free(rowshp);
|
||||||
|
HelperGdb.Free(rc_shp);
|
||||||
|
HelperGdb.Free(rc_secto);
|
||||||
|
HelperGdb.Free(fc_secto);
|
||||||
|
HelperGdb.Free(fc_shp);
|
||||||
|
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -437,22 +520,28 @@ namespace OliviaAddInPro.Services
|
||||||
//abre las capas, pintando los sectores
|
//abre las capas, pintando los sectores
|
||||||
string path_import = res.Value;
|
string path_import = res.Value;
|
||||||
int NOPEN = 6;
|
int NOPEN = 6;
|
||||||
|
int nopen_ = 4;
|
||||||
string[] path_lyr_arr = new string[NOPEN];
|
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
|
//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
|
//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;
|
path_lyr_arr[1]= 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;
|
|
||||||
//se añade la capa de ruta_aux y se pinta por sectores - shape + name_ruta_out + name_aux
|
//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;
|
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
|
//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;
|
path_lyr_arr[3] = path_import + NAME_CONTROL_OUT;
|
||||||
bool[] visible_arr = {false,false,true,true,false,false };
|
|
||||||
|
//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;
|
int i;
|
||||||
var resb = new Respuesta<bool>();
|
var resb = new Respuesta<bool>();
|
||||||
for(i =0;i<NOPEN;i++)
|
for(i =0;i<NOPEN;i++)
|
||||||
|
|
|
||||||
|
|
@ -55,16 +55,16 @@ namespace OliviaAddInPro.Services
|
||||||
if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecSecto)) //Ha terminado bien la sectorización
|
if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecSecto)) //Ha terminado bien la sectorización
|
||||||
{
|
{
|
||||||
//actualiza los flags
|
//actualiza los flags
|
||||||
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.EjecSecto);
|
//OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.EjecSecto);
|
||||||
//acciones de importación
|
//acciones de importación
|
||||||
resp2 = inst.ServCom.ImportSecto(GdbFileName);
|
resp2 = inst.ServCom.ImportSecto(GdbFileName);
|
||||||
}
|
}
|
||||||
else if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecPlanif)) //Ha terminado bien la planificación
|
else if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecPlanif)) //Ha terminado bien la planificación
|
||||||
{
|
{
|
||||||
//actualiza los flags
|
//actualiza los flags
|
||||||
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.EjecPlanif);
|
//OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.EjecPlanif);
|
||||||
//guarda csv
|
//guarda csv
|
||||||
GuardaCsv(inst);
|
//GuardaCsv(inst); en finEjecuta3
|
||||||
//acciones de importación
|
//acciones de importación
|
||||||
resp2 = inst.ServCom.ImportPlanif(GdbFileName);
|
resp2 = inst.ServCom.ImportPlanif(GdbFileName);
|
||||||
|
|
||||||
|
|
@ -120,7 +120,15 @@ namespace OliviaAddInPro.Services
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecPlanif)) //Ha terminado bien la planificación
|
||||||
|
{
|
||||||
|
//guarda csv
|
||||||
|
GuardaCsv(inst);
|
||||||
|
}
|
||||||
msg = Resource1.String_exito;
|
msg = Resource1.String_exito;
|
||||||
|
//actualiza los flags
|
||||||
|
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.EjecPlanif);
|
||||||
|
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.EjecSecto);
|
||||||
//pone modo config2
|
//pone modo config2
|
||||||
OliviaGlob.AddFlagTipEjec(TiposEjecucion.Config2);
|
OliviaGlob.AddFlagTipEjec(TiposEjecucion.Config2);
|
||||||
//actualiza la capa de la que tiene que leer ahora para planificar
|
//actualiza la capa de la que tiene que leer ahora para planificar
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ namespace OliviaAddInPro.Services
|
||||||
{
|
{
|
||||||
//NO SE USA AQUÍ, ESTÁ EN EJECSERV
|
//NO SE USA AQUÍ, ESTÁ EN EJECSERV
|
||||||
//si ha importado no hace falta que compruebe, seguro que las tiene
|
//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;
|
return true;
|
||||||
//no ha importado, comprueba capa
|
//no ha importado, comprueba capa
|
||||||
if (ComprCamposPlanif(limp.CapaElems))
|
if (ComprCamposPlanif(limp.CapaElems))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue