Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved performance with multi-threading in specific long running operations #640

Merged
merged 1 commit into from
Nov 11, 2024
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
2 changes: 1 addition & 1 deletion 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>1.1.0</AssemblyVersion>
<Version>2024.11.10.2351</Version>
<Version>2024.11.11.2302</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<RootNamespace>BLAZAM</RootNamespace>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Pages/Groups/ConfirmNewGroup.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@inherits AppComponentBase
@inject OUNotificationService OUNotificationService
@inject NotificationGenerationService OUNotificationService

<AppPageTitle>Confirm Group Creation</AppPageTitle>

Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Pages/OU/ConfirmNewOU.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@inherits AppComponentBase
@inject OUNotificationService OUNotificationService
@inject NotificationGenerationService OUNotificationService

<AppPageTitle>Confirm OU Creation</AppPageTitle>

Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Pages/OU/ViewOU.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@inherits DirectoryEntryViewBase
@inject OUNotificationService OUNotificationService
@inject NotificationGenerationService OUNotificationService

<AppPageTitle>@OU?.CanonicalName</AppPageTitle>

Expand Down
2 changes: 1 addition & 1 deletion BLAZAM/Pages/Users/ConfirmNewUser.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@using BLAZAM.EmailMessage.Email.Notifications
@inherits DirectoryModelComponent
@inject IJSRuntime JSRuntime
@inject OUNotificationService OUNotificationService
@inject NotificationGenerationService OUNotificationService


<AppPageTitle>Confirm User Creation</AppPageTitle>
Expand Down
4 changes: 2 additions & 2 deletions BLAZAM/ProgramHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ completed so it may not be usable as is

builder.Services.AddScoped<AppDialogService>();

builder.Services.AddSingleton<OUNotificationService>();
builder.Services.AddSingleton<NotificationGenerationService>();


builder.Host.UseWindowsService();
Expand Down Expand Up @@ -338,7 +338,7 @@ private static void PreloadServices()
{
try
{
var context = Program.AppInstance.Services.GetRequiredService<OUNotificationService>();
var context = Program.AppInstance.Services.GetRequiredService<NotificationGenerationService>();
}
catch (Exception ex)
{
Expand Down
58 changes: 55 additions & 3 deletions BLAZAMActiveDirectory/Adapters/DirectoryEntryAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public virtual List<AuditChangeLog> Changes
get
{
List<AuditChangeLog> changes = new();




foreach (var prop in NewEntryProperties)
{
object? currentValue = null;
Expand Down Expand Up @@ -640,9 +644,13 @@ public virtual IEnumerable<IDirectoryEntryAdapter> Children
List<IDirectoryEntryAdapter> directoryEntries = new List<IDirectoryEntryAdapter>();
var children = DirectoryEntry.Children;
DirectoryEntryAdapter? thisObject = null;
var list = new List<DirectoryEntry>();
foreach (DirectoryEntry child in children)
{

list.Add(child);
}
Parallel.ForEach<DirectoryEntry>(list, child =>
{
if (child.Properties["objectClass"].Contains("top"))
{
var objectClass = child.Properties["objectClass"];
Expand Down Expand Up @@ -674,14 +682,58 @@ public virtual IEnumerable<IDirectoryEntryAdapter> Children
if (thisObject != null)
{
thisObject.Parse(directory: Directory, directoryEntry: child);
directoryEntries.Add(thisObject);
lock (directoryEntries)
{
directoryEntries.Add(thisObject);
}

}

}
thisObject = null;
});
//foreach (DirectoryEntry child in children)
//{

}
// if (child.Properties["objectClass"].Contains("top"))
// {
// var objectClass = child.Properties["objectClass"];
// if (objectClass.Contains("computer"))
// {
// thisObject = new ADComputer();
// }
// else if (objectClass.Contains("user"))
// {
// thisObject = new ADUser();
// }
// else if (objectClass.Contains("organizationalUnit"))
// {
// thisObject = new ADOrganizationalUnit();
// }
// else if (objectClass.Contains("group"))
// {
// thisObject = new ADGroup();
// }
// else if (objectClass.Contains("printQueue"))
// {
// thisObject = new ADPrinter();
// }

// else if (objectClass.Contains("msFVE-RecoveryInformation"))
// {
// thisObject = new ADBitLockerRecovery();
// }
// if (thisObject != null)
// {
// thisObject.Parse(directory: Directory, directoryEntry: child);
// directoryEntries.Add(thisObject);

// }

// }
// thisObject = null;

//}
directoryEntries.OrderBy(x => x.CanonicalName).OrderBy(x => x.ObjectType);
CachedChildren = directoryEntries;
}
Expand Down
6 changes: 6 additions & 0 deletions BLAZAMEmailMessage/BLAZAMEmailMessage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@
<ProjectReference Include="..\BLAZAMStatic\BLAZAMStatic.csproj" />
</ItemGroup>

<ItemGroup>
<Content Update="Email\Notifications\AccessRequestEmailMessage.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@using BLAZAM.Database.Models.User
@using BLAZAM.Helpers
@using System.Security
@inherits NotificationTemplateComponent

<EmailTemplateHeader>
<strong> @Notification.Title</strong>
</EmailTemplateHeader>

<EmailTemplateBody>
<MudText Typo="Typo.caption">
@(Notification.Creator?.Username)
@AppLocalization["is requesting"]
@AppLocalization[Notification.Action.ToString()].ToString().ToLower()
@AppLocalization["access to"]
@TargetName
</MudText>
<br />


</EmailTemplateBody>


@code {
[Parameter]
public NotificationMessage Notification { get; set; }
[Parameter]
public string TargetName { get; set; }


public override string Render() => new ComponentRenderer<AccessRequestEmailMessage>()
.UseLayout<DefaultEmailLayout>()
.AddServiceProvider(ApplicationInfo.services)
.Set(c => c.Notification, Notification)
.Set(c => c.TargetName, TargetName)
.Render();
}



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

<EmailTemplateBody>
@(AppLocalization["he password for "] + EntryName + AppLocalization[" has been changed."])
@(AppLocalization["The password for "] + EntryName + AppLocalization[" has been changed."])
<br/>


Expand Down
4 changes: 0 additions & 4 deletions BLAZAMGui/Layouts/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

</AuthorizeView>
}
<CascadingValue Value="this">
<MudDrawer Width="350px"
@bind-Open=@NotificationsOpen
Anchor=Anchor.End
Expand All @@ -56,7 +55,6 @@
}
</MudDrawerContainer>
</MudDrawer>
</CascadingValue>


<MudBreakpointProvider @ref=_mudBreakPoint>
Expand Down Expand Up @@ -131,10 +129,8 @@
</Authorized>
<NotAuthorized>
<MudMainContent Style="height: 100vh;overflow: auto;">
<CascadingValue Value="this">
@Body

</CascadingValue>
</MudMainContent>
</NotAuthorized>
</AuthorizeView>
Expand Down
2 changes: 1 addition & 1 deletion BLAZAMGui/Layouts/UserNotificationPopover.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Style="height=60px;">

<MudText Typo="Typo.h6"
Class="align-middle">
Class="sticky align-middle">
@AppLocalization["Notifications"]
</MudText>
<MudSpacer />
Expand Down
2 changes: 1 addition & 1 deletion BLAZAMGui/UI/DirectoryEntryViewBase.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace BLAZAM.Gui.UI
public class DirectoryEntryViewBase : DatabaseComponentBase
{
[Inject]
public OUNotificationService OUNotificationService { get; set; }
public NotificationGenerationService OUNotificationService { get; set; }
[Parameter]
public IDirectoryEntryAdapter DirectoryEntry { get; set; }

Expand Down
Loading