예제 #1
0
        /// <summary>
        /// The process of the command
        /// </summary>
        /// <param name="commerceContext">
        /// The commerce context
        /// </param>
        /// <param name="parameter">
        /// The parameter for the command
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task <TransactionArgument> Process(CommerceContext commerceContext, bool errorOnInnerScope, bool errorOnOuterScope, bool errorBeforeInnerScope, bool newContext, string transactionScopeOption)
        {
            TransactionArgument result = null;

            var transactionScope = (TransactionScopeOption)Enum.Parse(typeof(TransactionScopeOption), transactionScopeOption);

            using (var activity = CommandActivity.Start(commerceContext, this))
            {
                await PerformTransaction(
                    commerceContext,
                    transactionScope,
                    async() =>
                {
                    var arg = new TransactionArgument(errorOnInnerScope, errorOnOuterScope, errorBeforeInnerScope, newContext, transactionScope);
                    result  = await _pipeline.Run(arg, new CommercePipelineExecutionContextOptions(commerceContext)).ConfigureAwait(false);
                }).ConfigureAwait(false);

                return(result);
            }
        }
        /// <summary>
        /// The process of the command
        /// </summary>
        /// <param name="commerceContext">
        /// The commerce context
        /// </param>
        /// <param name="parameter">
        /// The parameter for the command
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task <TransactionArgument> Process(CommerceContext commerceContext, TransactionArgument arg)
        {
            TransactionArgument result = null;

            var context = !arg.NewContext ? commerceContext : new CommerceContext(commerceContext.Logger, commerceContext.TelemetryClient)
            {
                GlobalEnvironment = commerceContext.GlobalEnvironment,
                Environment       = commerceContext.Environment,
                Headers           = commerceContext.Headers
            };

            using (var activity = CommandActivity.Start(context, this))
            {
                await PerformTransaction(
                    context,
                    arg.TransactionScopeOption,
                    async() =>
                {
                    result = await _pipeline.Run(arg, new CommercePipelineExecutionContextOptions(context)).ConfigureAwait(false);
                }).ConfigureAwait(false);

                return(result);
            }
        }