Skip to content
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
12 changes: 10 additions & 2 deletions src/Api/DicomAssociationInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

using System;
using System.Collections.Generic;

namespace Monai.Deploy.InformaticsGateway.Api
{
Expand All @@ -30,14 +31,21 @@ public class DicomAssociationInfo : MongoDBEntityBase
public string Errors { get; set; } = string.Empty;
public TimeSpan Duration { get; private set; } = default!;

public HashSet<string> PayloadIds { get; private set; }

public DicomAssociationInfo()
{
FileCount = 0;
PayloadIds = new HashSet<string>();
}

public void FileReceived()
public void FileReceived(string? payloadId)
{
FileCount++;
if (!string.IsNullOrWhiteSpace(payloadId))
{
FileCount++;
PayloadIds.Add(payloadId);
}
}

public void Disconnect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
* limitations under the License.
*/

using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Monai.Deploy.InformaticsGateway.Api;

Expand All @@ -25,6 +28,15 @@ internal class DicomAssociationInfoConfiguration : IEntityTypeConfiguration<Dico
{
public void Configure(EntityTypeBuilder<DicomAssociationInfo> builder)
{
var comparer = new ValueComparer<HashSet<string>>(
(c1, c2) => c1.SequenceEqual(c2),
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
c => c.ToHashSet());

var jsonSerializerSettings = new JsonSerializerOptions
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
builder.HasKey(j => j.Id);
builder.Property(j => j.CalledAeTitle).IsRequired();
builder.Property(j => j.CalledAeTitle).IsRequired();
Expand All @@ -35,6 +47,11 @@ public void Configure(EntityTypeBuilder<DicomAssociationInfo> builder)
builder.Property(j => j.RemoteHost).IsRequired();
builder.Property(j => j.RemotePort).IsRequired();
builder.Property(j => j.Errors).IsRequired();
builder.Property(j => j.PayloadIds).IsRequired()
.HasConversion(
v => JsonSerializer.Serialize(v, jsonSerializerSettings),
v => JsonSerializer.Deserialize<HashSet<string>>(v, jsonSerializerSettings))
.Metadata.SetValueComparer(comparer);
}
}
}
Loading