Call Geoprocessing.ExecuteToolAsync on managment.CreateTable is failing

1478
6
07-09-2020 08:00 AM
MarcusPolivirus
New Contributor

Hello,

Based on this example L. 90, I'm trying to create a FeatureClass in an Oracle database using the geoprocessing tool "managment.CreateTable".

In the documentation it's said that the argument "out_path" should be of type Workspace.

Problem is, in this documentation, it is said that only the following classes are supported :

  • Scalars – long, short, float, double, date, string
  • ArcGIS.Core.Geometry.SpatialReference
  • ArcGIS.Core.Geometry – point, line, polygon
  • ArcGIS.Core.Geometry.Envelope – supporting GP types of GPExtentEnv, GPExtent, GPEneveope
  • ArcGIS.Core.Data.Field – supporting GPField and list of fields for GPFieldList
  • ArcGIS.Desktop.Mapping – Layer, StandaloneTable
  • ArcGIS.Core.Data.Dataset – Table, FeatureClass

Based on those informations I'm using the following code 


private static Task<IGPResult> CreateFeatureClass(Geodatabase geodatabase,
string tableName,
Table templateTable)
{

var args = Geoprocessing.MakeValueArray(
geodatabase.GetConnectionString(),
GetTempoLayerNameFromFClassName(tableName),
templateTable,
null
);

System.Threading.CancellationTokenSource _cts = new System.Threading.CancellationTokenSource();

return Geoprocessing.ExecuteToolAsync("managment.CreateTable", args, null, _cts.Token,
(event_name, o) => // implement delegate and handle events, o is message object.
{
switch (event_name)
{
case "OnValidate": // stop execute if any warnings
if ((o as IGPMessage[]).Any(it => it.Type == GPMessageType.Warning))
_cts.Cancel();
break;
case "OnProgressMessage":
string msg = string.Format("{0}: {1}", new object[] { event_name, (string)o });
System.Diagnostics.Debug.WriteLine(msg);
_cts.Cancel();
break;
case "OnProgressPos":
string msg2 = string.Format("{0}: {1} %", new object[] { event_name, (int)o });
System.Diagnostics.Debug.WriteLine(msg2);
_cts.Cancel();
break;
}
});
}

The results of the request is :

ErrorCode = 2147483647

HasWarnings = False
IsFailed = True
IsCanceled = False

There is no messages whatsoever.

I have no idea how to debug that part.

Do you have any clue ?

Best regards,

Marcus

Tags (1)
0 Kudos
6 Replies
RichRuh
Esri Regular Contributor

Hi Marcus,

I'm not a geoprocessing expert, but I would try this:

var args = Geoprocessing.MakeValueArray(
geodatabase.GetPath(),
GetTempoLayerNameFromFClassName(tableName),
templateTable.GetPath(),
null
);

--Rich

0 Kudos
MarcusPolivirus
New Contributor

Hello Rich,

Thanks for your reply, I tried :

var args = Geoprocessing.MakeValueArray(
geodatabase.GetPath().AbsolutePath,
GetTempoLayerNameFromFClassName(tableName),
templateTable,
null
);

The class Table has no GetPath method.

The geoprocessing tool shoud use the "templateTable" object as a template for the new Table (create the same fields i think and maybe other things).

Normally it is supported to use a Table.

The method GetTempoLayerNameFromFClassName just return a string.

I end up with the same error :

ErrorCode = 2147483647

HasWarnings = False
IsFailed = True
IsCanceled = False

0 Kudos
RichRuh
Esri Regular Contributor

It was worth trying.  Hopefully someone from Geoprocessing‌ can provide a better answer.

Sorry about Table.GetPath(). I had forgotten when we added it- you should see it later this summer in Pro 2.6.  

--Rich

0 Kudos
RichRuh
Esri Regular Contributor

In Pro 2.6, GetPath() is now available on tables and other datasets.

0 Kudos
NarelleChedzey
Esri Contributor

Hi Marcus, 

I've had success using the following code

IGPResult result = await Geoprocessing.ExecuteToolAsync("CreateTable_management", new string[] {
gdbPath,
tableName
}, null, ctsToken, null, GPExecuteToolFlags.RefreshProjectItems);

Note that this will create an empty table as it is not using a template object.   

Right now you're not really sure which of the parameters is the problem, so I would suggest trying with just two parameters first to make sure you can create the empty table (gdbPath and tableName).  Then you are guaranteed to know that the problem is with the third parameter - the table template.   I'm thinking this should be a string too, but am not completely sure. 

Note also sing "CreateTable_management" or "management.CreateTable" should not make a difference. 

Narelle

0 Kudos
MarcusPolivirus
New Contributor

Hi Narelle,

I confirm using your code is working.

It works also with Geoprocessing.MakeValueArray instead of new string[]{}.

Using "management.CreateTable" is not working with your code, the error is:

ErrorCode = 2147483647
ReturnValue =
HasWarnings = False
IsFailed = True
IsCanceled = False

In deed, the parameters should be all strings, the following code is working well and create the fields from the template table.

var parameters = Geoprocessing.MakeValueArray(
   geodatabase.GetPath().AbsolutePath,
   tableName,
   System.IO.Path.Combine(templateTable.GetDatastore().GetPath().AbsolutePath, templateTable.GetName())
);

return Geoprocessing.ExecuteToolAsync(
   "CreateTable_management",
   parameters,
   null,
   _cts.Token,
   null,
   GPExecuteToolFlags.RefreshProjectItems);

Is there a list somewhere for the geoprocessing tools including: id | name | description | parameters ?

Thanks again for your help Narelle and Rich.

Marcus

0 Kudos