1-
2- using BL . Models . ViewModels ;
1+ using BL . Models . ViewModels ;
32using BL . Models ;
43using BL . Models . Enums ;
54using BL . Services ;
65using Microsoft . AspNetCore . Mvc ;
7- using Microsoft . EntityFrameworkCore ;
86using Swashbuckle . AspNetCore . Annotations ;
97using TRE_API . Attributes ;
108using TRE_API . Services ;
11- using TRE_API . Services . SignalR ;
129using Microsoft . AspNetCore . Authorization ;
13- using System . Data ;
1410using BL . Models . APISimpleTypeReturns ;
15- using TRE_API . Repositories . DbContexts ;
16- using EasyNetQ . Management . Client . Model ;
1711using BL . Rabbit ;
1812using EasyNetQ ;
19- using Newtonsoft . Json ;
20- using System ;
21- using Amazon . Runtime . Internal . Transform ;
13+ using Microsoft . FeatureManagement ;
2214using Serilog ;
15+ using TRE_API . Constants ;
2316using TRE_API . Models ;
24- using Minio ;
2517
2618namespace TRE_API . Controllers
2719{
28-
29-
3020 [ ApiController ]
3121 [ Route ( "api/[controller]" ) ]
3222 public class SubmissionController : Controller
3323 {
34- private readonly ISignalRService _signalRService ;
35- private readonly IDareClientWithoutTokenHelper _dareHelper ;
36- private readonly IDataEgressClientWithoutTokenHelper _dataEgressHelper ;
3724 private readonly IHutchClientHelper _hutchHelper ;
38- private readonly ApplicationDbContext _dbContext ;
3925 private readonly IBus _rabbit ;
4026 private readonly ISubmissionHelper _subHelper ;
4127 private readonly IMinioSubHelper _minioSubHelper ;
4228 private readonly IMinioTreHelper _minioTreHelper ;
4329 private readonly MinioTRESettings _minioTreSettings ;
44- private readonly string _treName ;
4530 private readonly AgentSettings _agentSettings ;
31+ private readonly IFeatureManager _features ;
4632
47- public SubmissionController ( ISignalRService signalRService , IDareClientWithoutTokenHelper helper ,
48- ApplicationDbContext dbContext ,
49- IBus rabbit ,
33+ public SubmissionController (
34+ IHutchClientHelper hutchHelper ,
35+ IBus rabbit ,
5036 ISubmissionHelper subHelper ,
51- IDataEgressClientWithoutTokenHelper egressHelper ,
52- IHutchClientHelper hutchClientHelper ,
5337 IMinioSubHelper minioSubHelper ,
5438 IMinioTreHelper minioTreHelper ,
55- MinioTRESettings minioTreSettings ,
56- IConfiguration config ,
57- AgentSettings agentSettings )
39+ MinioTRESettings minioTreSettings ,
40+ AgentSettings agentSettings , IFeatureManager features )
5841 {
59- _signalRService = signalRService ;
60- _dareHelper = helper ;
61- _dataEgressHelper = egressHelper ;
62- _hutchHelper = hutchClientHelper ;
63- _dbContext = dbContext ;
42+ _hutchHelper = hutchHelper ;
6443 _rabbit = rabbit ;
6544 _subHelper = subHelper ;
6645 _minioTreHelper = minioTreHelper ;
6746 _minioSubHelper = minioSubHelper ;
6847 _minioTreSettings = minioTreSettings ;
69- _treName = config [ "TreName" ] ;
7048 _agentSettings = agentSettings ;
49+ _features = features ;
7150 }
7251
7352
74-
75-
7653 [ Authorize ( Roles = "dare-tre-admin" ) ]
7754 [ HttpGet ( "IsUserApprovedOnProject" ) ]
7855 public BoolReturn IsUserApprovedOnProject ( int projectId , int userId )
7956 {
80-
8157 return new BoolReturn ( )
8258 {
8359 Result = _subHelper . IsUserApprovedOnProject ( projectId , userId )
@@ -136,10 +112,11 @@ public IActionResult UpdateStatusForTre(
136112 {
137113 _subHelper . CloseSubmissionForTre ( subDetails . SubId , subDetails . StatusType , "" , "" ) ;
138114 }
115+
139116 return StatusCode ( 200 , result ) ;
140117 }
141- catch ( Exception ex ) {
142-
118+ catch ( Exception ex )
119+ {
143120 Log . Error ( ex , "{Function} Crash" , "UpdateStatusForTre" ) ;
144121 throw ;
145122 }
@@ -156,7 +133,7 @@ public IActionResult GetOutputBucketInfo(string subId)
156133 try
157134 {
158135 var outputInfo = _subHelper . GetOutputBucketGuts ( subId , true , true ) ;
159-
136+
160137
161138 return StatusCode ( 200 , outputInfo ) ;
162139 }
@@ -176,7 +153,6 @@ public class OutputBucketInfo
176153 public bool Secure { get ; set ; }
177154 }
178155
179-
180156
181157 [ Authorize ( Roles = "dare-hutch-admin,dare-tre-admin" ) ]
182158 [ HttpPost ]
@@ -208,7 +184,7 @@ public IActionResult FilesReadyForReview([FromBody] ReviewFiles review)
208184 public async Task < IActionResult > EgressResults ( [ FromBody ] EgressReview review )
209185 {
210186 try
211- {
187+ {
212188 Dictionary < string , bool > hutchRes = new Dictionary < string , bool > ( ) ;
213189 ApprovalType approvalStatus ;
214190 var approvedCount = review . FileResults . Count ( x => x . Approved ) ;
@@ -230,22 +206,23 @@ public async Task<IActionResult> EgressResults([FromBody] EgressReview review)
230206 foreach ( var i in review . FileResults )
231207 {
232208 hutchRes . Add ( i . FileName , i . Approved ) ;
233-
234209 }
235210
236211 if ( approvalStatus != ApprovalType . FullyApproved )
237212 {
238213 _subHelper . UpdateStatusForTre ( review . SubId . ToString ( ) , StatusType . DataOutApprovalRejected , "" ) ;
239-
240214
241- var StatusResult = _subHelper . CloseSubmissionForTre ( review . SubId , StatusType . Failed , "" , "" ) ;
242-
215+
216+ var statusResult = _subHelper . CloseSubmissionForTre ( review . SubId , StatusType . Failed , "" , "" ) ;
243217 }
244218 else
245219 {
246220 _subHelper . UpdateStatusForTre ( review . SubId . ToString ( ) , StatusType . DataOutApproved , "" ) ;
247221 }
248- var realurl = string . IsNullOrWhiteSpace ( _minioTreSettings . HutchURLOverride ) ? _minioTreSettings . Url : _minioTreSettings . HutchURLOverride ;
222+
223+ var realurl = string . IsNullOrWhiteSpace ( _minioTreSettings . HutchURLOverride )
224+ ? _minioTreSettings . Url
225+ : _minioTreSettings . HutchURLOverride ;
249226 bool secure = ! realurl . ToLower ( ) . StartsWith ( "http://" ) ;
250227 var bucket = _subHelper . GetOutputBucketGutsSub ( review . SubId , true ) ;
251228 ApprovalResult hutchPayload = new ApprovalResult ( )
@@ -263,43 +240,46 @@ public async Task<IActionResult> EgressResults([FromBody] EgressReview review)
263240 _subHelper . UpdateStatusForTre ( review . SubId , StatusType . RequestingHutchDoesFinalPackaging , "" ) ;
264241 }
265242
266- if ( _agentSettings . SimulateResults )
243+ if ( await _features . IsEnabledAsync ( FeatureFlags . DemoAllInOne ) )
267244 {
268245 var exch = _rabbit . Advanced . ExchangeDeclare ( ExchangeConstants . Tre , "topic" ) ;
269246 var outcome = new FinalOutcome ( )
270247 {
271248 File = review . FileResults . First ( ) . FileName ,
272249 SubId = review . SubId
273250 } ;
274- _rabbit . Advanced . Publish ( exch , RoutingConstants . ProcessFinalOutput , false , new Message < FinalOutcome > ( outcome ) ) ;
251+ _rabbit . Advanced . Publish ( exch , RoutingConstants . ProcessFinalOutput , false ,
252+ new Message < FinalOutcome > ( outcome ) ) ;
275253 }
276254 else if ( _agentSettings . UseTESK == false )
277255 {
278- Log . Information ( "{Function} Minio url sent {Url} bucket {Bucket}, path {path}" , "EgressReview" , hutchPayload . Host , hutchPayload . Bucket , hutchPayload . Path ) ;
256+ Log . Information ( "{Function} Minio url sent {Url} bucket {Bucket}, path {path}" , "EgressReview" ,
257+ hutchPayload . Host , hutchPayload . Bucket , hutchPayload . Path ) ;
279258 //Not sure what the return type is
280259 var HUTCHres =
281260 await _hutchHelper . CallAPI < ApprovalResult , APIReturn > ( $ "/api/jobs/{ review . SubId } /approval",
282261 hutchPayload ) ;
283262 }
284263 else
285264 {
286- Log . Information ( $ "EgressResults with review.OutputBucket > { review . OutputBucket } bucket.Bucket > { bucket . Bucket } ") ;
287- foreach ( var File in review . FileResults )
265+ Log . Information (
266+ $ "EgressResults with review.OutputBucket > { review . OutputBucket } bucket.Bucket > { bucket . Bucket } ") ;
267+ foreach ( var file in review . FileResults )
288268 {
289- Log . Information ( $ "EgressResults with File.Approved > { File . Approved } File.FileName > { File . FileName } ") ;
290- if ( File . Approved )
269+ Log . Information (
270+ $ "EgressResults with File.Approved > { file . Approved } File.FileName > { file . FileName } ") ;
271+ if ( file . Approved )
291272 {
292- var source = await _minioTreHelper . GetCopyObject ( review . OutputBucket , File . FileName ) ;
293- var resultcopy = await _minioSubHelper . CopyObjectToDestination ( bucket . Bucket , File . FileName , source ) ;
273+ var source = await _minioTreHelper . GetCopyObject ( review . OutputBucket , file . FileName ) ;
274+ var resultcopy =
275+ await _minioSubHelper . CopyObjectToDestination ( bucket . Bucket , file . FileName , source ) ;
294276 }
295277 }
296278
297279 _subHelper . UpdateStatusForTre ( review . SubId , StatusType . Completed , "" ) ;
298280 }
299281
300282
301-
302-
303283 return StatusCode ( 200 , new BoolReturn ( ) { Result = true } ) ;
304284 }
305285 catch ( Exception ex )
@@ -310,8 +290,6 @@ await _hutchHelper.CallAPI<ApprovalResult, APIReturn>($"/api/jobs/{review.SubId}
310290 }
311291
312292
313-
314-
315293 [ Authorize ( Roles = "dare-hutch-admin,dare-tre-admin" ) ]
316294 [ HttpPost ]
317295 [ Route ( "FinalOutcome" ) ]
@@ -324,7 +302,8 @@ public IActionResult FinalOutcome([FromBody] FinalOutcome outcome)
324302 {
325303 var exch = _rabbit . Advanced . ExchangeDeclare ( ExchangeConstants . Tre , "topic" ) ;
326304
327- _rabbit . Advanced . Publish ( exch , RoutingConstants . ProcessFinalOutput , false , new Message < FinalOutcome > ( outcome ) ) ;
305+ _rabbit . Advanced . Publish ( exch , RoutingConstants . ProcessFinalOutput , false ,
306+ new Message < FinalOutcome > ( outcome ) ) ;
328307
329308 var boolresult = new BoolReturn ( )
330309 {
@@ -340,7 +319,6 @@ public IActionResult FinalOutcome([FromBody] FinalOutcome outcome)
340319 }
341320
342321
343-
344322 [ HttpPost ( "SendSubmissionToHUTCH" ) ]
345323 public IActionResult SendSubmissionToHUTCH ( Submission sub )
346324 {
@@ -374,7 +352,5 @@ public IActionResult SimulateSubmissionProcessing(Submission sub)
374352 throw ;
375353 }
376354 }
377-
378-
379355 }
380- }
356+ }
0 commit comments