ltrolltide

Geoprocessing SDE Feature Classes

Discussion created by ltrolltide on Dec 4, 2012
Latest reply on Dec 7, 2012 by ltrolltide
I'm trying to append two SDE feature classes together.  I've been able to piece together the following code with no luck.  My geoprocessor appears to be failing I believe because my feature classes are not wrapped in a strongly typed RCW, but I've not had any luck figuring out how to accomplish this (or I may be totally out in left field with what I'm trying to do).  Any thoughts would be greatly appreciated.

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;

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", "xxxxx");
            propertySet.SetProperty("INSTANCE", "xxxxx");
            propertySet.SetProperty("DATABASE", "xxxxx");
            propertySet.SetProperty("USER", "xxxxx");
            propertySet.SetProperty("PASSWORD", "xxxxx");
            propertySet.SetProperty("VERSION", "xxxxx");

            // Use activator
            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory");
            IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
            //workspaceFactory.Open(propertySet, 0);

            //IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactoryClass();

            IWorkspace workspace = (IWorkspace)workspaceFactory.Open(propertySet, 0);

            IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)workspace;

            //IFeatureWorkspace pFeatureWorkspace = workspaceFactory.Open(propertySet, 0) as IFeatureWorkspace;

            ESRI.ArcGIS.Geodatabase.IFeatureClass inputClass = (IFeatureClass)pFeatureWorkspace.OpenFeatureClass("sde.DBO.Tester2Updater");
            ESRI.ArcGIS.Geodatabase.IFeatureClass targetClass = (IFeatureClass)pFeatureWorkspace.OpenFeatureClass("sde.DBO.Tester2Updater");

            //MessageBox.Show(inputClass.ShapeType.ToString());

            IVariantArray array = new VarArrayClass();
            array.Add(inputClass);
            array.Add(targetClass);
            array.Add("NO_TEST");

            //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_management", array, null);

            m_AOLicenseInitializer.ShutdownApplication();
        }
    }
}

Outcomes