using System; using System.Collections.Generic; using System.Threading.Tasks; using ArcGIS.Desktop.Core.Geoprocessing; using ArcGIS.Desktop.Framework.Dialogs; using ArcGIS.Desktop.Framework.Threading.Tasks; using Newtonsoft.Json; namespace LinkToolAddin.server; public class CallArcGISPro { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(CallArcGISPro)); public async static Task CallArcGISProTool(string toolName, List toolParams) { var results = await Geoprocessing.ExecuteToolAsync(toolName, toolParams); JsonRpcResultEntity jsonRpcResultEntity; if (results.ErrorCode == 0) { jsonRpcResultEntity = new JsonRpcErrorEntity() { Error = new Error() { Code = results.ErrorCode.ToString(), Message = JsonConvert.SerializeObject(results.ErrorMessages) } }; } else { jsonRpcResultEntity = new JsonRpcSuccessEntity { Result = JsonConvert.SerializeObject(results.Messages) }; } return jsonRpcResultEntity; } }