diff --git a/projects/IoTCenter/Api/InfluxController.cs b/projects/IoTCenter/Api/InfluxController.cs new file mode 100644 index 00000000..ec1ed5af --- /dev/null +++ b/projects/IoTCenter/Api/InfluxController.cs @@ -0,0 +1,50 @@ +using Infrastructure.Extensions; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; + +namespace IoTCenter.Api +{ + [ApiVersion("1.0")] + [Route("api/v{version:apiVersion}/[controller]/[action]")] + [ApiController] + public class InfluxController : ControllerBase + { + private readonly IConfiguration _cfg; + private readonly IHttpClientFactory _httpClientFactory; + + public InfluxController(IConfiguration cfg, IHttpClientFactory httpClientFactory) + { + this._cfg = cfg; + this._httpClientFactory = httpClientFactory; + } + + [HttpPost] + [Produces("application/json")] + public async Task Query() + { + var server = this._cfg["influxdb:url"]; + var url = $"{server}/query"; + var data = new Dictionary(); + foreach (var item in this.Request.Form) + { + try + { + data.Add(item.Key, Encoding.UTF8.GetString(Convert.FromBase64String(item.Value.ToString()))); + } + catch (Exception ex) + { + ex.PrintStack(); + data.Add(item.Key, item.Value.ToString()); + } + } + using var content = new FormUrlEncodedContent(data); + var client = _httpClientFactory.CreateClient(); + return await client.PostAsync(url, content).Result.Content.ReadAsStringAsync(); + } + } +} \ No newline at end of file diff --git a/projects/Version.cs b/projects/Version.cs index 52d250f8..b8d3b94f 100644 --- a/projects/Version.cs +++ b/projects/Version.cs @@ -1,4 +1,4 @@ using System.Reflection; [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyInformationalVersion("1.0.0.0821d2")] \ No newline at end of file +[assembly: AssemblyInformationalVersion("1.0.0.0824d1")] \ No newline at end of file diff --git a/projects/WebMVC/wwwroot/components/shared/layout.html b/projects/WebMVC/wwwroot/components/shared/layout.html index 2fadc259..1f2496f4 100644 --- a/projects/WebMVC/wwwroot/components/shared/layout.html +++ b/projects/WebMVC/wwwroot/components/shared/layout.html @@ -319,7 +319,7 @@