|
@@ -21,6 +21,7 @@ using OpenXmlPowerTools;
|
|
using StackExchange.Redis;
|
|
using StackExchange.Redis;
|
|
using System;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections;
|
|
|
|
+using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel;
|
|
using System.IdentityModel.Tokens.Jwt;
|
|
using System.IdentityModel.Tokens.Jwt;
|
|
@@ -32,6 +33,7 @@ using System.Text;
|
|
using System.Text.Json;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Nodes;
|
|
using System.Text.Json.Nodes;
|
|
using System.Text.RegularExpressions;
|
|
using System.Text.RegularExpressions;
|
|
|
|
+using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using System.Web;
|
|
using System.Web;
|
|
using TEAMModelOS.Filter;
|
|
using TEAMModelOS.Filter;
|
|
@@ -57,10 +59,10 @@ namespace TEAMModelOS.Controllers
|
|
private readonly IConfiguration _configuration;
|
|
private readonly IConfiguration _configuration;
|
|
private readonly AzureStorageFactory _azureStorage;
|
|
private readonly AzureStorageFactory _azureStorage;
|
|
private readonly AzureRedisFactory _azureRedis;
|
|
private readonly AzureRedisFactory _azureRedis;
|
|
- private readonly ISearcher _ipSearcher;
|
|
|
|
|
|
+ private readonly IPSearcher _ipSearcher;
|
|
private readonly Option _option;
|
|
private readonly Option _option;
|
|
private readonly Region2LongitudeLatitudeTranslator _longitudeLatitudeTranslator;
|
|
private readonly Region2LongitudeLatitudeTranslator _longitudeLatitudeTranslator;
|
|
- public BillController(Region2LongitudeLatitudeTranslator longitudeLatitudeTranslator,IHttpClientFactory httpClient, IConfiguration configuration, AzureStorageFactory azureStorage, ISearcher searcher, DingDing dingDing, IOptionsSnapshot<Option> option)
|
|
|
|
|
|
+ public BillController(AzureRedisFactory azureRedis, Region2LongitudeLatitudeTranslator longitudeLatitudeTranslator, IHttpClientFactory httpClient, IConfiguration configuration, AzureStorageFactory azureStorage, IPSearcher searcher, DingDing dingDing, IOptionsSnapshot<Option> option)
|
|
{
|
|
{
|
|
_httpClient = httpClient;
|
|
_httpClient = httpClient;
|
|
_configuration = configuration;
|
|
_configuration = configuration;
|
|
@@ -68,6 +70,7 @@ namespace TEAMModelOS.Controllers
|
|
_ipSearcher = searcher;
|
|
_ipSearcher = searcher;
|
|
_dingDing = dingDing;
|
|
_dingDing = dingDing;
|
|
_option = option.Value;
|
|
_option = option.Value;
|
|
|
|
+ _azureRedis=azureRedis;
|
|
_longitudeLatitudeTranslator = longitudeLatitudeTranslator;
|
|
_longitudeLatitudeTranslator = longitudeLatitudeTranslator;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -81,70 +84,18 @@ namespace TEAMModelOS.Controllers
|
|
[RequestSizeLimit(102_400_000_00)] //最大10000m左右
|
|
[RequestSizeLimit(102_400_000_00)] //最大10000m左右
|
|
public async Task<IActionResult> ReportApi(JsonElement json)
|
|
public async Task<IActionResult> ReportApi(JsonElement json)
|
|
{
|
|
{
|
|
- {
|
|
|
|
- var vist= json.GetProperty("vist").ToObject<ApiVist>();
|
|
|
|
- IEnumerable<JToken> tokens;
|
|
|
|
- if (!string.IsNullOrWhiteSpace(vist.city) && !string.IsNullOrWhiteSpace(vist.province) && !string.IsNullOrWhiteSpace(vist.area))
|
|
|
|
- {
|
|
|
|
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.province}/i && @.city=~ /.*{vist.city}/i)]");
|
|
|
|
- }
|
|
|
|
- else if (string.IsNullOrWhiteSpace(vist.city) && !string.IsNullOrWhiteSpace(vist.province) && !string.IsNullOrWhiteSpace(vist.area))
|
|
|
|
- {
|
|
|
|
- if (vist.area.Equals("中国"))
|
|
|
|
- {
|
|
|
|
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.province}/i)]");
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.province}/i || @.province=~ /.*{vist.province}/i)]");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else if (!string.IsNullOrWhiteSpace(vist.city) && string.IsNullOrWhiteSpace(vist.province)&& !string.IsNullOrWhiteSpace(vist.area))
|
|
|
|
- {
|
|
|
|
- if (vist.area.Equals("中国"))
|
|
|
|
- {
|
|
|
|
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.city}/i)]");
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.city}/i || @.city=~ /.*{vist.province}/i)]");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else if (string.IsNullOrWhiteSpace(vist.city) && string.IsNullOrWhiteSpace(vist.province)&& !string.IsNullOrWhiteSpace(vist.area))
|
|
|
|
- {
|
|
|
|
- tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.country=~ /.*{vist.area}/i && @.m==1)]");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+
|
|
var jobject = JObject.Parse(json.GetRawText());
|
|
var jobject = JObject.Parse(json.GetRawText());
|
|
- var tks= jobject.SelectTokens(json.GetProperty("path").GetString());
|
|
|
|
|
|
+ string path = "$..[school,id,schoolId,schoolid,schoolCode,school_code,schoolcode,code]";
|
|
|
|
+ var tks = jobject.SelectTokens(json.GetProperty("path").GetString());
|
|
foreach (var t in tks)
|
|
foreach (var t in tks)
|
|
{
|
|
{
|
|
var s = $"{t}";
|
|
var s = $"{t}";
|
|
|
|
+ return Ok(tks);
|
|
}
|
|
}
|
|
|
|
|
|
- var regions= _longitudeLatitudeTranslator.regionJson.SelectTokens(json.GetProperty("region").GetString());
|
|
|
|
- foreach(var region in regions)
|
|
|
|
- {
|
|
|
|
- Console.WriteLine(region);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- var jsonPathContext = new JsonPathContext() { ValueSystem= new JsonNetValueSystem()};
|
|
|
|
- {
|
|
|
|
- var nodes_id_token = jsonPathContext.SelectNodes(json, json.GetProperty("path").GetString());
|
|
|
|
- foreach (var node in nodes_id_token)
|
|
|
|
- {
|
|
|
|
- if (node is string)
|
|
|
|
- {
|
|
|
|
- Console.WriteLine(node);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- return Ok(node);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //return Ok(nodes_id_token);
|
|
|
|
- }
|
|
|
|
- var reg = _ipSearcher.SearchIp(json.GetProperty("ip").GetString());
|
|
|
|
|
|
+ List<ApiVist> apiVists = new List<ApiVist>();
|
|
List<string> times = json.GetProperty("times").ToObject<List<string>>();
|
|
List<string> times = json.GetProperty("times").ToObject<List<string>>();
|
|
foreach (var time in times)
|
|
foreach (var time in times)
|
|
{
|
|
{
|
|
@@ -161,28 +112,40 @@ namespace TEAMModelOS.Controllers
|
|
List<ApiVist> vistsDay = new List<ApiVist>();
|
|
List<ApiVist> vistsDay = new List<ApiVist>();
|
|
List<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfos = new List<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)>();
|
|
List<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfos = new List<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)>();
|
|
List<string> files = await _azureStorage.GetBlobContainerClient("0-service-log").List($"http-log/{time}");
|
|
List<string> files = await _azureStorage.GetBlobContainerClient("0-service-log").List($"http-log/{time}");
|
|
- foreach (var file in files)
|
|
|
|
- {
|
|
|
|
|
|
+ //List<HttpLog> logs = new List<HttpLog>();
|
|
|
|
+ ConcurrentBag<HttpLog> logs = new ConcurrentBag<HttpLog>();
|
|
|
|
+ // object lockObj = new object();
|
|
|
|
+ await Parallel.ForEachAsync(files, async (file, _) => {
|
|
if (!file.Contains("index.json"))
|
|
if (!file.Contains("index.json"))
|
|
{
|
|
{
|
|
- string hour = DateTimeOffset.Now.GetGMTTime(8).ToString("HH");
|
|
|
|
- //当前小时的不保存
|
|
|
|
- if (!file.EndsWith($"{hour}.json"))
|
|
|
|
- {
|
|
|
|
|
|
+ //string hour = DateTimeOffset.Now.GetGMTTime(8).ToString("HH");
|
|
|
|
+ ////当前小时的不保存
|
|
|
|
+ //if (!file.EndsWith($"{hour}.json"))
|
|
|
|
+ //{
|
|
|
|
|
|
|
|
+ //}
|
|
|
|
+ BlobDownloadResult result = await _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient(file).DownloadContentAsync();
|
|
|
|
+ var content = result.Content.ToString();
|
|
|
|
+ content= content.Substring(0, content.Length-2);
|
|
|
|
+ if (content.EndsWith("}"))
|
|
|
|
+ {
|
|
|
|
+ content=$"[{content}]";
|
|
}
|
|
}
|
|
- BlobDownloadResult result = await _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{time}/{hour}.json").DownloadContentAsync();
|
|
|
|
- var httpLogs = result.Content.ToObjectFromJson<List<HttpLog>>();
|
|
|
|
- (List<ApiVist> vists, List<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo) = await Convert(httpLogs);
|
|
|
|
- vistsDay.AddRange(vists);
|
|
|
|
- uuidInfos.AddRange(uuidInfo);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ content=$"[{content}}}]";
|
|
|
|
+ }
|
|
|
|
+ var httpLogs = content.ToObject<List<HttpLog>>();
|
|
|
|
+ Parallel.ForEach(httpLogs, item =>
|
|
|
|
+ {
|
|
|
|
+ logs.Add( item);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ });
|
|
|
|
+ (ConcurrentBag<ApiVist> vists, ConcurrentBag<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo) = Convert(logs);
|
|
|
|
+ vistsDay.AddRange(vists);
|
|
|
|
+ uuidInfos.AddRange(uuidInfo);
|
|
vistsDay.FindAll(x => x.path.Contains("common/exam/upsert-record"));
|
|
vistsDay.FindAll(x => x.path.Contains("common/exam/upsert-record"));
|
|
-
|
|
|
|
List<(string tmd, bool exists, string scope)> tmdexists = new List<(string tmd, bool exists, string scope)>();
|
|
List<(string tmd, bool exists, string scope)> tmdexists = new List<(string tmd, bool exists, string scope)>();
|
|
List<(string sch, bool exists)> schexists = new List<(string sch, bool exists)>();
|
|
List<(string sch, bool exists)> schexists = new List<(string sch, bool exists)>();
|
|
var tmds = uuidInfos.SelectMany(x => x.tmdid).ToHashSet();
|
|
var tmds = uuidInfos.SelectMany(x => x.tmdid).ToHashSet();
|
|
@@ -245,35 +208,36 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ apiVists.AddRange(vistsDay);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return Ok(reg);
|
|
|
|
|
|
+ return Ok(new { apiVists });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- public async Task<(List<ApiVist> vists, List<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo)> Convert(List<HttpLog> logs)
|
|
|
|
|
|
+ public (ConcurrentBag<ApiVist> vists, ConcurrentBag<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo) Convert(ConcurrentBag<HttpLog> logs)
|
|
{
|
|
{
|
|
- List<ApiVist> vists = new List<ApiVist>();
|
|
|
|
- List<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo = new List<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)>();
|
|
|
|
- foreach (HttpLog log in logs)
|
|
|
|
- {
|
|
|
|
|
|
+ ConcurrentBag<ApiVist> vists = new ConcurrentBag<ApiVist>();
|
|
|
|
+ ConcurrentBag<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo = new ConcurrentBag<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)>();
|
|
|
|
+ object lockObj = new object();
|
|
|
|
+ Parallel.ForEach(logs, async log => {
|
|
string uuid = Guid.NewGuid().ToString();
|
|
string uuid = Guid.NewGuid().ToString();
|
|
List<string> schoolMatch = new List<string>();
|
|
List<string> schoolMatch = new List<string>();
|
|
List<string> useridMatch = new List<string>();
|
|
List<string> useridMatch = new List<string>();
|
|
var vist = new ApiVist() { id=uuid, ip=log.ip, tid=log.tid, time= log.time, userId= log.id, school= log.school, tname= log.name, path = log.path };
|
|
var vist = new ApiVist() { id=uuid, ip=log.ip, tid=log.tid, time= log.time, userId= log.id, school= log.school, tname= log.name, path = log.path };
|
|
if (string.IsNullOrWhiteSpace(vist.userId))
|
|
if (string.IsNullOrWhiteSpace(vist.userId))
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+
|
|
//var jsonPathContext = new JsonPathContext();
|
|
//var jsonPathContext = new JsonPathContext();
|
|
//jsonPathContext.ValueSystem= new JsonTextValueSystem();
|
|
//jsonPathContext.ValueSystem= new JsonTextValueSystem();
|
|
- string path = "$..[id_token,idToken,idtoken,tmdid,id,teacherId,teacher,tid,tId,userid,userId,code,studentId,student,studentid]";
|
|
|
|
|
|
+ string path = "$..['id_token','idToken','idtoken','tmdid','id','teacherId','teacher','tid','tId','userid','userId','code','studentId','student','studentid']";
|
|
|
|
|
|
JObject jsonObject = JObject.Parse(log.param.GetRawText());
|
|
JObject jsonObject = JObject.Parse(log.param.GetRawText());
|
|
//var nodes_path = jsonPathContext.SelectNodes(log.param, path);
|
|
//var nodes_path = jsonPathContext.SelectNodes(log.param, path);
|
|
|
|
|
|
- var nodes_path = jsonObject.SelectTokens(path);
|
|
|
|
|
|
+ var nodes_path = jsonObject.SelectTokens(path);
|
|
foreach (var node in nodes_path)
|
|
foreach (var node in nodes_path)
|
|
{
|
|
{
|
|
// 只获取是字符串的
|
|
// 只获取是字符串的
|
|
@@ -332,204 +296,28 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- /*
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- var nodes_id_token = selection.SelectNodes("$.request.id_token");
|
|
|
|
- if (nodes_id_token.Count()>0)
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- var jwt = new JwtSecurityToken($"{nodes_id_token[0].Value}");
|
|
|
|
- string id = jwt.Payload.Sub;
|
|
|
|
- var name = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("name"))?.Value;
|
|
|
|
- if (!string.IsNullOrWhiteSpace(id) && long.TryParse(id, out long _id))
|
|
|
|
- {
|
|
|
|
- //vist.userId=id;
|
|
|
|
- //vist.tname=name;
|
|
|
|
- useridMatch.Add(id);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- catch (Exception ex) { }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if (string.IsNullOrWhiteSpace(vist.userId))
|
|
|
|
- // {
|
|
|
|
- var nodes_idToken = selection.SelectNodes("$.request.idToken");
|
|
|
|
- if (nodes_idToken.Count()>0)
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- var jwt = new JwtSecurityToken($"{nodes_idToken[0].Value}");
|
|
|
|
- string id = jwt.Payload.Sub;
|
|
|
|
- var name = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("name"))?.Value;
|
|
|
|
- if (!string.IsNullOrWhiteSpace(id) && long.TryParse(id, out long _id))
|
|
|
|
- {
|
|
|
|
- //vist.userId=id;
|
|
|
|
- //vist.tname=name;
|
|
|
|
- useridMatch.Add(id);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- catch (Exception ex) { }
|
|
|
|
- }
|
|
|
|
- // }
|
|
|
|
- // if (string.IsNullOrWhiteSpace(vist.userId))
|
|
|
|
- //{
|
|
|
|
- var nodes_tmdid = selection.SelectNodes("$.request.tmdid");
|
|
|
|
- if (nodes_tmdid.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_tmdid[0].Value}") && long.TryParse($"{nodes_tmdid[0].Value}", out long _id))
|
|
|
|
- {
|
|
|
|
- // vist.userId=$"{nodes_tmdid[0].Value}";
|
|
|
|
- useridMatch.Add($"{nodes_tmdid[0].Value}");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // }
|
|
|
|
- //if (string.IsNullOrWhiteSpace(vist.userId))
|
|
|
|
- // {
|
|
|
|
- var nodes_id = selection.SelectNodes("$.request.id");
|
|
|
|
- if (nodes_id.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_id[0].Value}") && long.TryParse($"{nodes_id[0].Value}", out long _id))
|
|
|
|
- {
|
|
|
|
- // vist.userId=$"{nodes_id[0].Value}";
|
|
|
|
- useridMatch.Add($"{nodes_id[0].Value}");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // }
|
|
|
|
- // if (string.IsNullOrWhiteSpace(vist.userId))
|
|
|
|
- // {
|
|
|
|
- var nodes_teacherId = selection.SelectNodes("$.request.teacherId");
|
|
|
|
- if (nodes_teacherId.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_teacherId[0].Value}") && long.TryParse($"{nodes_teacherId[0].Value}", out long _id))
|
|
|
|
- {
|
|
|
|
- useridMatch.Add($"{nodes_teacherId[0].Value}");
|
|
|
|
- //vist.userId=$"{nodes_teacherId[0].Value}";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // }
|
|
|
|
- // if (string.IsNullOrWhiteSpace(vist.userId))
|
|
|
|
- // {
|
|
|
|
- var nodes_teacher = selection.SelectNodes("$.request.teacher");
|
|
|
|
- if (nodes_teacher.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_teacher[0].Value}") && long.TryParse($"{nodes_teacher[0].Value}", out long _id))
|
|
|
|
- {
|
|
|
|
- useridMatch.Add($"{nodes_teacher[0].Value}");
|
|
|
|
- // vist.userId=$"{nodes_teacher[0].Value}";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //}
|
|
|
|
- // if (string.IsNullOrWhiteSpace(vist.userId))
|
|
|
|
- // {
|
|
|
|
- var nodes_tid = selection.SelectNodes("$.request.tid");
|
|
|
|
- if (nodes_tid.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_tid[0].Value}") && long.TryParse($"{nodes_tid[0].Value}", out long _id))
|
|
|
|
- {
|
|
|
|
- useridMatch.Add($"{nodes_tid[0].Value}");
|
|
|
|
- // vist.userId=$"{nodes_tid[0].Value}";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- var nodes_userid = selection.SelectNodes("$.request.userid");
|
|
|
|
- if (nodes_userid.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_userid[0].Value}") && long.TryParse($"{nodes_userid[0].Value}", out long _id))
|
|
|
|
- {
|
|
|
|
- useridMatch.Add($"{nodes_userid[0].Value}");
|
|
|
|
- // vist.userId=$"{nodes_tid[0].Value}";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- var nodes_userId = selection.SelectNodes("$.request.userId");
|
|
|
|
- if (nodes_userId.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_userId[0].Value}") && long.TryParse($"{nodes_userId[0].Value}", out long _id))
|
|
|
|
- {
|
|
|
|
- useridMatch.Add($"{nodes_userId[0].Value}");
|
|
|
|
- // vist.userId=$"{nodes_tid[0].Value}";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // }
|
|
|
|
- // if (string.IsNullOrWhiteSpace(vist.userId))
|
|
|
|
- // {
|
|
|
|
- var nodes_code = selection.SelectNodes("$.request.code");
|
|
|
|
- if (nodes_code.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_code[0].Value}"))
|
|
|
|
- {
|
|
|
|
- if (long.TryParse($"{nodes_code[0].Value}", out long _id))
|
|
|
|
- {
|
|
|
|
- //vist.userId=$"{nodes_code[0].Value}";
|
|
|
|
- useridMatch.Add($"{nodes_code[0].Value}");
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- string[] codes = $"{nodes_code[0].Value}".Split("-");
|
|
|
|
- foreach (var _code in codes)
|
|
|
|
- {
|
|
|
|
- if (long.TryParse(_code, out long _codeid))
|
|
|
|
- {
|
|
|
|
- useridMatch.Add(vist.userId=$"{_code}");
|
|
|
|
- // vist.userId=$"{_code}";
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // }
|
|
|
|
- //学生
|
|
|
|
- // if (string.IsNullOrWhiteSpace(vist.userId))
|
|
|
|
- // {
|
|
|
|
- var nodes_studentId = selection.SelectNodes("$.request.studentId");
|
|
|
|
- if (nodes_studentId.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_studentId[0].Value}") && long.TryParse($"{nodes_studentId[0].Value}", out long _id))
|
|
|
|
- {
|
|
|
|
- useridMatch.Add($"{nodes_studentId[0].Value}");
|
|
|
|
- // vist.userId=$"{nodes_studentId[0].Value}";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // }
|
|
|
|
- // if (string.IsNullOrWhiteSpace(vist.userId))
|
|
|
|
- // {
|
|
|
|
- var nodes_student = selection.SelectNodes("$.request.student");
|
|
|
|
- if (nodes_student.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_student[0].Value}") && long.TryParse($"{nodes_student[0].Value}", out long _id))
|
|
|
|
- {
|
|
|
|
- useridMatch.Add($"{nodes_student[0].Value}");
|
|
|
|
- // vist.userId=$"{nodes_student[0].Value}";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // }
|
|
|
|
- */
|
|
|
|
}
|
|
}
|
|
if (string.IsNullOrWhiteSpace(vist.school))
|
|
if (string.IsNullOrWhiteSpace(vist.school))
|
|
{
|
|
{
|
|
- string path = "$..[school,id,schoolId,schoolid,schoolCode,school_code,schoolcode,code]";
|
|
|
|
- //var jsonPathContext = new JsonPathContext();
|
|
|
|
- //jsonPathContext.ValueSystem= new JsonTextValueSystem();
|
|
|
|
- //var nodes_path = jsonPathContext.SelectNodes(log.param, path);
|
|
|
|
|
|
+ string path = "$..['school','id','schoolId','schoolid','schoolCode','school_code','schoolcode','code']";
|
|
JObject jsonObject = JObject.Parse(log.param.GetRawText());
|
|
JObject jsonObject = JObject.Parse(log.param.GetRawText());
|
|
- //var nodes_path = jsonPathContext.SelectNodes(log.param, path);
|
|
|
|
-
|
|
|
|
var nodes_path = jsonObject.SelectTokens(path);
|
|
var nodes_path = jsonObject.SelectTokens(path);
|
|
foreach (var node in nodes_path)
|
|
foreach (var node in nodes_path)
|
|
{
|
|
{
|
|
// 只获取是字符串的
|
|
// 只获取是字符串的
|
|
- if (node.Type.Equals(JTokenType.String) )
|
|
|
|
|
|
+ if (node.Type.Equals(JTokenType.String))
|
|
{
|
|
{
|
|
switch (true)
|
|
switch (true)
|
|
{
|
|
{
|
|
case bool when node.Path.Contains("school")||node.Path.Contains("id")||node.Path.Contains("schoolId")
|
|
case bool when node.Path.Contains("school")||node.Path.Contains("id")||node.Path.Contains("schoolId")
|
|
||node.Path.Contains("schoolid")||node.Path.Contains("schoolCode")||node.Path.Contains("school_code")||node.Path.Contains("schoolcode"):
|
|
||node.Path.Contains("schoolid")||node.Path.Contains("schoolCode")||node.Path.Contains("school_code")||node.Path.Contains("schoolcode"):
|
|
- { break; }
|
|
|
|
|
|
+ {
|
|
|
|
+ if (!$"{node}".Contains("-")&& $"{node}".Length<=8)
|
|
|
|
+ {
|
|
|
|
+ schoolMatch.Add($"{node}");
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
case bool when node.Path.Contains("code"):
|
|
case bool when node.Path.Contains("code"):
|
|
{
|
|
{
|
|
if (!$"{node}".Contains("-")&& $"{node}".Length<=8)
|
|
if (!$"{node}".Contains("-")&& $"{node}".Length<=8)
|
|
@@ -550,94 +338,14 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- /*
|
|
|
|
- {
|
|
|
|
- var nodes_school = selection.SelectNodes("$.request.school");
|
|
|
|
- if (nodes_school.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_school[0].Value}") && $"{nodes_school[0].Value}".Length<=8)
|
|
|
|
- {
|
|
|
|
- schoolMatch.Add($"{nodes_school[0].Value}");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- var nodes_id = selection.SelectNodes("$.request.id");
|
|
|
|
- if (nodes_id.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_id[0].Value}") && $"{nodes_id[0].Value}".Length<=8)
|
|
|
|
- {
|
|
|
|
- schoolMatch.Add($"{nodes_id[0].Value}");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- var nodes_schoolId = selection.SelectNodes("$.request.schoolId");
|
|
|
|
- if (nodes_schoolId.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_schoolId[0].Value}") && $"{nodes_schoolId[0].Value}".Length<=8)
|
|
|
|
- {
|
|
|
|
- schoolMatch.Add($"{nodes_schoolId[0].Value}");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- var nodes_schoolid = selection.SelectNodes("$.request.schoolid");
|
|
|
|
- if (nodes_schoolid.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_schoolid[0].Value}") && $"{nodes_schoolid[0].Value}".Length<=8)
|
|
|
|
- {
|
|
|
|
- schoolMatch.Add($"{nodes_schoolid[0].Value}");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- var nodes_schoolCode = selection.SelectNodes("$.request.schoolCode");
|
|
|
|
- if (nodes_schoolCode.Count()>0)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_schoolCode[0].Value}") && $"{nodes_schoolCode[0].Value}".Length<=8)
|
|
|
|
- {
|
|
|
|
- schoolMatch.Add($"{nodes_schoolCode[0].Value}");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- var nodes_school_code = selection.SelectNodes("$.request.school_code");
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_school_code[0].Value}") && $"{nodes_school_code[0].Value}".Length<=8)
|
|
|
|
- {
|
|
|
|
- schoolMatch.Add($"{nodes_school_code[0].Value}");
|
|
|
|
- }
|
|
|
|
- var nodes_schoolcode = selection.SelectNodes("$.request.schoolcode");
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_schoolcode[0].Value}") && $"{nodes_schoolcode[0].Value}".Length<=8)
|
|
|
|
- {
|
|
|
|
- schoolMatch.Add($"{nodes_schoolcode[0].Value}");
|
|
|
|
- }
|
|
|
|
- var nodes_code = selection.SelectNodes("$.request.code");
|
|
|
|
- if (!string.IsNullOrWhiteSpace($"{nodes_code[0].Value}"))
|
|
|
|
- {
|
|
|
|
- if (!$"{nodes_code[0].Value}".Contains("-")&& $"{nodes_code[0].Value}".Length<=8)
|
|
|
|
- {
|
|
|
|
- //vist.userId=$"{nodes_code[0].Value}";
|
|
|
|
- schoolMatch.Add($"{nodes_code[0].Value}");
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- string[] codes = $"{nodes_code[0].Value}".Split("-");
|
|
|
|
- foreach (var _code in codes)
|
|
|
|
- {
|
|
|
|
- if ($"{nodes_code[0].Value}".Length<=8)
|
|
|
|
- {
|
|
|
|
- schoolMatch.Add(vist.userId=$"{_code}");
|
|
|
|
- // vist.userId=$"{_code}";
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- */
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- uuidInfo.Add((uuid, log, useridMatch, schoolMatch));
|
|
|
|
- vists.Add(vist);
|
|
|
|
|
|
+
|
|
//处理 client
|
|
//处理 client
|
|
{
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(log.client))
|
|
if (!string.IsNullOrWhiteSpace(log.client))
|
|
@@ -766,8 +474,7 @@ namespace TEAMModelOS.Controllers
|
|
log.host="hiteachcc.teammodel.cn";
|
|
log.host="hiteachcc.teammodel.cn";
|
|
vist.client="hiteachcc";
|
|
vist.client="hiteachcc";
|
|
}
|
|
}
|
|
- if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
|
- &&(log.host.Equals("appraisal.chinacloudsites.cn")))
|
|
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(log.host) &&(log.host.Equals("appraisal.chinacloudsites.cn")))
|
|
{
|
|
{
|
|
log.host="评价-正式站";
|
|
log.host="评价-正式站";
|
|
log.host="appraisal.teammodel.cn";
|
|
log.host="appraisal.teammodel.cn";
|
|
@@ -780,6 +487,12 @@ namespace TEAMModelOS.Controllers
|
|
log.host="appraisal-test.teammodel.cn";
|
|
log.host="appraisal-test.teammodel.cn";
|
|
vist.client="appraisal";
|
|
vist.client="appraisal";
|
|
}
|
|
}
|
|
|
|
+ if (log.host.Equals("localhost") && log.p.Equals("appraisal"))
|
|
|
|
+ {
|
|
|
|
+ log.host="评价-测试站";
|
|
|
|
+ log.host="appraisal-test.teammodel.cn";
|
|
|
|
+ vist.client="appraisal";
|
|
|
|
+ }
|
|
if (log.host.Equals("localhost") && log.p.Equals("os"))
|
|
if (log.host.Equals("localhost") && log.p.Equals("os"))
|
|
{
|
|
{
|
|
log.host="IES-测试站";
|
|
log.host="IES-测试站";
|
|
@@ -867,11 +580,12 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
|
|
|
|
//处理IP转地区
|
|
//处理IP转地区
|
|
- vist.region=_ipSearcher.SearchIp(vist.ip);
|
|
|
|
|
|
+ vist.region=await _ipSearcher.SearchIpAsync(vist.ip);
|
|
if (!string.IsNullOrWhiteSpace(vist.region))
|
|
if (!string.IsNullOrWhiteSpace(vist.region))
|
|
{
|
|
{
|
|
|
|
+ vist.region= vist.region.Replace("省·", "·").Replace("市·", "·").Replace("特别行政区·", "·").Replace("藏族羌族自治州·", "·");
|
|
var regions = vist.region.Split("·");
|
|
var regions = vist.region.Split("·");
|
|
- if (regions.Length==4)
|
|
|
|
|
|
+ if (regions.Length==4)
|
|
{
|
|
{
|
|
vist.area= regions[0];
|
|
vist.area= regions[0];
|
|
vist.province = regions[1];
|
|
vist.province = regions[1];
|
|
@@ -894,40 +608,78 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
//处理地区转经纬度
|
|
//处理地区转经纬度
|
|
{
|
|
{
|
|
|
|
+ IEnumerable<JToken> tokens = default;
|
|
if (!string.IsNullOrWhiteSpace(vist.city) && !string.IsNullOrWhiteSpace(vist.province) && !string.IsNullOrWhiteSpace(vist.area))
|
|
if (!string.IsNullOrWhiteSpace(vist.city) && !string.IsNullOrWhiteSpace(vist.province) && !string.IsNullOrWhiteSpace(vist.area))
|
|
{
|
|
{
|
|
- _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.province}/i && @.city=~ /.*{vist.city}/i)]");
|
|
|
|
|
|
+ tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.province}/i && @.city=~ /.*{vist.city}/i)]");
|
|
|
|
+ if (!(tokens.Any() && tokens.Count()>0))
|
|
|
|
+ {
|
|
|
|
+ tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.city}/i && @.city=~ /.*{vist.province}/i)]");
|
|
|
|
+ if (!(tokens.Any() && tokens.Count()>0))
|
|
|
|
+ {
|
|
|
|
+ tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.city}/i || @.city=~ /.*{vist.city}/i)]");
|
|
|
|
+ }
|
|
|
|
+ if (!(tokens.Any() && tokens.Count()>0))
|
|
|
|
+ {
|
|
|
|
+ tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.province}/i||@.city=~ /.*{vist.province}/i)]");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
else if (string.IsNullOrWhiteSpace(vist.city) && !string.IsNullOrWhiteSpace(vist.province) && !string.IsNullOrWhiteSpace(vist.area))
|
|
else if (string.IsNullOrWhiteSpace(vist.city) && !string.IsNullOrWhiteSpace(vist.province) && !string.IsNullOrWhiteSpace(vist.area))
|
|
{
|
|
{
|
|
if (vist.area.Equals("中国"))
|
|
if (vist.area.Equals("中国"))
|
|
{
|
|
{
|
|
- _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.province}/i)]");
|
|
|
|
|
|
+ tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.province}/i)]");
|
|
|
|
+ if (!(tokens.Any() && tokens.Count()>0))
|
|
|
|
+ {
|
|
|
|
+ tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.province}/i)]");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.province}/i || @.province=~ /.*{vist.province}/i)]");
|
|
|
|
|
|
+ tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.province}/i || @.province=~ /.*{vist.province}/i)]");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (!string.IsNullOrWhiteSpace(vist.city) && string.IsNullOrWhiteSpace(vist.province)&& !string.IsNullOrWhiteSpace(vist.area))
|
|
else if (!string.IsNullOrWhiteSpace(vist.city) && string.IsNullOrWhiteSpace(vist.province)&& !string.IsNullOrWhiteSpace(vist.area))
|
|
{
|
|
{
|
|
if (vist.area.Equals("中国"))
|
|
if (vist.area.Equals("中国"))
|
|
{
|
|
{
|
|
- _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.city}/i)]");
|
|
|
|
|
|
+ tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.city}/i)]");
|
|
|
|
+ if (!(tokens.Any() && tokens.Count()>0))
|
|
|
|
+ {
|
|
|
|
+ tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.province}/i)]");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.city}/i || @.city=~ /.*{vist.province}/i)]");
|
|
|
|
|
|
+ tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.city}/i || @.city=~ /.*{vist.province}/i)]");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (string.IsNullOrWhiteSpace(vist.city) && string.IsNullOrWhiteSpace(vist.province)&& !string.IsNullOrWhiteSpace(vist.area))
|
|
else if (string.IsNullOrWhiteSpace(vist.city) && string.IsNullOrWhiteSpace(vist.province)&& !string.IsNullOrWhiteSpace(vist.area))
|
|
{
|
|
{
|
|
- _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.country=~ /.*{vist.area}/i && @.m==1)]");
|
|
|
|
|
|
+ tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.country=~ /.*{vist.area}/i && @.m=='1')]");
|
|
|
|
+ }
|
|
|
|
+ if (tokens!= null && tokens!=default && tokens.Any() && tokens.Count()>0)
|
|
|
|
+ {
|
|
|
|
+ List<RegionLngLat> regionLngLats = new List<RegionLngLat>();
|
|
|
|
+ foreach (JToken token in tokens)
|
|
|
|
+ {
|
|
|
|
+ regionLngLats.Add(token.ToString().ToObject<RegionLngLat>());
|
|
|
|
+ }
|
|
|
|
+ var region = regionLngLats.FindAll(x => string.IsNullOrWhiteSpace(x.area));
|
|
|
|
+ if (!region.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ region= regionLngLats.FindAll(x => !string.IsNullOrWhiteSpace(x.m) && x.m.Equals("1"));
|
|
|
|
+ }
|
|
|
|
+ vist.point= region?.FirstOrDefault();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
vist.host= log.host;
|
|
vist.host= log.host;
|
|
vist.hostName=log.hostName;
|
|
vist.hostName=log.hostName;
|
|
- }
|
|
|
|
|
|
+ uuidInfo.Add((uuid, log, useridMatch, schoolMatch));
|
|
|
|
+ vists.Add(vist);
|
|
|
|
+ });
|
|
return (vists, uuidInfo);
|
|
return (vists, uuidInfo);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1624,6 +1376,7 @@ namespace TEAMModelOS.Controllers
|
|
/// tokenid
|
|
/// tokenid
|
|
/// </summary>
|
|
/// </summary>
|
|
public string tid { get; set; }
|
|
public string tid { get; set; }
|
|
|
|
+ public RegionLngLat point { get; set; }
|
|
}
|
|
}
|
|
|
|
|
|
public class HttpLog
|
|
public class HttpLog
|
|
@@ -1644,4 +1397,14 @@ namespace TEAMModelOS.Controllers
|
|
// public string referer { get; set; }
|
|
// public string referer { get; set; }
|
|
public string scope { get; set; }
|
|
public string scope { get; set; }
|
|
}
|
|
}
|
|
|
|
+ public record RegionLngLat
|
|
|
|
+ {
|
|
|
|
+ public string country { get; set; }
|
|
|
|
+ public string province { get; set; }
|
|
|
|
+ public string city { get; set; }
|
|
|
|
+ public string lat { get; set; }
|
|
|
|
+ public string lng { get; set; }
|
|
|
|
+ public string area { get; set; }
|
|
|
|
+ public string m { get; set; } = "0";
|
|
|
|
+ }
|
|
}
|
|
}
|