diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..4b3c87f
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,19 @@
+# Git - gitattributes Documentation
+# https://git-scm.com/docs/gitattributes
+
+
+
+# 禁用所有文件的换行符自动转换
+* -text
+
+
+
+# 机器生成的文件
+# Unity *.meta 所有平台下换行符均为 LF
+*.meta text eol=lf
+
+
+
+# 人类编写的文件
+# C# 代码
+*.cs text eol=lf
diff --git a/Controllers/IDIS_DiagnosisController.cs b/Controllers/IDIS_DiagnosisController.cs
new file mode 100644
index 0000000..8c29ddf
--- /dev/null
+++ b/Controllers/IDIS_DiagnosisController.cs
@@ -0,0 +1,24 @@
+using IDIS;
+using IDIS_Server_SIM.Extensions;
+using CAICT.IDIS.Service;
+using Microsoft.AspNetCore.Mvc;
+
+namespace CN.CAICT.IDIS.Controllers;
+
+///
+/// 诊断控制器
+///
+[ApiController]
+public class IDIS_DiagnosisController:Controller
+{
+ ///
+ /// 诊断,使用该接口确保应用运行中
+ ///
+ ///
+ [HttpGet]
+ [Route("/api/diagnosis")]
+ public string Diagnose()
+ {
+ return "OK";
+ }
+}
\ No newline at end of file
diff --git a/IDIS_Server-SIM/Controllers/IDIS_ServiceController.cs b/Controllers/IDIS_ServiceController.cs
similarity index 94%
rename from IDIS_Server-SIM/Controllers/IDIS_ServiceController.cs
rename to Controllers/IDIS_ServiceController.cs
index 6ce525e..d2386be 100644
--- a/IDIS_Server-SIM/Controllers/IDIS_ServiceController.cs
+++ b/Controllers/IDIS_ServiceController.cs
@@ -1,11 +1,11 @@
using BITKit;
using IDIS;
-using IDIS.Models;
-using IDIS.Services;
+using CAICT.IDIS;
+using CAICT.IDIS.Service;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
-namespace IDIS_Server_SIM.Controllers;
+namespace CN.CAICT.IDIS.Controllers;
[ApiController]
public class IDIS_ServiceController:Controller
@@ -109,7 +109,7 @@ public class IDIS_ServiceController:Controller
using var reader = new StreamReader(Request.Body);
var json = await reader.ReadToEndAsync();
var data = JsonConvert.DeserializeObject(json)!;
- await _service.RegisterAsync(data.Handle, data.TemplateVersion, data.Value);
+ await _service.RegisterIDISAsync(data.Handle, data.TemplateVersion, data.Value);
return Ok(new IDIS_Response());
}
catch (Exception e)
diff --git a/IDIS_Server-SIM/Controllers/IDIS_TemplateController.cs b/Controllers/IDIS_TemplateController.cs
similarity index 95%
rename from IDIS_Server-SIM/Controllers/IDIS_TemplateController.cs
rename to Controllers/IDIS_TemplateController.cs
index cc62ccc..420ef8c 100644
--- a/IDIS_Server-SIM/Controllers/IDIS_TemplateController.cs
+++ b/Controllers/IDIS_TemplateController.cs
@@ -1,11 +1,11 @@
using BITKit;
using IDIS;
-using IDIS.Models;
-using IDIS.Services;
+using CAICT.IDIS;
+using CAICT.IDIS.Service;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
-namespace IDIS_Server_SIM.Controllers;
+namespace CN.CAICT.IDIS.Controllers;
[ApiController]
diff --git a/IDIS_Server-SIM/Extensions/IDISExtensions.cs b/Extensions/IDISExtensions.cs
similarity index 100%
rename from IDIS_Server-SIM/Extensions/IDISExtensions.cs
rename to Extensions/IDISExtensions.cs
diff --git a/IDIS_Server-SIM/Controllers/IDIS_QueryController.cs b/IDIS_Server-SIM/Controllers/IDIS_QueryController.cs
deleted file mode 100644
index eef398b..0000000
--- a/IDIS_Server-SIM/Controllers/IDIS_QueryController.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-using System.Data.Entity;
-using BITKit;
-using IDIS;
-using IDIS_Server_SIM.Data;
-using IDIS_Server_SIM.Extensions;
-using IDIS.Models;
-using IDIS.Services;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.EntityFrameworkCore;
-using Newtonsoft.Json;
-
-namespace IDIS_Server_SIM.Controllers;
-
-[ApiController]
-public class IDIS_QueryController:Controller
-{
- private readonly IDIS_Statistics_MySQLBased _statisticsService;
- private readonly IDIS_Service_MySQLBased _service;
- private readonly QueryService _queryService;
- private readonly ILogger _logger;
- public IDIS_QueryController(IDIS_Statistics_MySQLBased statisticsService, ILogger logger, QueryService queryService, IDIS_Service_MySQLBased service)
- {
- _statisticsService = statisticsService;
- _logger = logger;
- _queryService = queryService;
- _service = service;
- }
- ///
- /// 查询当日的解析的标识
- ///
- ///
- [Route("/api/query/today")]
- [HttpGet]
- public async Task GetTodayQuery()
- {
- var result = await _statisticsService.GetTodayQuery();
-
- return new IDIS_Response(result).ToActionResult();
- }
- ///
- /// 查询该标识的解析次数
- ///
- /// 标识码,标识码为null则是查询所有表示的解析次数
- ///
- [Route("/api/query/count")]
- [HttpGet]
- public async Task GetQueryCount(string handle=null)
- {
- if (string.IsNullOrEmpty(handle))
- {
- var result =await EntityFrameworkQueryableExtensions.ToArrayAsync(_statisticsService.queryCounter);
- return new IDIS_Response(result).ToActionResult();
- }
- else
- {
- var result = await _statisticsService.GetQueryCount(handle);
- return new IDIS_Response(result).ToActionResult();
- }
- }
- ///
- /// 查询所有标识的解析次数综合
- ///
- ///
- [HttpGet]
- [Route(("/api/query/all_count"))]
- public async Task GetQueryAllCount()
- {
- return new IDIS_Response(await _statisticsService.GetAllQueryCount()).ToActionResult();
- }
- ///
- /// 获取所有标识的数量
- ///
- ///
- [HttpGet]
- [Route(("/api/all_count"))]
- public IActionResult GetAllCount()
- {
- var count = _service.handles.Count();
- return new IDIS_Response(count).ToActionResult();
- }
- ///
- /// 通过标签查询标识
- ///
- /// 标签,多个标签使用;分隔
- /// 是否仅查询今日的标识
- ///
- [HttpGet]
- [Route(("/api/query/by"))]
- public async Task GetQueryByTag(string tags,bool today=false)
- {
- return new IDIS_Response(await _queryService.QueryByTag(today,tags.Split(";"))).ToActionResult();
- }
- ///
- /// 通过Tag获取解析记录
- ///
- /// 标签,多个标签使用;分隔
- /// 是否仅查询今日的标识
- ///
- [HttpGet]
- [Route(("/api/queryRecords/by"))]
- public async Task GetQueryRecordsByTag(string tags, bool today = false)
- {
- return new IDIS_Response(await _queryService.QueryRecordsByTag(today,tags.Split(";"))).ToActionResult();
- }
-}
\ No newline at end of file
diff --git a/IDIS_Server-SIM/Data/QueryService.cs b/IDIS_Server-SIM/Data/QueryService.cs
deleted file mode 100644
index 20fc8db..0000000
--- a/IDIS_Server-SIM/Data/QueryService.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using Cysharp.Threading.Tasks;
-using IDIS.Models;
-using IDIS.Services;
-using IDIS.Services.Models;
-using Microsoft.EntityFrameworkCore;
-
-namespace IDIS_Server_SIM.Data;
-
-public class QueryService:DbContext
-{
- private readonly IDIS_Service _service;
- private readonly IDIS_Statistics_MySQLBased _statistics;
-
- public QueryService(IDIS_Service service, IDIS_Statistics_MySQLBased statistics)
- {
- _service = service;
- _statistics = statistics;
- }
-
- private DbSet values { get; set; }
-
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- var connectionString = BITKit.Data.Get("DefaultConnection");
-
- optionsBuilder.UseMySQL(connectionString);
-
- optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.TrackAll);
- }
- public async UniTask QueryRecordsByTag(bool today=false,params string[] tags)
- {
- var handles = await QueryByTag(today,tags);
- var record = (await _statistics.queryRecords.ToArrayAsync())
- .Where(x => handles.Contains(x.Handle))
- .OrderBy(x=>x.QueryTime)
- .DistinctBy(x=>x.Handle);
- return record.ToArray();
- }
- public async UniTask QueryByTag(bool today = false,params string[] tags)
- {
- var tagRecords =
- (await values.ToArrayAsync())
- .Where(x => x.Type is "Tags" or "tags")
- .DistinctBy(x=>x.Handle);
-
- var list = new List();
-
- foreach (var x in tagRecords)
- {
- if (today)
- {
- if(x.CreateTime.Day != DateTime.Now.Day)
- continue;
- }
- if(string.IsNullOrEmpty(x.Value))continue;
- var currentTags = x.Value.Split(";");
- if (tags.All(currentTags.Contains))
- list.Add(x.Handle);
- }
-
- return list.ToArray();
- }
-}
\ No newline at end of file
diff --git a/IDIS_Server-SIM/Program.cs b/IDIS_Server-SIM/Program.cs
deleted file mode 100644
index eed7161..0000000
--- a/IDIS_Server-SIM/Program.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-#pragma warning disable SYSLIB1045
-using System.Text.RegularExpressions;
-using BITKit;
-using IDIS_Server_SIM.Data;
-using IDIS.Services;
-
-await BITAppForNet.InitializeAsync("IDIS");
-
-var config = Path.Combine(Environment.CurrentDirectory,"appsettings.json");
-if (File.Exists(config))
-{
- var json = File.ReadAllText(config);
- DataParser.Set(json);
-}
-
-var builder = WebApplication.CreateBuilder(args);
-
-var cancellationTokenSource = new System.Threading.CancellationTokenSource();
-
-// Add services to the container.
-
-builder.Services.AddControllers();
-// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
-builder.Services.AddEndpointsApiExplorer();
-builder.Services.AddSwaggerGen(x =>
-{
- var currentDirectory = AppContext.BaseDirectory;
- x.IncludeXmlComments(currentDirectory + "/IDIS_Server-SIM.xml",true);
-});
-
-builder.Services.AddTransient();
-
-builder.Services.AddTransient();
-
-builder.Services.AddTransient();
-
-builder.Services.AddTransient();
-
-builder.Services.AddTransient();
-
-var app = builder.Build();
-var logger = app.Services.GetRequiredService>();
-
-// #region 输入二级节点地址
-//
-// logger.LogInformation("请输入二级节点地址,例如:88.123.99");
-// string? str;
-// while (true)
-// {
-// str = Console.ReadLine();
-// if (string.IsNullOrEmpty(str))
-// {
-// str = "88.123.99";
-// break;
-// }
-// const string pattern =@"^\d{1,3}\.\d{1,3}\.\d{1,3}$"; // 正则表达式模式
-// if (Regex.IsMatch(str,pattern))
-// {
-// break;
-// }
-// logger.LogInformation("错误的地址格式,请按照正确格式输入,例如:88.123.99");
-// }
-// logger.LogInformation("输入的地址符合要求。");
-//
-// #endregion
-
-var idis_Service = app.Services.GetRequiredService();
-//idis_Service.PreAddress = str!;
-
-app.Services.GetRequiredService();
-
-// Configure the HTTP request pipeline.
-
-//if (app.Environment.IsDevelopment())
-{
- app.UseSwagger();
- app.UseSwaggerUI();
-
-}
-
-app.MapGet("/", () => "Hello World!");
-
-app.UseHttpsRedirection();
-
-app.UseAuthorization();
-
-app.MapControllers();
-
-app.Run();
diff --git a/Program.cs b/Program.cs
new file mode 100644
index 0000000..2a00a27
--- /dev/null
+++ b/Program.cs
@@ -0,0 +1,87 @@
+#pragma warning disable SYSLIB1045
+using BITKit;
+using BITKit.Net;
+using CAICT.IDIS.Service;
+using CN.CAICT.IDIS;
+using IDIS.Model;
+using Net.BITKit.Teleport;
+using Newtonsoft.Json;
+
+await BITAppForNet.InitializeAsync("CN.CAICT.IDIS");
+
+var config = Path.Combine(Environment.CurrentDirectory,"appsettings.json");
+if (File.Exists(config))
+{
+ var json = File.ReadAllText(config);
+ DataParser.Set(json);
+}
+
+var builder = WebApplication.CreateBuilder(args);
+
+var cancellationTokenSource = new System.Threading.CancellationTokenSource();
+
+// Add services to the container.
+
+builder.Services.AddControllers();
+// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
+builder.Services.AddEndpointsApiExplorer();
+builder.Services.AddSwaggerGen(x =>
+{
+ var currentDirectory = AppContext.BaseDirectory;
+ x.IncludeXmlComments(currentDirectory + "/CN.CAICT.IDIS.xml",true);
+});
+
+builder.Services.AddSingleton();
+builder.Services.AddSingleton();
+builder.Services.AddSingleton(x => x.GetRequiredService().NetProvider);
+
+builder.Services.AddTransient();
+builder.Services.AddTransient();
+builder.Services.AddTransient();
+
+var app = builder.Build();
+
+var server = app.Services.GetRequiredService();
+
+server.StartServer(29755);
+
+// Configure the HTTP request pipeline.
+
+if (app.Environment.IsDevelopment())
+{
+ app.UseSwagger();
+ app.UseSwaggerUI();
+}
+
+app.MapGet("/", () => "Hello World!");
+
+app.UseHttpsRedirection();
+
+app.UseAuthorization();
+
+app.MapControllers();
+
+new Thread(Tick).Start();
+
+
+await app.RunAsync();
+
+return;
+void Tick()
+{
+ app.Services.QueryComponents(out ILogger logger);
+ while (true)
+ {
+ try
+ {
+ server.NetProvider.Tick();
+ }
+ catch (Exception exception)
+ {
+ logger.LogCritical(exception,exception.Message);
+ }
+
+ Thread.Sleep(16);
+ }
+
+}
\ No newline at end of file
diff --git a/IDIS_Server-SIM/Properties/launchSettings.json b/Properties/launchSettings.json
similarity index 96%
rename from IDIS_Server-SIM/Properties/launchSettings.json
rename to Properties/launchSettings.json
index 93e432a..834c2d8 100644
--- a/IDIS_Server-SIM/Properties/launchSettings.json
+++ b/Properties/launchSettings.json
@@ -1,40 +1,40 @@
-{
- "$schema": "https://json.schemastore.org/launchsettings.json",
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:39555",
- "sslPort": 44303
- }
- },
- "profiles": {
- "http": {
- "commandName": "Project",
- "dotnetRunMessages": true,
- "launchBrowser": false, "launchUrl": "swagger",
- "applicationUrl": "http://localhost:5242;http://localhost:5243",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "https": {
- "commandName": "Project",
- "dotnetRunMessages": true,
- "launchBrowser": true,
- "launchUrl": "swagger",
- "applicationUrl": "https://localhost:7254;http://localhost:5242",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "IIS Express": {
- "commandName": "IISExpress",
- "launchBrowser": true,
- "launchUrl": "swagger",
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- }
- }
-}
+{
+ "$schema": "https://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:39555",
+ "sslPort": 44303
+ }
+ },
+ "profiles": {
+ "http": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": false, "launchUrl": "swagger",
+ "applicationUrl": "http://localhost:5242;http://localhost:5243",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "https": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "applicationUrl": "https://localhost:7254;http://localhost:5242",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/ReadMe.md b/ReadMe.md
deleted file mode 100644
index 41fb9ea..0000000
--- a/ReadMe.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# IDIS Server Console
-### IDIS 标识解析服务器控制台
-指南版本`v0.2`
-
-### 已支持的功能
-- [x] 查询标识
-- [x] 注册标识
-- [x] 删除标识
-- [x] 查询数据模板
-- [x] 保存数据模板
-
-
-### 已支持的功能
-- [x] 查询当日解析的标识
-- [x] 查询标识所有解析记录
-## 食用指南
-### 基本功能
-1. 去寻找
-这份文档
-2. 按照`已支持的功能`去操作
-### 统计功能
-#### 查询当日解析的标识
-
-`Get:`http://localhost:5242/api/query/today
-#### 查询单个标识所有的解析次数
-
-`Get:`http://localhost:5242/api/query/count?handle=88.101.6/xx004
diff --git a/ReadMe/Clip_20240428_161137.png b/ReadMe/Clip_20240428_161137.png
deleted file mode 100644
index 851d8ef..0000000
Binary files a/ReadMe/Clip_20240428_161137.png and /dev/null differ
diff --git a/ReadMe/Clip_20240428_161438.png b/ReadMe/Clip_20240428_161438.png
deleted file mode 100644
index ff4e5bb..0000000
Binary files a/ReadMe/Clip_20240428_161438.png and /dev/null differ
diff --git a/ReadMe/Clip_20240429_230249.png b/ReadMe/Clip_20240429_230249.png
deleted file mode 100644
index addfb68..0000000
Binary files a/ReadMe/Clip_20240429_230249.png and /dev/null differ
diff --git a/ReadMe/Clip_20240429_230509.png b/ReadMe/Clip_20240429_230509.png
deleted file mode 100644
index e268249..0000000
Binary files a/ReadMe/Clip_20240429_230509.png and /dev/null differ
diff --git a/IDIS_Server-SIM/appsettings.Development.json b/appsettings.Development.json
similarity index 93%
rename from IDIS_Server-SIM/appsettings.Development.json
rename to appsettings.Development.json
index 0c208ae..ff66ba6 100644
--- a/IDIS_Server-SIM/appsettings.Development.json
+++ b/appsettings.Development.json
@@ -1,8 +1,8 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft.AspNetCore": "Warning"
- }
- }
-}
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/IDIS_Server-SIM/appsettings.json b/appsettings.json
similarity index 58%
rename from IDIS_Server-SIM/appsettings.json
rename to appsettings.json
index e658cb9..ddbaf83 100644
--- a/IDIS_Server-SIM/appsettings.json
+++ b/appsettings.json
@@ -1,11 +1,10 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft.AspNetCore": "Warning"
- }
- },
- "Urls": "http://+:5242",
- "DefaultConnection":"server=server.bitfall.icu;port=3306;database=ifactory;uid=ifactory;password=JdBfKR2dxhm76Ss2",
- "AllowedHosts": "*"
-}
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "Urls": "http://+:5242",
+ "AllowedHosts": "*"
+}
diff --git a/img.png b/img.png
deleted file mode 100644
index cb2efb5..0000000
Binary files a/img.png and /dev/null differ