Skip to content

Commit

Permalink
Merge pull request #226 from Blazam-App/Beta-Dev
Browse files Browse the repository at this point in the history
Fix application memory measurement, add CPU usage measuring
  • Loading branch information
jacobsen9026 authored Feb 13, 2024
2 parents c257412 + 6145523 commit ffde61b
Show file tree
Hide file tree
Showing 4,144 changed files with 480 additions and 196 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion BLAZAM.Tests/BLAZAM.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
145 changes: 145 additions & 0 deletions BLAZAM/BLAZAM - Backup.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ServerGarbageCollection>false</ServerGarbageCollection>
<AssemblyVersion>0.8.8</AssemblyVersion>
<Version>2024.02.13.2207</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<RootNamespace>BLAZAM</RootNamespace>
<GenerateDocumentationFile>False</GenerateDocumentationFile>

</PropertyGroup>

<ItemGroup>
<Compile Remove="Exceptions\**" />
<Content Remove="Exceptions\**" />
<EmbeddedResource Remove="Exceptions\**" />
<None Remove="Exceptions\**" />
</ItemGroup>

<ItemGroup>
<None Remove="nssm.exe" />
<None Remove="static\img\default_logo.png" />
<None Remove="static\img\default_logo2.png" />
<None Remove="static\img\default_logo3.png" />
<None Remove="static\img\default_logo4.png" />
</ItemGroup>





<ItemGroup>
<Content Include="nssm.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="static\img\default_logo.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="static\img\default_logo2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="static\img\default_logo3.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="static\img\default_logo4.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="BlazorTemplater" Version="1.5.1" />
<PackageReference Include="Cassia" Version="2.0.0.60" />
<PackageReference Include="Core.System.Configuration.Install" Version="1.1.0" />
<PackageReference Include="DuoUniversal" Version="1.2.1" />
<PackageReference Include="MailKit" Version="4.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.26" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.26" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.26" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.26" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="7.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.15">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.16" />
<PackageReference Include="MudBlazor.Markdown" Version="0.1.3" />
<PackageReference Include="MudBlazor.ThemeManager" Version="1.0.8" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Octokit" Version="9.1.2" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="SixLabors.ImageSharp.Web" Version="3.1.0" />
<PackageReference Include="System.DirectoryServices" Version="8.0.0" />

<PackageReference Include="System.DirectoryServices.AccountManagement" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BLAZAMActiveDirectory\BLAZAMActiveDirectory.csproj" />
<ProjectReference Include="..\BLAZAMCommon\BLAZAMCommon.csproj" />
<ProjectReference Include="..\BLAZAMDatabase\BLAZAMDatabase.csproj" />
<ProjectReference Include="..\BLAZAMEmailMessage\BLAZAMEmailMessage.csproj" />
<ProjectReference Include="..\BLAZAMEmail\BLAZAMEmail.csproj" />
<ProjectReference Include="..\BLAZAMFileSystem\BLAZAMFileSystem.csproj" />
<ProjectReference Include="..\BLAZAMGui\BLAZAMGui.csproj" />
<ProjectReference Include="..\BLAZAMJobs\BLAZAMJobs.csproj" />
<ProjectReference Include="..\BLAZAMLocalization\BLAZAMLocalization.csproj" />
<ProjectReference Include="..\BLAZAMLoggers\BLAZAMLogger.csproj" />
<ProjectReference Include="..\BLAZAMNav\BLAZAMNav.csproj" />
<ProjectReference Include="..\BLAZAMNotifications\BLAZAMNotifications.csproj" />
<ProjectReference Include="..\BLAZAMServices\BLAZAMServices.csproj" />
<ProjectReference Include="..\BLAZAMSession\BLAZAMSession.csproj" />
<ProjectReference Include="..\BLAZAMStatic\BLAZAMStatic.csproj" />
<ProjectReference Include="..\BlazamUpdate\BLAZAMUpdate.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\favicon.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<None Update="license.rtf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="updater\update.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Condition="'$(Configuration)' == 'Debug'" Command="powershell -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\IncrementBuildNumber.ps1 -ProjectDir $(ProjectDir) -ProjectPath $(ProjectPath)" />
</Target>
</Project>
12 changes: 10 additions & 2 deletions BLAZAM/BLAZAM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<ServerGarbageCollection>false</ServerGarbageCollection>
<AssemblyVersion>0.8.8</AssemblyVersion>
<Version>2024.02.11.1907</Version>
<Version>2024.02.13.2246</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<RootNamespace>BLAZAM</RootNamespace>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
Expand Down Expand Up @@ -50,11 +50,19 @@
</Content>
</ItemGroup>





<ItemGroup>
<None Include="..\BLAZAMGui\UI\Settings\ProcessCPUUsage.razor" Link="ProcessCPUUsage.razor" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BlazorTemplater" Version="1.5.1" />
<PackageReference Include="Cassia" Version="2.0.0.60" />
<PackageReference Include="Core.System.Configuration.Install" Version="1.1.0" />
<PackageReference Include="DuoUniversal" Version="1.2.1" />
<PackageReference Include="DuoUniversal" Version="1.2.2" />
<PackageReference Include="MailKit" Version="4.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.26" />
Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Pages/Search.razor
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
else
Searcher.Cancel();
SearchService.SearchTerm = SearchTermParameter;
Searcher.EnabledOnly = !SearchService.IncludeDisabled;
//Searcher.EnabledOnly = !SearchService.IncludeDisabled;
Searcher.GeneralSearchTerm = SearchService.SearchTerm;
Searcher.ObjectTypeFilter = SearchService.SeachObjectType;
Searcher.ExactMatch = true;
Expand Down
2 changes: 1 addition & 1 deletion BLAZAMCommon.Tests/BLAZAMCommon.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.15" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
Expand Down
2 changes: 1 addition & 1 deletion BLAZAMFileSystem/SystemDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public List<SystemFile> Files
/// <summary>
/// The full directory name
/// </summary>
public string? Name => System.IO.Path.GetDirectoryName(Path);
public string? Name => Path.Split("\\").Last();

public void ClearDirectory()
{
Expand Down
1 change: 1 addition & 0 deletions BLAZAMGui/BLAZAMGui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.1" />
<PackageReference Include="MudBlazor" Version="6.14.0" />
<PackageReference Include="MudBlazor.Markdown" Version="0.1.3" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="8.0.0" />
<PackageReference Include="System.Drawing.Common" Version="8.0.1" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion BLAZAMGui/UI/AppComponentBase.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace BLAZAM.Gui.UI
{

public class AppComponentBase : ComponentBase
public class AppComponentBase : ComponentBase,IDisposable
{
[Inject]
protected IStringLocalizer<AppLocalization> AppLocalization { get; set; }
Expand Down
1 change: 1 addition & 0 deletions BLAZAMGui/UI/Inputs/ADAutoComplete.razor
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
{
MaxResults += 10;
await GetResults(SearchTerm);
await InvokeAsync(StateHasChanged);
}

[Parameter]
Expand Down
2 changes: 1 addition & 1 deletion BLAZAMGui/UI/Outputs/Jobs/JobStepResultIcon.razor
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ else
<MudProgressLinear Indeterminate=@(Step.Progress==null) Value="@(Step.Progress.HasValue==true?Step.Progress.Value:0)" Max="100"/>
@if (Step.Progress != null)
{
<MudText Typo="Typo.caption">@Step.Progress.Value%</MudText>
<MudText Typo="Typo.caption">@Step.Progress.Value.Round()%</MudText>
}
</MudStack>

Expand Down
31 changes: 30 additions & 1 deletion BLAZAMGui/UI/Settings/DatabaseStatus.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@using System.IO.Compression
@inherits SettingsComponents


Expand All @@ -21,7 +22,11 @@
<SettingsField Label="@AppLocalization["Database"]">
<MudTextField Disabled=true Label="@AppLocalization["Database"]" Value="@Context?.ConnectionString?.Database" />
</SettingsField>
<SettingsField Label="@AppLocalization["Export Database"]">

<MudButton OnClick="Export" Color="Color.Success">Export</MudButton>

</SettingsField>

</MudForm>
@code {
Expand All @@ -35,5 +40,29 @@
LoadingData = false;
await InvokeAsync(StateHasChanged);
}

void Export()
{
MemoryStream memoryStream = new MemoryStream();

IJob exportJob = new Job(AppLocalization["Export Database"], CurrentUser.Username);
IJobStep exportData = new JobStep(AppLocalization["Export Data"], (step) =>
{
Context.Export("export");
return true;

});
IJobStep packageData = new JobStep(AppLocalization["Prepare Files"], (step) =>
{
ZipArchive exportZip = new ZipArchive(memoryStream, ZipArchiveMode.Create);
var exportDir = new SystemDirectory("export");
exportZip.AddToZip(exportDir, exportDir.Path);
memoryStream.SaveTo(new SystemFile("export/" + DatabaseCache.ApplicationSettings.AppName + "-" + DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + ".zip"));
return true;

});
exportJob.Steps.Add(exportData);
exportJob.Steps.Add(packageData);
exportJob.Run();
exportJob.ShowJobDetailsDialog(MessageService);
}
}
73 changes: 73 additions & 0 deletions BLAZAMGui/UI/Settings/ProcessResourceUsage.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
@inherits AppComponentBase
@using System.Diagnostics
<SettingsField Label=@AppLocalization["CPU"]>
@if (CPUCounter != null)
{
<MudText>@cpuUsage%</MudText>
}
else
{
<MudText>@AppLocalization["Loading"]</MudText>
}

</SettingsField>
<SettingsField Label=@AppLocalization["Memory"]>
@if (MemoryCounter != null)
{
<MudText>@memoryUsage</MudText>

}
else
{
<MudText>@AppLocalization["Loading"]</MudText>
}
</SettingsField>

@code {
[Parameter]
public Process Process { get; set; }

private string cpuUsage
{
get

{
return Math.Round(CPUCounter.NextValue(),2).ToString();
Process.Refresh();
return Process.TotalProcessorTime.ToString();

}
}
private string memoryUsage
{
get

{
return new ByteSize(MemoryCounter.NextValue()).ToString();


}
}
private PerformanceCounter? CPUCounter;
private PerformanceCounter? MemoryCounter;

private Timer? refreshTimer;
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
refreshTimer = new Timer((state) => { InvokeAsync(StateHasChanged); }, null, 2000, 2000);
await Task.Run(() =>
{
CPUCounter = new PerformanceCounter("Process", "% Processor Time",
Process.ProcessName);
MemoryCounter = new PerformanceCounter("Process", "Working Set",
Process.ProcessName);

});

}
public override void Dispose()
{
refreshTimer?.Dispose();
}
}
Loading

0 comments on commit ffde61b

Please sign in to comment.