/// <summary> /// Run the Geoprocessing model /// </summary> /// <param name="modelParametersHybridDictionary">A HybridDictionary that contains all of the arguments to run the model</param> /// <returns>A message of how well the model executed</returns> /// <remarks></remarks> public static System.String ExecuteCustomGeoprocessingFunction(System.Collections.Specialized.HybridDictionary modelParametersHybridDictionary) { try { // Create a Geoprocessor object ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor(); // Set the OverwriteOutput setting to True gp.OverwriteOutput = true; // Create a new instance of our custom model MYCUSTOMTOOLBOX.GolfFinder myModel = new MYCUSTOMTOOLBOX.GolfFinder(); // Set the custom models parameters. myModel.BufferDistance = modelParametersHybridDictionary["BufferDistance"]; myModel.AIRPORT = modelParametersHybridDictionary["Airports"]; myModel.GOLF = modelParametersHybridDictionary["Golf"]; myModel.AirportBuffer = modelParametersHybridDictionary["AirportBuffer"]; myModel.Golf_Courses_Near_Airports = modelParametersHybridDictionary["GolfNearAirports"]; // Execute the model and obtain the result from the run ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult geoProcessorResult = (ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult)gp.Execute(myModel, null); if (geoProcessorResult == null) { // We have an error running the model. // If the run fails a Nothing (VB.NET) or null (C#) is returned from the gp.Execute object sev = 2; string messages = gp.GetMessages(ref sev); return(messages); } else { // The model completed successfully return("Output successful. The shapefiles are locacted at: " + geoProcessorResult.ReturnValue.ToString()); } } catch (Exception ex) { // Catch any other errors return("Error running the model. Debug the application and test again."); } }
/// <summary> /// Run the Geoprocessing model /// </summary> /// <param name="modelParametersHybridDictionary">A HybridDictionary that contains all of the arguments to run the model</param> /// <returns>A message of how well the model executed</returns> /// <remarks></remarks> public static System.String ExecuteCustomGeoprocessingFunction(System.Collections.Specialized.HybridDictionary modelParametersHybridDictionary) { try { // Create a Geoprocessor object ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor(); // Set the OverwriteOutput setting to True gp.OverwriteOutput = true; // Create a new instance of our custom model MYCUSTOMTOOLBOX.GolfFinder myModel = new MYCUSTOMTOOLBOX.GolfFinder(); // Set the custom models parameters. myModel.BufferDistance = modelParametersHybridDictionary["BufferDistance"]; myModel.AIRPORT = modelParametersHybridDictionary["Airports"]; myModel.GOLF = modelParametersHybridDictionary["Golf"]; myModel.AirportBuffer = modelParametersHybridDictionary["AirportBuffer"]; myModel.Golf_Courses_Near_Airports = modelParametersHybridDictionary["GolfNearAirports"]; // Execute the model and obtain the result from the run ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult geoProcessorResult = (ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult)gp.Execute(myModel, null); if (geoProcessorResult == null) { // We have an error running the model. // If the run fails a Nothing (VB.NET) or null (C#) is returned from the gp.Execute object sev = 2; string messages = gp.GetMessages(ref sev); return messages; } else { // The model completed successfully return "Output successful. The shapefiles are locacted at: " + geoProcessorResult.ReturnValue.ToString(); } } catch (Exception ex) { // Catch any other errors return "Error running the model. Debug the application and test again."; } }