12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using log4net;
- using Newtonsoft.Json;
- using SCADA.CommonLib.Helper;
- using SCADA.CommonLib.LoggerHelper;
- using SCADA_DAQ.Plugin.Machine.WebHookConfig;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Web.Http;
- namespace SCADA_DAQ.Customer.Controllers
- {
- // 如果需要对外提供webapi接口,可以通过自定义 Service 继承 BaseService后从服务管理中配置自定义服务实现,对外访问,也可以通过自定义有的ApiController提供对外访问接口
- // 本demo就是提供可以一个对外的Api服务,设备通信中的 WebHooks 触发后会回调此接口
-
- /// <summary>
- /// 寄存器回调接口
- /// </summary>
- public class RegWebHookController : ApiController
- {
- private static ILog Log = Logger.CreateLogger("RegWebHook");
- /// <summary>
- ///
- /// </summary>
- /// <param name="hookValue"></param>
- public void RegTriggered(RegWebHook hookValue)
- {
- Log.Info($"收到WebHook回调");
- Log.Info($"{JsonHelper.JsonSerialize(hookValue)}");
- }
- }
- /// <summary>
- ///
- /// </summary>
- public class RegWebHook
- {
- /// <summary>
- ///
- /// </summary>
- public string TaskName { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string TriggerParameter { get; set; }
- /// <summary>
- /// 触发设备的Id
- /// </summary>
- public string TriggerMachine { get; set; }
- /// <summary>
- /// 触发的寄存器
- /// </summary>
- public string TriggerReg { get; set; }
- /// <summary>
- /// 触发时的值
- /// </summary>
- public object TriggerValue { get; set; }
- /// <summary>
- /// 子项明细
- /// </summary>
- public List<RegWebHookValueItem> Items { get; set; }
- }
- /// <summary>
- ///
- /// </summary>
- public class RegWebHookValueItem
- {
- /// <summary>
- ///
- /// </summary>
- public string Key { get; set; }
- /// <summary>
- ///
- /// </summary>
- public string Desc { get; set; }
- /// <summary>
- ///
- /// </summary>
- public object Value { get; set; }
- }
- }
|