// Export the joined data. private static void ExportTheJoinedFeatureClass(IFeatureClass featClass, string dataSetName) { Geoprocessor GP = new Geoprocessor(); // FeatureClass to Feature Class Tool ESRI.ArcGIS.ConversionTools.FeatureClassToFeatureClass importRoads = new ESRI.ArcGIS.ConversionTools.FeatureClassToFeatureClass(); importRoads.in_features = featClass; importRoads.out_name = dataSetName + jurisNameNoSpace + "_ToCheck"; importRoads.out_path = @"C:\temp\AddressCrossCheck.gdb"; // Execute the Feature Class to Feature Class Tool Console.WriteLine("Exporting the Joined " + dataSetName + "..."); GP.Execute(importRoads, null); // Back to Main function. }
// Import the table and feature classes. public static void ImportDataToFGDB() { // Import the text file as a table to the newly-created filegeodatabase. // Initialize the geoprocessor. Geoprocessor GP = new Geoprocessor(); // IMPORT THE TEXT FILE // Table to Table Tool. ESRI.ArcGIS.ConversionTools.TableToTable importTable = new ESRI.ArcGIS.ConversionTools.TableToTable(); importTable.in_rows = textFilePathName; //importTable.out_path = @"C:\temp\AddressCrossCheck.gdb"; importTable.out_path = @"C:\temp\" + fileGeodatabaseName; ////// remove space in juris name ////jurisNameNoSpace = jurisToCheck.Replace(" ", ""); ////importTable.out_name = "tbl" + jurisNameNoSpace.Trim() + "_Report"; importTable.out_name = "tbl_" + countyName + "Report"; // Execute the Table to Table Tool Console.WriteLine("Importing Text File as Table..."); GP.Execute(importTable, null); // if you get an error on this line it might be b/c there already a table in the fgdb with the same name. // Import the feature classes (address points and roads). // IMPORT THE ADDRESS POINTS // Re-initialize the geoprocessor GP = new Geoprocessor(); // Connect to sde sgid var factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory"); var workspaceFactory2 = (IWorkspaceFactory2)Activator.CreateInstance(factoryType); IWorkspace sgid = workspaceFactory2.OpenFromFile(@"C:\Users\gbunce\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\DC_agrc@[email protected]", 0); var sgidFeatureWorkspace = (IFeatureWorkspace)sgid; addressPointsSGID = sgidFeatureWorkspace.OpenFeatureClass("SGID10.LOCATION.AddressPoints"); var roadsSGID = sgidFeatureWorkspace.OpenFeatureClass("SGID10.TRANSPORTATION.Roads"); // FeatureClass to Feature Class Tool ESRI.ArcGIS.ConversionTools.FeatureClassToFeatureClass importAddrPnts = new ESRI.ArcGIS.ConversionTools.FeatureClassToFeatureClass(); importAddrPnts.in_features = addressPointsSGID; importAddrPnts.where_clause = countyOrAddressSystem + @" = '" + jurisToCheck + @"'"; importAddrPnts.out_name = "AddrPnts" + "_SGID"; //importAddrPnts.out_path = @"C:\temp\AddressCrossCheck.gdb"; importAddrPnts.out_path = @"C:\temp\" + fileGeodatabaseName; // Execute the Feature Class to Feature Class Tool Console.WriteLine("Importing Address Points as Feature Class..."); GP.Execute(importAddrPnts, null); // IMPORT THE ROADS // Re-initialize the geoprocessor GP = new Geoprocessor(); // FeatureClass to Feature Class Tool ESRI.ArcGIS.ConversionTools.FeatureClassToFeatureClass importRoads = new ESRI.ArcGIS.ConversionTools.FeatureClassToFeatureClass(); importRoads.in_features = roadsSGID; string roadsFieldType = ""; if (countyOrAddressSystem == "AddSystem") { roadsFieldType = "ADDRSYS"; } else { roadsFieldType = "COUNTY"; } importRoads.where_clause = roadsFieldType + @"_L = '" + jurisToCheck + @"' or " + roadsFieldType + @"_R = '" + jurisToCheck + @"'"; importRoads.out_name = "Roads" + "_SGID"; //importRoads.out_path = @"C:\temp\AddressCrossCheck.gdb"; importRoads.out_path = @"C:\temp\" + fileGeodatabaseName; // Execute the Feature Class to Feature Class Tool Console.WriteLine("Importing Roads as Feature Class..."); GP.Execute(importRoads, null); // Close the SDE connection (workspace). // Join the table to the feature class JoinTheTableToFeatureClass("AddrPoints"); JoinTheTableToFeatureClass("Roads"); }