v0.0.3 twa sys
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user