Documentation

Ucommerce includes full API reference documentation and lots of helpful articles to help you build your e-commerce site as effortlessly as possible.

Topics Payment Providers
v7.18

Initialize Pipeline

The initialize pipeline is run once every time application starts up, which means you can use it to hook in code that you want to execute right after the application has started and before a user visits the Ucommerce back office. This is a great extension point should you wish to make sure that some conditions are met for your app. This could be definitions that needs to be in place or something similar.

Pipeline implementation

  • windsor component id Initialize
  • type Ucommerce.Pipelines.Initialization.InitializePipeline
  • Description
    The initialize pipeline class.

Tasks and execution order


GenericPipelineTaskAsync`1

  • Windsor component id Initialize.ExecuteUpdateCurrencyExchangeRatesPipelineTask.Async
  • Type Ucommerce.Pipelines.GenericPipelineTaskAsync`1[[Ucommerce.Pipelines.Initialization.InitializeArgs, Ucommerce.Pipelines, Version=9.6.0.0, Culture=neutral, PublicKeyToken=null]]
  • Description
    Async pipeline task for executing tasks on a background thread. Arguments for this SHOULD NOT be an IEntity. If T is an IEntity, and is passed to the background thread, NHibernate will throw unrelated errors as it is not thread-safe.

ReinitializeWebApiControllerCache

  • Windsor component id Initialize.ReinitializeWebApiControllerCacheTask
  • Type Ucommerce.SystemHttp.Pipelines.Initialize.ReinitializeWebApiControllerCache
  • Description
    Poke the WebAPI internal cache to get it to re-read the controllers.

Pipeline configuration

Configuration as found under ucommerce\Pipelines\System\Initialize.config

    
    <configuration>
      <components>
        <component id="Initialize" service="Ucommerce.Pipelines.IPipeline`1[[Ucommerce.Pipelines.Initialization.InitializeArgs, Ucommerce.Pipelines]], Ucommerce" type="Ucommerce.Pipelines.Initialization.InitializePipeline, Ucommerce.Pipelines">
          <parameters>
            <tasks>
              <array>
                <value>${Initialize.ExecuteUpdateCurrencyExchangeRatesPipelineTask.Async}</value>
                <value>${Initialize.ReinitializeWebApiControllerCacheTask}</value>
              </array>
            </tasks>
          </parameters>
        </component>
        <component id="Initialize.ReinitializeWebApiControllerCacheTask" service="Ucommerce.Pipelines.IPipelineTask`1[[Ucommerce.Pipelines.Initialization.InitializeArgs, Ucommerce.Pipelines]], Ucommerce" type="Ucommerce.SystemHttp.Pipelines.Initialize.ReinitializeWebApiControllerCache, Ucommerce.SystemHttp" />
        <component id="Initialize.ExecuteUpdateCurrencyExchangeRatesPipelineTask" service="Ucommerce.Pipelines.IPipelineTask`1[[Ucommerce.Pipelines.Initialization.InitializeArgs, Ucommerce.Pipelines]], Ucommerce" type="Ucommerce.Pipelines.Initialization.ExecuteUpdateCurrencyExchangeRatesPipelineTask, Ucommerce.Pipelines" />
        <component id="Initialize.ExecuteUpdateCurrencyExchangeRatesPipelineTask.Async" service="Ucommerce.Pipelines.IPipelineTask`1[[Ucommerce.Pipelines.Initialization.InitializeArgs, Ucommerce.Pipelines]], Ucommerce" type="Ucommerce.Pipelines.GenericPipelineTaskAsync`1[[Ucommerce.Pipelines.Initialization.InitializeArgs, Ucommerce.Pipelines]], Ucommerce">
          <parameters>
            <pipelineTaskName>Initialize.ExecuteUpdateCurrencyExchangeRatesPipelineTask</pipelineTaskName>
            <MaxNumberOfTries>3</MaxNumberOfTries>
          </parameters>
        </component>
      </components>
    </configuration>

Custom task

If you're interested in creating your own pipeline task, here's a code sample and configuration below for the Initialize pipeline. If you haven't read how to create custom pipeline tasks before, we recommend giving it a read as there's a lot of valuable information covered in the article.

Code sample

    
    using Ucommerce.Pipelines;
    using Ucommerce.Pipelines.Initialization;
     
    namespace MyProject.Extensions.Pipelines.Initialize
    {
        public class MyInitializePipelineTask : Ucommerce.Pipelines.IPipelineTask<Ucommerce.Pipelines.Initialization.InitializeArgs>
        {
            public PipelineExecutionResult Execute(Ucommerce.Pipelines.Initialization.InitializeArgs subject)
            {
                return PipelineExecutionResult.Success;
            }
        }
    }
    

Configuration

    
    
                        <configuration>
    	                    <components>
                                <component id="Initialize.MyInitializePipelineTask"
                                           service="Ucommerce.Pipelines.IPipelineTask`1[[Ucommerce.Pipelines.Initialization.InitializeArgs, Ucommerce.Pipelines]], Ucommerce"
                                           type="MyProject.Extensions.Pipelines.Initialize.MyInitializePipelineTask, MyAssembly" />
    
                                <partial-component id="Initialize">
                                    <parameters>
                                        <tasks>
                                            <array>
                                                <value insert="last">${Initialize.MyInitializePipelineTask}</value>
                                            </array>
                                        </tasks>
                                    </parameters>
                                </partial-component>
    	                    </components>
                        </configuration>
                    
    

The configuration above just inserts your task as the last task in the pipeline. Mind this line in the configuration above: <value insert="last">${Initialize.MyInitializePipelineTask}</value> Additionally you can insert first, or before or after a specific task. Just like the example below You may also use insert="first" insert-before="${Initialize.ReinitializeWebApiControllerCacheTask}" or insert-after="${Initialize.ReinitializeWebApiControllerCacheTask}"