gpt4 book ai didi

c# - 如何使用 if 语句检查事件实体的状态码?

转载 作者:行者123 更新时间:2023-11-30 21:32:51 25 4
gpt4 key购买 nike

如何检查事件实体的状态代码,如果状态代码为 1 或 3,则执行 if 方法。状态码是一个选项集值,所以我不确定如何在 if 语句中传递它。

public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

IOrganizationServiceFactory factory =
(IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = factory.CreateOrganizationService(context.UserId);

//create an entity
Entity entity = (Entity)context.InputParameters["Target"];

//after creating the entity, we need to retrieve the required entity: Incident

//retrieve incident entity
Incident detail = entity.ToEntity<Incident>();


// var incident = service.Retrieve("incident", detail.IncidentId.Value, new Microsoft.Xrm.Sdk.Query.ColumnSet(true)).ToEntity<Incident>();


if (detail.StatusCode== new OptionSetValue(1) || detail.StatusCode == new OptionSetValue(3))
{
if (sec != null)
{
ExecuteWorkflowRequest request = new ExecuteWorkflowRequest()

最佳答案

OptionSetValue 是整数。这应该有效。

int statusCode = detail.GetAttributeValue<OptionSetValue>("statuscode").Value;

if(statusCode == 1 || statusCode == 3)
{

}

关于c# - 如何使用 if 语句检查事件实体的状态码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51987822/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com