Skip to content

Commit

Permalink
Improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
franklupo committed Jun 23, 2023
1 parent 3c8c168 commit eb3f97f
Show file tree
Hide file tree
Showing 23 changed files with 53 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<PackageReference Include="Hangfire.Storage.SQLite" Version="0.3.4" />

<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.7">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/Corsinvest.AppHero.AppBss/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Corsinvest.AppHero.Core;
using Corsinvest.AppHero.Core.Extensions;
using Corsinvest.AppHero.Core.Helpers;
using Corsinvest.AppHero.Core.SoftwareRelease;
using Corsinvest.AppHero.Core.SoftwareUpdater;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Http.Connections;
using Serilog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.8" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Corsinvest.AppHero.Authentication.ActiveDirectory;

public class Module : ModuleBase, IForceLoadModule, IAutenticationConfig, IAutentication
public class Module : ModuleBase, IForceLoadModule, IAutentication
{
private IServiceCollection _services = default!;

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

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="7.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="7.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="7.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="7.0.8" />
<PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="3.6.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace Corsinvest.AppHero.Authentication.OAuth.Facebook;

public class Module : ModuleBase, IForceLoadModule, IAutenticationConfig, IAutentication
public class Module : ModuleBase, IForceLoadModule, IAutentication
{
private bool _configurated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Corsinvest.AppHero.Authentication.OAuth.Google;

public class Module : ModuleBase, IForceLoadModule, IAutenticationConfig, IAutentication
public class Module : ModuleBase, IForceLoadModule, IAutentication
{
private bool _configurated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Corsinvest.AppHero.Authentication.OAuth.MicrosoftAccount;

public class Module : ModuleBase, IForceLoadModule, IAutenticationConfig, IAutentication
public class Module : ModuleBase, IForceLoadModule, IAutentication
{
private bool _configurated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected IEnumerable<ModuleBase> GetExternalProviders(AutenticationType type)
.Implements<IAutentication>()
.IsEnabled()
.IsConfigured()
.Where(a => ((IAutenticationConfig)a).AutenticationType == type);
.Where(a => ((IAutentication)a).AutenticationType == type);

protected class LoginDef
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

<ItemGroup>
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="6.5.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.8" />
<PackageReference Include="MudBlazor" Version="6.4.1" />
<PackageReference Include="BlazorDownloadFile" Version="2.4.0.2" />
<PackageReference Include="MudBlazor.Extensions" Version="1.7.49" />
<PackageReference Include="MudBlazor.Extensions" Version="1.7.54" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
<PackageReference Include="Toolbelt.Blazor.LoadingBar" Version="13.2.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Corsinvest.AppHero.Core.Hubs;
using Corsinvest.AppHero.Core.MudBlazorUI.Shared.Components;
using Corsinvest.AppHero.Core.MudBlazorUI.Style;
using Corsinvest.AppHero.Core.SoftwareRelease;
using Corsinvest.AppHero.Core.SoftwareUpdater;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.Localization;
using Microsoft.JSInterop;
Expand All @@ -28,7 +28,7 @@ public partial class MainLayout : IAsyncDisposable

private AppOptions AppOptions => SnapshotAppOptions.Value;
private bool DrawerOpen { get; set; } = true;
private RleaseInfo? ReleaseInfo { get; set; }
private ReleaseInfo? ReleaseInfo { get; set; }
private IReleaseService? _releaseService;
private Timer? _timer;
private MudThemeProvider? RefMudThemeProvider { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/Corsinvest.AppHero.Core/Corsinvest.AppHero.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<PackageReference Include="Ardalis.Specification.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="MailKit" Version="4.1.0" />

<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.7" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.8" />
<PackageReference Include="MiniExcel" Version="1.31.0" />
<PackageReference Include="RazorEngineCore" Version="2022.8.1" />

Expand Down
2 changes: 2 additions & 0 deletions src/Corsinvest.AppHero.Core/Security/Auth/IAutentication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ public interface IAutentication : IGroupableService
{
string IGroupableService.GetGroupName() => "Autentication";
string IGroupableService.GetGroupIcon() => UI.UIIcon.Key.GetName();

AutenticationType AutenticationType { get; }
}
10 changes: 0 additions & 10 deletions src/Corsinvest.AppHero.Core/Security/Auth/IAutenticationConfig.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
using Newtonsoft.Json;
using Semver;

namespace Corsinvest.AppHero.Core.SoftwareRelease;
namespace Corsinvest.AppHero.Core.SoftwareUpdater;

public class DockerHubReleaseService : IReleaseService
{
private readonly IOptionsSnapshot<AppOptions> _appOptions;

public DockerHubReleaseService(IOptionsSnapshot<AppOptions> appOptions) => _appOptions = appOptions;

public async Task<IEnumerable<RleaseInfo>> GetReleasesAsync()
public async Task<IEnumerable<ReleaseInfo>> GetReleasesAsync()
{
var repo = _appOptions.Value.RepoDockerHub;

using var client = new HttpClient();
var data = await client.GetStringAsync($"https://registry.hub.docker.com/v2/repositories/{repo}/tags");

return JsonConvert.DeserializeObject<Data>(data)!.Results
.Select(a => new RleaseInfo()
.Select(a => new ReleaseInfo()
{
Prerelease = SemVersion.Parse(a.Name, Semver.SemVersionStyles.Any).IsPrerelease,
Url = $"https://hub.docker.com/r/{repo}/tags",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
using Newtonsoft.Json;
using System.Net.Http.Headers;

namespace Corsinvest.AppHero.Core.SoftwareRelease;
namespace Corsinvest.AppHero.Core.SoftwareUpdater;

public class GitHubReleaseService : IReleaseService
{
private readonly IOptionsSnapshot<AppOptions> _appOptions;
public GitHubReleaseService(IOptionsSnapshot<AppOptions> appOptions) => _appOptions = appOptions;

public async Task<IEnumerable<RleaseInfo>> GetReleasesAsync()
public async Task<IEnumerable<ReleaseInfo>> GetReleasesAsync()
{
var repo = _appOptions.Value.RepoGitHub;

Expand All @@ -22,7 +22,7 @@ public async Task<IEnumerable<RleaseInfo>> GetReleasesAsync()

return JsonConvert.DeserializeObject<List<Data>>(data)!
.Where(a => !a.Draft)
.Select(a => new RleaseInfo()
.Select(a => new ReleaseInfo()
{
Prerelease = a.Prerelease,
Url = a.HtmlUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@
*/
using Semver;

namespace Corsinvest.AppHero.Core.SoftwareRelease;
namespace Corsinvest.AppHero.Core.SoftwareUpdater;

public interface IReleaseService
{
Task<IEnumerable<RleaseInfo>> GetReleasesAsync();
Task<IEnumerable<ReleaseInfo>> GetReleasesAsync();

private static DateTime? LastRun { get; set; }
private static RleaseInfo? LastValue { get; set; }
private static ReleaseInfo? LastValue { get; set; }

public async Task<RleaseInfo?> NewReleaseIsAvaibleAsync()
public async Task<ReleaseInfo?> NewReleaseIsAvaibleAsync()
{
if (LastRun == null || (DateTime.Now - LastRun).Value.Minutes > 5)
{
LastRun = DateTime.Now;

if (SemVersion.TryParse(ApplicationHelper.ProductVersion, SemVersionStyles.Any, out var currSemVer))
{
IEnumerable<RleaseInfo>? data = null;
IEnumerable<ReleaseInfo>? data = null;
try
{
data = await GetReleasesAsync();
}
catch { }

foreach (var item in data ?? new List<RleaseInfo>())
foreach (var item in data ?? new List<ReleaseInfo>())
{
if (SemVersion.TryParse(item.Version, SemVersionStyles.Any, out var semVer))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
*/
using Semver;

namespace Corsinvest.AppHero.Core.SoftwareRelease;
namespace Corsinvest.AppHero.Core.SoftwareUpdater;

public class RleaseInfo
public class ReleaseInfo
{
public string? Url { get; set; }
public bool Prerelease { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-FileCopyrightText: Copyright Corsinvest Srl
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Corsinvest.AppHero.Core.SoftwareRelease;
namespace Corsinvest.AppHero.Core.SoftwareUpdater;

public static class ServiceCollectionExtensions
{
Expand Down
11 changes: 11 additions & 0 deletions src/Corsinvest.AppHero.Core/SoftwareUpdater/UpdaterOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* SPDX-FileCopyrightText: Copyright Corsinvest Srl
* SPDX-License-Identifier: AGPL-3.0-only
*/

namespace Corsinvest.AppHero.Core.SoftwareUpdater;

public class UpdaterOptions
{
public bool Prerelease { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Hangfire.Console" Version="1.4.2" />
<PackageReference Include="Hangfire.Console.Extensions" Version="1.0.5" />
<PackageReference Include="Hangfire.Console.Extensions.Serilog" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.8" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

<ItemGroup>
<PackageReference Include="OrchardCore.Localization.Core" Version="1.6.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.7">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.8" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>

<LangVersion>latest</LangVersion>
<Version>0.0.104</Version>
<Version>0.0.106</Version>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<!--<NoWarn>$(NoWarn);CS1591;CS0436</NoWarn>-->

Expand Down

0 comments on commit eb3f97f

Please sign in to comment.