|
@@ -1,12 +1,15 @@
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
+using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text;
|
|
|
|
+using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using TEAMModelOS.SDK.Extension;
|
|
using TEAMModelOS.SDK.Extension;
|
|
|
|
+using TEAMModelOS.SDK.Models.Cosmos.BI;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.BIHome
|
|
namespace TEAMModelBI.Controllers.BIHome
|
|
{
|
|
{
|
|
@@ -22,8 +25,10 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
}
|
|
}
|
|
|
|
|
|
[HttpPost("get-visitjson")]
|
|
[HttpPost("get-visitjson")]
|
|
- public async Task<IActionResult> GetVisitJson()
|
|
|
|
|
|
+ public async Task<IActionResult> GetVisitJson(JsonElement jsonElement)
|
|
{
|
|
{
|
|
|
|
+ jsonElement.TryGetProperty("path", out JsonElement _path);
|
|
|
|
+ jsonElement.TryGetProperty("time", out JsonElement _time);
|
|
var path = $"{_environment.ContentRootPath}/JsonFile/TempFile/PT1H.json";
|
|
var path = $"{_environment.ContentRootPath}/JsonFile/TempFile/PT1H.json";
|
|
StreamReader streamReader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.UTF8);
|
|
StreamReader streamReader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.UTF8);
|
|
List<object> objs = new();
|
|
List<object> objs = new();
|
|
@@ -46,12 +51,37 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
string input = visits.ToString();
|
|
string input = visits.ToString();
|
|
List<AGInfo> aGInfos = input.ToObject<List<AGInfo>>();
|
|
List<AGInfo> aGInfos = input.ToObject<List<AGInfo>>();
|
|
|
|
|
|
|
|
+ //var ipGroup = aGInfos.GroupBy(g => g.properties.clientIp).ToDictionary(k => k.Key, k => k.Count()).ToList();
|
|
|
|
|
|
- return Ok(new { state = 200, aGInfos, objs, visits });
|
|
|
|
|
|
+ List<RecGWInfo> recInfo = aGInfos.Select(x => new RecGWInfo { hour = DateTimeOffset.Parse(x.time).ToString("yyyyMMddHH"),hostName=x.properties.hostname }).ToList();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<StatisNameCnt> ipCnt = aGInfos.GroupBy(g => g.properties.clientIp).Select(x => new StatisNameCnt { name = x.Key, cnt = x.Count() }).ToList();
|
|
|
|
+ ipCnt.Sort((x, y) => y.cnt.CompareTo(x.cnt));
|
|
|
|
+
|
|
|
|
+ DateTimeOffset dateTime = DateTimeOffset.UtcNow;
|
|
|
|
+ var apiCnt = aGInfos.Select(s => s.properties.requestUri.Split("?").ToList().Count()>1 ? s.properties.requestUri.Split("?").ToList()[0]: s.properties.requestUri).GroupBy(g => g).Select(x=>new { key = x.Key,cnt =x.Count()}).ToList();
|
|
|
|
+
|
|
|
|
+ return Ok(new { state = 200, apiCnt, ipCnt });
|
|
|
|
+ }
|
|
|
|
+ public record RecGWInfo
|
|
|
|
+ {
|
|
|
|
+ public string hour { get; set; }
|
|
|
|
+ public string ip { get; set; }
|
|
|
|
+ public string api { get; set; }
|
|
|
|
+ public string hostName { get; set; }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public record StatisNameCnt
|
|
|
|
+ {
|
|
|
|
+ public string name { get; set; }
|
|
|
|
+ public int cnt { get; set; }
|
|
|
|
+ }
|
|
|
|
+
|
|
public record AGInfo
|
|
public record AGInfo
|
|
{
|
|
{
|
|
//public string resourceId { get; set; }
|
|
//public string resourceId { get; set; }
|