11using System . Reactive ;
22using System . Reactive . Linq ;
3- using System . Threading . Tasks ;
43using ByteSync . Business . PathItems ;
54using ByteSync . Business . Profiles ;
65using ByteSync . Business . SessionMembers ;
1110using ByteSync . Common . Business . Sessions ;
1211using ByteSync . Common . Business . Sessions . Cloud ;
1312using ByteSync . Common . Business . Sessions . Local ;
14- using ByteSync . Common . Helpers ;
1513using ByteSync . Interfaces . Controls . Communications ;
1614using ByteSync . Interfaces . Controls . Communications . Http ;
1715using ByteSync . Interfaces . Controls . Encryptions ;
1816using ByteSync . Interfaces . Controls . Inventories ;
1917using ByteSync . Interfaces . Repositories ;
2018using ByteSync . Interfaces . Services . Sessions ;
2119using DynamicData ;
22- using Serilog ;
2320
2421namespace ByteSync . Services . Inventories ;
2522
@@ -32,10 +29,11 @@ public class DataInventoryStarter : IDataInventoryStarter
3229 private readonly IInventoryApiClient _inventoryApiClient ;
3330 private readonly IPathItemRepository _pathItemRepository ;
3431 private readonly ISessionMemberRepository _sessionMemberRepository ;
32+ private readonly ILogger < DataInventoryStarter > _logger ;
3533
36- public DataInventoryStarter ( ISessionService sessionService , ICloudProxy connectionManager ,
37- IDataEncrypter dataEncrypter , IDataInventoryRunner dataInventoryRunner ,
38- IInventoryApiClient inventoryApiClient , IPathItemRepository pathItemRepository , ISessionMemberRepository sessionMemberRepository )
34+ public DataInventoryStarter ( ISessionService sessionService , ICloudProxy connectionManager , IDataEncrypter dataEncrypter ,
35+ IDataInventoryRunner dataInventoryRunner , IInventoryApiClient inventoryApiClient , IPathItemRepository pathItemRepository ,
36+ ISessionMemberRepository sessionMemberRepository , ILogger < DataInventoryStarter > logger )
3937 {
4038 _sessionService = sessionService ;
4139 _connectionManager = connectionManager ;
@@ -44,6 +42,7 @@ public DataInventoryStarter(ISessionService sessionService, ICloudProxy connecti
4442 _inventoryApiClient = inventoryApiClient ;
4543 _pathItemRepository = pathItemRepository ;
4644 _sessionMemberRepository = sessionMemberRepository ;
45+ _logger = logger ;
4746
4847 _connectionManager . HubPushHandler2 . InventoryStarted
4948 . Where ( dto => _sessionService . CheckSession ( dto . SessionId ) )
@@ -65,7 +64,7 @@ public DataInventoryStarter(ISessionService sessionService, ICloudProxy connecti
6564 }
6665 catch ( Exception e )
6766 {
68- Log . Error ( e , "An unexpected error occurred while checking the inventory auto-start" ) ;
67+ _logger . LogError ( e , "An unexpected error occurred while checking the inventory auto-start" ) ;
6968 }
7069 return Unit . Default ;
7170 } )
@@ -130,11 +129,11 @@ public async Task<StartInventoryResult> StartDataInventory(bool isLaunchedByUser
130129
131130 if ( isLaunchedByUser )
132131 {
133- Log . Information ( "The current user has requested to start the Data Inventory" ) ;
132+ _logger . LogInformation ( "The current user has requested to start the Data Inventory" ) ;
134133 }
135134 else
136135 {
137- Log . Information ( "The Data Inventory has been automatically started" ) ;
136+ _logger . LogInformation ( "The Data Inventory has been automatically started" ) ;
138137 }
139138
140139 var sessionSettings = _sessionService . CurrentSessionSettings ;
@@ -150,14 +149,12 @@ public async Task<StartInventoryResult> StartDataInventory(bool isLaunchedByUser
150149 {
151150 return result ;
152151 }
153-
154- // todo : remonter également les autres paramètres pour contrôle par les aux parties de l'égalité des paramètres
155152
156153 result = await SendSessionSettings ( session , sessionSettings ) ;
157154
158155 if ( result . IsOK )
159156 {
160- await _sessionService . SetSessionSettings ( sessionSettings ) ;
157+ await _sessionService . SetSessionSettings ( sessionSettings , false ) ;
161158 await _dataInventoryRunner . RunDataInventory ( ) ;
162159
163160 return result ;
@@ -172,17 +169,17 @@ public async void OnDataInventoryStarted(InventoryStartedDTO inventoryStartedDto
172169 {
173170 try
174171 {
175- Log . Information ( "The Data Inventory has been started by another client (ClientInstanceId:{ClientInstanceId})" ,
172+ _logger . LogInformation ( "The Data Inventory has been started by another client (ClientInstanceId:{ClientInstanceId})" ,
176173 inventoryStartedDto . ClientInstanceId ) ;
177174
178175 var sessionSettings = _dataEncrypter . DecryptSessionSettings ( inventoryStartedDto . EncryptedSessionSettings ) ;
179176
180- await _sessionService . SetSessionSettings ( sessionSettings ) ;
177+ await _sessionService . SetSessionSettings ( sessionSettings , false ) ;
181178 await _dataInventoryRunner . RunDataInventory ( ) ;
182179 }
183180 catch ( Exception ex )
184181 {
185- Log . Error ( ex , "OnStartInventory" ) ;
182+ _logger . LogError ( ex , "OnStartInventory" ) ;
186183 }
187184 }
188185
@@ -269,7 +266,7 @@ private void FinalizeSessionSettings(SessionSettings sessionSettings)
269266
270267 private StartInventoryResult LogAndBuildStartInventoryResult ( AbstractSession localSession , StartInventoryStatuses status )
271268 {
272- Log . Information ( "StartInventory: session {@localSession} - {Status}" , localSession . SessionId , status ) ;
269+ _logger . LogInformation ( "StartInventory: session {@localSession} - {Status}" , localSession . SessionId , status ) ;
273270 return StartInventoryResult . BuildFrom ( status ) ;
274271 }
275272}
0 commit comments