[성현모] Tra Overview 기능, 페이지 추가
This commit is contained in:
@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using System.Data;
|
||||
using SystemX.Core.DB;
|
||||
using SystemX.Core.Services;
|
||||
using Web.Tra.Model;
|
||||
using WebClient.Library.Config;
|
||||
|
||||
namespace Web.Tra.Services
|
||||
@ -17,8 +18,33 @@ namespace Web.Tra.Services
|
||||
_scopeFactory = scopeFactory;
|
||||
_configService = configService;
|
||||
}
|
||||
public async Task Test()
|
||||
|
||||
//Get Overview
|
||||
public async Task<List<Overview>> GetOverview(RequestSearch request)
|
||||
{
|
||||
List<Overview> overview = new List<Overview>();
|
||||
|
||||
int startYear = request.SearchStart.Year;
|
||||
int endYear = request.SearchEnd.Year;
|
||||
|
||||
//search log
|
||||
List<HIST_LogSummary> SearchLogList = new List<HIST_LogSummary>();
|
||||
for (int i = startYear; i <= endYear; i++)
|
||||
{
|
||||
using (var scope = _scopeFactory.CreateScope())
|
||||
{
|
||||
var provider = scope.ServiceProvider.GetRequiredService<DbContextProvider>();
|
||||
using (var context = GetDBContext<CPXV2Log>(provider, i))
|
||||
{
|
||||
if (context is not null)
|
||||
{
|
||||
SearchLogList.AddRange(await context.HIST_LogSummaries.Where(x => request.SearchStart <= DateOnly.FromDateTime(x.TestDT) && DateOnly.FromDateTime(x.TestDT) <= request.SearchEnd).ToListAsync());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//search testlist
|
||||
using (var scope = _scopeFactory.CreateScope())
|
||||
{
|
||||
var provider = scope.ServiceProvider.GetRequiredService<DbContextProvider>();
|
||||
@ -26,88 +52,49 @@ namespace Web.Tra.Services
|
||||
{
|
||||
if (context is not null)
|
||||
{
|
||||
var varProdVariant = context.PROD_Variants.ToList();
|
||||
var varProudGroup = context.PROD_Groups.ToList();
|
||||
var TesetInfoList = varProdVariant.Select(x => new TestInfo
|
||||
{
|
||||
PROD_Variant = x,
|
||||
PROD_Group = varProudGroup.Find(y => y.No == x.GroupNo)
|
||||
}).ToList();
|
||||
|
||||
var search = SearchLogList.Select(x => new SearchData
|
||||
{
|
||||
Summary = x,
|
||||
TestInfo = TesetInfoList.Find(y => y.PROD_Variant.No == x.TestListVariantNo)
|
||||
});
|
||||
|
||||
var ListSearchData = search
|
||||
.Where(x => x.Summary.TestListVariantNo > 0)
|
||||
.OrderBy(x => x.Summary.TestDT).ToList();
|
||||
|
||||
var group = ListSearchData
|
||||
.GroupBy(x => (x.Summary.HostID, x.Summary.Section))
|
||||
.Select(x => x.ToOverview())
|
||||
.OrderBy(x => x.Host);
|
||||
|
||||
overview.AddRange(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (var scope = _scopeFactory.CreateScope())
|
||||
{
|
||||
var provider = scope.ServiceProvider.GetRequiredService<DbContextProvider>();
|
||||
using (var context = GetDBContext<CPXV2Log>(provider, 2023))
|
||||
{
|
||||
if (context is not null)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (var scope = _scopeFactory.CreateScope())
|
||||
{
|
||||
var provider = scope.ServiceProvider.GetRequiredService<DbContextProvider>();
|
||||
using (var context = GetDBContext<CPXV2Log>(provider, 2024))
|
||||
{
|
||||
if (context is not null)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
return overview.OrderBy(x=>x.TestDate).ToList();
|
||||
}
|
||||
|
||||
|
||||
//Get DBContext
|
||||
private T? GetDBContext<T>(DbContextProvider provider, int dbID) where T : DbContext
|
||||
{
|
||||
var findDB = provider.DBDictionary.Keys.First(x => x.Contains(dbID.ToString()));
|
||||
if(string.IsNullOrEmpty(findDB) == false)
|
||||
var contextName = typeof(T).Name;
|
||||
|
||||
var findDB = provider.DBDictionary.Values.First(x => x.DBID == dbID);
|
||||
if(findDB is not null)
|
||||
{
|
||||
if (provider.DBDictionary.TryGetValue(findDB, out var dbContext))
|
||||
{
|
||||
return provider?.GetDBContext<T>($"{dbContext.DBName}");
|
||||
}
|
||||
return provider?.GetDBContext<T>($"{findDB.DBName}");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//public async Task<Response_SelectUniqueKy> Request_SelectUniqueKey(Request_SelectUniqueKey request, string guid = "")
|
||||
//{
|
||||
// Response_SelectUniqueKy response = new Response_SelectUniqueKy();
|
||||
|
||||
// if (request != null)
|
||||
// {
|
||||
// response.Identity = request.Identity;
|
||||
// using (var scope = _scopeFactory.CreateScope())
|
||||
// {
|
||||
// var provider = scope.ServiceProvider.GetRequiredService<DbContextProvider>();
|
||||
// using (var context = GetUniqueKeyDBContext(provider, 1))
|
||||
// {
|
||||
// if (context is not null)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// using (var transaction = await context.CreateTransactionAsync(IsolationLevel.ReadUncommitted))
|
||||
// {
|
||||
// var data = await context.tUniqueKeyStorages.AsNoTracking().FirstOrDefaultAsync(x => x.cIdentity == request.Identity);
|
||||
// await context.CloseTransactionAsync(transaction);
|
||||
// if (data != null)
|
||||
// {
|
||||
// response.Data1 = data.cData1;
|
||||
// response.Data2 = data.cData2;
|
||||
// response.Data3 = data.cData3;
|
||||
// response.Data4 = data.cData4;
|
||||
// response.Data5 = data.cData5;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// LogXnet.WriteLine($"Select Unique Key Transaction Error::{guid}", LogXLabel.Error);
|
||||
// LogXnet.WriteLine(e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return response;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user