@@ -15,9 +15,18 @@ public static void MapDebugEndpoints(this WebApplication app)
1515 {
1616 var doc = await dv . GetDocumentAsync ( id . ToString ( ) ) ;
1717 if ( doc == null ) return Results . Ok ( new { status = "NOT_FOUND" , documentId = id . ToString ( ) } ) ;
18- return Results . Ok ( new { status = "FOUND" , documentId = doc . Id , name = doc . Name , fileName = doc . FileName ,
19- isEmailArchive = doc . IsEmailArchive , parentDocumentId = doc . ParentDocumentId ,
20- matterId = doc . MatterId , projectId = doc . ProjectId , invoiceId = doc . InvoiceId } ) ;
18+ return Results . Ok ( new
19+ {
20+ status = "FOUND" ,
21+ documentId = doc . Id ,
22+ name = doc . Name ,
23+ fileName = doc . FileName ,
24+ isEmailArchive = doc . IsEmailArchive ,
25+ parentDocumentId = doc . ParentDocumentId ,
26+ matterId = doc . MatterId ,
27+ projectId = doc . ProjectId ,
28+ invoiceId = doc . InvoiceId
29+ } ) ;
2130 }
2231 catch ( Exception ex ) { log . LogError ( ex , "Error {Id}" , id ) ; return Results . Ok ( new { status = "ERROR" , error = ex . Message } ) ; }
2332 } ) . AllowAnonymous ( ) ;
@@ -27,9 +36,21 @@ public static void MapDebugEndpoints(this WebApplication app)
2736 try
2837 {
2938 var children = ( await dv . GetDocumentsByParentAsync ( parentId ) ) . ToList ( ) ;
30- return Results . Ok ( new { status = "OK" , parentDocumentId = parentId . ToString ( ) , childCount = children . Count ,
31- children = children . Select ( c => new { documentId = c . Id , name = c . Name , fileName = c . FileName ,
32- isEmailArchive = c . IsEmailArchive , parentDocumentId = c . ParentDocumentId , createdOn = c . CreatedOn } ) } ) ;
39+ return Results . Ok ( new
40+ {
41+ status = "OK" ,
42+ parentDocumentId = parentId . ToString ( ) ,
43+ childCount = children . Count ,
44+ children = children . Select ( c => new
45+ {
46+ documentId = c . Id ,
47+ name = c . Name ,
48+ fileName = c . FileName ,
49+ isEmailArchive = c . IsEmailArchive ,
50+ parentDocumentId = c . ParentDocumentId ,
51+ createdOn = c . CreatedOn
52+ } )
53+ } ) ;
3354 }
3455 catch ( Exception ex ) { log . LogError ( ex , "Error parent {Id}" , parentId ) ; return Results . Ok ( new { status = "ERROR" , error = ex . Message } ) ; }
3556 } ) . AllowAnonymous ( ) ;
@@ -80,9 +101,14 @@ private static void MapDiagnosticEndpoints(WebApplication app)
80101 var info = handlers . Select ( h => new { jobType = h . JobType , handlerType = h . GetType ( ) . FullName } ) . ToList ( ) ;
81102 string ? err1 = TryResolve < Sprk . Bff . Api . Services . Jobs . Handlers . AppOnlyDocumentAnalysisJobHandler > ( scope ) ;
82103 string ? err2 = TryResolve < Sprk . Bff . Api . Services . Ai . IAppOnlyAnalysisService > ( scope ) ;
83- return Results . Ok ( new { totalHandlers = handlers . Count , handlers = info ,
104+ return Results . Ok ( new
105+ {
106+ totalHandlers = handlers . Count ,
107+ handlers = info ,
84108 hasAppOnlyDocumentAnalysis = handlers . Any ( h => h . JobType == "AppOnlyDocumentAnalysis" ) ,
85- directHandlerResolution = err1 ?? "OK" , analysisServiceResolution = err2 ?? "OK" } ) ;
109+ directHandlerResolution = err1 ?? "OK" ,
110+ analysisServiceResolution = err2 ?? "OK"
111+ } ) ;
86112 }
87113 catch ( Exception ex ) { log . LogError ( ex , "Error" ) ; return Results . Ok ( new { error = ex . Message } ) ; }
88114 } ) . AllowAnonymous ( ) ;
@@ -94,8 +120,11 @@ private static void MapDiagnosticEndpoints(WebApplication app)
94120 {
95121 var svc = sp . GetRequiredService < Sprk . Bff . Api . Services . Communication . CommunicationAccountService > ( ) ;
96122 results [ "CommunicationAccountService" ] = "OK" ;
97- try { var accts = await svc . QueryReceiveEnabledAccountsAsync ( ) ; results [ "ReceiveEnabledAccounts" ] = $ "{ accts . Length } found";
98- foreach ( var a in accts ) results [ $ "Account:{ a . EmailAddress } "] = $ "SubId={ a . SubscriptionId ?? "none" } , AutoCreate={ a . AutoCreateRecords } "; }
123+ try
124+ {
125+ var accts = await svc . QueryReceiveEnabledAccountsAsync ( ) ; results [ "ReceiveEnabledAccounts" ] = $ "{ accts . Length } found";
126+ foreach ( var a in accts ) results [ $ "Account:{ a . EmailAddress } "] = $ "SubId={ a . SubscriptionId ?? "none" } , AutoCreate={ a . AutoCreateRecords } ";
127+ }
99128 catch ( Exception ex ) { results [ "ReceiveEnabledAccounts" ] = $ "FAILED: { ex . Message } "; }
100129 }
101130 catch ( Exception ex ) { results [ "CommunicationAccountService" ] = $ "FAILED: { ex . Message } "; }
@@ -129,17 +158,36 @@ private static async Task<object> PeekDlq(Azure.Messaging.ServiceBus.ServiceBusC
129158 ReceiveMode = Azure . Messaging . ServiceBus . ServiceBusReceiveMode . PeekLock
130159 } ) ;
131160 var messages = await receiver . PeekMessagesAsync ( 10 ) ;
132- return new { queue = $ "{ queueName } /$DeadLetterQueue", count = messages . Count ,
133- messages = messages . Select ( m => new { m . SequenceNumber , m . DeadLetterReason , m . EnqueuedTime , m . MessageId ,
134- bodyPreview = m . Body . ToString ( ) . Length > 500 ? m . Body . ToString ( ) [ ..500 ] + "..." : m . Body . ToString ( ) } ) } ;
161+ return new
162+ {
163+ queue = $ "{ queueName } /$DeadLetterQueue",
164+ count = messages . Count ,
165+ messages = messages . Select ( m => new
166+ {
167+ m . SequenceNumber ,
168+ m . DeadLetterReason ,
169+ m . EnqueuedTime ,
170+ m . MessageId ,
171+ bodyPreview = m . Body . ToString ( ) . Length > 500 ? m . Body . ToString ( ) [ ..500 ] + "..." : m . Body . ToString ( )
172+ } )
173+ } ;
135174 }
136175
137176 private static async Task < object > PeekQueue ( Azure . Messaging . ServiceBus . ServiceBusClient sbc , string queueName )
138177 {
139178 await using var receiver = sbc . CreateReceiver ( queueName ) ;
140179 var messages = await receiver . PeekMessagesAsync ( 10 ) ;
141- return new { queue = queueName , count = messages . Count ,
142- messages = messages . Select ( m => new { m . SequenceNumber , m . EnqueuedTime , m . MessageId ,
143- bodyPreview = m . Body . ToString ( ) . Length > 500 ? m . Body . ToString ( ) [ ..500 ] + "..." : m . Body . ToString ( ) } ) } ;
180+ return new
181+ {
182+ queue = queueName ,
183+ count = messages . Count ,
184+ messages = messages . Select ( m => new
185+ {
186+ m . SequenceNumber ,
187+ m . EnqueuedTime ,
188+ m . MessageId ,
189+ bodyPreview = m . Body . ToString ( ) . Length > 500 ? m . Body . ToString ( ) [ ..500 ] + "..." : m . Body . ToString ( )
190+ } )
191+ } ;
144192 }
145193}
0 commit comments