Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ jobs:
- run: |
git fetch --prune --unshallow

- name: Show environment
run: Get-Variable
shell: pwsh

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
Expand All @@ -37,8 +33,8 @@ jobs:
- name: Test with OpenCover
run: |
.\CreateCoverReport.ps1
Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh
bash codecov.sh -f "CoverOutput/coverage.xml" -t ${{ secrets.CODECOV_TOKEN }}
# Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh
# bash codecov.sh -f "CoverOutput/coverage.xml" -t ${{ secrets.CODECOV_TOKEN }}
shell: pwsh
- name: Build Release
run: dotnet build --configuration Release
Expand Down
11 changes: 9 additions & 2 deletions PatchVersion.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
# check whether build on tag
$version = "DEVEL"

Write-Host ref = $env:GITHUB_REF
if ($env:GITHUB_REF -match "/tags/") {
# use tag as version name
$version = $env:GITHUB_REF -replace "(\w+/)*",""
} else {
if ($env:GITHUB_REF -match "/heads/") {
# use branch as version name base
$version = $env:GITHUB_REF -replace "(\w+/)*",""
}

# use git sha as version name
$version = ($env:GITHUB_SHA).Substring(0, 8)
$version = $version + "-" + ($env:GITHUB_SHA).Substring(0, 8)
}

Write-Host version = $version
Expand All @@ -17,4 +24,4 @@ $xml.Project.PropertyGroup.InformationalVersion = $version
$utf8 = New-Object System.Text.UTF8Encoding($true)
$sw = New-Object System.IO.StreamWriter($file.Fullname, $false, $utf8)
$xml.Save( $sw )
$sw.Close()
$sw.Close()
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) Lukas Grützmacher. All rights reserved.
// </copyright>

namespace lg2de.SimpleAccounting.Presentation
namespace lg2de.SimpleAccounting.Abstractions
{
using System.Diagnostics.CodeAnalysis;
using System.Windows;
Expand Down
42 changes: 42 additions & 0 deletions src/SimpleAccounting/Abstractions/WindowsMessageBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// <copyright>
// Copyright (c) Lukas Grützmacher. All rights reserved.
// </copyright>

namespace lg2de.SimpleAccounting.Abstractions
{
using System.Diagnostics.CodeAnalysis;
using System.Windows;
using Caliburn.Micro;

/// <summary>
/// Default implementation of <see cref="IMessageBox"/> using <see cref="MessageBox"/>.
/// </summary>
[ExcludeFromCodeCoverage]
internal class WindowsMessageBox : IMessageBox
{
public MessageBoxResult Show(
string messageBoxText,
string caption,
MessageBoxButton button = MessageBoxButton.OK,
MessageBoxImage icon = MessageBoxImage.None,
MessageBoxResult defaultResult = MessageBoxResult.None,
MessageBoxOptions options = MessageBoxOptions.None)
{
MessageBoxResult result = MessageBoxResult.None;
Execute.OnUIThread(
() =>
{
Application.Current.MainWindow.Activate();
result = MessageBox.Show(
Application.Current.MainWindow,
messageBoxText,
caption,
button,
icon,
defaultResult,
options);
});
return result;
}
}
}
2 changes: 1 addition & 1 deletion src/SimpleAccounting/AppBootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public AppBootstrapper()
this.container.Singleton<IWindowManager, WindowManager>();
this.container.Singleton<IReportFactory, ReportFactory>();
this.container.Singleton<IApplicationUpdate, ApplicationUpdate>();
this.container.Singleton<IMessageBox, MessageBoxWrapper>();
this.container.Singleton<IMessageBox, WindowsMessageBox>();
this.container.Singleton<IFileSystem, FileSystem>();
this.container.Singleton<IProcess, DotNetProcess>();
this.container.PerRequest<ShellViewModel>();
Expand Down
33 changes: 18 additions & 15 deletions src/SimpleAccounting/Infrastructure/ApplicationUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace lg2de.SimpleAccounting.Infrastructure
using System.Windows;
using lg2de.SimpleAccounting.Abstractions;
using lg2de.SimpleAccounting.Extensions;
using lg2de.SimpleAccounting.Presentation;
using Octokit;

[SuppressMessage(
Expand Down Expand Up @@ -106,20 +105,24 @@ internal bool AskForUpdate(IEnumerable<Release> releases, string currentVersion)
Justification = "catch exceptions from external library")]
private async Task<IEnumerable<Release>> GetAllReleasesAsync()
{
try
{
var productInformation = new ProductHeaderValue(Defines.ProjectName);
var client = new GitHubClient(productInformation);
return await client.Repository.Release.GetAll(Defines.OrganizationName, Defines.ProjectName);
}
catch (Exception exception)
{
this.messageBox.Show(
$"Abfrage neuer Versionen fehlgeschlagen:\n{exception.Message}",
Caption,
icon: MessageBoxImage.Error);
return Enumerable.Empty<Release>();
}
return await Task.Run(
async () =>
{
try
{
var productInformation = new ProductHeaderValue(Defines.ProjectName);
var client = new GitHubClient(productInformation);
return await client.Repository.Release.GetAll(Defines.OrganizationName, Defines.ProjectName);
}
catch (Exception exception)
{
this.messageBox.Show(
$"Abfrage neuer Versionen fehlgeschlagen:\n{exception.Message}",
Caption,
icon: MessageBoxImage.Error);
return Enumerable.Empty<Release>();
}
});
}
}
}
52 changes: 52 additions & 0 deletions src/SimpleAccounting/Infrastructure/AsyncCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// <copyright>
// Copyright (c) Lukas Grützmacher. All rights reserved.
// </copyright>

namespace lg2de.SimpleAccounting.Infrastructure
{
using System;
using System.Threading.Tasks;
using System.Windows.Input;

public class AsyncCommand : IAsyncCommand
{
private readonly IBusy busy;
private readonly Func<Task> command;

public AsyncCommand(IBusy busy, Func<Task> command)
{
this.busy = busy;
this.command = command;
}

public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}

public async void Execute(object parameter)
{
await this.ExecuteAsync(parameter);
}

public bool CanExecute(object parameter)
{
return true;
}

public async Task ExecuteAsync(object parameter)
{
this.busy.IsBusy = true;
RaiseCanExecuteChanged();
await this.command();
this.busy.IsBusy = false;
RaiseCanExecuteChanged();
}

private static void RaiseCanExecuteChanged()
{
CommandManager.InvalidateRequerySuggested();
}
}
}
2 changes: 2 additions & 0 deletions src/SimpleAccounting/Infrastructure/Defines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ internal static class Defines

public static readonly string ProjectUrl = $"https://{GithubDomain}/{OrganizationName}/{ProjectName}";
public static readonly string NewIssueUrl = $"{ProjectUrl}/issues/new?template=bug-report.md";

public static string GetAutoSaveFileName(string fileName) => fileName + "~";
}
}
14 changes: 14 additions & 0 deletions src/SimpleAccounting/Infrastructure/IAsyncCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// <copyright>
// Copyright (c) Lukas Grützmacher. All rights reserved.
// </copyright>

namespace lg2de.SimpleAccounting.Infrastructure
{
using System.Threading.Tasks;
using System.Windows.Input;

public interface IAsyncCommand : ICommand
{
Task ExecuteAsync(object parameter);
}
}
11 changes: 11 additions & 0 deletions src/SimpleAccounting/Infrastructure/IBusy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// <copyright>
// Copyright (c) Lukas Grützmacher. All rights reserved.
// </copyright>

namespace lg2de.SimpleAccounting.Infrastructure
{
public interface IBusy
{
bool IsBusy { get; set; }
}
}
Loading