Procházet zdrojové kódy

Merge branch 'develop' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into develop

jeff před 1 rokem
rodič
revize
d520590282

+ 4 - 4
TEAMModelOS.FunctionV4/CosmosDB/TriggerArt.cs

@@ -360,7 +360,7 @@ namespace TEAMModelOS.FunctionV4.CosmosDB
                             {
 
                             }
-                            if (art.publish == 0)
+                            if (art.classes.Any())
                             {
                                 //获取该艺术评测的评测Id
                                 List<(string id, string subjectId)> ids = new();
@@ -671,7 +671,7 @@ namespace TEAMModelOS.FunctionV4.CosmosDB
                                             if (res.score >= 95) {
                                                 res.score = new Random().Next(90, 99);
                                             }*/
-                                            res.score = Math.Round(res.score);
+                                            //res.score = Math.Round(res.score);
                                         }
                                     }
 
@@ -739,7 +739,7 @@ namespace TEAMModelOS.FunctionV4.CosmosDB
                                             totalScore = 100,
                                             id = sj.id,  
                                             type = sj.id,
-                                            block = stuBlocks.Where(c => c.subjectId.Equals(sj.id)).SelectMany(x => x.dim).Where(z => z.stuId.Equals(rs.studentId)).FirstOrDefault().blk,
+                                            block = stuBlocks.Where(c => c.subjectId.Equals(sj.id)).SelectMany(x => x.dim).Where(z => z.stuId.Equals(rs.studentId))?.FirstOrDefault().blk,
                                             kno = studentScores.Where(c => c.stuId.Equals(rs.studentId)).SelectMany(c => c.studentScore).Where(
                                                 p => p.subject.Equals(sj.id)).Select(z => new
                                                 {
@@ -816,7 +816,7 @@ namespace TEAMModelOS.FunctionV4.CosmosDB
 
                     string code = $"Knowledge-{school}-{subjectId}";
                     StringBuilder sql = new StringBuilder($"select value(c) from c");
-                    if (string.IsNullOrWhiteSpace(pId))
+                    if (!string.IsNullOrWhiteSpace(pId))
                     {
                         sql.Append($" where c.periodId = '{pId}'");
                     }

+ 0 - 1
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -17,7 +17,6 @@ using Azure.Storage.Blobs.Models;
 using System.IO;
 using System.Text;
 using System.Text.Json.Nodes;
-using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
 using Newtonsoft.Json.Linq;
 using TEAMModelOS.SDK.Models.Cosmos.Student;
 using HTEXLib.Helpers.ShapeHelpers;

+ 0 - 1
TEAMModelOS.SDK/DI/AzureCosmos/AzureCosmosExtensions.cs

@@ -16,7 +16,6 @@ using System.Text.Json;
 using System.Net;
 using System.Linq.Expressions;
 using TEAMModelOS.SDK;
-using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;

+ 1 - 2
TEAMModelOS.SDK/Helper/Common/JsonHelper/JsonParser.cs

@@ -22,7 +22,7 @@ namespace TEAMModelOS.SDK.Helper.Common.JsonHelper
         public static T[] As<T>(this JsonPathNode[] nodes, T prototype) { return nodes.Select(node => node.As<T>()).ToArray(); }
     }
 
-    public delegate object JsonPathScriptEvaluator(string script, object value,IJsonPathContext context);
+    public delegate object JsonPathScriptEvaluator(string script, object value, IJsonPathContext context);
 
     public sealed class JsonPathSelection
     {
@@ -1788,4 +1788,3 @@ namespace TEAMModelOS.SDK.Helper.Common.JsonHelper
 // THE SOFTWARE.
 //
 #endregion
- 

+ 1 - 1
TEAMModelOS.SDK/Helper/Common/JsonHelper/JsonPath/IJsonPathValueSystem.cs

@@ -4,7 +4,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 
-namespace TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath
+namespace TEAMModelOS.SDK
 {
     public interface IJsonPathValueSystem
     {

+ 70 - 0
TEAMModelOS.SDK/Helper/Common/JsonHelper/JsonPath/JsonNetValueSystem.cs

@@ -0,0 +1,70 @@
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TEAMModelOS.SDK
+{
+   public sealed class JsonNetValueSystem : IJsonPathValueSystem
+    {
+        public bool HasMember(object value, string member)
+        {
+            if (value is JObject)
+                return (value as JObject).Properties().Any(property => property.Name == member);
+            if (value is JArray)
+            {
+                int index = ParseInt(member, -1);
+                return index >= 0 && index < (value as JArray).Count;
+            }
+            return false;
+        }
+
+        public object GetMemberValue(object value, string member)
+        {
+            if (value is JObject)
+            {
+                var memberValue = (value as JObject)[member];
+                return memberValue;
+            }
+            if (value is JArray)
+            {
+                int index = ParseInt(member, -1);
+                return (value as JArray)[index];
+            }
+            return null;
+        }
+
+        public IEnumerable GetMembers(object value)
+        {
+            var jobject = value as JObject;
+            return jobject.Properties().Select(property => property.Name);
+        }
+
+        public bool IsObject(object value)
+        {
+            return value is JObject;
+        }
+
+        public bool IsArray(object value)
+        {
+            return value is JArray;
+        }
+
+        public bool IsPrimitive(object value)
+        {
+            if (value == null)
+                throw new ArgumentNullException("value");
+
+            return value is JObject || value is JArray ? false : true;
+        }
+
+        private int ParseInt(string s, int defaultValue)
+        {
+            int result;
+            return int.TryParse(s, out result) ? result : defaultValue;
+        }
+    }
+}

+ 1 - 1
TEAMModelOS.SDK/Helper/Common/JsonHelper/JsonPath/JsonPathContext.cs

@@ -9,7 +9,7 @@ using System.Text.Json;
 using System.Text.RegularExpressions;
 using TEAMModelOS.SDK;
 
-namespace TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath
+namespace TEAMModelOS.SDK
 {
     /// <summary>
     /// 语法文档  https://www.cnblogs.com/aoyihuashao/p/8665873.html

+ 2 - 3
TEAMModelOS.SDK/Helper/Common/JsonHelper/JsonPath/JsonApiValueSystem.cs

@@ -5,9 +5,8 @@ using System.Linq;
 using System.Text.Json;
 using System.Threading.Tasks;
 
-namespace TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath
-{
-    public class JsonApiValueSystem : IJsonPathValueSystem
+namespace TEAMModelOS.SDK { 
+    public class JsonTextValueSystem : IJsonPathValueSystem
     {
         public bool HasMember(object value, string member)
         {

+ 4 - 4
TEAMModelOS.SDK/Helper/Network/IP2Region/IPSearcher.cs

@@ -386,10 +386,10 @@ namespace TEAMModelOS.SDK
                 if (block != null)
                 {
                     string region = block.Region.Replace("0|0|0|0|", "").Replace("0|0|0|", "").Replace("|0|0|0|0", "").Replace("|0|0|0|", "").Replace("|0|0|0", "").Replace("|0|0|", "").Replace("|0|0", "").Replace("|0|", "·").Replace("|0", "").Replace("|", "·");
-                    if (!string.IsNullOrWhiteSpace(region))
-                    {
-                        region = region.Replace("中国·", "").Replace("中国", "").Replace("台湾省", "台湾");
-                    }
+                    //if (!string.IsNullOrWhiteSpace(region))
+                   // {
+                       // region = region.Replace("中国·", "").Replace("中国", "").Replace("台湾省", "台湾");
+                   // }
                     return region;
                 }
                 else { return null; }

+ 0 - 1
TEAMModelOS.SDK/Helper/Security/RSACrypt/RsaHelper.cs

@@ -4,7 +4,6 @@ using System.Collections.Generic;
 using System.IO;
 using System.Security.Cryptography;
 using System.Text;
-using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 
 namespace TEAMModelOS.SDK.Helper.Security.RSACrypt
 {

+ 2 - 1
TEAMModelOS/ClientApp/src/utils/editorTools.js

@@ -1130,13 +1130,14 @@ export default {
 									img.src = src;
 									// 如果是宽度 则需要根据编辑器的宽度来计算出 拉伸后的高度和宽度
 									img.onload = async () => {
-										let newWidth = editorWidth.optionWidth *
+										let newWidth = (editorWidth.optionWidth || editorWidth.questionWidth) *
 											srcWidth * 0.01
 										let newHeight = newWidth * (img.height / img
 											.width)
 										let newBase64 = await this.compressImg(src,
 											newWidth, newHeight)
 										item = item.replace(src, newBase64)
+										console.log('压缩后', newBase64)
 										r(item)
 									}
 								} else {

+ 0 - 2
TEAMModelOS/Controllers/Analysis/ChangeController.cs

@@ -11,8 +11,6 @@ using System.Threading.Tasks;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
-using TEAMModelOS.SDK.Helper.Common.JsonHelper;
-using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
 using TEAMModelOS.SDK.Helper.Security.ShaHash;
 using TEAMModelOS.SDK.Module.AzureBlob.Container;
 using TEAMModelOS.SDK.Models;

+ 0 - 1
TEAMModelOS/Controllers/Both/SyllabusController.cs

@@ -6,7 +6,6 @@ using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK;
 using System;
-using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using System.Linq;
 using TEAMModelOS.Models;
 using System.Text.Json;

+ 177 - 330
TEAMModelOS/Controllers/System/BillController.cs

@@ -14,12 +14,14 @@ using Microsoft.AspNetCore.Mvc;
 using Microsoft.Azure.Amqp.Framing;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Options;
+using Newtonsoft.Json.Linq;
 using NUnit.Framework;
 using OfficeOpenXml;
 using OpenXmlPowerTools;
 using StackExchange.Redis;
 using System;
 using System.Collections;
+using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.IdentityModel.Tokens.Jwt;
@@ -29,7 +31,9 @@ using System.Net.Http;
 using System.Runtime.Intrinsics.Arm;
 using System.Text;
 using System.Text.Json;
+using System.Text.Json.Nodes;
 using System.Text.RegularExpressions;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Web;
 using TEAMModelOS.Filter;
@@ -37,8 +41,6 @@ using TEAMModelOS.Models;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
-using TEAMModelOS.SDK.Helper.Common.JsonHelper;
-using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
 using TEAMModelOS.SDK.IP2Region;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 using Top.Api;
@@ -57,9 +59,10 @@ namespace TEAMModelOS.Controllers
         private readonly IConfiguration _configuration;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureRedisFactory _azureRedis;
-        private readonly ISearcher _ipSearcher;
+        private readonly IPSearcher _ipSearcher;
         private readonly Option _option;
-        public BillController(IHttpClientFactory httpClient, IConfiguration configuration, AzureStorageFactory azureStorage, ISearcher searcher, DingDing dingDing, IOptionsSnapshot<Option> option)
+        private readonly Region2LongitudeLatitudeTranslator _longitudeLatitudeTranslator;
+        public BillController(AzureRedisFactory azureRedis, Region2LongitudeLatitudeTranslator longitudeLatitudeTranslator, IHttpClientFactory httpClient, IConfiguration configuration, AzureStorageFactory azureStorage, IPSearcher searcher, DingDing dingDing, IOptionsSnapshot<Option> option)
         {
             _httpClient = httpClient;
             _configuration = configuration;
@@ -67,6 +70,8 @@ namespace TEAMModelOS.Controllers
             _ipSearcher = searcher;
             _dingDing = dingDing;
             _option = option.Value;
+            _azureRedis=azureRedis;
+            _longitudeLatitudeTranslator = longitudeLatitudeTranslator;
         }
         /// <summary>
         /// 使用时长,一天内累计
@@ -79,24 +84,18 @@ namespace TEAMModelOS.Controllers
         [RequestSizeLimit(102_400_000_00)] //最大10000m左右
         public async Task<IActionResult> ReportApi(JsonElement json)
         {
-            var reg = _ipSearcher.SearchIp(json.GetProperty("ip").GetString());
-            var untyped = new JsonParser().Parse(json.GetRawText());
-            var selection = new JsonPathSelection(untyped);
+
+
+            var jobject = JObject.Parse(json.GetRawText());
+            string path = "$..[school,id,schoolId,schoolid,schoolCode,school_code,schoolcode,code]";
+            var tks = jobject.SelectTokens(json.GetProperty("path").GetString());
+            foreach (var t in tks)
             {
-                var nodes_id_token = selection.SelectNodes(json.GetProperty("path").GetString());
-                foreach (var node in nodes_id_token)
-                {
-                    if (node.Value is string)
-                    {
-                        Console.WriteLine(node.Value);
-                    }
-                    else
-                    {
-                        return Ok(node);
-                    }
-                }
-                //return Ok(nodes_id_token);
+                var s = $"{t}";
+                return Ok(tks);
             }
+
+            List<ApiVist> apiVists = new List<ApiVist>();
             List<string> times = json.GetProperty("times").ToObject<List<string>>();
             foreach (var time in times)
             {
@@ -113,28 +112,40 @@ namespace TEAMModelOS.Controllers
                     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}");
-                    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"))
                         {
-                            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"));
-
                     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();
@@ -197,35 +208,40 @@ 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();
                 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 };
                 if (string.IsNullOrWhiteSpace(vist.userId))
                 {
-                    var untyped = new JsonParser().Parse(log.param.GetRawText());
-                    var selection = new JsonPathSelection(untyped);
-                    string path = "$..[id_token,idToken,idtoken,tmdid,id,teacherId,teacher,tid,tId,userid,userId,code,studentId,student,studentid]";
 
-                    var nodes_path = selection.SelectNodes(path);
+                    //var jsonPathContext = new JsonPathContext();
+                    //jsonPathContext.ValueSystem= new JsonTextValueSystem();
+                    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());
+                    //var nodes_path = jsonPathContext.SelectNodes(log.param, path);
+
+                    var nodes_path = jsonObject.SelectTokens(path);
                     foreach (var node in nodes_path)
                     {
                         // 只获取是字符串的 
-                        if (node.Value is string)
+                        if (node.Type.Equals(JTokenType.String))
                         {
                             switch (true)
                             {
@@ -233,7 +249,7 @@ namespace TEAMModelOS.Controllers
                                     {
                                         try
                                         {
-                                            var jwt = new JwtSecurityToken($"{node.Value}");
+                                            var jwt = new JwtSecurityToken($"{node}");
                                             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))
@@ -248,23 +264,23 @@ namespace TEAMModelOS.Controllers
                                 ||node.Path.Contains("teacher")||node.Path.Contains("tid")||node.Path.Contains("tId")||node.Path.Contains("userid")
                                 ||node.Path.Contains("userId")||node.Path.Contains("studentId")||node.Path.Contains("student")||node.Path.Contains("studentid"):
                                     {
-                                        if (!string.IsNullOrWhiteSpace($"{node.Value}") && long.TryParse($"{node.Value}", out long _id))
+                                        if (!string.IsNullOrWhiteSpace($"{node}") && long.TryParse($"{node}", out long _id))
                                         {
-                                            useridMatch.Add($"{node.Value}");
+                                            useridMatch.Add($"{node}");
                                         }
                                         break;
                                     }
                                 case bool when node.Path.Contains("code"):
                                     {
-                                        if (!string.IsNullOrWhiteSpace($"{node.Value}"))
+                                        if (!string.IsNullOrWhiteSpace($"{node}"))
                                         {
-                                            if (long.TryParse($"{node.Value}", out long _id))
+                                            if (long.TryParse($"{node}", out long _id))
                                             {
-                                                useridMatch.Add($"{node.Value}");
+                                                useridMatch.Add($"{node}");
                                             }
                                             else
                                             {
-                                                string[] codes = $"{node.Value}".Split("-");
+                                                string[] codes = $"{node}".Split("-");
                                                 foreach (var _code in codes)
                                                 {
                                                     if (long.TryParse(_code, out long _codeid))
@@ -280,213 +296,40 @@ 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))
                 {
-                    var untyped = new JsonParser().Parse(log.param.GetRawText());
-                    var selection = new JsonPathSelection(untyped);
-
-                    string path = "$..[school,id,schoolId,schoolid,schoolCode,school_code,schoolcode,code]";
-                    var nodes_path = selection.SelectNodes(path);
+                    string path = "$..['school','id','schoolId','schoolid','schoolCode','school_code','schoolcode','code']";
+                    JObject jsonObject = JObject.Parse(log.param.GetRawText());
+                    var nodes_path = jsonObject.SelectTokens(path);
                     foreach (var node in nodes_path)
                     {
                         // 只获取是字符串的 
-                        if (node.Value is string)
+                        if (node.Type.Equals(JTokenType.String))
                         {
                             switch (true)
                             {
                                 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"):
-                                    { break; }
+                                    {
+                                        if (!$"{node}".Contains("-")&&  $"{node}".Length<=8)
+                                        {
+                                            schoolMatch.Add($"{node}");
+                                        }
+                                        break;
+                                    }
                                 case bool when node.Path.Contains("code"):
                                     {
-                                        if (!$"{node.Value}".Contains("-")&&  $"{node.Value}".Length<=8)
+                                        if (!$"{node}".Contains("-")&&  $"{node}".Length<=8)
                                         {
-                                            schoolMatch.Add($"{node.Value}");
+                                            schoolMatch.Add($"{node}");
                                         }
                                         else
                                         {
-                                            string[] codes = $"{node.Value}".Split("-");
+                                            string[] codes = $"{node}".Split("-");
                                             foreach (var _code in codes)
                                             {
-                                                if ($"{node.Value}".Length<=8)
+                                                if ($"{node}".Length<=8)
                                                 {
                                                     schoolMatch.Add($"{_code}");
                                                     break;
@@ -495,94 +338,14 @@ namespace TEAMModelOS.Controllers
                                         }
                                         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
                 {
                     if (!string.IsNullOrWhiteSpace(log.client))
@@ -711,8 +474,7 @@ namespace TEAMModelOS.Controllers
                         log.host="hiteachcc.teammodel.cn";
                         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="appraisal.teammodel.cn";
@@ -725,6 +487,12 @@ namespace TEAMModelOS.Controllers
                         log.host="appraisal-test.teammodel.cn";
                         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"))
                     {
                         log.host="IES-测试站";
@@ -812,11 +580,12 @@ namespace TEAMModelOS.Controllers
                 }
 
                 //处理IP转地区
-                vist.region=_ipSearcher.SearchIp(vist.ip);
+                vist.region=await _ipSearcher.SearchIpAsync(vist.ip);
                 if (!string.IsNullOrWhiteSpace(vist.region))
                 {
+                    vist.region= vist.region.Replace("省·", "·").Replace("市·", "·").Replace("特别行政区·", "·").Replace("藏族羌族自治州·", "·");
                     var regions = vist.region.Split("·");
-                    if (regions.Length==4) 
+                    if (regions.Length==4)
                     {
                         vist.area=  regions[0];
                         vist.province   = regions[1];
@@ -838,12 +607,79 @@ namespace TEAMModelOS.Controllers
                     }
                 }
                 //处理地区转经纬度
-                { 
-                   
+                {
+                    IEnumerable<JToken> tokens = default;
+                    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)]");
+                        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))
+                    {
+                        if (vist.area.Equals("中国"))
+                        {
+                            tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.province=~ /.*{vist.province}/i)]");
+                            if (!(tokens.Any() && tokens.Count()>0))
+                            {
+                                tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{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)]");
+                            if (!(tokens.Any() && tokens.Count()>0))
+                            {
+                                tokens= _longitudeLatitudeTranslator.regionJson.SelectTokens($"$..[?(@.city=~ /.*{vist.province}/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')]");
+                    }
+                    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.hostName=log.hostName;
-            }
+                uuidInfo.Add((uuid, log, useridMatch, schoolMatch));
+                vists.Add(vist);
+            });
             return (vists, uuidInfo);
         }
 
@@ -1540,6 +1376,7 @@ namespace TEAMModelOS.Controllers
         /// tokenid
         /// </summary>
         public string tid { get; set; }
+        public RegionLngLat point { get; set; }
     }
 
     public class HttpLog
@@ -1560,4 +1397,14 @@ namespace TEAMModelOS.Controllers
         // public string referer { 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";
+    }
 }

+ 0 - 1
TEAMModelOS/Controllers/System/BlobController.cs

@@ -6,7 +6,6 @@ using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK;
-using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Module.AzureBlob.Configuration;
 using TEAMModelOS.SDK.DI;
 using System.Net.Http;

+ 316 - 315
TEAMModelOS/Controllers/XTest/TestController.cs

@@ -54,7 +54,6 @@ using TEAMModelOS.Models;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
-using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
@@ -2545,325 +2544,327 @@ namespace TEAMModelOS.Controllers
             }
         }
 
-        
-        //自主學習綱領 資料架構測試
-        [HttpPost("test-selflearn-structure")]
-        public async Task<IActionResult> TestSelfLearnStructure(JsonElement json)
-        {
-            string tmid = "1595321354";
-            PaperSimple paper = new PaperSimple()
+
+        /*
+             //自主學習綱領 資料架構測試
+            [HttpPost("test-selflearn-structure")]
+            public async Task<IActionResult> TestSelfLearnStructure(JsonElement json)
             {
-                id = "d774c93c-4af3-76ce-aca4-6e8a3254873b",
-                subjectId = "c5f96ea0-e65c-f15c-dc59-410da564c185",
-                code = "Paper-1595321354",
-                name = "國文洩題試卷",
-                blob = "/exam/0bfe6855-289b-4d7a-b5f5-9a027acf277c/paper/c5f96ea0-e65c-f15c-dc59-410da564c185",
-                scope = "private",
-                multipleRule = 1,
-                point = new List<double>() { 25, 25, 25, 25 },
-                answers = new List<List<string>>() { new List<string>() { "D", "C", "B", "A" } },
-                type = new List<string>() { "single", "single", "single", "single" },
-                field = new List<int>() { 1, 1, 1, 1 }
-            };
-            ////個人課程
-            //主體
-            SelfLearn selfLearnT = new SelfLearn();
-            selfLearnT.code = $"SelfLearn-{tmid}";
-            selfLearnT.id = "a6dc752f-7cae-44a5-9b7b-92cfe71cea14";
-            selfLearnT.scope = "private";
-            selfLearnT.name = "測試課程課綱";
-            selfLearnT.course = new IdName();
-            selfLearnT.course.id = "ae64e6a4-54f3-10df-a7f3-79dbe252d295";
-            selfLearnT.course.name = "測試課程001";
-            selfLearnT.creatorId = $"{tmid}";
-            selfLearnT.creatorName = "Miss Lo";
-            selfLearnT.release = true;
-            selfLearnT.groupLists.Add(new IdName { id = "a986bf87-da87-4bd3-bd90-19ee9fd52836", name = "測試課程名單" });
-            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnT);
-            //節點:章節
-            SelfLearnNode selfLearnNodeTChapter = new SelfLearnNode();
-            selfLearnNodeTChapter.code = $"SelfLearn-{tmid}";
-            selfLearnNodeTChapter.id = "0990cbb6-3228-41d0-aeb0-62209f37dc0d";
-            selfLearnNodeTChapter.name = "第一章節";
-            selfLearnNodeTChapter.selfLearnId = selfLearnT.id;
-            selfLearnNodeTChapter.nodeType = "chapter";
-            selfLearnNodeTChapter.openType = "order";
-            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnNodeTChapter);
-            //節點:項目
-            SelfLearnNode selfLearnNodeTContent = new SelfLearnNode();
-            selfLearnNodeTContent.code = $"SelfLearn-{tmid}";
-            selfLearnNodeTContent.id = "5627184f-e9b4-4ceb-a1d0-47727db569b1";
-            selfLearnNodeTContent.name = "四則運算";
-            selfLearnNodeTContent.selfLearnId = selfLearnT.id;
-            selfLearnNodeTContent.selfLearnNodeId = selfLearnNodeTChapter.id;
-            selfLearnNodeTContent.nodeType = "content";
-            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnNodeTContent);
-            //內容:評量
-            SelfLearnContentExam selfLearnTContentExam = new SelfLearnContentExam();
-            selfLearnTContentExam.code = $"SelfLearn-{tmid}";
-            selfLearnTContentExam.id = "07e6fdd2-6083-4eb6-ac6d-06421edb0b48";
-            selfLearnTContentExam.name = "隨堂測驗1";
-            selfLearnTContentExam.selfLearnNodeId = selfLearnNodeTContent.id;
-            selfLearnTContentExam.contentType = "exam";
-            selfLearnTContentExam.examInfo.code = $"Exam-{tmid}";
-            selfLearnTContentExam.examInfo.scope = "private";
-            selfLearnTContentExam.examInfo.owner = "teacher";
-            selfLearnTContentExam.examInfo.creatorId = tmid;
-            selfLearnTContentExam.examInfo.source = "0";
-            selfLearnTContentExam.examInfo.qamode = 0;
-            selfLearnTContentExam.examInfo.stuLists.Add("a986bf87-da87-4bd3-bd90-19ee9fd52836");
-            selfLearnTContentExam.examInfo.subjects = new List<ExamSubject>();
-            ExamSubject privateExamSubject = new ExamSubject();
-            privateExamSubject.id = "e1d817e5-71b3-bc50-52ac-fa828e5f38d6";
-            privateExamSubject.name = "test";
-            privateExamSubject.classCount = 0;
-            selfLearnTContentExam.examInfo.subjects.Add(privateExamSubject);
-            selfLearnTContentExam.examInfo.papers.Add(paper);
-            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnTContentExam);
-
-            ////學校課程
-            //主體
-            SelfLearn selfLearnS = new SelfLearn();
-            selfLearnS.pk = "SelfLearn";
-            selfLearnS.code = $"SelfLearn-{tmid}";
-            selfLearnS.id = "f05f79f2-c58d-4e27-8214-48385e2ac3cd";
-            selfLearnS.scope = "private";
-            selfLearnS.school = "hbgl";
-            selfLearnS.name = "數學一年級上學期課綱";
-            selfLearnS.subject = new IdName();
-            selfLearnS.subject.id = "c5f96ea0-e65c-f15c-dc59-410da564c185";
-            selfLearnS.subject.name = "數學";
-            selfLearnS.period = new IdName();
-            selfLearnS.period.id = "127e71a7-0ca8-82b8-476b-5269b78066f7";
-            selfLearnS.period.name = "測試國中";
-            selfLearnS.course = new IdName();
-            selfLearnS.course.id = "0d4fa541-ad4f-bee1-c604-764275f6d10e";
-            selfLearnS.course.name = "數學一";
-            selfLearnS.creatorId = $"{tmid}";
-            selfLearnS.creatorName = "Miss Lo";
-            selfLearnS.release = true;
-            selfLearnS.classes.Add(new IdName { id = "d3090c56-21de-4cc8-a962-a7e7eaa2e913", name = "2023年A班" });
-            selfLearnS.groupLists.Add(new IdName { id = "54a39ec1-be0b-43cd-a978-f3133552f291", name = "七年A班" });
-            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnS);
-            //節點:章節
-            SelfLearnNode selfLearnNodeSChapter = new SelfLearnNode();
-            selfLearnNodeSChapter.code = $"SelfLearn-{tmid}";
-            selfLearnNodeSChapter.id = "77172663-aa17-44c6-8259-61870c44121f";
-            selfLearnNodeSChapter.name = "第一章節";
-            selfLearnNodeSChapter.selfLearnId = selfLearnS.id;
-            selfLearnNodeSChapter.nodeType = "chapter";
-            selfLearnNodeSChapter.openType = "order";
-            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnNodeSChapter);
-            //節點:項目
-            SelfLearnNode selfLearnNodeSContent = new SelfLearnNode();
-            selfLearnNodeSContent.code = $"SelfLearn-{tmid}";
-            selfLearnNodeSContent.id = "f28c6ecd-38a6-4edb-9160-363a116b8c3b";
-            selfLearnNodeSContent.name = "四則運算";
-            selfLearnNodeSContent.selfLearnId = selfLearnS.id;
-            selfLearnNodeSContent.selfLearnNodeId = selfLearnNodeSChapter.id;
-            selfLearnNodeSContent.nodeType = "content";
-            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnNodeSContent);
-            //內容:評量
-            SelfLearnContentExam selfLearnSContentExam = new SelfLearnContentExam();
-            selfLearnSContentExam.code = $"SelfLearn-{tmid}";
-            selfLearnSContentExam.id = "3f088f49-fefa-4af5-a324-c577ffb6d1f8";
-            selfLearnSContentExam.name = "隨堂測驗1";
-            selfLearnSContentExam.selfLearnNodeId = selfLearnNodeSContent.id;
-            selfLearnSContentExam.contentType = "exam";
-            selfLearnSContentExam.examInfo.papers.Add(paper);
-            await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnSContentExam);
+                string tmid = "1595321354";
+                PaperSimple paper = new PaperSimple()
+                {
+                    id = "d774c93c-4af3-76ce-aca4-6e8a3254873b",
+                    subjectId = "c5f96ea0-e65c-f15c-dc59-410da564c185",
+                    code = "Paper-1595321354",
+                    name = "國文洩題試卷",
+                    blob = "/exam/0bfe6855-289b-4d7a-b5f5-9a027acf277c/paper/c5f96ea0-e65c-f15c-dc59-410da564c185",
+                    scope = "private",
+                    multipleRule = 1,
+                    point = new List<double>() { 25, 25, 25, 25 },
+                    answers = new List<List<string>>() { new List<string>() { "D", "C", "B", "A" } },
+                    type = new List<string>() { "single", "single", "single", "single" },
+                    field = new List<int>() { 1, 1, 1, 1 }
+                };
+                ////個人課程
+                //主體
+                SelfLearn selfLearnT = new SelfLearn();
+                selfLearnT.code = $"SelfLearn-{tmid}";
+                selfLearnT.id = "a6dc752f-7cae-44a5-9b7b-92cfe71cea14";
+                selfLearnT.scope = "private";
+                selfLearnT.name = "測試課程課綱";
+                selfLearnT.course = new IdName();
+                selfLearnT.course.id = "ae64e6a4-54f3-10df-a7f3-79dbe252d295";
+                selfLearnT.course.name = "測試課程001";
+                selfLearnT.creatorId = $"{tmid}";
+                selfLearnT.creatorName = "Miss Lo";
+                selfLearnT.release = true;
+                selfLearnT.groupLists.Add(new IdName { id = "a986bf87-da87-4bd3-bd90-19ee9fd52836", name = "測試課程名單" });
+                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnT);
+                //節點:章節
+                SelfLearnNode selfLearnNodeTChapter = new SelfLearnNode();
+                selfLearnNodeTChapter.code = $"SelfLearn-{tmid}";
+                selfLearnNodeTChapter.id = "0990cbb6-3228-41d0-aeb0-62209f37dc0d";
+                selfLearnNodeTChapter.name = "第一章節";
+                selfLearnNodeTChapter.selfLearnId = selfLearnT.id;
+                selfLearnNodeTChapter.nodeType = "chapter";
+                selfLearnNodeTChapter.openType = "order";
+                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnNodeTChapter);
+                //節點:項目
+                SelfLearnNode selfLearnNodeTContent = new SelfLearnNode();
+                selfLearnNodeTContent.code = $"SelfLearn-{tmid}";
+                selfLearnNodeTContent.id = "5627184f-e9b4-4ceb-a1d0-47727db569b1";
+                selfLearnNodeTContent.name = "四則運算";
+                selfLearnNodeTContent.selfLearnId = selfLearnT.id;
+                selfLearnNodeTContent.selfLearnNodeId = selfLearnNodeTChapter.id;
+                selfLearnNodeTContent.nodeType = "content";
+                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnNodeTContent);
+                //內容:評量
+                SelfLearnContentExam selfLearnTContentExam = new SelfLearnContentExam();
+                selfLearnTContentExam.code = $"SelfLearn-{tmid}";
+                selfLearnTContentExam.id = "07e6fdd2-6083-4eb6-ac6d-06421edb0b48";
+                selfLearnTContentExam.name = "隨堂測驗1";
+                selfLearnTContentExam.selfLearnNodeId = selfLearnNodeTContent.id;
+                selfLearnTContentExam.contentType = "exam";
+                selfLearnTContentExam.examInfo.code = $"Exam-{tmid}";
+                selfLearnTContentExam.examInfo.scope = "private";
+                selfLearnTContentExam.examInfo.owner = "teacher";
+                selfLearnTContentExam.examInfo.creatorId = tmid;
+                selfLearnTContentExam.examInfo.source = "0";
+                selfLearnTContentExam.examInfo.qamode = 0;
+                selfLearnTContentExam.examInfo.stuLists.Add("a986bf87-da87-4bd3-bd90-19ee9fd52836");
+                selfLearnTContentExam.examInfo.subjects = new List<ExamSubject>();
+                ExamSubject privateExamSubject = new ExamSubject();
+                privateExamSubject.id = "e1d817e5-71b3-bc50-52ac-fa828e5f38d6";
+                privateExamSubject.name = "test";
+                privateExamSubject.classCount = 0;
+                selfLearnTContentExam.examInfo.subjects.Add(privateExamSubject);
+                selfLearnTContentExam.examInfo.papers.Add(paper);
+                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnTContentExam);
+
+                ////學校課程
+                //主體
+                SelfLearn selfLearnS = new SelfLearn();
+                selfLearnS.pk = "SelfLearn";
+                selfLearnS.code = $"SelfLearn-{tmid}";
+                selfLearnS.id = "f05f79f2-c58d-4e27-8214-48385e2ac3cd";
+                selfLearnS.scope = "private";
+                selfLearnS.school = "hbgl";
+                selfLearnS.name = "數學一年級上學期課綱";
+                selfLearnS.subject = new IdName();
+                selfLearnS.subject.id = "c5f96ea0-e65c-f15c-dc59-410da564c185";
+                selfLearnS.subject.name = "數學";
+                selfLearnS.period = new IdName();
+                selfLearnS.period.id = "127e71a7-0ca8-82b8-476b-5269b78066f7";
+                selfLearnS.period.name = "測試國中";
+                selfLearnS.course = new IdName();
+                selfLearnS.course.id = "0d4fa541-ad4f-bee1-c604-764275f6d10e";
+                selfLearnS.course.name = "數學一";
+                selfLearnS.creatorId = $"{tmid}";
+                selfLearnS.creatorName = "Miss Lo";
+                selfLearnS.release = true;
+                selfLearnS.classes.Add(new IdName { id = "d3090c56-21de-4cc8-a962-a7e7eaa2e913", name = "2023年A班" });
+                selfLearnS.groupLists.Add(new IdName { id = "54a39ec1-be0b-43cd-a978-f3133552f291", name = "七年A班" });
+                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnS);
+                //節點:章節
+                SelfLearnNode selfLearnNodeSChapter = new SelfLearnNode();
+                selfLearnNodeSChapter.code = $"SelfLearn-{tmid}";
+                selfLearnNodeSChapter.id = "77172663-aa17-44c6-8259-61870c44121f";
+                selfLearnNodeSChapter.name = "第一章節";
+                selfLearnNodeSChapter.selfLearnId = selfLearnS.id;
+                selfLearnNodeSChapter.nodeType = "chapter";
+                selfLearnNodeSChapter.openType = "order";
+                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnNodeSChapter);
+                //節點:項目
+                SelfLearnNode selfLearnNodeSContent = new SelfLearnNode();
+                selfLearnNodeSContent.code = $"SelfLearn-{tmid}";
+                selfLearnNodeSContent.id = "f28c6ecd-38a6-4edb-9160-363a116b8c3b";
+                selfLearnNodeSContent.name = "四則運算";
+                selfLearnNodeSContent.selfLearnId = selfLearnS.id;
+                selfLearnNodeSContent.selfLearnNodeId = selfLearnNodeSChapter.id;
+                selfLearnNodeSContent.nodeType = "content";
+                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnNodeSContent);
+                //內容:評量
+                SelfLearnContentExam selfLearnSContentExam = new SelfLearnContentExam();
+                selfLearnSContentExam.code = $"SelfLearn-{tmid}";
+                selfLearnSContentExam.id = "3f088f49-fefa-4af5-a324-c577ffb6d1f8";
+                selfLearnSContentExam.name = "隨堂測驗1";
+                selfLearnSContentExam.selfLearnNodeId = selfLearnNodeSContent.id;
+                selfLearnSContentExam.contentType = "exam";
+                selfLearnSContentExam.examInfo.papers.Add(paper);
+                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(selfLearnSContentExam);
 
-            return Ok();
+                return Ok();
 
-        }
-        //自主學習綱領 生成評量架構測試
-        public async void TestSelfLearnCreateExam(JsonElement json)
-        {
-            string tmid = "1595321354";
-            long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-            //取得自主學習綱領內容
-            string contentExamCode = $"SelfLearn-{tmid}";
-            string contentExamId = "3f088f49-fefa-4af5-a324-c577ffb6d1f8";
-            SelfLearnContentExam contentExam = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<SelfLearnContentExam>(contentExamId, new PartitionKey(contentExamCode));
-            if (contentExam != null)
+            }
+            //自主學習綱領 生成評量架構測試
+            public async void TestSelfLearnCreateExam(JsonElement json)
             {
-                ExamInfo exam = new ExamInfo();
-                exam.ttl = -1;
+                string tmid = "1595321354";
+                long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                //取得自主學習綱領內容
+                string contentExamCode = $"SelfLearn-{tmid}";
+                string contentExamId = "3f088f49-fefa-4af5-a324-c577ffb6d1f8";
+                SelfLearnContentExam contentExam = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<SelfLearnContentExam>(contentExamId, new PartitionKey(contentExamCode));
+                if (contentExam != null)
+                {
+                    ExamInfo exam = new ExamInfo();
+                    exam.ttl = -1;
+                }
+                //{
+                //  "pk": "Exam",
+                //  "id": null,
+                //  "code": "1595321354",
+                //  "school": "tbslgb",
+                //  "name": "國文洩題試卷",
+                //  "creatorId": "1595321354",
+                //  "type": "",
+                //  "subjects": [
+                //    {
+                //      "id": "e1d817e5-71b3-bc50-52ac-fa828e5f38d6",
+                //      "name": "test"
+                //    }
+                //  ],
+                //  "grades": [],
+                //  "papers": [
+                //    {
+                //      "id": "d774c93c-4af3-76ce-aca4-6e8a3254873b",
+                //      "code": "Paper-1595321354",
+                //      "name": "國文洩題試卷",
+                //      "blob": "/paper/國文洩題試卷",
+                //      "scope": "private",
+                //      "sheet": null,
+                //      "periodId": null,
+                //      "multipleRule": 1,
+                //      "answers": [
+                //        [
+                //          "D"
+                //        ],
+                //        [
+                //          "C"
+                //        ],
+                //        [
+                //          "B"
+                //        ],
+                //        [
+                //          "A"
+                //        ]
+                //      ],
+                //      "point": [
+                //        25,
+                //        25,
+                //        25,
+                //        25
+                //      ],
+                //      "knowledge": [
+                //        [],
+                //        [],
+                //        [],
+                //        []
+                //      ],
+                //      "field": [
+                //        1,
+                //        1,
+                //        1,
+                //        1
+                //      ],
+                //      "type": [
+                //        "single",
+                //        "single",
+                //        "single",
+                //        "single"
+                //      ],
+                //      "subjectName": "test",
+                //      "subjectId": "e1d817e5-71b3-bc50-52ac-fa828e5f38d6"
+                //    }
+                //  ],
+                //  "examType": null,
+                //  "year": 2024,
+                //  "source": "0",
+                //  "classes": [],
+                //  "stuLists": [
+                //    "4dd434a8-a94a-4373-9a05-1a1add533a71"
+                //  ],
+                //  "targets": [
+                //    [
+                //      "e1d817e5-71b3-bc50-52ac-fa828e5f38d6",
+                //      "4dd434a8-a94a-4373-9a05-1a1add533a71"
+                //    ]
+                //  ],
+                //  "startTime": -1,
+                //  "endTime": 1710604799999,
+                //  "scope": "private",
+                //  "createDate": 1710472208137,
+                //  "owner": "teacher",
+                //  "isCompletion": 0
+                //}{
+                //  "pk": "Exam",
+                //  "id": null,
+                //  "code": "1595321354",
+                //  "school": "tbslgb",
+                //  "name": "國文洩題試卷",
+                //  "creatorId": "1595321354",
+                //  "type": "",
+                //  "subjects": [
+                //    {
+                //      "id": "e1d817e5-71b3-bc50-52ac-fa828e5f38d6",
+                //      "name": "test"
+                //    }
+                //  ],
+                //  "grades": [],
+                //  "papers": [
+                //    {
+                //      "id": "d774c93c-4af3-76ce-aca4-6e8a3254873b",
+                //      "code": "Paper-1595321354",
+                //      "name": "國文洩題試卷",
+                //      "blob": "/paper/國文洩題試卷",
+                //      "scope": "private",
+                //      "sheet": null,
+                //      "periodId": null,
+                //      "multipleRule": 1,
+                //      "answers": [
+                //        [
+                //          "D"
+                //        ],
+                //        [
+                //          "C"
+                //        ],
+                //        [
+                //          "B"
+                //        ],
+                //        [
+                //          "A"
+                //        ]
+                //      ],
+                //      "point": [
+                //        25,
+                //        25,
+                //        25,
+                //        25
+                //      ],
+                //      "knowledge": [
+                //        [],
+                //        [],
+                //        [],
+                //        []
+                //      ],
+                //      "field": [
+                //        1,
+                //        1,
+                //        1,
+                //        1
+                //      ],
+                //      "type": [
+                //        "single",
+                //        "single",
+                //        "single",
+                //        "single"
+                //      ],
+                //      "subjectName": "test",
+                //      "subjectId": "e1d817e5-71b3-bc50-52ac-fa828e5f38d6"
+                //    }
+                //  ],
+                //  "examType": null,
+                //  "year": 2024,
+                //  "source": "0",
+                //  "classes": [],
+                //  "stuLists": [
+                //    "4dd434a8-a94a-4373-9a05-1a1add533a71"
+                //  ],
+                //  "targets": [
+                //    [
+                //      "e1d817e5-71b3-bc50-52ac-fa828e5f38d6",
+                //      "4dd434a8-a94a-4373-9a05-1a1add533a71"
+                //    ]
+                //  ],
+                //  "startTime": -1,
+                //  "endTime": 1710604799999,
+                //  "scope": "private",
+                //  "createDate": 1710472208137,
+                //  "owner": "teacher",
+                //  "isCompletion": 0
+                //}
             }
-            //{
-            //  "pk": "Exam",
-            //  "id": null,
-            //  "code": "1595321354",
-            //  "school": "tbslgb",
-            //  "name": "國文洩題試卷",
-            //  "creatorId": "1595321354",
-            //  "type": "",
-            //  "subjects": [
-            //    {
-            //      "id": "e1d817e5-71b3-bc50-52ac-fa828e5f38d6",
-            //      "name": "test"
-            //    }
-            //  ],
-            //  "grades": [],
-            //  "papers": [
-            //    {
-            //      "id": "d774c93c-4af3-76ce-aca4-6e8a3254873b",
-            //      "code": "Paper-1595321354",
-            //      "name": "國文洩題試卷",
-            //      "blob": "/paper/國文洩題試卷",
-            //      "scope": "private",
-            //      "sheet": null,
-            //      "periodId": null,
-            //      "multipleRule": 1,
-            //      "answers": [
-            //        [
-            //          "D"
-            //        ],
-            //        [
-            //          "C"
-            //        ],
-            //        [
-            //          "B"
-            //        ],
-            //        [
-            //          "A"
-            //        ]
-            //      ],
-            //      "point": [
-            //        25,
-            //        25,
-            //        25,
-            //        25
-            //      ],
-            //      "knowledge": [
-            //        [],
-            //        [],
-            //        [],
-            //        []
-            //      ],
-            //      "field": [
-            //        1,
-            //        1,
-            //        1,
-            //        1
-            //      ],
-            //      "type": [
-            //        "single",
-            //        "single",
-            //        "single",
-            //        "single"
-            //      ],
-            //      "subjectName": "test",
-            //      "subjectId": "e1d817e5-71b3-bc50-52ac-fa828e5f38d6"
-            //    }
-            //  ],
-            //  "examType": null,
-            //  "year": 2024,
-            //  "source": "0",
-            //  "classes": [],
-            //  "stuLists": [
-            //    "4dd434a8-a94a-4373-9a05-1a1add533a71"
-            //  ],
-            //  "targets": [
-            //    [
-            //      "e1d817e5-71b3-bc50-52ac-fa828e5f38d6",
-            //      "4dd434a8-a94a-4373-9a05-1a1add533a71"
-            //    ]
-            //  ],
-            //  "startTime": -1,
-            //  "endTime": 1710604799999,
-            //  "scope": "private",
-            //  "createDate": 1710472208137,
-            //  "owner": "teacher",
-            //  "isCompletion": 0
-            //}{
-            //  "pk": "Exam",
-            //  "id": null,
-            //  "code": "1595321354",
-            //  "school": "tbslgb",
-            //  "name": "國文洩題試卷",
-            //  "creatorId": "1595321354",
-            //  "type": "",
-            //  "subjects": [
-            //    {
-            //      "id": "e1d817e5-71b3-bc50-52ac-fa828e5f38d6",
-            //      "name": "test"
-            //    }
-            //  ],
-            //  "grades": [],
-            //  "papers": [
-            //    {
-            //      "id": "d774c93c-4af3-76ce-aca4-6e8a3254873b",
-            //      "code": "Paper-1595321354",
-            //      "name": "國文洩題試卷",
-            //      "blob": "/paper/國文洩題試卷",
-            //      "scope": "private",
-            //      "sheet": null,
-            //      "periodId": null,
-            //      "multipleRule": 1,
-            //      "answers": [
-            //        [
-            //          "D"
-            //        ],
-            //        [
-            //          "C"
-            //        ],
-            //        [
-            //          "B"
-            //        ],
-            //        [
-            //          "A"
-            //        ]
-            //      ],
-            //      "point": [
-            //        25,
-            //        25,
-            //        25,
-            //        25
-            //      ],
-            //      "knowledge": [
-            //        [],
-            //        [],
-            //        [],
-            //        []
-            //      ],
-            //      "field": [
-            //        1,
-            //        1,
-            //        1,
-            //        1
-            //      ],
-            //      "type": [
-            //        "single",
-            //        "single",
-            //        "single",
-            //        "single"
-            //      ],
-            //      "subjectName": "test",
-            //      "subjectId": "e1d817e5-71b3-bc50-52ac-fa828e5f38d6"
-            //    }
-            //  ],
-            //  "examType": null,
-            //  "year": 2024,
-            //  "source": "0",
-            //  "classes": [],
-            //  "stuLists": [
-            //    "4dd434a8-a94a-4373-9a05-1a1add533a71"
-            //  ],
-            //  "targets": [
-            //    [
-            //      "e1d817e5-71b3-bc50-52ac-fa828e5f38d6",
-            //      "4dd434a8-a94a-4373-9a05-1a1add533a71"
-            //    ]
-            //  ],
-            //  "startTime": -1,
-            //  "endTime": 1710604799999,
-            //  "scope": "private",
-            //  "createDate": 1710472208137,
-            //  "owner": "teacher",
-            //  "isCompletion": 0
-            //}
-        }
+         */
 
     }
 }

+ 4 - 1
TEAMModelOS/Filter/IpToRegion.cs

@@ -12,6 +12,10 @@ namespace TEAMModelOS
             {
                 ip = "127.0.0.1";
             }
+            if (ip.Equals("0:0:0:0:0:0:0:1"))
+            {
+                ip = "127.0.0.1";
+            }
             try
             {
                 string region = _ipSearcher.Search(ip);
@@ -25,7 +29,6 @@ namespace TEAMModelOS
                     return region;
                 }
                 else { return null; }
-
             }
             catch (Exception)
             {

+ 7 - 3
TEAMModelOS/Filter/Region2LongitudeLatitudeTranslator.cs

@@ -1,13 +1,16 @@
-using System.IO;
+using Newtonsoft.Json.Linq;
+using System.IO;
 using System.Text;
 using System.Text.Json;
 using TEAMModelOS.SDK.Extension;
+using Top.Api;
 
 namespace TEAMModelOS.Filter
 {
     public class Region2LongitudeLatitudeTranslator
     {
-        public readonly JsonElement regionJson;
+
+        public readonly JArray regionJson;
         public Region2LongitudeLatitudeTranslator(string configPath) {
             StreamReader streamReader = new StreamReader(new FileStream(configPath + "/latlng.json", FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.UTF8);
             StringBuilder stringBuilder = new StringBuilder();
@@ -18,7 +21,8 @@ namespace TEAMModelOS.Filter
             }
             streamReader.Close();
             string input = stringBuilder.ToString();
-            input.ToObject<JsonElement>();
+            regionJson=  JArray.Parse(input);
+           
         }
     }
 }

binární
TEAMModelOS/JsonFile/Core/ip2region.xdb


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 4012 - 21
TEAMModelOS/JsonFile/Core/latlng.json


+ 1 - 1
TEAMModelOS/Startup.cs

@@ -164,7 +164,7 @@ namespace TEAMModelOS
             services.AddHtexTranslator(path);
             services.TryAddSingleton(new Region2LongitudeLatitudeTranslator(path));
             services.AddIPSearcher(path);
-            services.AddSingleton<ISearcher>(new Searcher(CachePolicy.File, Path.Combine(path, "ip2region.xdb")));
+            //services.AddSingleton<ISearcher>(new Searcher(CachePolicy.VectorIndex, Path.Combine(path, "ip2region.xdb")));
             services.AddServerSentEvents(o =>
             {
                 o.KeepaliveMode = ServerSentEventsKeepaliveMode.Always;

+ 1 - 1
TEAMModelOS/TEAMModelOS.csproj

@@ -8,7 +8,7 @@
 	<PackageReference Include="DinkToPdf" Version="1.0.8" />
 	<PackageReference Include="EPPlus" Version="6.2.6" />
 	<PackageReference Include="IP2Region.Net" Version="2.0.2" />
-	<PackageReference Include="JsonPath.Net" Version="0.7.1" />
+	<PackageReference Include="JsonPath.Net" Version="1.0.0" />
     <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
 	<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="2.20.0" />
 	<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />