實作 ExecutionState(執行狀態)

要根據當前狀態和期望狀態計算動作,請透過實作 mip::ExecutionState 類別將資訊傳入 MIP SDK。 與 SDK 中的其他類別一樣, ExecutionState 是抽象類別,開發者必須實作它。

Note

如需 ExecutionState 實作的完整範例,請參閱以下範例原始碼:

mip::執行狀態成員

ExecutionState 公開下列虛擬成員。 每個成員都會為政策引擎提供上下文,使其能回傳應用程式應採取哪些動作的資訊。 SDK 也能利用這些資訊向 Microsoft Purview 提供稽核資訊。

成員 退貨
std::shared_ptr<mip::Label> GetNewLabel() 回傳 SDK 套用到物件上的標籤。
mip::DataState GetDataState() 回傳物件的 mip::DataState。
std::pair<bool, std::string> IsDowngradeJustified() 傳回 std::pair 來表示是否應該降級以及其理由。
std::string GetContentIdentifier() 傳回內容識別碼。 使用可辨識的識別碼來標示物件的位置。
mip::ActionSource GetNewLabelActionSource() 傳回標籤的 mip::ActionSource。
mip::AssignmentMethod GetNewLabelAssignmentMethod() 回傳標籤的 mip::AssignmentMethod。
std::vector<std::pair<std::string, std::string>> GetNewLabelExtendedProperties() 回傳一個包含字串配對的 std::vector,其中包含 SDK 套用至文件的自訂中繼資料。
std::vector<std::pair<std::string, std::string>> GetContentMetadata() 回傳一個包含字串配對(std::pair)的 std::vector,其中含有目前內容的中繼資料。
std::shared_ptr<mip::ProtectionDescriptor> GetProtectionDescriptor() 傳回指向 mip::ProtectionDescriptor 的指標。
std::string GetContentFormat() 回傳一個字串。
mip::ActionType GetSupportedActions() 傳回標籤的 mip::ActionTypes。
std::shared_ptr<mip::ClassificationResults> 傳回分類結果清單 (如果已實作)。

在由 衍生 mip::ExecutionState出的類別實作中,覆蓋每個成員。 在前述範例應用中,範例實作了一個稱為 ExecutionStateOptions 結構的結構,並將該結構傳遞給衍生類別的建構子。

範例定義了一個名為 ExecutionStateOptions 的結構:

struct ExecutionStateOptions {
    std::unordered_map<std::string, std::string> metadata;
    std::string newLabelId;
    std::string contentIdentifier;
    mip::ActionSource actionSource = mip::ActionSource::MANUAL;
    mip::DataState dataState = mip::DataState::USE;
    mip::AssignmentMethod assignmentMethod = mip::AssignmentMethod::STANDARD;
    bool isDowngradeJustified = false;
    std::string downgradeJustification;
    std::string templateId;
    std::string contentFormat = mip::GetFileContentFormat();
    mip::ActionType supportedActions;
    bool generateAuditEvent;
};

在應用程式中設定每個屬性,然後傳遞 ExecutionStateOptions 給從 mip::ExecutionState衍生出的類別的建構子。 SDK 利用這些資訊來決定應採取的行動。 Microsoft Purview 的稽核報告也會顯示在 mip::ExecutionState 中提供的資料。

下一步