This repository was archived by the owner on Jul 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +40
-36
lines changed
Expand file tree Collapse file tree 5 files changed +40
-36
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ public class FileDiscoveryFunction(
1414 IFileDiscoveryFunctionConfiguration configuration ,
1515 IMeshInboxService meshInboxService ,
1616 ServiceLayerDbContext serviceLayerDbContext ,
17- IFileExtractQueueClient fileExtractQueueClient )
17+ IFileExtractQueueClient fileExtractQueueClient ,
18+ IMeshFileStatusService meshFileStatusService )
1819{
1920 [ Function ( "FileDiscoveryFunction" ) ]
2021 public async Task Run ( [ TimerTrigger ( "%FileDiscoveryTimerExpression%" ) ] TimerInfo myTimer )
Original file line number Diff line number Diff line change 1+ using ServiceLayer . Data ;
2+ using ServiceLayer . Data . Models ;
3+
4+ namespace ServiceLayer . Mesh . Functions ;
5+
6+ public interface IMeshFileStatusService
7+ {
8+ Task SetStatusAsync ( MeshFile file , MeshFileStatus status , FileEventSource source ) ;
9+ }
10+
11+ public class MeshFileStatusService ( ServiceLayerDbContext serviceLayerDbContext ) : IMeshFileStatusService
12+ {
13+ public async Task SetStatusAsync ( MeshFile file , MeshFileStatus status , FileEventSource source )
14+ {
15+ var now = DateTime . UtcNow ;
16+
17+ serviceLayerDbContext . MeshFileEvents . Add ( new MeshFileEvent
18+ {
19+ FileId = file . FileId ,
20+ NewStatus = status ,
21+ OldStatus = file . Status ,
22+ TimestampUtc = now ,
23+ Source = source
24+ } ) ;
25+
26+ file . Status = status ;
27+ file . LastUpdatedUtc = now ;
28+
29+ await serviceLayerDbContext . SaveChangesAsync ( ) ;
30+ }
31+ }
Original file line number Diff line number Diff line change 66using ServiceLayer . Mesh . Messaging ;
77using ServiceLayer . Mesh . Storage ;
88using ServiceLayer . Mesh . FileTypes . NbssAppointmentEvents ;
9+ using ServiceLayer . Mesh . Functions ;
910
1011var host = new HostBuilder ( )
1112 . ConfigureFunctionsWebApplication ( )
2324
2425 services . AddApplicationConfiguration ( ) ;
2526 services . AddNbssAppointmentEventServices ( ) ;
27+
28+ services . AddScoped < IMeshFileStatusService , MeshFileStatusService > ( ) ;
2629 } ) ;
2730
2831var app = host . Build ( ) ;
Original file line number Diff line number Diff line change @@ -20,37 +20,6 @@ public class MeshFile
2020 // ReSharper disable once EntityFramework.ModelValidation.UnlimitedStringLength
2121 public string ? ValidationErrors { get ; set ; }
2222
23- public List < MeshFileEvent > Events { get ; } = [ ] ;
24-
25- public static MeshFile Create (
26- FileEventSource source ,
27- MeshFileType fileType ,
28- string fileId ,
29- string mailboxId )
30- {
31- var now = DateTime . UtcNow ;
32-
33- var file = new MeshFile
34- {
35- FileId = fileId ,
36- FileType = fileType ,
37- Status = MeshFileStatus . Discovered ,
38- MailboxId = mailboxId ,
39- FirstSeenUtc = now ,
40- LastUpdatedUtc = now
41- } ;
42-
43- file . Events . Add ( new MeshFileEvent
44- {
45- FileId = fileId ,
46- Source = source ,
47- NewStatus = MeshFileStatus . Discovered ,
48- TimestampUtc = now
49- } ) ;
50-
51- return file ;
52- }
53-
5423 public void SetStatus ( FileEventSource source , MeshFileStatus status )
5524 {
5625 var now = DateTime . UtcNow ;
Original file line number Diff line number Diff line change @@ -21,10 +21,6 @@ private static void ConfigureMeshFiles(ModelBuilder modelBuilder)
2121 modelBuilder . Entity < MeshFile > ( ) . HasKey ( p => p . FileId ) ;
2222 modelBuilder . Entity < MeshFile > ( ) . Property ( e => e . Status ) . HasConversion < string > ( ) ;
2323 modelBuilder . Entity < MeshFile > ( ) . Property ( e => e . FileType ) . HasConversion < string > ( ) ;
24- modelBuilder . Entity < MeshFile > ( )
25- . HasMany ( f => f . Events )
26- . WithOne ( )
27- . HasForeignKey ( e => e . FileId ) ;
2824 }
2925
3026 private static void ConfigureMeshFileEvents ( ModelBuilder modelBuilder )
@@ -33,6 +29,10 @@ private static void ConfigureMeshFileEvents(ModelBuilder modelBuilder)
3329 modelBuilder . Entity < MeshFileEvent > ( ) . Property ( e => e . NewStatus ) . HasConversion < string > ( ) ;
3430 modelBuilder . Entity < MeshFileEvent > ( ) . Property ( e => e . OldStatus ) . HasConversion < string > ( ) ;
3531 modelBuilder . Entity < MeshFileEvent > ( ) . Property ( e => e . Source ) . HasConversion < string > ( ) ;
32+ modelBuilder . Entity < MeshFileEvent > ( )
33+ . HasOne < MeshFile > ( )
34+ . WithMany ( )
35+ . HasForeignKey ( e => e . FileId ) ;
3636 }
3737
3838 private static void ConfigureNbssAppointmentEvents ( ModelBuilder modelBuilder )
You can’t perform that action at this time.
0 commit comments