Пример #1
0
        private void CreateIndexHtml(string tempFolder, string packageId)
        {
            Log.Information("Creating index.html file.");

            // Get Metadata xml
            var transformationFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Html", "Xslt", "gebrauchskopie.xsl");
            var metadataFile       = Path.Combine(tempFolder, "header", "metadata.xml");

            // IF one of the files does not exist, log warning and create an "error" index.html file.
            if (!File.Exists(transformationFile) || !File.Exists(metadataFile))
            {
                Log.Warning(
                    "Could not find the transformation file or the source file to transform. Make sure the both file exists.\n{transformationFile}\n{metadataFile}",
                    transformationFile, metadataFile);
                File.WriteAllText(Path.Combine(tempFolder, "index.html"),
                                  "The index.html could not be created. Please inform the Swiss Federal Archive.");
                return;
            }

            // Benutzungskopien have no package id. In that case we pass a null parameter
            var paramCollection = string.IsNullOrEmpty(packageId) ? null : new Dictionary <string, string> {
                { "packageId", packageId }
            };
            // Do transformation
            var result = transformEngine.TransformXml(metadataFile, transformationFile, paramCollection);

            File.WriteAllText(Path.Combine(tempFolder, "index.html"), result);
        }
Пример #2
0
        private void ConvertAreldaMetadataXml(string tempFolder)
        {
            Log.Information("Converting arelda metadata.xml file...");

            var metadataFile       = Path.Combine(tempFolder, "header", "metadata.xml");
            var transformationFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Html", "Xslt", "areldaConvert.xsl");

            // IF one of the files does not exist, log warning and create an "error" index.html file.
            if (!File.Exists(transformationFile) || !File.Exists(metadataFile))
            {
                throw new Exception(
                          $"Could not find the transformation file or the source file to transform. Make sure the both file exists.\nTransformation file: {transformationFile}\nSource file: {metadataFile}");
            }

            var result = transformEngine.TransformXml(metadataFile, transformationFile, null);

            File.WriteAllText(metadataFile, result);
            Log.Information("Converted.");
        }