Exemplo n.º 1
0
        /// <summary>
        /// Creates a child log scope.
        /// </summary>
        /// <param name="scopeName">The child scope name.</param>
        /// <returns>Newly-created scope.</returns>
        public BackgroundLogScope CreateChildScope(string scopeName)
        {
            var now = DateTime.UtcNow;
            int scopeSequence;

            lock (this.syncLock)
            {
                if (this.completed.HasValue)
                {
                    throw new InvalidOperationException($"Log scope \"{this.Name}\" has alrady been completed.");
                }

                scopeSequence = this.ExecutionLogger.GetNextScopeSequence();
                var scope = new BackgroundLogScope(this.ExecutionLogger, scopeName ?? string.Empty, Task.Run(createScopeInternalAsync));
                this.childScopes.Add(scope);
                return(scope);
            }

            async Task <int?> createScopeInternalAsync()
            {
                int?parentScopeId = await this.ScopeId.ConfigureAwait(false);

                await RompDb.CreateLogScopeAsync(this.ExecutionId, scopeSequence, parentScopeId, scopeName ?? string.Empty, now);

                return(scopeSequence);
            }
        }
Exemplo n.º 2
0
 public RompScopedExecutionLog(BackgroundLogScope scope)
 {
     this.scope = scope;
 }