12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace TEAMModelBI.Controllers.BIHome
- {
- [Route("analyse")]
- [ApiController]
- public class AnalyseFileController : ControllerBase
- {
- private readonly IWebHostEnvironment _environment; //读取文件流
- public AnalyseFileController(IWebHostEnvironment environment)
- {
- _environment = environment;
- }
- [HttpPost("get-visitjson")]
- public async Task<IActionResult> GetVisitJson()
- {
- var path = $"{_environment.ContentRootPath}/JsonFile/TempFile/PT1H.json";
- StreamReader streamReader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.UTF8);
- List<object> objs = new();
- StringBuilder visits = new("[");
- string text;
- while ((text = streamReader.ReadLine()) != null)
- {
- objs.Add(text.ToString());
- visits.Append($"{text},");
- }
- visits.Append("]");
- streamReader.Close();
- //var temp = visits.Split("||");
- //var temp1 = string.Join("||");
- return Ok(new { state = 200, objs, visits });
- }
- public record AGInfo
- {
-
- }
- }
- }
|