Skip to content

Commit

Permalink
Merge pull request #4 from atc-net/feature/maintenance
Browse files Browse the repository at this point in the history
Feature/maintenance
  • Loading branch information
davidkallesen authored Oct 9, 2023
2 parents a491377 + 405500d commit 9da96b3
Show file tree
Hide file tree
Showing 28 changed files with 643 additions and 40 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
<ItemGroup Label="Code Analyzers">
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
<PackageReference Include="Asyncify" Version="0.9.7" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.84" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.92" PrivateAssets="All" />
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.6.7" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.9.0.77355" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.11.0.78383" PrivateAssets="All" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ Today the Atc.Installer supports a different kind of "Components" that are defin
| NativeNoSettings | |
| DonNetFramework48 | .NET Framework |
| DotNet7 | .NET |
| DotNet8 | .NET |
| NodeJs | NodeJs (min. v.18) |
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.349" />
<PackageReference Include="Azure.Identity" Version="1.10.0" />
<PackageReference Include="Atc" Version="2.0.360" />
<PackageReference Include="Azure.Identity" Version="1.10.1" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.18.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.349" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0-preview.6.23329.7" />
<PackageReference Include="Atc" Version="2.0.360" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0-rc.1.23419.4" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public interface IWindowsApplicationInstallerService : IInstallerService

bool IsMicrosoftDonNet7();

bool IsMicrosoftDonNet8();

ComponentRunningState GetServiceState(
string serviceName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public bool IsMicrosoftDonNetFramework48()
public bool IsMicrosoftDonNet7()
=> iaInstallerService.IsMicrosoftDonNet7();

public bool IsMicrosoftDonNet8()
=> iaInstallerService.IsMicrosoftDonNet8();

public ComponentRunningState GetServiceState(
string serviceName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.349" />
<PackageReference Include="Atc" Version="2.0.360" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public enum HostingFrameworkType
NativeNoSettings,
DonNetFramework48,
DotNet7,
DotNet8,
NodeJs,
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public interface IInstalledAppsInstallerService : IInstallerService

bool IsMicrosoftDonNet7();

bool IsMicrosoftDonNet8();

Task<bool> IsNodeJs18();

bool IsJavaRuntime8();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public bool IsMicrosoftDonNetFramework48()
public bool IsMicrosoftDonNet7()
=> IsMicrosoftDonNet(7);

public bool IsMicrosoftDonNet8()
=> IsMicrosoftDonNet(8);

public bool IsJavaRuntime8()
=> IsJavaRuntime(8);

Expand Down
6 changes: 3 additions & 3 deletions src/Atc.Installer.Wpf.App/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
[assembly: AssemblyCompany("atc-net")]
[assembly: AssemblyProduct("Atc.Installer")]
[assembly: AssemblyTitle("Atc.Installer")]
[assembly: AssemblyVersion("1.0.7.0")]
[assembly: AssemblyInformationalVersion("1.0.7.0")]
[assembly: AssemblyFileVersion("1.0.7.0")]
[assembly: AssemblyVersion("1.0.8.0")]
[assembly: AssemblyInformationalVersion("1.0.8.0")]
[assembly: AssemblyFileVersion("1.0.8.0")]
[assembly: System.Resources.NeutralResourcesLanguage("en")]
[assembly: System.Runtime.Versioning.TargetPlatform("Windows7.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatform("Windows7.0")]
15 changes: 8 additions & 7 deletions src/Atc.Installer.Wpf.App/Atc.Installer.Wpf.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.265" />
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.265" />
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.265" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0-preview.6.23329.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0-preview.6.23329.7" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0-preview.6.23329.7" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0-preview.6.23329.7" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="7.0.0" />
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="ClosedXML" Version="0.103.0-beta" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0-rc.1.23419.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0-rc.1.23419.4" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0-rc.1.23419.4" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0-rc.1.23419.4" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0-rc.1.23419.4" />
<PackageReference Include="Serilog" Version="3.1.0-dev-02072" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.1-dev-00968" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/Atc.Installer.Wpf.App/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
global using Atc.Installer.Wpf.ComponentProvider.ElasticSearch;
global using Atc.Installer.Wpf.ComponentProvider.InternetInformationServer;
global using Atc.Installer.Wpf.ComponentProvider.Messages;
global using Atc.Installer.Wpf.ComponentProvider.Models;
global using Atc.Installer.Wpf.ComponentProvider.PostgreSql;
global using Atc.Installer.Wpf.ComponentProvider.ViewModels;
global using Atc.Installer.Wpf.ComponentProvider.WindowsApplication;
Expand All @@ -37,7 +38,7 @@
global using Atc.Wpf.Messaging;
global using Atc.Wpf.Mvvm;
global using Atc.Wpf.Theming.Themes.Dialogs;

global using ClosedXML.Excel;
global using ControlzEx.Theming;

global using Microsoft.Extensions.Configuration;
Expand Down
156 changes: 156 additions & 0 deletions src/Atc.Installer.Wpf.App/Helpers/ExcelHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// ReSharper disable ParameterTypeCanBeEnumerable.Local
namespace Atc.Installer.Wpf.App.Helpers;

[SuppressMessage("Design", "MA0051:Method is too long", Justification = "OK.")]
public static class ExcelHelper
{
public static void CreateAndSave(
FileInfo exportToFile,
IEnumerable<ReportingData> reportingDataForComponentProviders)
{
ArgumentNullException.ThrowIfNull(exportToFile);

var dataForComponentProviders = reportingDataForComponentProviders
.OrderBy(x => x.Name, StringComparer.Ordinal)
.ToArray();

var distinctFileShortNames = new List<string>();
foreach (var dataForComponentProvider in dataForComponentProviders.Where(x => x.InstalledMainFilePath is not null))
{
var mainFileInfo = new FileInfo(dataForComponentProvider.InstalledMainFilePath!);
var mainFileDirectoryInfo = $"{mainFileInfo.Directory!.FullName}\\";

foreach (var reportingFile in dataForComponentProvider.Files)
{
var shortName = reportingFile.FullName.Replace(mainFileDirectoryInfo, string.Empty, StringComparison.Ordinal);
if (!distinctFileShortNames.Contains(shortName, StringComparer.OrdinalIgnoreCase))
{
distinctFileShortNames.Add(shortName);
}
}
}

using var workbook = new XLWorkbook();
CreateAndAddWorksheetOverview(workbook, dataForComponentProviders);
CreateAndAddWorksheetFiles(workbook, dataForComponentProviders, distinctFileShortNames);
workbook.SaveAs(exportToFile.FullName);
}

private static void CreateAndAddWorksheetOverview(
IXLWorkbook workbook,
IReadOnlyCollection<ReportingData> dataForComponentProviders)
{
var wsOverview = workbook.Worksheets.Add("Overview");

var colNr = 1;
wsOverview.Cell(1, colNr).Value = "System";
colNr++;
wsOverview.Cell(1, colNr).Value = "Version";
colNr++;
wsOverview.Cell(1, colNr).Value = "MainFile";

var rowNr = 1;
foreach (var dataForComponentProvider in dataForComponentProviders)
{
rowNr++;
wsOverview.Cell(rowNr, 1).Value = dataForComponentProvider.Name;
wsOverview.Cell(rowNr, 2).Value = dataForComponentProvider.Version;
wsOverview.Cell(rowNr, 3).Value = dataForComponentProvider.InstalledMainFilePath;
}

var totalRowNr = rowNr;
var totalColNr = colNr;

// Header row
wsOverview.SheetView.Freeze(1, totalColNr);

wsOverview.Range(1, 1, 1, totalColNr)
.Style
.Font.SetBold()
.Fill.SetBackgroundColor(XLColor.LightBlue)
.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);

wsOverview.Columns().AdjustToContents();
wsOverview.Range(1, 1, 1, totalColNr).SetAutoFilter();

// Content - 1 column
wsOverview.Range(2, 1, totalRowNr, 1)
.Style
.Fill.SetBackgroundColor(XLColor.LightBlue);
}

private static void CreateAndAddWorksheetFiles(
IXLWorkbook workbook,
IReadOnlyCollection<ReportingData> dataForComponentProviders,
IReadOnlyCollection<string> distinctFileShortNames)
{
var wsFiles = workbook.Worksheets.Add("Files");

var colNr = 1;
wsFiles.Cell(1, colNr).Value = "File";
colNr++;

foreach (var dataForComponentProvider in dataForComponentProviders)
{
wsFiles.Cell(1, colNr).Value = dataForComponentProvider.Name;
colNr++;
}

var rowNr = 2;
foreach (var fileShortName in distinctFileShortNames.OrderBy(x => x, StringComparer.OrdinalIgnoreCase))
{
colNr = 1;
wsFiles.Cell(rowNr, colNr).Value = fileShortName;
colNr++;

foreach (var dataForComponentProvider in dataForComponentProviders)
{
var reportingFile = dataForComponentProvider.Files.FirstOrDefault(x =>
x.FullName.EndsWith(fileShortName, StringComparison.OrdinalIgnoreCase));
if (reportingFile is null)
{
wsFiles.Cell(rowNr, colNr).Value = "-";
}
else
{
if (reportingFile.Version is null)
{
wsFiles.Cell(rowNr, colNr).Value = "Unknown";
}
else
{
wsFiles.Cell(rowNr, colNr).Value = reportingFile.IsDebugBuild
? $"{reportingFile.Version} - Debug"
: reportingFile.Version;
}
}

colNr++;
}

rowNr++;
}

// Header row
wsFiles.SheetView.Freeze(1, dataForComponentProviders.Count + 1);

wsFiles.Range(1, 1, 1, dataForComponentProviders.Count + 1)
.Style
.Font.SetBold()
.Fill.SetBackgroundColor(XLColor.LightBlue)
.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);

wsFiles.Columns().AdjustToContents();
wsFiles.Range(1, 1, 1, dataForComponentProviders.Count + 1).SetAutoFilter();

// Content - 1 column
wsFiles.Range(2, 1, distinctFileShortNames.Count + 1, 1)
.Style
.Fill.SetBackgroundColor(XLColor.LightBlue);

// Content - rest
wsFiles.Range(2, 2, distinctFileShortNames.Count + 1, dataForComponentProviders.Count + 1)
.Style
.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
}
}
10 changes: 10 additions & 0 deletions src/Atc.Installer.Wpf.App/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@
<Image Source="{Binding Source={x:Static fontIcons:FontMaterialDesignType.Azure}, Converter={StaticResource FontIconImageSourceValueConverter}, ConverterParameter={StaticResource BlueBrush}}" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="_Reporting">
<MenuItem.Icon>
<Image Source="{Binding Source={x:Static fontIcons:FontMaterialDesignType.Export}, Converter={StaticResource FontIconImageSourceValueConverter}, ConverterParameter={StaticResource BlueBrush}}" />
</MenuItem.Icon>
<MenuItem Command="{Binding Path=ReportingToExcelCommand}" Header="_Excel">
<MenuItem.Icon>
<Image Source="{Binding Source={x:Static fontIcons:IcoFontType.FileExcel}, Converter={StaticResource FontIconImageSourceValueConverter}, ConverterParameter={StaticResource BlueBrush}}" />
</MenuItem.Icon>
</MenuItem>
</MenuItem>
</MenuItem>
<MenuItem Header="_Help">
<MenuItem Command="{Binding Path=OpenApplicationCheckForUpdatesCommand}" Header="_Check for updates">
Expand Down
Loading

0 comments on commit 9da96b3

Please sign in to comment.