| | |
| | | return Ok($"设置{param}成功"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// SendMQTTAsync |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public async Task<IActionResult> SendMQTTAsync([FromBody] ApiAction action) |
| | | { |
| | | string msg = ""; |
| | | await Task.Run(() => |
| | | { |
| | | msg = action.ID; |
| | | MQTTHelper.Send("TestSendMQTT001", new MQTTMessage() |
| | | { |
| | | Type = "TestSendMQTT001", |
| | | Content = "TestSendMQTT001,测试消息!", |
| | | Data = "", |
| | | DataType = typeof(String).Name, |
| | | IsSuccessed = true, |
| | | }); |
| | | }); |
| | | return Ok(MQTTHelper.Send(action.GetResponse(msg))); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// DeleteMQTTTopicAsync |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public async Task<IActionResult> DeleteMQTTTopicAsync([FromBody] ApiAction action) |
| | | { |
| | | string msg = ""; |
| | | await Task.Run(() => |
| | | { |
| | | msg = MQTTHelper.DeleteTopic(action.ID) ? "删除Topic成功" : "删除Topic失败"; |
| | | }); |
| | | return Ok(action.GetResponse(msg)); |
| | | } |
| | | |
| | | [HttpPost] |
| | | public async Task<IActionResult> TestTask([FromBody] ApiAction action) |
| | | { |
| | |
| | | [Route("api/[controller]/[action]")] |
| | | public partial class _TestController : ControllerBase |
| | | { |
| | | |
| | | [HttpGet] |
| | | public async Task<IActionResult> DoSomething(int duration) |
| | | { |
| | |
| | | Logger.Default.Info($"{begin:mmssfff} completed"); |
| | | return Ok($"{begin:mmssfff} completed"); |
| | | } |
| | | |
| | | [HttpGet] |
| | | public async Task<IActionResult> DoSomething1(int duration) |
| | | { |
| | | var begin = DateTime.Now; |
| | | |
| | | return Ok($"{begin:mmssfff} completed"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// SendMQTTAsync |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public async Task<IActionResult> SendMQTTAsync([FromBody] ApiAction action) |
| | | { |
| | | string msg = ""; |
| | | await Task.Run(() => |
| | | { |
| | | msg = action.ID; |
| | | MQTTHelper.Send("TestSendMQTT001", new MQTTMessage() |
| | | { |
| | | Type = "TestSendMQTT001", |
| | | Content = "TestSendMQTT001,测试消息!", |
| | | Data = "", |
| | | DataType = typeof(String).Name, |
| | | IsSuccessed = true, |
| | | }); |
| | | }); |
| | | return Ok(MQTTHelper.Send(action.GetResponse(msg))); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// DeleteMQTTTopicAsync |
| | | /// </summary> |
| | | /// <param name="action"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public async Task<IActionResult> DeleteMQTTTopicAsync([FromBody] ApiAction action) |
| | | { |
| | | string msg = ""; |
| | | await Task.Run(() => |
| | | { |
| | | msg = MQTTHelper.DeleteTopic(action.ID) ? "删除Topic成功" : "删除Topic失败"; |
| | | }); |
| | | return Ok(action.GetResponse(msg)); |
| | | } |
| | | } |
| | | } |