diff --git a/vHC/HC_Reporting/Functions/Reporting/Html/CHtmlExporter.cs b/vHC/HC_Reporting/Functions/Reporting/Html/CHtmlExporter.cs index 2429843..5a4c712 100644 --- a/vHC/HC_Reporting/Functions/Reporting/Html/CHtmlExporter.cs +++ b/vHC/HC_Reporting/Functions/Reporting/Html/CHtmlExporter.cs @@ -9,7 +9,7 @@ using VeeamHealthCheck.Scrubber; using VeeamHealthCheck.Shared; using VeeamHealthCheck.Shared.Logging; -using VeeamHealthCheck.Functions.Reporting.Pdf; +using VeeamHealthCheck.Functions.Reporting.Html.Exportables; namespace VeeamHealthCheck.Functions.Reporting.Html { @@ -100,6 +100,7 @@ public int ExportHtmlVb365(string htmlString, bool scrub) if (!scrub && CGlobals.EXPORTPDF) { ExportHtmlStringToPDF(htmlString); + } OpenHtmlIfEnabled(CGlobals.OpenHtml); @@ -127,7 +128,7 @@ public int ExportVbrHtml(string htmlString, bool scrub) //test export to PDF: if (!scrub && CGlobals.EXPORTPDF) { - ExportHtmlStringToPDF(htmlString); + ExportHtmlStringToPDF(htmlString); } OpenHtmlIfEnabled(CGlobals.OpenHtml); @@ -168,6 +169,9 @@ private void ExportHtmlStringToPDF(string htmlString) pdf.ConvertHtmlToPdf(htmlShowAll, _latestReport.Replace(".html", ".pdf")); pdf.Dispose(); + + //var htmlToDocx = new CHtmlToDocx(); + //htmlToDocx.ExportHtmlToDocx(htmlShowAll, _latestReport.Replace(".html", ".docx")); } public int ExportVbrSecurityHtml(string htmlString, bool scrub) diff --git a/vHC/HC_Reporting/Functions/Reporting/Html/Exportables/CHtmlToDocx.cs b/vHC/HC_Reporting/Functions/Reporting/Html/Exportables/CHtmlToDocx.cs new file mode 100644 index 0000000..ea7cc35 --- /dev/null +++ b/vHC/HC_Reporting/Functions/Reporting/Html/Exportables/CHtmlToDocx.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; +using System; +using System.IO; +using Xceed.Words.NET; +using HtmlToOpenXml; +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Wordprocessing; +using DocumentFormat.OpenXml; + +namespace VeeamHealthCheck.Functions.Reporting.Html.Exportables +{ + internal class CHtmlToDocx + { + public void ExportHtmlToDocx(string htmlContent, string outputPath) + { + // Create a new document + using (var wordDocument = WordprocessingDocument.Create(outputPath, WordprocessingDocumentType.Document)) + { + // Add a main document part + var mainPart = wordDocument.AddMainDocumentPart(); + mainPart.Document = new Document(); + var body = new Body(); + mainPart.Document.Append(body); + + // Set the document to landscape mode + var sectionProperties = new SectionProperties(); + var pageSize = new PageSize + { + Width = 16838, // 11.69 inches in twentieths of a point (A4 landscape width) + Height = 11906, // 8.27 inches in twentieths of a point (A4 landscape height) + Orient = PageOrientationValues.Landscape + }; + var pageMargin = new PageMargin + { + Top = 720, // 1 inch in twentieths of a point + Right = 720, + Bottom = 720, + Left = 720 + }; + sectionProperties.Append(pageSize); + sectionProperties.Append(pageMargin); + body.Append(sectionProperties); + + // Create a new HtmlConverter + var converter = new HtmlConverter(mainPart); + + // Convert the HTML content to DocX format + converter.ParseBody(htmlContent); + + // Save the document + mainPart.Document.Save(); + } + } + } +} diff --git a/vHC/HC_Reporting/Functions/Reporting/PDF/HtmlToPdfConverter.cs b/vHC/HC_Reporting/Functions/Reporting/Html/Exportables/HtmlToPdfConverter.cs similarity index 95% rename from vHC/HC_Reporting/Functions/Reporting/PDF/HtmlToPdfConverter.cs rename to vHC/HC_Reporting/Functions/Reporting/Html/Exportables/HtmlToPdfConverter.cs index 2459aea..dd22f9d 100644 --- a/vHC/HC_Reporting/Functions/Reporting/PDF/HtmlToPdfConverter.cs +++ b/vHC/HC_Reporting/Functions/Reporting/Html/Exportables/HtmlToPdfConverter.cs @@ -6,8 +6,8 @@ using System.IO; using System.Windows.Controls; -namespace VeeamHealthCheck.Functions.Reporting.Pdf -{ +namespace VeeamHealthCheck.Functions.Reporting.Html.Exportables +{ public class HtmlToPdfConverter { private IConverter _converter; diff --git a/vHC/HC_Reporting/Properties/launchSettings.json b/vHC/HC_Reporting/Properties/launchSettings.json index 9a79950..ce7beb9 100644 --- a/vHC/HC_Reporting/Properties/launchSettings.json +++ b/vHC/HC_Reporting/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "VeeamHealthCheck": { "commandName": "Project", - "commandLineArgs": "/import", + "commandLineArgs": "/import /pdf", "remoteDebugEnabled": true, "authenticationMode": "Windows", "remoteDebugMachine": "192.168.20.152:4026" diff --git a/vHC/HC_Reporting/Startup/CClientFunctions.cs b/vHC/HC_Reporting/Startup/CClientFunctions.cs index f46a65f..bb63b2a 100644 --- a/vHC/HC_Reporting/Startup/CClientFunctions.cs +++ b/vHC/HC_Reporting/Startup/CClientFunctions.cs @@ -80,14 +80,15 @@ public string ModeCheck() CGlobals.Logger.Error("No Veeam Software detected. Is this server the VBR or VB365 management server?", false); return "fail"; } - if (CGlobals.IsVbr) - return title + " - " + VbrLocalizationHelper.GuiTitleBnR; - if (CGlobals.IsVb365) - return title + " - " + VbrLocalizationHelper.GuiTitleVB365; + if (CGlobals.IsVbr && CGlobals.IsVb365) return title + " - " + VbrLocalizationHelper.GuiTitleBnR + " & " + VbrLocalizationHelper.GuiTitleVB365; if (!CGlobals.IsVb365 && !CGlobals.IsVbr) return title + " - " + VbrLocalizationHelper.GuiImportModeOnly; + if (CGlobals.IsVbr) + return title + " - " + VbrLocalizationHelper.GuiTitleBnR; + if (CGlobals.IsVb365) + return title + " - " + VbrLocalizationHelper.GuiTitleVB365; else return title; } diff --git a/vHC/HC_Reporting/VeeamHealthCheck.csproj b/vHC/HC_Reporting/VeeamHealthCheck.csproj index 54ca579..8c28eaa 100644 --- a/vHC/HC_Reporting/VeeamHealthCheck.csproj +++ b/vHC/HC_Reporting/VeeamHealthCheck.csproj @@ -11,10 +11,10 @@ Veeam AdamC Health_Check_Icon.ico - 2.0.0.572 + 2.0.0.588 False false - 2.0.0.572 + 2.0.0.588 full true @@ -117,6 +117,8 @@ + + diff --git a/vHC/HC_Reporting/VhcGui.xaml.cs b/vHC/HC_Reporting/VhcGui.xaml.cs index 47dc6f8..87afa64 100644 --- a/vHC/HC_Reporting/VhcGui.xaml.cs +++ b/vHC/HC_Reporting/VhcGui.xaml.cs @@ -22,6 +22,7 @@ public VhcGui() SetUi(); pathBox.IsEnabled = false; + //pdfCheckBox.IsEnabled = false; } private void SetUi() @@ -30,6 +31,11 @@ private void SetUi() this.Title = _functions.ModeCheck(); + if(CGlobals.IsVb365 && CGlobals.IsVbr) + { + pdfCheckBox.IsEnabled = false; + pdfCheckBox.ToolTip = "PDF Export not available when both VB365 & VBR are detected on the same machine."; + } _functions.PreRunCheck(); SetUiText(); diff --git a/vHC/VhcXTests/VhcXTests.csproj b/vHC/VhcXTests/VhcXTests.csproj index e7a1268..6e20e8f 100644 --- a/vHC/VhcXTests/VhcXTests.csproj +++ b/vHC/VhcXTests/VhcXTests.csproj @@ -7,8 +7,8 @@ false true - 1.0.0.296 - 1.0.0.296 + 1.0.0.310 + 1.0.0.310