v0.0.3 twa sys

This commit is contained in:
2025-11-19 07:57:43 +07:00
parent a586da6edc
commit ccf08a3077
24 changed files with 75 additions and 35 deletions

View File

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class Files
{

View File

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class Folder
{

View File

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class Folders_has_StorageArea
{

View File

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class LocalServer
{

View File

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class MicrosoftAccount
{

View File

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class RefreshToken
{

View File

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class RefreshToken_Log
{

View File

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class ServerAuthorization
{
@ -12,11 +12,11 @@ namespace TWASys_App.DBModels
[ForeignKey("IdStorageServer")]
public long IdStorageServer { get; set; }
public DateTime CreateDate { get; set; }
public int Count { get; set; }
public int Count { get; set; }
public int Status { get; set; }
[NotMapped()]
public ICollection<ServerAuthorization_has_Token> Tokens { get; set; } = new List<ServerAuthorization_has_Token>();
public ICollection<Token> Tokens { get; set; } = new List<Token>();
[NotMapped()]
public ICollection<RefreshToken> RefreshTokens { get; set; } = new List<RefreshToken>();

View File

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class ServerAuthorization_has_Token
{

View File

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class StorageArea
{

View File

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class StorageArea_has_StorageServer
{

View File

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class StorageServer
{

View File

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class StorageServer_has_LocalServer
{

View File

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class StorageServer_has_MicrosoftAccount
{

View File

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class StorageServers_ValidationDomain
{

View File

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc.Filters;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class SyncFile_Log
{

View File

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class Token
{

View File

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class TypeStorageServer
{

View File

@ -1,7 +1,7 @@
 using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
namespace TWASys_App.DBModels.SotrageModel
{
public class ValidationDomain
{

View File

@ -6,10 +6,12 @@ using Microsoft.AspNetCore.Razor.Language.Intermediate;
using Microsoft.VisualBasic;
using MySqlConnector;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Data.Common;
using System.Xml.Linq;
using TWASys_App.Dapper.AExtentions;
using TWASys_App.DBModels;
using TWASys_App.DBModels.SotrageModel;
namespace TWASys_App.Models
{
@ -24,7 +26,7 @@ namespace TWASys_App.Models
public ICollection<ValidationDomain> ValidationDomains { set; get; } = new List<ValidationDomain>();
public int Size { set; get; };
public int Size { set; get; }
public string IpPublic { set; get; } = "";
public string IpPrivatev4 { set; get; } = "";
@ -208,6 +210,37 @@ namespace TWASys_App.Models
throw new NotImplementedException();
}
private void ProccessToken(Dictionary<long, ServerAuthorization> dict, IList<dynamic> tokens, bool isToken =true)
{
foreach (dynamic token in tokens)
{
if (dict.ContainsKey(token.idServerAuthorization))
{
ServerAuthorization tm;
if (dict.TryGetValue(token.idServerAuthorization, out tm))
{
if (isToken)
{
tm.Tokens.Add(new Token { IdToken = token.idToken, AccessToken = token.accessToken, CreateDate = token.createDate, ExpireDate = token.expireDate });
}
else
{
tm.RefreshTokens.Add(new RefreshToken { });
}
}
}
else
{
var tmp = new ServerAuthorization
{
IdServerAuthorization = token.idServerAuthorization
};
tmp.Tokens.Add(new Token { IdToken = token.idToken, AccessToken = token.accessToken });
dict.TryAdd(token.idServerAuthorization, tmp);
}
}
}
public async Task<MessageHeader> UpdateStorageSize()
{
var fMess = new MessageHeader();
@ -228,7 +261,9 @@ namespace TWASys_App.Models
SELECT
sa.idServerAuthorization,
st.idToken,
t.accessToken
t.accessToken,
t.createDate,
t.expireDate
FROM sa_need sa
JOIN maxc m ON m.idServerAuthorization = sa.idServerAuthorization
JOIN ServerAuthorization_has_Token st
@ -254,8 +289,13 @@ namespace TWASys_App.Models
await con.OpenAsync();
using var trans = await con.BeginTransactionAsync();
using var multi = await con.QueryMultipleAsync(sql, new { size = Size, id = IdStorageServer }, trans);
IList<dynamic> tokens = (await multi.ReadAsync()).AsList();
IList<dynamic> rTokens = (await multi.ReadAsync()).AsList();
Dictionary<long, ServerAuthorization> dict = new Dictionary<long, ServerAuthorization>();
ProccessToken(dict, tokens);
ProccessToken(dict, rTokens, false);
using (var writer = new StreamWriter(Path.GetFullPath("Json/dataServer.json"), false))
{
await writer.WriteAsync(JsonConvert.SerializeObject(new

View File

@ -6,6 +6,7 @@ using MySqlConnector;
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations;
using System.Data.Common;
using TWASys_App.DBModels.SotrageModel;
namespace TWASys_App.Models
{

View File

@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc;
using MySqlConnector;
using Newtonsoft.Json;
using System.Data.Common;
using TWASys_App.DBModels.SotrageModel;
namespace TWASys_App.Models
{

View File

@ -53,4 +53,8 @@
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="DBModels\WebAppModel\" />
</ItemGroup>
</Project>