/// <summary> /// Public wrapper used to execute an instantiated MDPublisher geoprocessing tool. /// The wrapper's try/catch block contains an error message identifying the type of tool. ///param name="gpTool" the geoprocessing tool ///param name="publicationResults" the publication results /// </summary> static public int Execute(MDPublisher gpTool, out string[] publicationResults) { publicationResults = new string[1]; object PubMaxSeverityErrCode = esriGPMessageSeverity.esriGPMessageSeverityInformative; try { Execute(gpTool as IGPProcess); if (geoprocessor.MaxSeverity >= (int)PubMaxSeverityErrCode) { publicationResults[0] = geoprocessor.GetMessages(ref PubMaxSeverityErrCode); retVal = -1; } } catch (Exception ex) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Unexpected exception generated by geoprocessing tool"); sb.AppendLine("Metadata Publisher (Conversion Tools - Metadata)"); sb.AppendLine(""); sb.AppendLine(ex.Message); MessageBox.Show(sb.ToString(), "Publication Failure", MessageBoxButtons.OK, MessageBoxIcon.Warning); retVal = -1; } return(retVal); }
/// <summary> /// Publishes metadata document /// </summary> /// <remarks> /// used to publish metadata document. /// </remarks> /// <param name="xmlMetadata">Metadata to be converted</param> /// <param name="mdFileID">Unique file identifier</param> /// <param name="publicationResults">string[] output publication results.</param> /// <returns>Returns true if execution was successful.</returns> private bool PublishMetadata(string xmlMetadata, string mdFileID, out string[] publicationResults) { // Request that the GpHelper instantiate an MDPublisher geoprocessing // tool and set tool's parameters. MDPublisher gpTool = GpHelper.xmlPublisher(xmlMetadata, mdFileID, parameters); // Request that the GpHelper execute the instantiated tool. A wrapper is // used to abstract error handling and allow a simple integer success code // equivalency check to determine success/failure. return(GpHelper.Execute(gpTool, out publicationResults) == 0); }
/// <summary> /// Returns an instantiated MDPublisher geoprocessing tool with input /// and output parameters set to the specified values. /// param name="inFile" the input file /// param name="mdFileID" a file identifier (like source uri) /// param name="param" the publication parameters /// </summary> static public MDPublisher xmlPublisher(string inFile, string mdFileID, PublicationParams param) { // Instantiate the geoprocessing tool and define its parameters // Usage: MDPublisher_conversion <source> <publisher> <url> <service> <user> <password> MDPublisher mdPublisher = new MDPublisher(); mdPublisher.source = inFile; mdPublisher.publisher = param.CurrentWorkDir; mdPublisher.url = param.ServerUrl; mdPublisher.service = param.Service + ":EB:" + mdFileID; mdPublisher.user = param.UserName; mdPublisher.password = param.Password; return(mdPublisher); }
/// <summary> /// Returns an instantiated MDPublisher geoprocessing tool with input /// and output parameters set to the specified values. /// param name="inFile" the input file /// param name="mdFileID" a file identifier (like source uri) /// param name="param" the publication parameters /// </summary> static public MDPublisher xmlPublisher(string inFile, string mdFileID, PublicationParams param) { // Instantiate the geoprocessing tool and define its parameters // Usage: MDPublisher_conversion <source> <publisher> <url> <service> <user> <password> MDPublisher mdPublisher = new MDPublisher(); mdPublisher.source = inFile; mdPublisher.publisher = param.CurrentWorkDir; mdPublisher.url = param.ServerUrl; mdPublisher.service = param.Service + ":EB:" + mdFileID; mdPublisher.user = param.UserName; mdPublisher.password = param.Password; return mdPublisher; }
/// <summary> /// Public wrapper used to execute an instantiated MDPublisher geoprocessing tool. /// The wrapper's try/catch block contains an error message identifying the type of tool. ///param name="gpTool" the geoprocessing tool ///param name="publicationResults" the publication results /// </summary> static public int Execute(MDPublisher gpTool, out string[] publicationResults) { publicationResults = new string[1]; object PubMaxSeverityErrCode = esriGPMessageSeverity.esriGPMessageSeverityInformative; try { Execute(gpTool as IGPProcess); if (geoprocessor.MaxSeverity >= (int)PubMaxSeverityErrCode) { publicationResults[0] = geoprocessor.GetMessages(ref PubMaxSeverityErrCode); retVal = -1; } } catch (Exception ex) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Unexpected exception generated by geoprocessing tool"); sb.AppendLine("Metadata Publisher (Conversion Tools - Metadata)"); sb.AppendLine(""); sb.AppendLine(ex.Message); MessageBox.Show(sb.ToString(), "Publication Failure", MessageBoxButtons.OK, MessageBoxIcon.Warning); retVal = -1; } return retVal; }