v0.0.3 twa sys
This commit is contained in:
@ -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
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace TWASys_App.DBModels
|
||||
namespace TWASys_App.DBModels.SotrageModel
|
||||
{
|
||||
public class Folders_has_StorageArea
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
@ -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>();
|
||||
@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace TWASys_App.DBModels
|
||||
namespace TWASys_App.DBModels.SotrageModel
|
||||
{
|
||||
public class ServerAuthorization_has_Token
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace TWASys_App.DBModels
|
||||
namespace TWASys_App.DBModels.SotrageModel
|
||||
{
|
||||
public class StorageArea_has_StorageServer
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace TWASys_App.DBModels
|
||||
namespace TWASys_App.DBModels.SotrageModel
|
||||
{
|
||||
public class StorageServer_has_LocalServer
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace TWASys_App.DBModels
|
||||
namespace TWASys_App.DBModels.SotrageModel
|
||||
{
|
||||
public class StorageServer_has_MicrosoftAccount
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -53,4 +53,8 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="DBModels\WebAppModel\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user