独自のアクティビティ タイプ サービスを挿入する

Version:
日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

アクティビティタイプのコンテキストで独自のサービスを使用できます。カスタムサービスを構成に登録し、アクティビティタイプコンストラクタに挿入する必要があります。

サービスを作成し、アクティビティの種類のコンストラクターに追加する

  1. サービスのインターフェイスと具象実装を作成します。次の例では、IExampleServiceインターフェイスとExampleService具象クラスを使用しています。

    using System;
    
    namespace Documentation.Examples
    {
        public interface IExampleService
        {
            void DoSomething();
        }
    
        public class ExampleService() : IExampleService
        {
            public void DoSomething()
            {
                // Does something
            }
        }
    }
  2. アクティビティの種類のコンストラクタにサービス インターフェイスを追加し、次のようにプライベート サービス プロパティを設定します。

    using Sitecore.Xdb.MarketingAutomation.Core.Activity;
    using Sitecore.Xdb.MarketingAutomation.Core.Processing.Plan;
    using Microsoft.Extensions.Logging;
    
    namespace Documentation.Examples
    {
        public class DoNothingActivity : IActivity
        {
            private IExampleService ExampleService { get; set; }
    
            public IActivityServices Services { get; set; }
    
            public DoNothingActivity(IExampleService exampleService)
            {
                ExampleService = exampleService;
            }
    
            public ActivityResult Invoke(IContactProcessingContext context)
            {
                ExampleService.DoSomething();
    
                return new SuccessMove();
            }
        }
    }

構成にサービスを追加する

  1. Automation Engineルートの次のフォルダーに移動します。 \App_Data\Config\sitecore\MarketingAutomation

    先端

    ローカル インスタンスでは、Automation EngineはC:\path\to\xconnect\App_data\jobs\continuous\AutomationEngineフォルダーにあります。

  2. sc.MarketingAutomation.ActivityServices.xmlを拡張し、カスタムサービスを登録する新しいXMLファイルを作成します。

    <Settings>
    <!--
        Marketing Automation Activity Services configuration
    -->
    <Sitecore>
        <XConnect>
        <MarketingAutomation>
            <Engine>
            <Services>
                <Documentation.ExampleService>
                    <Type>Documentation.Examples.ExampleService, Documentation.Examples</Type>
                    <As>Documentation.Examples.IExampleService, Documentation.Examples</As>
                    <LifeTime>Singleton</LifeTime>
                </Documentation.ExampleService>
            </Services>
            </Engine>
        </MarketingAutomation>
        </XConnect>
    </Sitecore>
    </Settings>
    メモ

    ノード名は一意である必要があります (たとえば、Documentation.ExampleServiceノードは1つだけです)。ノード名はユーザー次第であり、サービスの完全な名前空間である必要はありません。

この記事を改善するための提案がある場合は、 お知らせください!