結果

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

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

結果の定義は、Sitecore.Marketing.Definitions.Outcomes.OutcomeDefinitionManagerクラスによって管理されます。

メモ

結果は特別なイベントです。 IOutcomeDefinitionIEventDefinitionを継承します。

OutcomeDefinitionManagerへのアクセス

OutcomeDefinitionManagerは、Sitecore DIコンテナから入手できます。クラスのコンストラクタにDefinitionManagerBase<IOutcomeDefinition, OutcomeDefinitionRecord> 型のパラメータを含め、コンテナからクラスをプルして、コンテナがインスタンスを解決できるようにすることをお勧めします。

public MyClass(DefinitionManagerBase<IOutcomeDefinition, OutcomeDefinitionRecord> outcomeDefinitionManager)
{
        ...
}

コンテナを使用してクラスを構築できない場合は、サービス ロケータを使用できます。このクラスは、Sitecore DIコンテナーでも使用できます。

using Sitecore.DependencyInjection;
using Sitecore.Marketing.Definitions;

ServiceLocator.ServiceProvider.GetDefinitionManagerFactory().GetDefinitionManager<IOutcomeDefinition>();

結果の定義

結果は、Sitecore.Marketing.Definitions.Outcomes.Model名前空間の型を使用して定義されます。

Guid outcomeId = Guid.NewGuid(); // Outcome ID
CultureInfo outcomeCulture = new CultureInfo("es"); // Outcome culture
string outcomeName = "Newly created outcome"; // Outcome name
DateTime creationDate = DateTime.UtcNow; // Outcome creation date
string createdBy = "sitecore\admin"; // Outcome creator

OutcomeDefinition outcome = new OutcomeDefinition(outcomeId, "Outcome item name", outcomeCulture, outcomeName, creationDate, createdBy);

outcome.IsMonetaryValueApplicable = true;
手記

IsMonetaryValueApplicableはレポートで使用されます。契約に署名したり、約束をしたりなど、意味のある金銭的価値がない結果が出ることは有効です。このような場合は、IsMonetaryValueApplicableをfalseに設定します。

AdditionalRegistrationsAreIgnoredOutcomeManagerによって使用され、現在は使用されていません。このプロパティをコードから削除してください。

ライブイベント

IsLiveEventプロパティは基本EventDefinitionクラスの一部であり、イベントをセッション終了時ではなくすぐに処理する必要があるかどうかを判断するためにMarketing Automationによって使用されます。ライブイベント処理の詳細については、こちらをご覧ください。

結果の保存

結果を定義したら、定義マネージャーでSaveAsync() メソッドを呼び出して保存できます。

Guid outcomeId = Guid.NewGuid(); // Outcome ID
CultureInfo outcomeCulture = new CultureInfo("es"); // Outcome culture
string outcomeName = "Newly created outcome"; // Outcome name
DateTime creationDate = DateTime.UtcNow; // Outcome creation date
string createdBy = "sitecore\admin"; // Outcome creator

OutcomeDefinition outcome = new OutcomeDefinition(outcomeId, "Outcome item name", outcomeCulture, outcomeName, creationDate, createdBy);

outcome.IsMonetaryValueApplicable = true;

    OutcomeDefinitionManager manager = ServiceLocator.ServiceProvider.GetDefinitionManagerFactory().GetDefinitionManager<IOutcomeDefinition>();

manager.SaveAsync(outcome);

オプションで、SaveAsync()メソッドの2番目のパラメーターにtrueを渡すことで、保存中に結果をアクティブ化することもできます。

manager.SaveAsync(outcome, true);

結果のアクティブ化

成果は、管理外で使用できるようになる前にアクティブ化する必要があります。結果は、SaveAsync()メソッドのactivate (2番目) パラメーターにtrueを渡すことで保存するときにアクティブ化できます。

manager.SaveAsync(outcome, true);

結果は、ActivateAsync() メソッドを使用して、saveを呼び出さずにアクティブ化することもできます。

manager.ActivateAsync(outcomeId);

ActivateAsync() メソッドは、結果のIDを受け取り、結果定義モデルを必要としません。

結果の削除

結果を削除するには、マネージャーでDelete() メソッドを使用します。個々のカルチャを定義から削除することはできず、定義全体のみを削除します。メソッド呼び出しに提供されるカルチャは、null (既定値) またはCultureInfo.InvariantCultureである必要があります。

manager.Delete(outcomeId);

結果を取得する

1つの結果は、マネージャーのGet() メソッドのいずれかを使用して、そのIDで取得できます。

Guid outcomeId = Guid.NewGuid(); // Ensure this is the ID of an existing outcome

// Get by ID and culture. Will get the latest active version
IOutcomeDefinition outcome = manager.Get(outcomeId, new CultureInfo("da"));

// Get by ID and culture. Will get the latest version, including if the version is inactive
IOutcomeDefinition outcome = manager.Get(outcomeId, new CultureInfo("da"), true);

結果をエイリアスで取得する

また、結果をエイリアスで取得することもできます。

CultureInfo outcomeCulture = new CultureInfo("fr-fr");
var outcomeDefinitionByAlias = definitionManager.GetByAlias("My alias", outcomeCulture);

既存の結果を更新する

既存の結果定義を更新するには、IDで結果を取得し、結果を編集します

Guid outcomeId = Guid.NewGuid(); // Ensure this is the ID of an existing outcome

// Get by ID and culture. Will get the latest active version
IOutcomeDefinition outcome = manager.Get(outcomeId, new CultureInfo("da"));

// Make updates to outcome
outcome.Name = "Updated name";

// Save to update
manager.SaveAsync(outcome);

すべての結果の取得

GetAll() メソッドを使用して、マネージャーからすべての結果を取得できます。定義が多数ある可能性があるため、このメソッドはページングをサポートします。戻り値は1ページの結果です。

    // Get All with defaults which will be first page, page size 20, latest active versions only
    ResultSet<DefinitionResult<IOutcomeDefinition>> outcomes = manager.GetAll(new CultureInfo("da"), new RetrievalParameters<IOutcomeDefinition, string>());

    // Get page 2
    ResultSet<DefinitionResult<IOutcomeDefinition>> page2Outcomes = manager.GetAll(new CultureInfo("da"), new RetrievalParameters<IOutcomeDefinition, string>(pageNumber: 2));

    // Include inactive versions
ResultSet<DefinitionResult<IOutcomeDefinition>> page1Outcomes = manager.GetAll(new CultureInfo("da"), new RetrievalParameters<IOutcomeDefinition, string>(), true);

結果にアクセスするには、結果のDataPageプロパティを使用します。

IOutcomeDefinition outcome = page1Outcomes.DataPage.ElementAt(0);

この結果には、定義の総数と現在のページ・インデックスおよびページ・サイズを公開するプロパティも含まれます。

long totalDefinitionCount = page1Outcomes.Total;
int pageNumber = page1Outcomes.PageNumber;
int pageSize = page1Outcomes.Count;
この記事を改善するための提案がある場合は、 お知らせください!