private void ShowMetadata(ILayer layer) { if (layer is IDataLayer) { //Check style sheet exists if (File.Exists(cboStyleSheets.Text) == false) { System.Windows.Forms.MessageBox.Show("The selected style sheet does not exist!", "Missing Style Sheet"); return; } //QI for IDataLayer IDataLayer dataLayer = (IDataLayer)layer; //Get the metadata IMetadata metaData = (IMetadata)dataLayer.DataSourceName; //Get the xml property set from the metadata IXmlPropertySet2 xml = (IXmlPropertySet2)metaData.Metadata; //Save the xml to a temporary file and transforms it using the selected style sheet xml.SaveAsFile(cboStyleSheets.Text, "", false, ref m_tempFile); //Navigate the web browser to the temporary file object obj = null; webBrowser1.Navigate(m_tempFile); } else { System.Windows.Forms.MessageBox.Show("Metadata shown for IDataLayer objects only", "IDataLayer objects only"); } }
/// <summary> /// Translates metadata document /// </summary> /// <remarks> /// used to translate source metadata to another format using xslt. /// </remarks> /// <param name="propertySet">IXmlPropertySet2 metadata to be converted</param> /// <param name="xmlFilePaths">string[] output string array of file paths.</param> /// <returns>Returns true if execution was successful.</returns> private bool TranslateMetadata(IXmlPropertySet2 propertySet, out string[] xmlFilePaths) { const string noHeader = ""; const bool ansiRestrict = false; string sourceXml = Path.GetTempFileName(); propertySet.SaveAsFile(null, noHeader, ansiRestrict, ref sourceXml); ESRITranslator gpTool = GpHelper.xmlTranslator(sourceXml); // 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 xmlFilePaths) == 0); }
/// <summary> /// Translates metadata document /// </summary> /// <remarks> /// used to translate source metadata to another format using xslt. /// </remarks> /// <param name="propertySet">IXmlPropertySet2 metadata to be converted</param> /// <param name="xmlFilePaths">string[] output string array of file paths.</param> /// <returns>Returns true if execution was successful.</returns> private bool TranslateMetadata(IXmlPropertySet2 propertySet, out string[] xmlFilePaths) { const string noHeader = ""; const bool ansiRestrict = false; string sourceXml = Path.GetTempFileName(); propertySet.SaveAsFile(null, noHeader, ansiRestrict, ref sourceXml); ESRITranslator gpTool = GpHelper.xmlTranslator(sourceXml); // 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 xmlFilePaths) == 0); }
/// <summary> /// Translates metadata document /// </summary> /// <remarks> /// used to translate source metadata to another format using xslt. /// </remarks> /// <param name="propertySet">IXmlPropertySet2 metadata to be converted</param> /// <param name="xmlFilePaths">string[] output string array of file paths.</param> /// <returns>Returns true if execution was successful.</returns> private bool TranslateMetadata(IXmlPropertySet2 propertySet, out string[] xmlFilePaths) { const string noHeader = ""; const bool ansiRestrict = false; string sourceXml = Path.GetTempFileName(); propertySet.SaveAsFile(null, noHeader, ansiRestrict, ref sourceXml); String selectedStyleCfg = Globals.ArcGISInstallationFolderFromCommandLine + "\\Metadata\\Config\\" + Globals.ArcGISDesktopMetadataConfig + ".cfg"; translatorPath = readTranslatorFromConfig(selectedStyleCfg); ESRITranslator gpTool = GpHelper.xmlTranslator(sourceXml, translatorPath); // 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 xmlFilePaths) == 0); }
/// <summary> /// Translates metadata document /// </summary> /// <remarks> /// used to translate source metadata to another format using xslt. /// </remarks> /// <param name="propertySet">IXmlPropertySet2 metadata to be converted</param> /// <param name="xmlFilePaths">string[] output string array of file paths.</param> /// <returns>Returns true if execution was successful.</returns> private bool TranslateMetadata(IXmlPropertySet2 propertySet, out string[] xmlFilePaths) { const string noHeader = ""; const bool ansiRestrict = false; string sourceXml = Path.GetTempFileName(); propertySet.SaveAsFile(null, noHeader, ansiRestrict, ref sourceXml); String selectedStyleCfg = Globals.ArcGISInstallationFolderFromCommandLine + "\\Metadata\\Config\\" + Globals.ArcGISDesktopMetadataConfig + ".cfg"; translatorPath = readTranslatorFromConfig(selectedStyleCfg); ESRITranslator gpTool = GpHelper.xmlTranslator(sourceXml, translatorPath); // 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 xmlFilePaths) == 0); }