Esempio n. 1
0
        /// <summary>
        /// Returns an instantiated ESRITranslator geoprocessing tool with input
        /// and output parameters set to the specified values.
        /// param name="inFile" input file to be translated
        /// </summary>
        static public ESRITranslator xmlTranslator(string inFile, string translatorPath)
        {
            // Assign/Create the temporary files for translation output
            string outFile = Path.GetTempFileName();
            string logFile = Path.GetTempFileName();

            // Identify the XSL transformation to be used
            string xslTranslator = Path.Combine(Globals.ArcGISInstallationFolderFromCommandLine,
                                                translatorPath);

            // Instantiate the geoprocessing tool and define its parameters
            // Usage: ESRITranslator_conversion <source> <translator> <output> <logfile>
            ESRITranslator mdTranslator = new ESRITranslator();

            mdTranslator.source = inFile;
            if (xslTranslator.Trim().Length > 0)
            {
                mdTranslator.translator = xslTranslator;        // ""
            }
            else
            {
                mdTranslator.translator = "";
            }
            mdTranslator.output  = outFile;
            mdTranslator.logfile = logFile;

            return(mdTranslator);
        }
Esempio n. 2
0
        /// <summary>
        /// Translates metadata document
        /// </summary>
        /// <remarks>
        /// used to translate metadata document.
        /// </remarks>
        /// <param name="sourceXml">Metadata to be converted</param>
        /// <param name="xsltFileName">Translation xslt</param>
        /// <param name="xmlFileName">Metadata xml file name.</param>
        /// <returns>Returns true if execution was successful.</returns>
        private bool TranslateMetadata(string sourceXml, String xsltFileName, ref String xmlFileName)
        {
            ESRITranslator gpTool = GpHelper.xmlTranslator(sourceXml, xsltFileName, xmlFileName);

            // 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.
            string[] xmlFilePaths;
            return(GpHelper.Execute(gpTool, out xmlFilePaths) == 0);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        /// <summary>
        /// Returns an instantiated ESRITranslator geoprocessing tool with input
        /// and output parameters set to the specified values.
        /// param name="inFile" input file to be translated
        /// </summary>
        static public ESRITranslator xmlTranslator(string inFile)
        {
            // Assign/Create the temporary files for translation output
            string outFile = Path.GetTempFileName();
            string logFile = Path.GetTempFileName();

            // Instantiate the geoprocessing tool and define its parameters
            // Usage: ESRITranslator_conversion <source> <translator> <output> <logfile>
            ESRITranslator mdTranslator = new ESRITranslator();

            mdTranslator.source     = inFile;
            mdTranslator.translator = "";
            mdTranslator.output     = outFile;
            mdTranslator.logfile    = logFile;

            return(mdTranslator);
        }
        /// <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);
        }
Esempio n. 6
0
        /// <summary>
        /// Public wrapper used to execute an instantiated ESRITranslator 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="xmlFilePaths" the xml file paths
        /// </summary>
        static public int Execute(ESRITranslator gpTool, out string[] xmlFilePaths)
        {
            // Instantiate a new string array and set the anticipated paths
            // into the array. Invoking method is  responsible for cleanup
            // once it has processed the files generated by this method.
            xmlFilePaths    = new string[3];
            xmlFilePaths[0] = gpTool.source.ToString();  // Original XML
            xmlFilePaths[1] = gpTool.output.ToString();  // Translated XML
            xmlFilePaths[2] = gpTool.logfile.ToString(); // Translation Log

            try
            {
                Execute(gpTool as IGPProcess);
            }
            catch (Exception ex)
            {
            }

            return(retVal);
        }
Esempio n. 7
0
        /// <summary>
        /// Public wrapper used to execute an instantiated ESRITranslator 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="xmlFilePaths" the xml file paths
        /// </summary>
        static public int Execute(ESRITranslator gpTool, out string[] xmlFilePaths)
        {
            // Instantiate a new string array and set the anticipated paths
            // into the array. Invoking method is  responsible for cleanup
            // once it has processed the files generated by this method.
            xmlFilePaths = new string[3];
            xmlFilePaths[0] = gpTool.source.ToString();  // Original XML
            xmlFilePaths[1] = gpTool.output.ToString();  // Translated XML
            xmlFilePaths[2] = gpTool.logfile.ToString(); // Translation Log

            try
            {
                Execute(gpTool as IGPProcess);
            }
            catch (Exception ex)
            {
              
            }

            return retVal;
        }
Esempio n. 8
0
        /// <summary>
        /// Returns an instantiated ESRITranslator geoprocessing tool with input
        /// and output parameters set to the specified values.
        /// param name="inFile" the input file
        /// param name="xmlFileName" the xml file name
        /// param name="xsltFile" the xslt file
        /// </summary>
        static public ESRITranslator xmlTranslator(string inFile, String xsltFile, String xmlFileName)
        {
            // Assign/Create the temporary files for translation output
            string outFile = xmlFileName;
            string logFile = Path.GetTempFileName();

            // Identify the XSL transformation to be used
            string xslTranslator = xsltFile;

            // Instantiate the geoprocessing tool and define its parameters
            // Usage: ESRITranslator_conversion <source> <translator> <output> <logfile>
            ESRITranslator mdTranslator = new ESRITranslator();
            mdTranslator.source = inFile;
            mdTranslator.translator = xslTranslator;
            mdTranslator.output = outFile;
            mdTranslator.logfile = logFile;

            return mdTranslator;
        }
Esempio n. 9
0
        /// <summary>
        /// Returns an instantiated ESRITranslator geoprocessing tool with input
        /// and output parameters set to the specified values.
        /// param name="inFile" input file to be translated
        /// </summary>
        static public ESRITranslator xmlTranslator(string inFile,string translatorPath)
        {
            // Assign/Create the temporary files for translation output
            string outFile = Path.GetTempFileName();
            string logFile = Path.GetTempFileName();
            
            // Identify the XSL transformation to be used
            string xslTranslator = Path.Combine(Globals.ArcGISInstallationFolderFromCommandLine,
                translatorPath);

            // Instantiate the geoprocessing tool and define its parameters
            // Usage: ESRITranslator_conversion <source> <translator> <output> <logfile>
            ESRITranslator mdTranslator = new ESRITranslator();
            mdTranslator.source = inFile;
            if (xslTranslator.Trim().Length > 0)
            {
                mdTranslator.translator = xslTranslator;        // ""
            }
            else
            {
                mdTranslator.translator = "";
            }
            mdTranslator.output = outFile;
            mdTranslator.logfile = logFile;

            return mdTranslator;
        }