1212using SIL . LCModel . Core . Cellar ;
1313using SIL . LCModel . Core . KernelInterfaces ;
1414using SIL . LCModel . Utils ;
15+ using SIL . Reporting ;
1516using Timer = System . Timers . Timer ;
1617
1718namespace SIL . LCModel . Infrastructure . Impl
@@ -26,7 +27,7 @@ namespace SIL.LCModel.Infrastructure.Impl
2627 /// via the 'PropChanged' method of the IVwNotifyChange interface.
2728 /// In this implementation, the LCM ISILDataAccess implementation farms out this
2829 /// notification function to this class.
29- /// IVwNotifyChange implementations are not to use this notificatin mechanism
30+ /// IVwNotifyChange implementations are not to use this notification mechanism
3031 /// to make additional data changes. That is done using the second set of Mediator clients.
3132 ///
3233 /// The second set of Mediator clients is between CmObjects.
@@ -35,7 +36,7 @@ namespace SIL.LCModel.Infrastructure.Impl
3536 /// of properties on other CmObjects.
3637 ///
3738 /// With this twofold Mediator mechanism,
38- /// the IVwNotifyChange system can stay with its purpose of refeshing UI display,
39+ /// the IVwNotifyChange system can stay with its purpose of refreshing UI display,
3940 /// while the second system can take care of side effect data changes.
4041 /// </summary>
4142 /// <remarks>
@@ -103,6 +104,7 @@ internal enum BusinessTransactionState
103104 private readonly IDataStorer m_dataStorer ;
104105 private readonly IdentityMap m_identityMap ;
105106 private readonly ILcmUI m_ui ;
107+ private readonly ITransactionLogger m_logger ;
106108 internal ICmObjectRepositoryInternal ObjectRepository
107109 {
108110 get ;
@@ -151,7 +153,7 @@ internal BusinessTransactionState CurrentProcessingState {
151153 /// <summary>
152154 /// Constructor.
153155 /// </summary>
154- internal UnitOfWorkService ( IDataStorer dataStorer , IdentityMap identityMap , ICmObjectRepositoryInternal objectRepository , ILcmUI ui )
156+ internal UnitOfWorkService ( IDataStorer dataStorer , IdentityMap identityMap , ICmObjectRepositoryInternal objectRepository , ILcmUI ui , ITransactionLogger logger )
155157 {
156158 if ( dataStorer == null ) throw new ArgumentNullException ( "dataStorer" ) ;
157159 if ( identityMap == null ) throw new ArgumentNullException ( "identityMap" ) ;
@@ -160,6 +162,7 @@ internal UnitOfWorkService(IDataStorer dataStorer, IdentityMap identityMap, ICmO
160162
161163 m_dataStorer = dataStorer ;
162164 m_identityMap = identityMap ;
165+ m_logger = logger ;
163166 ObjectRepository = objectRepository ;
164167 m_ui = ui ;
165168 CurrentProcessingState = BusinessTransactionState . ReadyForBeginTask ;
@@ -216,6 +219,7 @@ private void Dispose(bool fDisposing)
216219 m_saveTimer . Dispose ( ) ;
217220 }
218221 IsDisposed = true ;
222+ m_logger ? . AddBreadCrumb ( "UOW Disposed." ) ;
219223 }
220224 #endregion
221225
@@ -247,7 +251,7 @@ void SaveOnIdle(object sender, ElapsedEventArgs e)
247251 // If it is less than 2s since the user did something don't save to smooth performance (unless the user has been busy as a beaver for more than 5 minutes)
248252 if ( now - m_ui . LastActivityTime < TimeSpan . FromSeconds ( 2.0 ) && now < ( m_lastSave + TimeSpan . FromMinutes ( 5 ) ) )
249253 return ;
250-
254+ m_logger . AddBreadCrumb ( "Saving from SaveOnIdle" ) ;
251255 SaveInternal ( ) ;
252256 }
253257 }
@@ -282,6 +286,7 @@ public void Save()
282286
283287 private void SaveInternal ( )
284288 {
289+ m_logger ? . AddBreadCrumb ( "Attempting Save." ) ;
285290 // don't allow reentrant calls.
286291 if ( m_fInSaveInternal )
287292 return ;
@@ -309,6 +314,7 @@ private void SaveInternal()
309314 if ( stack . CanUndo ( ) )
310315 undoable = true ;
311316 }
317+ m_logger ? . AddBreadCrumb ( $ "Raising save event: New:{ newbies . Count } Changed:{ dirtballs . Count } Deleted:{ goners . Count } ") ;
312318 RaiseSave ( undoable ) ;
313319 }
314320
@@ -324,6 +330,7 @@ private void SaveInternal()
324330 return ; // Don't try to save the changes we just reverted!
325331 }
326332
333+ m_logger ? . AddBreadCrumb ( "Committing" ) ;
327334 // let the BEP determine if a commit should occur or not
328335 if ( ! m_dataStorer . Commit ( realNewbies , dirtballs , goners ) )
329336 {
@@ -520,7 +527,7 @@ internal void SendPropChangedNotifications(IEnumerable<ChangeInformation> change
520527 ChangeInformation [ ] changes = subscribers . Length == 0 ? changesEnum . Where ( ci => ci . HasNotifier ) . ToArray ( ) : changesEnum . ToArray ( ) ;
521528 if ( changes . Length == 0 )
522529 return ;
523-
530+ m_logger ? . AddBreadCrumb ( $ "Sending prop changed notifications. Changes: { changes . Length } Subscribers: { subscribers . Length } " ) ;
524531 m_ui . SynchronizeInvoke . Invoke ( ( ) =>
525532 {
526533 foreach ( IVwNotifyChange sub in subscribers )
0 commit comments