自分だけのアクティビティタイプのサービスを注入しましょう
このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。
アクティビティタイプの文脈で自分のサービスを利用できます。カスタムサービスを設定で登録し、アクティビティタイプ構造体に注入する必要があります。
サービスを作成し、それをアクティビティタイプのコンストラクタに追加します
-
サービス用のインターフェースと具体的な実装を作成します。以下の例はIExampleServiceインターフェースとExampleServiceコンクリートクラスを使用しています。
using System;
namespace Documentation.Examples { public interface IExampleService { void DoSomething(); }
public class ExampleService() : IExampleService { public void DoSomething() { // Does something } } }
-
アクティビティタイプのコンストラクタにサービスインターフェースを追加し、示すようにプライベートサービスプロパティを設定します。
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(); } } }
サービスを追加して構成に加えてください
-
Automation Engineのルートにある以下のフォルダに移動します: \App_Data\Config\sitecore\MarketingAutomation
!tipローカルインスタンスでは、オートメーションエンジンはC:\path\to\xconnect\App_data\jobs\continuous\AutomationEngineフォルダにあります。
-
カスタムサービスを拡張し登録する新しいXMLファイルを作成しsc.MarketingAutomation.ActivityServices.xml :
Documentation.Examples.ExampleService, Documentation.Examples Documentation.Examples.IExampleService, Documentation.Examples Singleton !注ノード名は一意でなければなりません。例えば、Documentation.ExampleServiceノードは1つしか存在できません。ノード名はあなた次第で、サービスの完全な名前空間である必要はありません。