| | |
| | | using Tiger.Model.Sharetronic.Shelf; |
| | | using Newtonsoft.Json.Linq; |
| | | using Tiger.Api.iBiz; |
| | | using System.Net; |
| | | using System.Reflection; |
| | | using Swifter.Tools; |
| | | |
| | | namespace Tiger.Api.Controllers.Test |
| | | { |
| | |
| | | public IActionResult GetDBSchemaAsync() |
| | | { |
| | | return Ok(Biz.Db.DbMaintenance.GetTableInfoList()); |
| | | } |
| | | |
| | | [HttpGet] |
| | | public IActionResult GetEntitys(string AssemblyName, string NameSpace) |
| | | { |
| | | Assembly assembly = Assembly.Load(AssemblyName); |
| | | Type[] types = assembly.GetTypes(); |
| | | var entitys = types.Where(q => q.GetInterfaces().Contains(typeof(iEntity)) && q.IsClass).ToList(); |
| | | var data = entitys.Select(q => new |
| | | { |
| | | q.Namespace, |
| | | q.FullName, |
| | | Properties = q.GetProperties().Select(p => new { p.Name, Type = p.PropertyType.Name }).ToList() |
| | | }); |
| | | return Ok(data); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | Logger.Default.Info($"{begin:mmssfff} completed"); |
| | | return Ok($"{begin:mmssfff} completed"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// MQTT测试控制器 |
| | | /// </summary> |
| | | [ApiController] |
| | | [Route("api/[controller]/[action]")] |
| | | public partial class _MqttTestController : ControllerBase |
| | | { |
| | | [HttpGet] |
| | | public async Task<IActionResult> DoSomething1(int duration) |
| | | { |
| | |
| | | /// </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))); |
| | | } |
| | | //[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 |
| | |
| | | string msg = ""; |
| | | await Task.Run(() => |
| | | { |
| | | msg = MQTTHelper.DeleteTopic(action.ID) ? "删除Topic成功" : "删除Topic失败"; |
| | | //msg = MQTTHelper.DeleteTopic(action.ID) ? "删除Topic成功" : "删除Topic失败"; |
| | | }); |
| | | |
| | | return Ok(action.GetResponse(msg)); |
| | | } |
| | | } |