feat: integrate d3-org-chart for network visualization and add SignalR token notification service

This commit is contained in:
masoodafar-web
2025-12-18 03:19:06 +03:30
parent 27c2c0259b
commit 6b457d0ce6
21 changed files with 1558 additions and 201 deletions
@@ -9,10 +9,32 @@ public class NetworkNodeDto
public string FullName { get; set; } = string.Empty;
public string Mobile { get; set; } = string.Empty;
public string? Avatar { get; set; }
public string Position { get; set; } = string.Empty; // "Left" or "Right"
public string Position { get; set; } = string.Empty; // "Root", "Left" or "Right"
public NetworkNodeDto? LeftChild { get; set; }
public NetworkNodeDto? RightChild { get; set; }
public int Level { get; set; }
public bool IsActive { get; set; } = true;
public DateTime? JoinedAt { get; set; }
public bool IsClubActive { get; set; }
public string? ActivationWeekNumber { get; set; }
}
/// <summary>
/// DTO for flat node structure (for d3-org-chart)
/// </summary>
public class FlatNetworkNodeDto
{
public string Id { get; set; } = string.Empty;
public string ParentId { get; set; } = string.Empty;
public string FullName { get; set; } = string.Empty;
public string Mobile { get; set; } = string.Empty;
public string? Avatar { get; set; }
public string Position { get; set; } = string.Empty;
public int Level { get; set; }
public bool IsActive { get; set; } = true;
public bool IsClubActive { get; set; }
public string? ActivationWeekNumber { get; set; }
public DateTime? JoinedAt { get; set; }
}
/// <summary>
@@ -23,6 +45,48 @@ public class NetworkTreeDto
public NetworkNodeDto? RootNode { get; set; }
public int TotalMembers { get; set; }
public int CurrentDepth { get; set; }
/// <summary>
/// Convert hierarchical tree to flat array for d3-org-chart
/// </summary>
public List<FlatNetworkNodeDto> ToFlatArray()
{
var result = new List<FlatNetworkNodeDto>();
if (RootNode == null) return result;
TraverseAndFlatten(RootNode, "", result);
return result;
}
private void TraverseAndFlatten(NetworkNodeDto node, string parentId, List<FlatNetworkNodeDto> result)
{
var flatNode = new FlatNetworkNodeDto
{
Id = node.UserId.ToString(),
ParentId = parentId,
FullName = node.FullName,
Mobile = node.Mobile,
Avatar = node.Avatar,
Position = node.Position,
Level = node.Level,
IsActive = node.IsActive,
IsClubActive = node.IsClubActive,
ActivationWeekNumber = node.ActivationWeekNumber,
JoinedAt = node.JoinedAt
};
result.Add(flatNode);
if (node.LeftChild != null)
{
TraverseAndFlatten(node.LeftChild, flatNode.Id, result);
}
if (node.RightChild != null)
{
TraverseAndFlatten(node.RightChild, flatNode.Id, result);
}
}
}
/// <summary>