optimizacion ids

Elena/develop
Gerardo 2022-07-05 23:59:46 +02:00
parent 20a1ac9fd4
commit c9c25b77c4
1 changed files with 18 additions and 7 deletions

View File

@ -1325,10 +1325,19 @@ namespace OliviaAddInPro.Helper
return false; return false;
} }
List<long> ids = new List<long>(); List<long> ids = new List<long>();
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
//Añade a la lista los ids que cumplen el filtro espacial //Añade a la lista los ids que cumplen el filtro espacial
using (RowCursor cursor = fc.Search(filter)) try
{
ids = fc.Select(filter, SelectionType.ObjectID, SelectionOption.Normal).GetObjectIDs().ToList();
}
catch
{
ids = new List<long>();
}
/*using (RowCursor cursor = fc.Search(filter))
{ {
while (cursor.MoveNext() && !cps.Getcancelled()) while (cursor.MoveNext() && !cps.Getcancelled())
{ {
@ -1337,7 +1346,7 @@ namespace OliviaAddInPro.Helper
ids.Add(feature.GetObjectID()); ids.Add(feature.GetObjectID());
} }
} }
} }*/
if (ids.Count <= 0) if (ids.Count <= 0)
{ {
OutStr = "Error al aplicar filtro espacial en exportación"; OutStr = "Error al aplicar filtro espacial en exportación";
@ -1675,7 +1684,9 @@ namespace OliviaAddInPro.Helper
if (ids.Count <= 0) if (ids.Count <= 0)
return string.Empty; return string.Empty;
string ids_str = "("; //string ids_str = "("+;
return ObjectId+" IN (" + String.Join(",", ids) + ")";
/*
bool first = true; bool first = true;
foreach (long i in ids) foreach (long i in ids)
{ {
@ -1688,9 +1699,9 @@ namespace OliviaAddInPro.Helper
ids_str += "," + i.ToString(); ids_str += "," + i.ToString();
} }
//el último //el último
ids_str += ")"; ids_str += ")";*/
string whereClause = ObjectId + " IN " + ids_str; //Cambiar id a otro sitio //string whereClause = ObjectId + " IN " + ids_str; //Cambiar id a otro sitio
return whereClause; //return whereClause;
/*string consulta, orstr; /*string consulta, orstr;
consulta = string.Empty; consulta = string.Empty;