Exemple #1
0
        /// <summary>
        /// Get the last access time from the config.
        /// </summary>
        /// <param name="token"></param>
        private async Task <DateTime> GetLastUpdatedTimeAsync(CancellationToken token)
        {
            var transaction = await _persister.BeginRead(token).ConfigureAwait(false);

            if (null == transaction)
            {
                //  we probably cancelled.
                throw new Exception("Unable to get transaction!");
            }

            try
            {
                // finally we can set the last time we checked the entire data tree.
                var lastAccessTimeUtc = await _persister.Config.GetConfigValueAsync("LastAccessTimeUtc", DateTime.MinValue, transaction, token).ConfigureAwait(false);

                // we can commit our code.
                _persister.Commit(transaction);

                return(lastAccessTimeUtc);
            }
            catch (Exception)
            {
                _persister.Rollback(transaction);
                throw;
            }
        }