实现执行状态(ExecutionState)

若要基于当前状态和所需状态计算操作,请通过实现 mip::ExecutionState 类将信息传递到 MIP SDK。 与 SDK 中的其他类一样, ExecutionState 是一个抽象类,开发人员必须实现它。

Note

有关 ExecutionState 实现的完整示例,请参阅以下示例源代码:

mip::ExecutionState 成员

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() 返回内容标识符。 使用指示对象位置的人类可读标识符。
std::string GetApplicationScenarioId() 返回一个标识符,该标识符将应用程序事件与相应的审核或保护服务 REST 请求相关联。
mip::AssignmentMethod GetNewLabelAssignmentMethod() 返回标签的 mip::AssignmentMethod。
std::vector<std::pair<std::string, std::string>> GetNewLabelExtendedProperties() 返回一个 std::vector,其中包含字符串对,这些字符串对包含 SDK 应用于文档的自定义元数据。
std::vector<mip::MetadataEntry> GetContentMetadata() 返回包含当前内容元数据的 mip::MetadataEntry 对象的 std::vector。
std::shared_ptr<mip::ProtectionDescriptor> GetProtectionDescriptor() 返回指向 mip::ProtectionDescriptor 的指针。
std::string GetContentFormat() 返回一个字符串。
mip::ActionType GetSupportedActions() 返回标签的 mip::ActionTypes。
std::shared_ptr<mip::ClassificationResults> GetClassificationResults() 返回分类结果的列表(如果已实现)。

重写派生自 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中提供的数据。

后续步骤