Merge branch 'Gerardo/arregloImportacion' into develop

Elena/develop
Gerardo 2022-05-29 17:21:08 +02:00
commit fe3e58ed2c
1 changed files with 21 additions and 4 deletions

View File

@ -24,6 +24,7 @@ using OliviaAddInPro.View;
using OliviaAddInPro.Model.contract;
using ArcGIS.Core.Data.DDL;
using ArcGIS.Core.CIM;
using System.Threading;
namespace OliviaAddInPro.Helper
{
@ -1741,7 +1742,8 @@ namespace OliviaAddInPro.Helper
ArcGIS.Core.Geometry.SpatialReference spatref = GetSpatRef(nom_shp);
var environments = Geoprocessing.MakeEnvironmentArray(outputCoordinateSystem: spatref);
CancelableProgressorSource cps = new CancelableProgressorSource();
IGPResult gpResult = Geoprocessing.ExecuteToolAsync("FeatureClassToFeatureClass_conversion", Geoprocessing.MakeValueArray(args), environments,cps.CancellationTokenSource.Token,
var completa = false;
var gpres = Geoprocessing.ExecuteToolAsync("FeatureClassToFeatureClass_conversion", args, environments,cps.CancellationTokenSource.Token,
(event_name, o) => // implement delegate and handle events
{
switch (event_name)
@ -1765,6 +1767,7 @@ namespace OliviaAddInPro.Helper
var av = (int)o;
if ((int)o < 0)
{
completa = true;
//System.Windows.MessageBox.Show(msg2);
//cps.CancellationTokenSource.Cancel();
@ -1772,13 +1775,18 @@ namespace OliviaAddInPro.Helper
break;
}
}
}).Result;
if (gpResult.IsCanceled)
});
while (!gpres.IsCompleted && gpres.IsCanceled && gpres.IsFaulted && !completa)
Thread.Sleep(10);
if (gpres.IsCanceled)
{
return res;
}
if (gpResult.IsFailed)
if (gpres.IsFaulted)
{
var gpResult = gpres.Result;
string msg;
if (gpResult.ErrorMessages != null)
msg = gpResult.ErrorMessages.First().Text;
@ -1787,6 +1795,15 @@ namespace OliviaAddInPro.Helper
res.Error.Add("Error: " + msg);
return res;
}
try
{
gpres.Dispose();
}
catch (Exception e)
{
string msg = "";
msg = e.Message;
}
res.Value = true;
//actualiza la gdb
Refresh(System.IO.Path.GetDirectoryName(Gdb_dataset));