示例#1
0
        /// <summary>
        /// Finds transactions that were left over from an unexpected shutdown and rolls them back.
        /// </summary>
        public void Recover()
        {
            var transactionPaths = Directory.EnumerateDirectories(_core.Settings.TransactionPath).ToList();

            if (transactionPaths.Count > 0)
            {
                _core.LogInformation($"Rolling back {transactionPaths.Count} transactions.");
            }

            foreach (var transactionPath in transactionPaths)
            {
                var transactionId = Path.GetFileName(transactionPath);
                _core.LogInformation($"Rolling back transaction: {transactionId}.");
                var transaction = new Transaction(_core, Guid.Parse(transactionId));
                transaction.Rollback();
            }
        }