I am attempting to write a method that will export features using the conversion.ExportFeatures geoprocessing tool. I am setting the parameters using the MakeValueArray and the envionments using the MakeEnvironmentArray. I then use the Geoprocessing.ExecuteToolAsync and store the result in resultGp. The tool always fails and I do not even get any meaningful error messages. The code is below and any help would be appreciated. Also the where clause used in the parameters looks something like this:
"valid_to = '2019-01-01 00:00:00' and CATEG IS NOT NULL".
I check the count for the where clause before calling the method as well and there are in fact records that exist using the where clause.
public async Task<bool> ExportFeatures(FeatureClass inputFeatureClass, string outputFeatureClassName, string whereClause)
{
Log.Log.MethodEntry();
try
{
string fullPathName = _projectGeodatabase + $"\\{outputFeatureClassName}";
var parameters = Geoprocessing.MakeValueArray(
inputFeatureClass,
fullPathName,
whereClause
);
var environments = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true, outputCoordinateSystem: inputFeatureClass.GetDefinition().GetSpatialReference());
IGPResult resultGp = await Geoprocessing.ExecuteToolAsync(
"conversion.ExportFeatures",
parameters,
environments,
null,
null,
GPExecuteToolFlags.AddOutputsToMap
);
if (resultGp.IsFailed)
{
Log.Log.Error($"Failed to export features {resultGp.Messages.Select(x => x.Text)}");
return false;
}
return true;
}
catch (Exception e)
{
Log.Log.Error($"{e}");
return false;
}
}