/// <summary> /// Processes the specified args. /// </summary> /// <param name="args">The args.</param> /// <returns></returns> public object Process(dynamic args) { Logger.Info(string.Format("Processing {0} ", args.ToString())); logType = args[0].ToString(); filters = (ICollection)args[1]; matcher = defaultMatcher; aggregator = new FileAggregator(); aggregator.Matcher = matcher; if (matcher == null) { BaseMessage.ErrorHandler(String.Format(CultureInfo.InvariantCulture, "matcher for {0} logs not found", logType)); } if (aggregator == null) { BaseMessage.ErrorHandler(String.Format(CultureInfo.InvariantCulture, "aggregator for {0} logs not found", logType)); } if (filters != null && filters.Count > 0) { matcher.Globs = filterGlobs; } string tarballPath = aggregator.GenerateTarball(); string blobstoreId = UploadTarball(tarballPath); return(new Dictionary <string, string>() { { "blobstore_id", blobstoreId } }); }
/// <summary> /// Creates an XDocument with a set of documents from the given <paramref name="inputFolderPath"/> and saves it to the <paramref name="outputPath"/>. /// </summary> public static void ConvertDocumentsToXml(string extension, string inputFolderPath, string outputPath) { if (!extension.StartsWith(".")) { extension = $".{extension}"; } XElement rootElement; ToXml converter; switch (extension) { case ".txt": rootElement = new XElement("DocumentSet"); converter = new TxtToXml(); break; case ".csv": rootElement = new XElement("SheetSet"); converter = new CsvToXml(); break; case ".xml": rootElement = new XElement("XmlSet"); converter = new ToXmlViaXslt(_xsltPath); break; default: throw new NotSupportedException($"{extension} is not a supported file format\r\n" + $"Supported formats: {supportedConversionFormats.ShowElements()}."); } string[] files = Directory.GetFiles(inputFolderPath); if (files .Where(file => Path.HasExtension(file)) .All(file => Path.GetExtension(file) == extension)) { var aggregator = new FileAggregator(inputFolderPath); foreach (string file in files) { var doc = new XDocument(); doc.Add(aggregator.ConvertFilesToXml(rootElement, converter)); doc.Save(outputPath); } } else { throw new NotSupportedException($"{inputFolderPath} must only contain files with this extension: {extension} and subfolders"); } }
/// <summary> /// Processes the specified args. /// </summary> /// <param name="args">The args.</param> /// <returns></returns> public object Process(dynamic args) { Logger.Info(string.Format("Processing {0} ", args.ToString())); logType = args[0].ToString(); filters = (ICollection)args[1]; matcher = defaultMatcher; aggregator = new FileAggregator(); aggregator.Matcher = matcher; if (matcher == null) { BaseMessage.ErrorHandler(String.Format(CultureInfo.InvariantCulture, "matcher for {0} logs not found", logType)); } if (aggregator == null) { BaseMessage.ErrorHandler(String.Format(CultureInfo.InvariantCulture, "aggregator for {0} logs not found", logType)); } if (filters != null && filters.Count > 0) { matcher.Globs = filterGlobs; } string tarballPath = aggregator.GenerateTarball(); string blobstoreId = UploadTarball(tarballPath); return new Dictionary<string, string>() { { "blobstore_id", blobstoreId } }; }