try { gp.Execute(app, null); } catch(Exception exc) { MessageBox.Show(exc.ToString()); }
gp.ToolExecuted += new EventHandler<ToolExecutedEventArgs>(geoprocessor_ToolExecuted); private void geoprocessor_ToolExecuted(object sender, ToolExecutedEventArgs e) { m_AOLicenseInitializer.ShutdownApplication(); }
using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.DataManagementTools; using ESRI.ArcGIS.Geoprocessing; using ESRI.ArcGIS.Geoprocessor; using ESRI.ArcGIS.DataSourcesGDB; using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.Carto; namespace T { class Program { private static LicenseInitializer m_AOLicenseInitializer = new T.LicenseInitializer(); [STAThread()] static void Main(string[] args) { //ESRI License Initializer generated code. m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeArcInfo }, new esriLicenseExtensionCode[] { }); //ESRI License Initializer generated code. //Do not make any call to ArcObjects after ShutDownApplication() // Get geoprocessor ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor(); gp.AddOutputsToMap = false; // Get append tool ESRI.ArcGIS.DataManagementTools.Append app = new ESRI.ArcGIS.DataManagementTools.Append(); IPropertySet propertySet = new PropertySetClass(); propertySet.SetProperty("SERVER", "xyz"); propertySet.SetProperty("INSTANCE", "xyz"); propertySet.SetProperty("DATABASE", "xyz"); propertySet.SetProperty("USER", "xyz"); propertySet.SetProperty("PASSWORD", "xyz"); propertySet.SetProperty("VERSION", "xyz"); // Use activator Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType); IWorkspace workspace = (IWorkspace)workspaceFactory.Open(propertySet, 0); IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)workspace; ESRI.ArcGIS.Geodatabase.IFeatureClass inputClass = (IFeatureClass)pFeatureWorkspace.OpenFeatureClass("sde.DBO.Tester2Updater"); ESRI.ArcGIS.Geodatabase.IFeatureClass targetClass = (IFeatureClass)pFeatureWorkspace.OpenFeatureClass("sde.DBO.Tester1Main"); //IVariantArray array = new VarArrayClass(); //array.Add(inputClass); //array.Add(targetClass); //array.Add("NO_TEST"); app.inputs = inputClass; app.target = targetClass; app.schema_type = "NO_TEST"; //This works for non-sde input (not worried about creating sde connection) //IVariantArray array = new VarArrayClass(); //array.Add(@D:\ProjectData\TestData2\test2.shp); //array.Add(@D:\ProjectData\TestData1\test1.shp); //array.Add("NO_TEST"); //gp.Execute("Append_managament", array, null); //gp.Execute("Append_management", array, null); gp.Execute(app, null); m_AOLicenseInitializer.ShutdownApplication(); } } }
// Get append tool ESRI.ArcGIS.DataManagementTools.Append app = new ESRI.ArcGIS.DataManagementTools.Append();
Append append = new Append(); append.inputs = inputClass; append.target = targetClass ; append.schema_type = "NO_TEST" GP.Execute(append , null);
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.