ArcGIS Pro定制和开发-执行GP环境变量的设置
var in_table = main_lyr; var out_table = Path.Combine(Project.Current.DefaultGeodatabasePath, GVar.FtrLyr + " Results"); var statistics_fields = [["Shape_Area", "SUM"]]; //[['FEET', 'SUM']]"; var case_field = "Diameter"; // "['Diameter']"; var args = Geoprocessing.MakeValueArray(in_table, out_table, statistics_fields, case_field); var sp_ref = SpatialReferenceBuilder.CreateSpatialReference(102629); // NAD83 SP AL E FIPS 0101 Feet var envi = Geoprocessing.MakeEnvironmentArray(outputCoordinateSystem: sp_ref); Geoprocessing.ExecuteToolAsync("Statistics_analysis", args, envi, null, null, GPExecuteToolFlags.Default);
private async Task<bool> ExecuteAddFieldTool(KeyValuePair<string, string> field, string fieldType, int? fieldLength = null, bool isNullable = true) { try { var inTable = DeltaLayer.Name; var workspaceName = ((IInternalMapMember)DeltaLayer).WorkspaceName; var parameters = Geoprocessing.MakeValueArray(inTable, field.Key, fieldType.ToUpper(), null, null, fieldLength, field.Value, isNullable ? "NULABLE" : "NON_NULLABLE"); var env = Geoprocessing.MakeEnvironmentArray(workspace: workspaceName); var cts = new CancellationTokenSource(); var results = Geoprocessing.ExecuteToolAsync("management.AddField", parameters, env, cts.Token, (eventName, o) => { switch (eventName) { case "OnValidate": if (((IGPMessage[])o).Any(it => it.Type == GPMessageType.Warning)) { var fieldExists = ((IGPMessage[])o).FirstOrDefault(it => it.ErrorCode == 12); if (fieldExists != null) { //MessageBox.Show($"{fieldExists.Text}"); cts.Cancel(); } } break; } }); await results; return true; } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString()); return false; } }