|
@@ -97,119 +97,131 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
List<ApiVist> apiVists = new List<ApiVist>();
|
|
|
List<string> times = json.GetProperty("times").ToObject<List<string>>();
|
|
|
- foreach (var time in times)
|
|
|
+ foreach (var timeDate in times)
|
|
|
{
|
|
|
- var BlobClient = _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{time}/index.json");
|
|
|
- string nowMonth = DateTimeOffset.Now.GetGMTTime(8).ToString("yyyy-MM-dd");
|
|
|
- string force = json.GetProperty("force").GetString();
|
|
|
- if (BlobClient.Exists() && !force.Equals("1") && !nowMonth.Equals(time))
|
|
|
- {
|
|
|
- BlobDownloadResult result = await _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{time}/index.json").DownloadContentAsync();
|
|
|
- var vist = result.Content.ToObjectFromJson<List<ApiVist>>();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- 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> files = await _azureStorage.GetBlobContainerClient("0-service-log").List($"http-log/{time}");
|
|
|
- //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"))
|
|
|
- {
|
|
|
- //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("}"))
|
|
|
+ if (DateTimeOffset.TryParse(timeDate, out DateTimeOffset date)) {
|
|
|
+ var BlobClient = _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{date:yyyy}/{date:MM}/{date:dd}/index.json");
|
|
|
+ string nowMonth = DateTimeOffset.Now.GetGMTTime(8).ToString("yyyy-MM-dd");
|
|
|
+ string force = json.GetProperty("force").GetString();
|
|
|
+ if (BlobClient.Exists() && !force.Equals("1") && !nowMonth.Equals(date.ToString("yyyy-MM-dd")))
|
|
|
+ {
|
|
|
+ BlobDownloadResult result = await _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{date:yyyy}/{date:MM}/{date:dd}/index.json").DownloadContentAsync();
|
|
|
+ var vist = result.Content.ToObjectFromJson<List<ApiVist>>();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ 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> files = await _azureStorage.GetBlobContainerClient("0-service-log").List($"http-log/{date:yyyy}/{date:MM}/{date:dd}");
|
|
|
+ //List<HttpLog> logs = new List<HttpLog>();
|
|
|
+ ConcurrentBag<HttpLog> logs = new ConcurrentBag<HttpLog>();
|
|
|
+ // object lockObj = new object();
|
|
|
+
|
|
|
+ files.Find(x => x.Contains("index.json"));
|
|
|
+ await Parallel.ForEachAsync(files, async (file, _) => {
|
|
|
+ if (!file.Contains("index.json"))
|
|
|
{
|
|
|
- content=$"[{content}]";
|
|
|
+ //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}]";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ content=$"[{content}}}]";
|
|
|
+ }
|
|
|
+ var paths = file.Split("/");
|
|
|
+ var hour = paths[paths.Length-1].Replace(".log", "");
|
|
|
+ var httpLogs = content.ToObject<List<HttpLog>>();
|
|
|
+ Parallel.ForEach(httpLogs, item =>
|
|
|
+ {
|
|
|
+ item.year = $"{date:yyyy}";
|
|
|
+ item.month = $"{date:MM}";
|
|
|
+ item.day = $"{date:dd}";
|
|
|
+ item.hour = hour;
|
|
|
+ logs.Add(item);
|
|
|
+ });
|
|
|
}
|
|
|
- else
|
|
|
+ });
|
|
|
+ (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"));
|
|
|
+ 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)>();
|
|
|
+ var tmds = uuidInfos.SelectMany(x => x.tmdid).ToHashSet();
|
|
|
+ if (tmds.Any())
|
|
|
+ {
|
|
|
+ foreach (var tmd in tmds)
|
|
|
{
|
|
|
- content=$"[{content}}}]";
|
|
|
+ var exists = await _azureRedis.GetRedisClient().KeyExistsAsync($"Blob:Catalog:{tmd}");
|
|
|
+ if (exists)
|
|
|
+ {
|
|
|
+ tmdexists.Add((tmd, exists, "teacher"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ exists = await _azureRedis.GetRedisClient().KeyExistsAsync($"Login:School:hbcn:student:{tmd}");
|
|
|
+ tmdexists.Add((tmd, exists, "student"));
|
|
|
+ }
|
|
|
}
|
|
|
- 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"));
|
|
|
- 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)>();
|
|
|
- var tmds = uuidInfos.SelectMany(x => x.tmdid).ToHashSet();
|
|
|
- if (tmds.Any())
|
|
|
- {
|
|
|
- foreach (var tmd in tmds)
|
|
|
+ var schs = uuidInfos.SelectMany(x => x.school).ToHashSet();
|
|
|
+ if (schs.Any())
|
|
|
{
|
|
|
- var exists = await _azureRedis.GetRedisClient().KeyExistsAsync($"Blob:Catalog:{tmd}");
|
|
|
- if (exists)
|
|
|
- {
|
|
|
- tmdexists.Add((tmd, exists, "teacher"));
|
|
|
- }
|
|
|
- else
|
|
|
+ foreach (var sch in schs)
|
|
|
{
|
|
|
- exists = await _azureRedis.GetRedisClient().KeyExistsAsync($"Login:School:hbcn:student:{tmd}");
|
|
|
- tmdexists.Add((tmd, exists, "student"));
|
|
|
+ var exists = await _azureRedis.GetRedisClient().KeyExistsAsync(sch);
|
|
|
+ schexists.Add((sch, exists));
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- var schs = uuidInfos.SelectMany(x => x.school).ToHashSet();
|
|
|
- if (schs.Any())
|
|
|
- {
|
|
|
- foreach (var sch in schs)
|
|
|
+ foreach (var item in uuidInfos)
|
|
|
{
|
|
|
- var exists = await _azureRedis.GetRedisClient().KeyExistsAsync(sch);
|
|
|
- schexists.Add((sch, exists));
|
|
|
- }
|
|
|
- }
|
|
|
- foreach (var item in uuidInfos)
|
|
|
- {
|
|
|
- foreach (var tmd in item.tmdid)
|
|
|
- {
|
|
|
- var tmdext = tmdexists.Find(x => x.tmd.Equals(tmd));
|
|
|
- if (tmdext.tmd!= null && tmdext.exists)
|
|
|
+ foreach (var tmd in item.tmdid)
|
|
|
{
|
|
|
- var vist = vistsDay.Find(x => x.id.Equals(item.uuid));
|
|
|
- if (vist!= null)
|
|
|
+ var tmdext = tmdexists.Find(x => x.tmd.Equals(tmd));
|
|
|
+ if (tmdext.tmd!= null && tmdext.exists)
|
|
|
{
|
|
|
- vist.userId=tmd;
|
|
|
- if (string.IsNullOrWhiteSpace(vist.scope))
|
|
|
+ var vist = vistsDay.Find(x => x.id.Equals(item.uuid));
|
|
|
+ if (vist!= null)
|
|
|
{
|
|
|
- vist.scope=tmdext.scope;
|
|
|
+ vist.userId=tmd;
|
|
|
+ if (string.IsNullOrWhiteSpace(vist.scope))
|
|
|
+ {
|
|
|
+ vist.scope=tmdext.scope;
|
|
|
+ }
|
|
|
}
|
|
|
+ break;
|
|
|
}
|
|
|
- break;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- foreach (var sch in item.school)
|
|
|
- {
|
|
|
- var schext = schexists.Find(x => x.sch.Equals(sch));
|
|
|
- if (schext.sch!= null && schext.exists)
|
|
|
+ foreach (var sch in item.school)
|
|
|
{
|
|
|
- var vist = vistsDay.Find(x => x.id.Equals(item.uuid));
|
|
|
- if (vist!= null)
|
|
|
+ var schext = schexists.Find(x => x.sch.Equals(sch));
|
|
|
+ if (schext.sch!= null && schext.exists)
|
|
|
{
|
|
|
- vist.school=sch;
|
|
|
+ var vist = vistsDay.Find(x => x.id.Equals(item.uuid));
|
|
|
+ if (vist!= null)
|
|
|
+ {
|
|
|
+ vist.school=sch;
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
+ apiVists.AddRange(vistsDay);
|
|
|
}
|
|
|
- apiVists.AddRange(vistsDay);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
return Ok(new { apiVists });
|
|
|
}
|
|
@@ -226,7 +238,20 @@ namespace TEAMModelOS.Controllers
|
|
|
string uuid = Guid.NewGuid().ToString();
|
|
|
List<string> schoolMatch = 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,
|
|
|
+ year=log.year,
|
|
|
+ month=log.month,
|
|
|
+ day=log.day,
|
|
|
+ hour=log.hour
|
|
|
+ };
|
|
|
if (string.IsNullOrWhiteSpace(vist.userId))
|
|
|
{
|
|
|
|
|
@@ -1355,8 +1380,14 @@ namespace TEAMModelOS.Controllers
|
|
|
/// <summary>
|
|
|
/// 细分
|
|
|
/// ies5 ,hiteach,hita,cc,bi,contest,open,aclassone,sokrates,ability,art
|
|
|
+ /// 产品端
|
|
|
/// </summary>
|
|
|
public string client { get; set; }
|
|
|
+ /// <summary>
|
|
|
+ /// 具体功能
|
|
|
+ /// </summary>
|
|
|
+ public string func { get; set; }
|
|
|
+
|
|
|
public string userId { get; set; }
|
|
|
public string scope { get; set; }
|
|
|
public string tname { get; set; }
|
|
@@ -1376,6 +1407,10 @@ namespace TEAMModelOS.Controllers
|
|
|
/// tokenid
|
|
|
/// </summary>
|
|
|
public string tid { get; set; }
|
|
|
+ public string year { get; set; }
|
|
|
+ public string month { get; set; }
|
|
|
+ public string day { get; set; }
|
|
|
+ public string hour { get; set; }
|
|
|
public RegionLngLat point { get; set; }
|
|
|
}
|
|
|
|
|
@@ -1396,6 +1431,11 @@ namespace TEAMModelOS.Controllers
|
|
|
// public string ua { get; set; }
|
|
|
// public string referer { get; set; }
|
|
|
public string scope { get; set; }
|
|
|
+ public string year { get; set; }
|
|
|
+ public string month { get; set; }
|
|
|
+ public string day { get; set; }
|
|
|
+ public string hour { get; set; }
|
|
|
+
|
|
|
}
|
|
|
public record RegionLngLat
|
|
|
{
|