<PackageReference Include="Relativity.Server.Import.SDK" Version="2.9.2" />

HtmlCellFormatter

using kCura.WinEDDS; using kCura.WinEDDS.Exporters; using Relativity.DataExchange.Export.VolumeManagerV2.Directories; using System.Text; using System.Web; namespace Relativity.DataExchange.Export { public class HtmlCellFormatter : ILoadFileCellFormatter { private const string ROW_PREFIX = "<tr>"; private const string ROW_SUFFIX = "</tr>"; private const string COLUMN_PREFIX = "<td>"; private const string COLUMN_SUFFIX = "</td>"; private readonly IFilePathTransformer _filePathTransformer; private readonly ExportFile _settings; public string RowPrefix => "<tr>"; public string RowSuffix => "</tr>"; public HtmlCellFormatter(ExportFile settings, IFilePathTransformer filePathTransformer) { _settings = settings; _filePathTransformer = filePathTransformer; } public string TransformToCell(string contents) { contents = HttpUtility.HtmlEncode(contents); return "<td>" + contents + "</td>"; } public string CreateImageCell(ObjectExportInfo artifact) { if (!_settings.ExportImages || !IsDocument()) return string.Empty; return "<td>" + GetImagesHtmlString(artifact) + "</td>"; } public string CreateNativeCell(string location, ObjectExportInfo artifact) { return "<td>" + GetNativeHtmlString(artifact, location) + "</td>"; } public string CreatePdfCell(string location, ObjectExportInfo artifact) { return "<td>" + GetPdfHtmlString(artifact, location) + "</td>"; } private string GetNativeHtmlString(ObjectExportInfo artifact, string location) { if (IsDocument() && artifact.NativeCount == 0) return string.Empty; if (!IsDocument() && artifact.FileID <= 0) return string.Empty; string text = artifact.NativeFileName(_settings.AppendOriginalFileName); return GetLink(location, text); } private string GetPdfHtmlString(ObjectExportInfo artifact, string location) { if (!IsDocument() || !artifact.HasPdf) return string.Empty; string text = artifact.PdfFileName(artifact.IdentifierValue, _settings.AppendOriginalFileName); return GetLink(location, text); } private bool IsDocument() { return _settings.ArtifactTypeID == 10; } private string GetImagesHtmlString(ObjectExportInfo artifact) { StringBuilder stringBuilder = new StringBuilder(); foreach (ImageExportInfo image in artifact.Images) { string href = (!_settings.VolumeInfo.CopyImageFilesFromRepository) ? image.SourceLocation : _filePathTransformer.TransformPath(image.TempLocation); stringBuilder.Append(GetLink(href, image.FileName)); ExportFile.ImageType? typeOfImage = _settings.TypeOfImage; ExportFile.ImageType imageType = ExportFile.ImageType.MultiPageTiff; if ((typeOfImage.GetValueOrDefault() == imageType) & typeOfImage.HasValue) break; typeOfImage = _settings.TypeOfImage; imageType = ExportFile.ImageType.Pdf; if ((typeOfImage.GetValueOrDefault() == imageType) & typeOfImage.HasValue) break; } return stringBuilder.ToString(); } private string GetLink(string href, string text) { return "<a style='display:block' href='" + href + "'>" + text + "</a>"; } } }