internal void PruneOrphans()
{
long? currentId = null;
lock (this.runLocker)
{
currentId = this.currentRecord != null ? this.currentRecord.Id : null;
}
using (IRepository repository = this.repositoryFactory.Create())
{
using (IDbTransaction transaction = repository.BeginTransaction())
{
foreach (WorkingRecord working in repository.GetWorkingForWorker(this.Id, currentId, transaction))
{
if (working.Id != currentId)
{
HistoryRecord history = CreateHistory(working, HistoryStatus.Interrupted);
repository.DeleteWorking(working.Id.Value, transaction);
repository.CreateHistory(history, transaction);
}
}
transaction.Commit();
}
}
}