1313using Ardalis . GuardClauses ;
1414using Microsoft . Extensions . DependencyInjection ;
1515using Microsoft . Extensions . Hosting ;
16- using Microsoft . Extensions . Logging ;
1716using Monai . Deploy . InformaticsGateway . Api ;
1817using Monai . Deploy . InformaticsGateway . CLI . Services ;
1918using Monai . Deploy . InformaticsGateway . Client ;
@@ -109,22 +108,22 @@ private async Task<int> ListAeTitlehandlerAsync(IHost host, bool verbose, Cancel
109108 client . ConfigureServiceUris ( configService . Configurations . InformaticsGatewayServerUri ) ;
110109 LogVerbose ( verbose , host , $ "Connecting to { Strings . ApplicationName } at { configService . Configurations . InformaticsGatewayServerEndpoint } ...") ;
111110 LogVerbose ( verbose , host , $ "Retrieving MONAI SCP AE Titles...") ;
112- items = await client . MonaiScpAeTitle . List ( cancellationToken ) ;
111+ items = await client . MonaiScpAeTitle . List ( cancellationToken ) . ConfigureAwait ( false ) ;
113112 }
114113 catch ( ConfigurationException ex )
115114 {
116- logger . Log ( LogLevel . Critical , ex . Message ) ;
115+ logger . ConfigurationException ( ex . Message ) ;
117116 return ExitCodes . Config_NotConfigured ;
118117 }
119118 catch ( Exception ex )
120119 {
121- logger . Log ( LogLevel . Critical , $ "Error retrieving MONAI SCP AE Titles: { ex . Message } " ) ;
120+ logger . ErrorListingMonaiAeTitles ( ex . Message ) ;
122121 return ExitCodes . MonaiScp_ErrorList ;
123122 }
124123
125124 if ( items . IsNullOrEmpty ( ) )
126125 {
127- logger . Log ( LogLevel . Warning , "No MONAI SCP Application Entities configured." ) ;
126+ logger . NoAeTitlesFound ( ) ;
128127 }
129128 else
130129 {
@@ -166,17 +165,17 @@ private async Task<int> RemoveAeTitlehandlerAsync(string name, IHost host, bool
166165 client . ConfigureServiceUris ( configService . Configurations . InformaticsGatewayServerUri ) ;
167166 LogVerbose ( verbose , host , $ "Connecting to { Strings . ApplicationName } at { configService . Configurations . InformaticsGatewayServerEndpoint } ...") ;
168167 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 ) ;
171170 }
172171 catch ( ConfigurationException ex )
173172 {
174- logger . Log ( LogLevel . Critical , ex . Message ) ;
173+ logger . ConfigurationException ( ex . Message ) ;
175174 return ExitCodes . Config_NotConfigured ;
176175 }
177176 catch ( Exception ex )
178177 {
179- logger . Log ( LogLevel . Critical , $ "Error deleting MONAI SCP AE Title { name } : { ex . Message } " ) ;
178+ logger . ErrorDeletingMonaiAeTitle ( name , ex . Message ) ;
180179 return ExitCodes . MonaiScp_ErrorDelete ;
181180 }
182181 return ExitCodes . Success ;
@@ -202,33 +201,29 @@ private async Task<int> AddAeTitlehandlerAsync(MonaiApplicationEntity entity, IH
202201 client . ConfigureServiceUris ( configService . Configurations . InformaticsGatewayServerUri ) ;
203202
204203 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 ) ;
206205
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 ) ;
212207
213208 if ( result . Workflows . Any ( ) )
214209 {
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 ( ) ;
217212 }
218213 if ( result . IgnoredSopClasses . Any ( ) )
219214 {
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 ( ) ;
222217 }
223218 }
224219 catch ( ConfigurationException ex )
225220 {
226- logger . Log ( LogLevel . Critical , ex . Message ) ;
221+ logger . ConfigurationException ( ex . Message ) ;
227222 return ExitCodes . Config_NotConfigured ;
228223 }
229224 catch ( Exception ex )
230225 {
231- logger . Log ( LogLevel . Critical , $ "Error creating MONAI SCP AE Title { entity . AeTitle } : { ex . Message } " ) ;
226+ logger . MonaiAeCreateCritical ( entity . AeTitle , ex . Message ) ;
232227 return ExitCodes . MonaiScp_ErrorCreate ;
233228 }
234229 return ExitCodes . Success ;
0 commit comments