[성현모] HubX DB구조, 쿼리 개선
This commit is contained in:
Binary file not shown.
@ -248,7 +248,6 @@ PRINT N'테이블 [dbo].[tStorage]을(를) 만드는 중...';
|
||||
|
||||
GO
|
||||
CREATE TABLE [dbo].[tStorage] (
|
||||
[cHuid] BIGINT IDENTITY (1, 1) NOT NULL,
|
||||
[cIdentity] NVARCHAR (200) NOT NULL,
|
||||
[cDateTime] DATETIME2 (7) NOT NULL,
|
||||
[cData1] NVARCHAR (4000) NULL,
|
||||
@ -256,7 +255,7 @@ CREATE TABLE [dbo].[tStorage] (
|
||||
[cData3] NVARCHAR (4000) NULL,
|
||||
[cData4] NVARCHAR (4000) NULL,
|
||||
[cData5] NVARCHAR (4000) NULL,
|
||||
PRIMARY KEY CLUSTERED ([cHuid] ASC)
|
||||
PRIMARY KEY CLUSTERED ([cIdentity] ASC)
|
||||
);
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@ -1,7 +1,6 @@
|
||||
CREATE TABLE [dbo].[tStorage]
|
||||
(
|
||||
[cHuid] BIGINT NOT NULL PRIMARY KEY IDENTITY(1,1),
|
||||
[cIdentity] NVARCHAR(200) NOT NULL,
|
||||
[cIdentity] NVARCHAR(200) NOT NULL PRIMARY KEY,
|
||||
[cDateTime] DATETIME2 NOT NULL,
|
||||
[cData1] NVARCHAR(4000),
|
||||
[cData2] NVARCHAR(4000),
|
||||
|
||||
@ -25,11 +25,13 @@ public partial class HubXContext : DbContext
|
||||
{
|
||||
modelBuilder.Entity<TStorage>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.CHuid).HasName("PK__tStorage__346C9EFC86D3DC51");
|
||||
entity.HasKey(e => e.CIdentity).HasName("PK__tStorage__3EBC650D3753A7B8");
|
||||
|
||||
entity.ToTable("tStorage");
|
||||
|
||||
entity.Property(e => e.CHuid).HasColumnName("cHuid");
|
||||
entity.Property(e => e.CIdentity)
|
||||
.HasMaxLength(200)
|
||||
.HasColumnName("cIdentity");
|
||||
entity.Property(e => e.CData1)
|
||||
.HasMaxLength(4000)
|
||||
.HasColumnName("cData1");
|
||||
@ -46,9 +48,6 @@ public partial class HubXContext : DbContext
|
||||
.HasMaxLength(4000)
|
||||
.HasColumnName("cData5");
|
||||
entity.Property(e => e.CDateTime).HasColumnName("cDateTime");
|
||||
entity.Property(e => e.CIdentity)
|
||||
.HasMaxLength(200)
|
||||
.HasColumnName("cIdentity");
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
|
||||
@ -5,8 +5,6 @@ namespace DB.HubXDB;
|
||||
|
||||
public partial class TStorage
|
||||
{
|
||||
public long CHuid { get; set; }
|
||||
|
||||
public string CIdentity { get; set; } = null!;
|
||||
|
||||
public DateTime CDateTime { get; set; }
|
||||
|
||||
@ -21,7 +21,7 @@ namespace HubX.Server.Services
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task<Response_InsertUniqueKy> Request_InsertUniqueKey(Request_InsertUniqueKey request)
|
||||
public async Task<Response_InsertUniqueKy> Request_InsertUniqueKey(Request_InsertUniqueKey request, string guid = "")
|
||||
{
|
||||
Response_InsertUniqueKy response = new Response_InsertUniqueKy();
|
||||
|
||||
@ -35,10 +35,10 @@ namespace HubX.Server.Services
|
||||
var context = scope.ServiceProvider.GetRequiredService<HubXContext>();
|
||||
if (context != null)
|
||||
{
|
||||
var data = context.TStorages.AsNoTracking().Where(x => x.CIdentity == request.Identity).ToList();
|
||||
var data = await context.TStorages.AsNoTracking().Where(x => x.CIdentity == request.Identity).ToListAsync();
|
||||
if (data?.Count() > 0)
|
||||
{
|
||||
Log4net.WriteLine($"Exist Unique Key", LogType.Error);
|
||||
Log4net.WriteLine($"Exist Unique Key::{guid}", LogType.Error);
|
||||
response.Result = "Exist Unique Key";
|
||||
}
|
||||
else
|
||||
@ -64,7 +64,7 @@ namespace HubX.Server.Services
|
||||
if (transactionResult == false)
|
||||
{
|
||||
response.Result = EnumResult.Failed.ToString();
|
||||
Log4net.WriteLine($"Transaction Error", LogType.Error);
|
||||
Log4net.WriteLine($"Transaction Error::{guid}", LogType.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -78,7 +78,7 @@ namespace HubX.Server.Services
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<Response_SelectUniqueKy> Request_SelectUniqueKey(Request_SelectUniqueKey request)
|
||||
public async Task<Response_SelectUniqueKy> Request_SelectUniqueKey(Request_SelectUniqueKey request, string guid = "")
|
||||
{
|
||||
Response_SelectUniqueKy response = new Response_SelectUniqueKy();
|
||||
|
||||
@ -94,7 +94,7 @@ namespace HubX.Server.Services
|
||||
{
|
||||
using (var transaction = await context.CreateTransactionAsync(IsolationLevel.ReadUncommitted))
|
||||
{
|
||||
var data = context.TStorages.AsNoTracking().ToList().First(x => x.CIdentity == request.Identity);
|
||||
var data = await context.TStorages.AsNoTracking().FirstOrDefaultAsync(x => x.CIdentity == request.Identity);
|
||||
await context.CloseTransactionAsync(transaction);
|
||||
if (data != null)
|
||||
{
|
||||
@ -108,7 +108,7 @@ namespace HubX.Server.Services
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log4net.WriteLine($"Select Unique Key Transaction Error", LogType.Error);
|
||||
Log4net.WriteLine($"Select Unique Key Transaction Error::{guid}", LogType.Error);
|
||||
Log4net.WriteLine(e);
|
||||
}
|
||||
}
|
||||
@ -118,7 +118,7 @@ namespace HubX.Server.Services
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<Response_UpdateUniqueKy> Request_UpdateUniqueKey(Request_UpdateUniqueKey request)
|
||||
public async Task<Response_UpdateUniqueKy> Request_UpdateUniqueKey(Request_UpdateUniqueKey request, string guid = "")
|
||||
{
|
||||
Response_UpdateUniqueKy response = new Response_UpdateUniqueKy();
|
||||
|
||||
@ -133,7 +133,7 @@ namespace HubX.Server.Services
|
||||
var context = scope.ServiceProvider.GetRequiredService<HubXContext>();
|
||||
if (context != null)
|
||||
{
|
||||
var selected = context.TStorages.First(x => x.CIdentity == request.Identity);
|
||||
var selected = await context.TStorages.FirstOrDefaultAsync(x => x.CIdentity == request.Identity);
|
||||
if (selected != null)
|
||||
{
|
||||
selected.CData1 = request.Data1;
|
||||
@ -154,7 +154,7 @@ namespace HubX.Server.Services
|
||||
if (transactionResult == false)
|
||||
{
|
||||
response.Result = EnumResult.Failed.ToString();
|
||||
Log4net.WriteLine($"Transaction Error", LogType.Error);
|
||||
Log4net.WriteLine($"Transaction Error::{guid}", LogType.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -21,16 +21,16 @@ namespace SystemX.Core.Communication
|
||||
|
||||
using (HttpClient httpClient = new HttpClient(GetClientHandler()))
|
||||
{
|
||||
var timeOutSec = SetTimeout(timeOutSeconds);
|
||||
httpClient.Timeout = new TimeSpan(0, 0, timeOutSec);
|
||||
httpClient.BaseAddress = new Uri($"{url}");
|
||||
|
||||
int retry = 0;
|
||||
while (true)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
try
|
||||
{
|
||||
var timeOutSec = SetTimeout(timeOutSeconds);
|
||||
httpClient.Timeout = new TimeSpan(0, 0, timeOutSec);
|
||||
httpClient.BaseAddress = new Uri($"{url}");
|
||||
|
||||
Log4net.WriteLine($"[POST] Request({guid})::{url}{Environment.NewLine}{request?.ToJson()}", LogType.HTTP);
|
||||
|
||||
DateTime requestTime = DateTime.Now;
|
||||
|
||||
Reference in New Issue
Block a user