update TWA Management v0.0.1

This commit is contained in:
2025-11-05 10:08:06 +07:00
parent d4e91c7960
commit b4b191f829
73 changed files with 2249 additions and 418 deletions

View File

@ -4,7 +4,7 @@ namespace TWASys_App.DBModels
{
public class DBManagement
{
public static string GetConnectionString()
public static string GetConnectionString(bool allowVar = false)
{
string fp = Path.GetFullPath("Keys/db/");
@ -28,6 +28,7 @@ namespace TWASys_App.DBModels
SslCa = Path.Combine(fp, "ca-cert.pem"),
SslCert = Path.Combine(fp, "client-cert.pem"),
SslKey = Path.Combine(fp, "client-key.pem"),
AllowUserVariables = allowVar
};
//172.168.192.204
return builder.ConnectionString;

View File

@ -0,0 +1,26 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class Files
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public ulong IdFiles { get; set; }
[ForeignKey("IdFolders")]
public ulong IdFolders { get; set; } // BIGINT FK → Folders.idFolders
public string Code { get; set; } = ""; // VARCHAR(100)
public string Name { get; set; } = ""; // VARCHAR(100)
public string Path { get; set; } = ""; // TEXT
public string Options { get; set; } = ""; // LONGTEXT (JSON, metadata)
public DateTime CreateDate { get; set; } = DateTime.UtcNow; // DATETIME (UTC khuyên dùng)
public DateTime? LastModified { get; set; } = null; // DATETIME NULL
public int Status { get; set; } // INT(11)
public Folder? Folder { get; set; } = null!; // nav
}
}

View File

@ -0,0 +1,27 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class Folder
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public ulong IdFolders { get; set; } // BIGINT PK
public ulong? IdParent { get; set; } // BIGINT FK, null = root
public string Name { get; set; } = ""; // VARCHAR(45)
public string Code { get; set; } = ""; // VARCHAR(100)
public string Path { get; set; } = ""; // TEXT
public string Options { get; set; } = ""; // LONGTEXT
public DateTime CreateDate { get; set; } = DateTime.UtcNow; // DATETIME
public DateTime? LastModified { get; set; } = null; // DATETIME NULL
public int Status { get; set; } // INT(11)
public Folder? Parent { get; set; } = null;
public ICollection<Folder> Children { get; set; } = new List<Folder>();
}
}

View File

@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class Folders_has_StorageArea
{
[ForeignKey("")]
public ulong IdFolders { get; set; }
[ForeignKey("")]
public long IdStorage { get; set; }
public Folder Folder { get; set; } = null!;
public StorageArea Storage { get; set; } = null!;
}
}

View File

@ -7,66 +7,30 @@ namespace TWASys_App.DBModels
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("idLocalServer")]
public int IdLocalServer { get; set; } = 0;
public long IdLocalServer { get; set; } = 0;
[StringLength(20)]
[Column("ipPrivateServer")]
public string IpPrivateServer { get; set; } = "";
[StringLength(100)]
[Column("ipPrivateServer6")]
public string IpPrivateServer6 { get; set; } = "";
[StringLength(100)]
[Column("ipPublicServer")]
public string IpPrivateServerv6 { get; set; } = "";
public string IpPublicServer { get; set; } = "";
[StringLength(45)]
[Column("pathServer")]
public string PathServer { get; set; } = "";
[StringLength(100)]
[Column("serialNumber")]
public string SerialNumber { get; set; } = "";
// Ảnh gốc ghi "osVesion" (sai chính tả). Giữ nguyên để khớp DB.
[StringLength(100)]
[Column("osVesion")]
public string OsVersion { get; set; } = "";
[StringLength(100)]
[Column("osName")]
public string OsName { get; set; } = "";
[StringLength(45)]
[Column("osArch")]
public string OsArch { get; set; } = "";
// Ảnh gốc ghi "osKernal". Giữ nguyên để khớp DB.
[StringLength(100)]
[Column("osKernal")]
public string OsKernel { get; set; } = "";
[Column("socketNum")]
public string OsKernal { get; set; } = "";
public int SocketNum { get; set; } = 0;
[StringLength(150)]
[Column("cpuName")]
public string CpuName { get; set; } = "";
public float TotalRam { get; set; } = 0;
[Column("totalRam")]
public int TotalRam { get; set; } = 0;
[StringLength(100)]
[Column("biosVendor")]
public string BiosVendor { get; set; } = "";
[StringLength(100)]
[Column("productUUID")]
public string BiosVender { get; set; } = "";
public string ProductUuid { get; set; } = "";
[Column("status")]
public int Status { get; set; } = 0;
}

View File

@ -0,0 +1,26 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class MicrosoftAccount
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long IdCloudAccount { get; set; }
public string AccName { get; set; } = null!;
public string ClientID { get; set; } = null!; // GUID string
public string TenantID { get; set; } = null!;
public string? ClientSecret { get; set; } // encrypted at rest
public string? SiteID { get; set; }
public string? DriveID { get; set; }
public string? PathSharePoint { get; set; }
public string? RefreshToken { get; set; } // encrypted
public string? AccessToken { get; set; } // optional cache
public DateTime? ExpiresAt { get; set; }
public string? Scopes { get; set; }
public DateTime CreateDate { get; set; }
public DateTime? LastModified { get; set; }
public int Status { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class RefreshToken
{
[Key]
public string IdRefreshToken { get; set; } = "";
[ForeignKey("IdServerAuthorization")]
public ulong IdServerAuthorization { get; set; }
public string __RefreshToken { get; set; } = ""; // refreshToken
public DateTime CreateDate { get; set; }
public DateTime ExpireDate { get; set; }
public int Status { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class RefreshToken_Log
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public ulong IdRefreshTokenLog { get; set; }
public string IdRefreshToken { get; set; } = null!;
public DateTime DateRenew { get; set; } // UTC
public int Count { get; set; } = 1;
public int LifeTime { get; set; }
public int Status { get; set; } = 1;
public RefreshToken RefreshToken { get; set; } = null!;
}
}

View File

@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class ServerAuthorization
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public ulong IdServerAuthorization { get; set; }
[ForeignKey("IdStorageServer")]
public long IdStorageServer { get; set; }
public DateTime CreateDate { 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>();
}
}

View File

@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class ServerAuthorization_has_Token
{
[ForeignKey("")]
public ulong IdServerAuthorization { get; set; }
[ForeignKey("")]
public string IdToken { get; set; } = "";
public int Count { get; set; }
public int Status { get; set; }
public ServerAuthorization ServerAuthorization { get; set; } = null!;
public Token Token { get; set; } = null!;
}
}

View File

@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class StorageArea
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long IdStorage { get; set; } // PK (AUTO_INCREMENT nếu DB đang để vậy)
public ulong? IdEmp { get; set; } = null; // FK -> Emp (nếu có)
public DateTime CreateDate { get; set; } = DateTime.UtcNow;
public double TotalSize { get; set; } = 0; // map FLOAT MySQL -> double
public int Status { get; set; } = 0;
}
}

View File

@ -0,0 +1,24 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class StorageArea_has_StorageServer
{
[ForeignKey("IdStorage")]
public long IdStorage { get; set; }
[ForeignKey("IdStorageServer")]
public long IdStorageServer { get; set; }
[Column("priority", TypeName = "int")]
public int Priority { get; set; } = 0;
[Column("createDate", TypeName = "datetime")]
public DateTime CreateDate { get; set; } = DateTime.UtcNow;
[Column("status", TypeName = "int")]
public int Status { get; set; } = 0;
}
}

View File

@ -0,0 +1,25 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class StorageServer
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long IdStorageServer { get; set; }
public long? IdEmp { get; set; }
[ForeignKey("IdTypeStorageServer")]
public long IdTypeStorageServer { get; set; }
public string StorageName { get; set; } = "";
public DateTime? CreateDate { get; set; }
public string ControllerID { get; set; } = "";
public int Status { get; set; } = 0;
}
}

View File

@ -2,22 +2,22 @@
namespace TWASys_App.DBModels
{
public class StorageServerHasLocalServer
public class StorageServer_has_LocalServer
{
[Column("idStorageServer")]
public int IdStorageServer { get; set; } = 0;
[Column("idLocalServer")]
public int IdLocalServer { get; set; } = 0;
[ForeignKey("IdStorageServer")]
public long IdStorageServer { get; set; } = 0;
[Column("createDate")]
[ForeignKey("IdLocalServer")]
public long IdLocalServer { get; set; } = 0;
public DateTime CreateDate { get; set; } = DateTime.UtcNow; // nên lưu UTC
[Column("modifyDate")]
public DateTime? ModifyDate { get; set; } = null; // nên lưu UTC
[Column("status")]
public int Status { get; set; } = 0;
}
}

View File

@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class StorageServer_has_MicrosoftAccount
{
[ForeignKey("")]
public long IdStorageServer { get; set; }
[ForeignKey("")]
public long IdCloudAccount { get; set; }
public DateTime CreateDate { get; set; } = DateTime.UtcNow;
public int Status { get; set; } = 1;
public StorageServer StorageServer { get; set; } = null!;
public MicrosoftAccount CloudAccount { get; set; } = null!;
}
}

View File

@ -0,0 +1,24 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class StorageServers_ValidationDomain
{
[ForeignKey("")]
public long IdStorageServer { get; set; }
[ForeignKey("")]
public long IdValidationDomain { get; set; }
[Column("modifyDate", TypeName = "datetime")]
public DateTime? ModifyDate { get; set; } = null;
[Column("createDate", TypeName = "datetime")]
public DateTime CreateDate { get; set; } = DateTime.UtcNow;
[Column("status", TypeName = "int")]
public int Status { get; set; } = 0;
}
}

View File

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Mvc.Filters;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class SyncFile_Log
{
public ulong Id { get; set; }
[ForeignKey("")]
public long IdFiles { get; set; }
[ForeignKey("")]
public long IdStorageServer { get; set; }
[ForeignKey("")]
public long IdLocalServer { get; set; }
[ForeignKey("")]
public long IdCloudAccount { get; set; } // FK -> CloudAccounts.id
public DateTime SyncDate { get; set; } = DateTime.UtcNow; // UTC
public string? PathOnServer { get; set; } // đường dẫn lưu trên đích
public int Status { get; set; } // 0=pending,1=ok,2=retry,3=failed,...
// nav
public Files File { get; set; } = null!;
}
}

View File

@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class Token
{
[Key]
public string IdToken { get; set; } = "";
public string AccessToken { get; set; } = "";
public DateTime CreateDate { get; set; }
public DateTime ExpireDate { get; set; }
public int Status { get; set; }
}
}

View File

@ -1,10 +1,12 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class TypeStorageServer
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdTypeStorageServer { get; set; }
public string TypeName { get; set; }

View File

@ -1,11 +1,13 @@
using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TWASys_App.DBModels
{
public class ValidationDomain
{
[Key]
public int IdValidationDomain { set; get; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long IdValidationDomain { set; get; }
public string Protocol { set; get; }
public int PortNumber { set; get; }