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 做绑定。

  • 相关阅读:
    Android APK反编译
    android 安卓APP获取手机设备信息和手机号码的代码示例
    Android-- ArrayAdapter用法举例(转载)
    Android--ListView 分割线
    Android——检测TXT文件中是否含有双字节字符
    Android--------从一个包中的Avtivity创建另外另外一个包的Context
    百度地图技术大揭秘
    Lotusscript统计在线用户数
    代理中如何获取参数么
    DXL之通过程序修改Domino的设计
  • 原文地址:https://www.cnblogs.com/TheMiao/p/11083546.html
Copyright © 2011-2022 走看看