Skip to content

Commit

Permalink
DN8P5 (#81)
Browse files Browse the repository at this point in the history
* Add IDispose

* 2023-06-08 BoD

* 2023-06-09 EoD

* Add duration

* Disable logging

* Remove last vestiges of logging

* 8080 exposed

* P5 changes
  • Loading branch information
MarkStega authored Jun 14, 2023
1 parent e477331 commit 74d6c18
Show file tree
Hide file tree
Showing 28 changed files with 964 additions and 791 deletions.
2 changes: 1 addition & 1 deletion ApplicationConfiguration/ApplicationConfiguration.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="Material.Blazor" Version="4.0.0-preview.18" />
<PackageReference Include="Material.Blazor" Version="4.0.0-preview.19" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="Material.Blazor" Version="4.0.0-preview.18" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.0-preview.4.23260.4" />
<PackageReference Include="Material.Blazor" Version="4.0.0-preview.19" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.0-preview.5.23302.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="Material.Blazor" Version="4.0.0-preview.18" />
<PackageReference Include="Material.Blazor" Version="4.0.0-preview.19" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion DataTier/DataTier.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
<PackageReference Include="Google.Protobuf" Version="3.23.1" />
<PackageReference Include="Google.Protobuf" Version="3.23.2" />
<PackageReference Include="Grpc.Net.Client" Version="2.53.0" />
</ItemGroup>

Expand Down
10 changes: 3 additions & 7 deletions ICEBG.Blazor/ICEBG.Blazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@

<ItemGroup>
<PackageReference Include="Blazor.Extensions.Logging" Version="2.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0-preview.4.23260.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0-preview.4.23260.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="2.2.8" />
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Serilog.Sinks.BrowserConsole" Version="1.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0-preview.4.23259.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0-preview.5.23302.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0-preview.5.23302.2" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0-preview.5.23280.8" />
</ItemGroup>

<ItemGroup>
Expand Down
124 changes: 46 additions & 78 deletions ICEBG.Blazor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,94 +6,62 @@
//

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;

using Blazor.Extensions.Logging;

using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Blazored.LocalStorage;

using GoogleAnalytics.Blazor;

using ICEBG.Client.Infrastructure.ClientServices;
using ICEBG.AppConfig;
using ICEBG.Blazor;
using ICEBG.Client;
using ICEBG.Client.Infrastructure.ClientServices;

using Microsoft.AspNetCore.Components.Web;
using Blazored.LocalStorage;
using GoogleAnalytics.Blazor;
using Material.Blazor;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.CookiePolicy;
using Serilog;
using Serilog.Events;
using Serilog.Extensions.Logging;
using System.Collections.Generic;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

builder.Logging.ClearProviders();
builder.Logging.SetMinimumLevel(LogLevel.Information);

builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

// Initialize defaults
ApplicationConfigurationWASM.Initialize();

builder.Services.AddScoped(
sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

builder.Services.AddScoped<INotification, WebAssemblyNotificationService>();

namespace ICEBG.Blazor;
public class Program
// Add Blazor.Extensions.Logging.BrowserConsoleLogger
builder.Services.AddLogging(
builder => builder
.AddBrowserConsole()
.SetMinimumLevel(LogLevel.Trace)
);

builder.Services.AddOptions();

ClientServices.Inject(ApplicationConfiguration.pDataServicesEndpointPrefix, builder.Services);

builder.Services.AddBlazoredLocalStorage();

builder.Services.AddGBService(options =>
{
options.TrackingId = "G-2VZJ2X14RH";
options.GlobalEventParams = new Dictionary<string, object>()
{
public static async Task Main(string[] arguments)
{
var builder = WebAssemblyHostBuilder.CreateDefault(arguments);
builder.Logging.SetMinimumLevel(LogLevel.Information);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

// Initialize defaults
ApplicationConfigurationWASM.Initialize();

builder.Services.AddScoped(
sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

builder.Services.AddScoped<INotification, WebAssemblyNotificationService>();

builder.Services.AddLogging(builder => builder
.AddBrowserConsole() // Add Blazor.Extensions.Logging.BrowserConsoleLogger
.SetMinimumLevel(LogLevel.Information)
);

builder.Services.AddOptions();

ClientServices.Inject(ApplicationConfiguration.pDataServicesEndpointPrefix, builder.Services);

builder.Services.Configure<CookiePolicyOptions>(options =>
{
// Has Pentest fixes
options.CheckConsentNeeded = context => true;
options.HttpOnly = HttpOnlyPolicy.Always;
options.MinimumSameSitePolicy = SameSiteMode.Strict;
options.Secure = CookieSecurePolicy.Always;
});

builder.Services.AddBlazoredLocalStorage();

Log.Logger = new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Debug()
#else
.MinimumLevel.Information()
#endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("GoogleAnalytics.Blazor", LogEventLevel.Debug)
.Enrich.FromLogContext()
.WriteTo.Async(a => a.BrowserConsole(outputTemplate: "{Timestamp:HH:mm:ss.fff}\t[{Level:u3}]\t{Message}{NewLine}{Exception}"))
.CreateLogger();

builder.Logging.AddProvider(new SerilogLoggerProvider());

builder.Services.AddGBService(options =>
{
options.TrackingId = "G-2VZJ2X14RH";
options.GlobalEventParams = new Dictionary<string, object>()
{
{ Utilities.EventCategory, Utilities.DialogActions },
{ Utilities.NonInteraction, true },
};
});

await builder.Build().RunAsync();
}

}
};
});

await builder.Build().RunAsync();
27 changes: 13 additions & 14 deletions ICEBG.Client/Components/FlowLabeledText.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@namespace ICEBG.Client.Components

<h2>Time is @time</h2>
<h3>Count is @count</h3>
<h2>Duration is @duration</h2>
<h3>Count1 is @count</h3>
<h3>Count2 is @count2</h3>
@if (configuration == null)
{
Expand All @@ -12,17 +13,17 @@ else
@if (configuration.pSuccess)
{
<table class="table">
<thead>
<tr>
<th>Success</th>
<th>Key</th>
<th>pResult</th>
</tr>
</thead>
<tbody>
<tr>
<td><b>Success</b></td>
<td>true</td>
</tr>
<tr>
<td><b>Key</b></td>
<td>@configuration.pResult.Id</td>
</tr>
<tr>
<td><b>pResult</b></td>
<td>@configuration.pResult.Configuration</td>
</tr>
</tbody>
Expand All @@ -31,15 +32,13 @@ else
else
{
<table class="table">
<thead>
<tr>
<th>Success</th>
<th>pError</th>
</tr>
</thead>
<tbody>
<tr>
<td><b>Success</b></td>
<td>false</td>
</tr>
<tr>
<td><b>pError</b></td>
<td>@configuration.pError</td>
</tr>
</tbody>
Expand Down
1 change: 1 addition & 0 deletions ICEBG.Client/Components/FlowLabeledText.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public partial class FlowLabeledText
{
[Parameter] public string count { get; set; }
[Parameter] public string count2 { get; set; }
[Parameter] public string duration { get; set; }
[Parameter] public string time { get; set; }
[Parameter] public ServiceResult<Configuration_DD> configuration { get; set; }
}
Expand Down
7 changes: 3 additions & 4 deletions ICEBG.Client/ICEBG.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
<PackageReference Include="Grpc.Net.Client" Version="2.53.0" />
<PackageReference Include="Grpc.Net.Client.Web" Version="2.53.0" />
<PackageReference Include="libphonenumber-csharp" Version="8.13.11" />
<PackageReference Include="Material.Blazor" Version="4.0.0-preview.18" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0-preview.4.23260.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0-preview.4.23260.4" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Material.Blazor" Version="4.0.0-preview.19" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0-preview.5.23302.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0-preview.5.23302.2" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ICEBG.Client/Pages/About.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public About()
pOSArchitecture = RuntimeInformation.OSArchitecture.ToString();
pOSDescription = RuntimeInformation.OSDescription.ToString();
pRuntime = RuntimeInformation.FrameworkDescription.ToString();
pVersion = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
pVersion = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion.Split('+')[0];
}

}
5 changes: 4 additions & 1 deletion ICEBG.Client/Pages/ConsumeResources.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@

@inject iConfigurationClient ConfigurationClient

@implements IDisposable

<h1>Consume resources</h1>

<FlowLabeledText time="@time"
duration="@duration"
configuration="@configuration"
count="@count"
count="@count1"
count2="@count2"/>

44 changes: 30 additions & 14 deletions ICEBG.Client/Pages/ConsumeResources.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ namespace ICEBG.Client.Pages
{
public partial class ConsumeResources : ComponentBase
{
private static System.Timers.Timer pTimer { get; set; }
private System.Timers.Timer pTimer { get; set; }

private string count { get; set; } = "'Not yet initialized'";
private string count1 { get; set; } = "'Not yet initialized'";
private string count2 { get; set; } = "0";
private string duration { get; set; } = "'Not yet initialized'";
private DateTime startTime { get; set; } = DateTime.MinValue;
private string time { get; set; } = "'Not yet initialized'";
private ServiceResult<Configuration_DD> configuration { get; set; }

Expand All @@ -32,33 +34,40 @@ public partial class ConsumeResources : ComponentBase
#region LoadReportCollectionAsync
private async Task LoadReportCollectionAsync()
{
for (int i = 0; i < 10; i++)
configuration = await ConfigurationClient.SelectAsync(ApplicationConfiguration.pConfigurationIdentifier);
internalCount += 1;
count1 = internalCount.ToString("N0");

var currentTime = DateTime.Now;
if (startTime == DateTime.MinValue)
{
configuration = await ConfigurationClient.SelectAsync(ApplicationConfiguration.pConfigurationIdentifier);
internalCount += 1;
count = internalCount.ToString();
startTime = currentTime;
}
time = DateTime.Now.ToString();

duration = (currentTime - startTime).ToString(@"d\.hh\:mm\:ss");

time = currentTime.ToString();
if (internalCount >= (int.MaxValue - 100))
{
internalCount = 0;
internalCount2 += 1;
count2 = internalCount2.ToString();
count2 = internalCount2.ToString("N0");
}
StateHasChanged();
pTimer.Dispose();
pTimer = new System.Timers.Timer(100);
pTimer?.Dispose();
pTimer = new System.Timers.Timer(1);
pTimer.Elapsed += RefreshTimerTick;
pTimer.Enabled = true;
}

#endregion

protected override void OnInitialized()
protected override void OnAfterRender(bool isFirstRender)
{
pTimer = new System.Timers.Timer(100);
pTimer.Elapsed += RefreshTimerTick;
pTimer.Enabled = true;
if (isFirstRender)
{
RefreshTimerTick(null, null);
}
}

#region RefreshTimerTick
Expand All @@ -68,5 +77,12 @@ public void RefreshTimerTick(Object source, ElapsedEventArgs e)
}
#endregion

#region IDispose
void IDisposable.Dispose()
{
pTimer?.Dispose();
}

#endregion
}
}
Loading

0 comments on commit 74d6c18

Please sign in to comment.