13
13
using Ardalis . GuardClauses ;
14
14
using Microsoft . Extensions . DependencyInjection ;
15
15
using Microsoft . Extensions . Hosting ;
16
- using Microsoft . Extensions . Logging ;
17
16
using Monai . Deploy . InformaticsGateway . Api ;
18
17
using Monai . Deploy . InformaticsGateway . CLI . Services ;
19
18
using Monai . Deploy . InformaticsGateway . Client ;
@@ -109,22 +108,22 @@ private async Task<int> ListAeTitlehandlerAsync(IHost host, bool verbose, Cancel
109
108
client . ConfigureServiceUris ( configService . Configurations . InformaticsGatewayServerUri ) ;
110
109
LogVerbose ( verbose , host , $ "Connecting to { Strings . ApplicationName } at { configService . Configurations . InformaticsGatewayServerEndpoint } ...") ;
111
110
LogVerbose ( verbose , host , $ "Retrieving MONAI SCP AE Titles...") ;
112
- items = await client . MonaiScpAeTitle . List ( cancellationToken ) ;
111
+ items = await client . MonaiScpAeTitle . List ( cancellationToken ) . ConfigureAwait ( false ) ;
113
112
}
114
113
catch ( ConfigurationException ex )
115
114
{
116
- logger . Log ( LogLevel . Critical , ex . Message ) ;
115
+ logger . ConfigurationException ( ex . Message ) ;
117
116
return ExitCodes . Config_NotConfigured ;
118
117
}
119
118
catch ( Exception ex )
120
119
{
121
- logger . Log ( LogLevel . Critical , $ "Error retrieving MONAI SCP AE Titles: { ex . Message } " ) ;
120
+ logger . ErrorListingMonaiAeTitles ( ex . Message ) ;
122
121
return ExitCodes . MonaiScp_ErrorList ;
123
122
}
124
123
125
124
if ( items . IsNullOrEmpty ( ) )
126
125
{
127
- logger . Log ( LogLevel . Warning , "No MONAI SCP Application Entities configured." ) ;
126
+ logger . NoAeTitlesFound ( ) ;
128
127
}
129
128
else
130
129
{
@@ -166,17 +165,17 @@ private async Task<int> RemoveAeTitlehandlerAsync(string name, IHost host, bool
166
165
client . ConfigureServiceUris ( configService . Configurations . InformaticsGatewayServerUri ) ;
167
166
LogVerbose ( verbose , host , $ "Connecting to { Strings . ApplicationName } at { configService . Configurations . InformaticsGatewayServerEndpoint } ...") ;
168
167
LogVerbose ( verbose , host , $ "Deleting MONAI SCP AE Title { name } ...") ;
169
- _ = await client . MonaiScpAeTitle . Delete ( name , cancellationToken ) ;
170
- logger . Log ( LogLevel . Information , $ "MONAI SCP AE Title ' { name } ' deleted." ) ;
168
+ _ = await client . MonaiScpAeTitle . Delete ( name , cancellationToken ) . ConfigureAwait ( false ) ;
169
+ logger . MonaiAeTitleDeleted ( name ) ;
171
170
}
172
171
catch ( ConfigurationException ex )
173
172
{
174
- logger . Log ( LogLevel . Critical , ex . Message ) ;
173
+ logger . ConfigurationException ( ex . Message ) ;
175
174
return ExitCodes . Config_NotConfigured ;
176
175
}
177
176
catch ( Exception ex )
178
177
{
179
- logger . Log ( LogLevel . Critical , $ "Error deleting MONAI SCP AE Title { name } : { ex . Message } " ) ;
178
+ logger . ErrorDeletingMonaiAeTitle ( name , ex . Message ) ;
180
179
return ExitCodes . MonaiScp_ErrorDelete ;
181
180
}
182
181
return ExitCodes . Success ;
@@ -202,33 +201,29 @@ private async Task<int> AddAeTitlehandlerAsync(MonaiApplicationEntity entity, IH
202
201
client . ConfigureServiceUris ( configService . Configurations . InformaticsGatewayServerUri ) ;
203
202
204
203
LogVerbose ( verbose , host , $ "Connecting to { Strings . ApplicationName } at { configService . Configurations . InformaticsGatewayServerEndpoint } ...") ;
205
- var result = await client . MonaiScpAeTitle . Create ( entity , cancellationToken ) ;
204
+ var result = await client . MonaiScpAeTitle . Create ( entity , cancellationToken ) . ConfigureAwait ( false ) ;
206
205
207
- logger . Log ( LogLevel . Information , "New MONAI Deploy SCP Application Entity created:" ) ;
208
- logger . Log ( LogLevel . Information , $ "\t Name: { result . Name } ") ;
209
- logger . Log ( LogLevel . Information , $ "\t AE Title: { result . AeTitle } ") ;
210
- logger . Log ( LogLevel . Information , $ "\t Grouping: { result . Grouping } ") ;
211
- logger . Log ( LogLevel . Information , $ "\t Timeout: { result . Grouping } s") ;
206
+ logger . MonaiAeTitleCreated ( result . Name , result . AeTitle , result . Grouping , result . Timeout ) ;
212
207
213
208
if ( result . Workflows . Any ( ) )
214
209
{
215
- logger . Log ( LogLevel . Information , $ " \t Workflows: { string . Join ( ',' , result . Workflows ) } " ) ;
216
- logger . Log ( LogLevel . Warning , "Data received by this Application Entity will bypass Data Routing Service." ) ;
210
+ logger . MonaiAeWorkflows ( string . Join ( ',' , result . Workflows ) ) ;
211
+ logger . WorkflowWarning ( ) ;
217
212
}
218
213
if ( result . IgnoredSopClasses . Any ( ) )
219
214
{
220
- logger . Log ( LogLevel . Information , $ " \t Ignored SOP Classes: { string . Join ( ',' , result . IgnoredSopClasses ) } " ) ;
221
- logger . Log ( LogLevel . Warning , "Instances with matching SOP class UIDs are accepted but dropped." ) ;
215
+ logger . MonaiAeIgnoredSops ( string . Join ( ',' , result . IgnoredSopClasses ) ) ;
216
+ logger . IgnoreSopClassesWarning ( ) ;
222
217
}
223
218
}
224
219
catch ( ConfigurationException ex )
225
220
{
226
- logger . Log ( LogLevel . Critical , ex . Message ) ;
221
+ logger . ConfigurationException ( ex . Message ) ;
227
222
return ExitCodes . Config_NotConfigured ;
228
223
}
229
224
catch ( Exception ex )
230
225
{
231
- logger . Log ( LogLevel . Critical , $ "Error creating MONAI SCP AE Title { entity . AeTitle } : { ex . Message } " ) ;
226
+ logger . MonaiAeCreateCritical ( entity . AeTitle , ex . Message ) ;
232
227
return ExitCodes . MonaiScp_ErrorCreate ;
233
228
}
234
229
return ExitCodes . Success ;
0 commit comments