zoukankan      html  css  js  c++  java
  • Dynamics 365 CRM Connected Field Service 自动发送command

    上期降到了怎样部署connected field service(CFS)

    我们假设现在IoT 设备是温度监控器, 当温度触发我们之前预设的温度值, IoT会通过IoT Hub 发送IoT Alert到CFS中。 第一次触发, 系统会自动发送reboot的command。

    为了有更好的用户体验, 我们需要自动发送command。

    自动发送非常简单。

    首先,我们需要创建一个workflow

     我们的workflow需要在IoT Alert创建的时候触发。

    这个workflow需要有以下两步:

    1. 获取到当前IoT Alert的GUID

    2. 创建IoT device command 并且把IoT Alert的GUID 绑定进去。

    首先我们需要创建workflow。

    如果不清楚workflow的,可以查看我的workflow 扫盲贴 Step by Step 开发dynamics CRM

    public class RetrieveCFSData : CodeActivity
        {
            [Input("Key")]
            public InArgument<string> Key { get; set; }
    
            [ReferenceTarget("msdyn_iotalert")]
            [Output("IoTAlertId")]
            public OutArgument<EntityReference> IoTAlertId { get; set; }
    
            protected override void Execute(CodeActivityContext executionContext)
            {
                //Create the tracing service
                ITracingService tracingService = executionContext.GetExtension<ITracingService>();
    
                //Create the context
                IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
                IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
                IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
    
                if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
                {
                    // Obtain the target entity from the input parameters.  
                    Entity iotAlert = (Entity)context.InputParameters["Target"];
                    var alertId = iotAlert.Attributes["msdyn_iotalertid"].ToString();
    //Update Record by using Custom Assembly output parameter
                    var iotAlertRef = new EntityReference("msdyn_iotalert", new Guid(alertId));
                    iotAlertRef.Name = "Hello World From Workflow";
                    IoTAlertId.Set(executionContext, iotAlertRef);
                }
                
            }
        }

    我们把这个workflow添加到之前简历好的step当中。不用set properties

     并且,我们要创建一个IoT Device Command 的step。

    在这个step当中, 我们需要在operator找到我们创建好的step 1 custom workflow。

    并且把parent alert 做绑定。

  • 相关阅读:
    c#中value是什么意思
    javascript json转为 go struct 小工具代码
    android greendao的外部封装不太友好。
    redis 内存泄露
    Robolectric 配置
    android studio 代理配置
    python 写文件,utf-8问题
    go 的 time ticker 设置定时器
    FQ记(nexus7 2代 恢复出厂设置,然后重启,因为被墙,卡住了!)
    lua https request 调用
  • 原文地址:https://www.cnblogs.com/TheMiao/p/11083546.html
Copyright © 2011-2022 走看看