|
@@ -21,6 +21,10 @@ using TEAMModelOS.SDK.Models.Table;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using TEAMModelOS.Models;
|
|
|
using Microsoft.Azure.Cosmos.Table;
|
|
|
+using DocumentFormat.OpenXml.Spreadsheet;
|
|
|
+using System.Text.Json;
|
|
|
+using HTEXLib.DOCX.Models;
|
|
|
+using static TEAMModelOS.SDK.CoreAPIHttpService;
|
|
|
|
|
|
namespace TEAMModelOS.SDK.DI
|
|
|
{
|
|
@@ -328,6 +332,52 @@ namespace TEAMModelOS.SDK.DI
|
|
|
_ = dingDing.SendBotMsg($"日志保存失败:{ex.Message}\n{ex.StackTrace},,{log.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public static async Task SaveLogLang(this AzureStorageFactory azureStorage, string type,string rootPath, Dictionary<string, object> replaceData, DingDing dingDing, string scope = null, string bizId = null, Option option = null, HttpContext httpContext = null)
|
|
|
+ {
|
|
|
+ string msg = FileWay.FileValue(rootPath, "zh-cn", type, replaceData);
|
|
|
+ var table = azureStorage.GetCloudTableClient().GetTableReference("IESOptLog");
|
|
|
+ OptLog log = new() { RowKey = Guid.NewGuid().ToString() };
|
|
|
+ try
|
|
|
+ {
|
|
|
+ object id = null, school = null, name = null, website = null;
|
|
|
+ httpContext?.Items.TryGetValue("ID", out id);
|
|
|
+ httpContext?.Items.TryGetValue("School", out school);
|
|
|
+ httpContext?.Items.TryGetValue("Name", out name);
|
|
|
+ httpContext?.Items.TryGetValue("Website", out website);
|
|
|
+ log.tmdId = id != null ? $"{id}" : log.tmdId;
|
|
|
+ log.name = name != null ? $"{name}" : log.name;
|
|
|
+ string host = httpContext?.Request?.Host.Value;
|
|
|
+ log.school = school != null ? $"{school}" : log.school;
|
|
|
+ log.PartitionKey = type != null ? $"Log-{type}" : "Log-Default";
|
|
|
+ log.RowKey = bizId != null ? bizId : log.RowKey;
|
|
|
+ log.platform = website != null ? $"{website}" : "Default";
|
|
|
+ log.msg = msg;
|
|
|
+ log.tmsg = FileWay.FileValue(rootPath, "zh-tw", type, replaceData);
|
|
|
+ log.emsg = FileWay.FileValue(rootPath, "en-us", type, replaceData);
|
|
|
+ log.type = type;
|
|
|
+ log.scope = scope;
|
|
|
+ host = !string.IsNullOrWhiteSpace($"{host}") ? $"{host}" : option?.Location != null ? $"{host}" : "Default";
|
|
|
+ log.url = $"{host}{httpContext?.Request.Path}";
|
|
|
+ if (!string.IsNullOrWhiteSpace(msg) && msg.Length > 256)
|
|
|
+ {
|
|
|
+ log.saveMod = 1;
|
|
|
+ log.jsonfile = $"/0-public/optlog/{log.RowKey}-{log.PartitionKey}.json";
|
|
|
+ await azureStorage.GetBlobContainerClient("0-public").UploadFileByContainer(log.ToJsonString(), "optlog", $"{log.RowKey}-{log.PartitionKey}.json");
|
|
|
+ log.msg = null;
|
|
|
+ await table.SaveOrUpdate<OptLog>(log);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await table.SaveOrUpdate<OptLog>(log);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ _ = dingDing.SendBotMsg($"日志保存失败:{ex.Message}\n{ex.StackTrace},,{log.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ }
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 系统管理员 资源,题目关联,htex关联,学习活动学生上传文件关联,基本信息关联,教室平面图关联,评测冷数据关联
|
|
|
/// "system": [ "res", "item", "htex", "task", "info", "room", "exam" ],
|