[성현모] CPMeta 기능 구현 완료
This commit is contained in:
@ -0,0 +1,70 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SystemX.Core.Controller;
|
||||
using WebApi.Project.UniqueKeyApi.Models;
|
||||
using WebApi.Project.UniqueKeyApi.Services;
|
||||
|
||||
namespace WebApi.Project.UniqueKeyApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
|
||||
public class CPMetaController : CommonController<UniqueKeyApiConfig>
|
||||
{
|
||||
private readonly CPMetaService _cpMetaService;
|
||||
|
||||
public CPMetaController(IServiceProvider serviceProvider, IHttpContextAccessor httpContextAccessor, CPMetaService cpMetaService)
|
||||
: base(serviceProvider, httpContextAccessor)
|
||||
{
|
||||
_cpMetaService = cpMetaService;
|
||||
}
|
||||
|
||||
[HttpGet("health")]
|
||||
public async Task<IResult> Health()
|
||||
{
|
||||
LogXnet.WriteLine($"[{GetRequestMethod()}:{GetMethodName()}] [Client IP:{GetClientIP()}] [RequestUrl:{GetRequestUrl()}]{Environment.NewLine}", LogXLabel.CONTROLLER);
|
||||
|
||||
await Task.CompletedTask;
|
||||
return Results.Ok("Healthy");
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IResult> SetWbmsMeta([FromBody]Request_SetWbmsMeta request)
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||
|
||||
Response_SetWbmsMeta response = await _cpMetaService.SetWbmsMeta(request, guid.ToString());
|
||||
|
||||
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||
|
||||
return Results.Ok(response);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IResult> GetWbmsMetaByProductID([FromQuery] string ProductID, int? ShardID = 1)
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} key:{ProductID}", LogXLabel.CONTROLLER);
|
||||
|
||||
Response_GetWbms response = await _cpMetaService.GetWbmsMeta(new Request_GetWbmsMetaByProductID() { ProductID = ProductID, ShardID = (int)ShardID }, guid.ToString());
|
||||
|
||||
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||
|
||||
return Results.Ok(response);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IResult> GetWbmsMetaByMacAddress([FromQuery] string MacAddress, int? ShardID = 1)
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} key:{MacAddress}", LogXLabel.CONTROLLER);
|
||||
|
||||
Response_GetWbms response = await _cpMetaService.GetWbmsMeta(new Request_GetWbmsMetaByMacAddress() { MacAddress = MacAddress, ShardID = (int)ShardID }, guid.ToString());
|
||||
|
||||
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||
|
||||
return Results.Ok(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,78 +8,78 @@ using WebApi.Project.UniqueKeyApi.Services;
|
||||
|
||||
namespace WebApi.Project.UniqueKeyApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
//[ApiController]
|
||||
//[Route("[controller]/[action]")]
|
||||
|
||||
public class UniqueKeyController : CommonController<UniqueKeyApiConfig>
|
||||
{
|
||||
private readonly UniqueKeyService _uniqueKeyService;
|
||||
//public class UniqueKeyController : CommonController<UniqueKeyApiConfig>
|
||||
//{
|
||||
// private readonly UniqueKeyService _uniqueKeyService;
|
||||
|
||||
public UniqueKeyController(IServiceProvider serviceProvider, IHttpContextAccessor httpContextAccessor, UniqueKeyService uniqueKeyService)
|
||||
: base(serviceProvider, httpContextAccessor)
|
||||
{
|
||||
_uniqueKeyService = uniqueKeyService;
|
||||
}
|
||||
// public UniqueKeyController(IServiceProvider serviceProvider, IHttpContextAccessor httpContextAccessor, UniqueKeyService uniqueKeyService)
|
||||
// : base(serviceProvider, httpContextAccessor)
|
||||
// {
|
||||
// _uniqueKeyService = uniqueKeyService;
|
||||
// }
|
||||
|
||||
[HttpGet("health")]
|
||||
public async Task<IResult> Health()
|
||||
{
|
||||
LogXnet.WriteLine($"[{GetRequestMethod()}:{GetMethodName()}] [Client IP:{GetClientIP()}] [RequestUrl:{GetRequestUrl()}]{Environment.NewLine}", LogXLabel.CONTROLLER);
|
||||
// [HttpGet("health")]
|
||||
// public async Task<IResult> Health()
|
||||
// {
|
||||
// LogXnet.WriteLine($"[{GetRequestMethod()}:{GetMethodName()}] [Client IP:{GetClientIP()}] [RequestUrl:{GetRequestUrl()}]{Environment.NewLine}", LogXLabel.CONTROLLER);
|
||||
|
||||
await Task.CompletedTask;
|
||||
return Results.Ok("Healthy");
|
||||
}
|
||||
// await Task.CompletedTask;
|
||||
// return Results.Ok("Healthy");
|
||||
// }
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IResult> InsertUniqueKey(Request_InsertUniqueKey request)
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||
// [HttpPost]
|
||||
// public async Task<IResult> InsertUniqueKey(Request_InsertUniqueKey request)
|
||||
// {
|
||||
// Guid guid = Guid.NewGuid();
|
||||
// LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||
|
||||
Response_InsertUniqueKy response = await _uniqueKeyService.Request_InsertUniqueKey(request);
|
||||
// Response_InsertUniqueKy response = await _uniqueKeyService.Request_InsertUniqueKey(request);
|
||||
|
||||
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||
|
||||
return Results.Ok(response);
|
||||
}
|
||||
// return Results.Ok(response);
|
||||
// }
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IResult> SelectUniqueKey([FromBody]Request_SelectUniqueKey request)
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||
// [HttpPost]
|
||||
// public async Task<IResult> SelectUniqueKey([FromBody]Request_SelectUniqueKey request)
|
||||
// {
|
||||
// Guid guid = Guid.NewGuid();
|
||||
// LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||
|
||||
Response_SelectUniqueKy response = await _uniqueKeyService.Request_SelectUniqueKey(request);
|
||||
// Response_SelectUniqueKy response = await _uniqueKeyService.Request_SelectUniqueKey(request);
|
||||
|
||||
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||
|
||||
return Results.Ok(response);
|
||||
}
|
||||
// return Results.Ok(response);
|
||||
// }
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IResult> SelectUniqueKeyGet([FromQuery] string key)
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} key:{key}", LogXLabel.CONTROLLER);
|
||||
// [HttpGet]
|
||||
// public async Task<IResult> SelectUniqueKeyGet([FromQuery] string key)
|
||||
// {
|
||||
// Guid guid = Guid.NewGuid();
|
||||
// LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} key:{key}", LogXLabel.CONTROLLER);
|
||||
|
||||
Response_SelectUniqueKy response = await _uniqueKeyService.Request_SelectUniqueKey(new Request_SelectUniqueKey { Identity = key });
|
||||
// Response_SelectUniqueKy response = await _uniqueKeyService.Request_SelectUniqueKey(new Request_SelectUniqueKey { Identity = key });
|
||||
|
||||
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||
|
||||
return Results.Ok(response);
|
||||
}
|
||||
// return Results.Ok(response);
|
||||
// }
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IResult> UpdateUniqueKey(Request_UpdateUniqueKey request)
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||
// [HttpPost]
|
||||
// public async Task<IResult> UpdateUniqueKey(Request_UpdateUniqueKey request)
|
||||
// {
|
||||
// Guid guid = Guid.NewGuid();
|
||||
// LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||
|
||||
Response_UpdateUniqueKy response = await _uniqueKeyService.Request_UpdateUniqueKey(request);
|
||||
// Response_UpdateUniqueKy response = await _uniqueKeyService.Request_UpdateUniqueKey(request);
|
||||
|
||||
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||
|
||||
return Results.Ok(response);
|
||||
}
|
||||
}
|
||||
// return Results.Ok(response);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
@ -1,7 +1,54 @@
|
||||
using WebApi.Library.Enums;
|
||||
using SystemX.Core.DB;
|
||||
using WebApi.Library.Enums;
|
||||
|
||||
namespace WebApi.Project.UniqueKeyApi.Models
|
||||
{
|
||||
#region CPMeta Wbms
|
||||
|
||||
//Wbms Meta Insert or Update
|
||||
public class Request_SetWbmsMeta
|
||||
{
|
||||
//pk
|
||||
public string ProductID { get; set; } = string.Empty;
|
||||
//uk
|
||||
public string? MacAddress1 { get; set; } = string.Empty;
|
||||
public string? MacAddress2 { get; set; } = string.Empty;
|
||||
|
||||
//value
|
||||
public string? Type { get; set; } = string.Empty;
|
||||
public string? ProductNo { get; set; } = string.Empty;
|
||||
public string? SpareValue { get; set; } = string.Empty;
|
||||
|
||||
public int ShardID { get; set; } = 1;
|
||||
}
|
||||
public class Response_SetWbmsMeta
|
||||
{
|
||||
public string ProductID { get; set; } = string.Empty;
|
||||
public string Result { get; set; } = string.Empty;
|
||||
public string Message { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
//Wbms Meta Select
|
||||
public class Request_GetWbmsMetaByProductID
|
||||
{
|
||||
public string ProductID { get; set; } = string.Empty;
|
||||
public int ShardID { get; set; } = 1;
|
||||
}
|
||||
public class Request_GetWbmsMetaByMacAddress
|
||||
{
|
||||
public string MacAddress { get; set; } = string.Empty;
|
||||
public int ShardID { get; set; } = 1;
|
||||
}
|
||||
|
||||
public class Response_GetWbms
|
||||
{
|
||||
public List<tWbms> Wbms { get; set; }
|
||||
public string Result { get; set; } = string.Empty;
|
||||
public string Message { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unique Key
|
||||
//Insert
|
||||
public class Request_InsertUniqueKey
|
||||
|
||||
@ -26,6 +26,7 @@ builder.Services.AddSingleton<ConfigService<UniqueKeyApiConfig>>();
|
||||
|
||||
//scoped
|
||||
builder.Services.AddSingleton<UniqueKeyService>();
|
||||
builder.Services.AddSingleton<CPMetaService>();
|
||||
|
||||
//db
|
||||
builder.Services.AddSingleton<DbContextProvider>(); // Generic <20><><EFBFBD><EFBFBD>
|
||||
|
||||
@ -0,0 +1,258 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Data;
|
||||
using SystemX.Core.DB;
|
||||
using SystemX.Core.Services;
|
||||
using WebApi.Library.Enums;
|
||||
using WebApi.Project.UniqueKeyApi.Models;
|
||||
|
||||
namespace WebApi.Project.UniqueKeyApi.Services
|
||||
{
|
||||
public class CPMetaService
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
private readonly ConfigService<UniqueKeyApiConfig>? _configService;
|
||||
|
||||
public CPMetaService(IServiceProvider serviceProvider, IServiceScopeFactory scopeFactory, ConfigService<UniqueKeyApiConfig> configSerice)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
_configService = configSerice;
|
||||
}
|
||||
|
||||
public async Task<Response_SetWbmsMeta> SetWbmsMeta(Request_SetWbmsMeta request, string guid = "")
|
||||
{
|
||||
Response_SetWbmsMeta response = new Response_SetWbmsMeta();
|
||||
|
||||
if (request != null)
|
||||
{
|
||||
response.ProductID = request.ProductID;
|
||||
|
||||
bool transactionResult = true;
|
||||
using (var scope = _scopeFactory.CreateScope())
|
||||
{
|
||||
int shardId = request.ShardID;
|
||||
if (shardId <= 0)
|
||||
shardId = 1;
|
||||
|
||||
var provider = scope.ServiceProvider.GetRequiredService<DbContextProvider>();
|
||||
using (var context = GetCPMetaDBContext(provider, shardId))
|
||||
{
|
||||
if (context is not null)
|
||||
{
|
||||
var data = await context.tWbms.AsNoTracking().Where(x => x.cProductID == request.ProductID)?.FirstOrDefaultAsync();
|
||||
if (data is not null) //update
|
||||
{
|
||||
var selected = await context.tWbms.FirstOrDefaultAsync(x => x.cProductID == request.ProductID);
|
||||
if (selected != null)
|
||||
{
|
||||
selected.cMacAddress1 = request.MacAddress1;
|
||||
selected.cMacAddress2 = request.MacAddress2;
|
||||
selected.cType = request.Type;
|
||||
selected.cProductNo = request.ProductNo;
|
||||
selected.cSpareValue = request.SpareValue;
|
||||
|
||||
selected.cDateTime = DateTime.Now;
|
||||
|
||||
using (var transaction = await context.CreateTransactionAsync())
|
||||
{
|
||||
context.Update(selected);
|
||||
transactionResult = await context.CloseTransactionAsync(transaction);
|
||||
}
|
||||
}
|
||||
|
||||
LogXnet.WriteLine($"Update::{guid}", LogXLabel.DB);
|
||||
response.Result = WebApiResult.Update.ToString();
|
||||
}
|
||||
else //insert
|
||||
{
|
||||
var row = new tWbms
|
||||
{
|
||||
cProductID = request.ProductID,
|
||||
cMacAddress1 = request.MacAddress1,
|
||||
cMacAddress2 = request.MacAddress2,
|
||||
cType = request.Type,
|
||||
cProductNo = request.ProductNo,
|
||||
cSpareValue = request.SpareValue,
|
||||
|
||||
cDateTime = DateTime.Now
|
||||
};
|
||||
|
||||
using (var transaction = await context.CreateTransactionAsync())
|
||||
{
|
||||
await context.AddAsync(row);
|
||||
transactionResult = await context.CloseTransactionAsync(transaction);
|
||||
}
|
||||
|
||||
LogXnet.WriteLine($"Insert::{guid}", LogXLabel.DB);
|
||||
response.Result = WebApiResult.Success.ToString();
|
||||
}
|
||||
|
||||
//db error
|
||||
if (transactionResult == false)
|
||||
{
|
||||
LogXnet.WriteLine($"Transaction Error::{guid}", LogXLabel.Error);
|
||||
response.Result = WebApiResult.Failed.ToString();
|
||||
response.Message = "Duplicate Mac Address";
|
||||
}
|
||||
}
|
||||
else //invalid shard id
|
||||
{
|
||||
LogXnet.WriteLine($"ShardID Error::{guid}", LogXLabel.Error);
|
||||
response.Result = WebApiResult.Failed.ToString();
|
||||
response.Message = "Invalid shard id";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<Response_GetWbms> GetWbmsMeta(Request_GetWbmsMetaByProductID request, string guid = "")
|
||||
{
|
||||
Response_GetWbms response = new Response_GetWbms();
|
||||
response.Wbms = new List<tWbms>();
|
||||
|
||||
if (request != null)
|
||||
{
|
||||
using (var scope = _scopeFactory.CreateScope())
|
||||
{
|
||||
int shardId = request.ShardID;
|
||||
if (shardId <= 0)
|
||||
shardId = 1;
|
||||
|
||||
var provider = scope.ServiceProvider.GetRequiredService<DbContextProvider>();
|
||||
using (var context = GetCPMetaDBContext(provider, shardId))
|
||||
{
|
||||
if (context is not null)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var transaction = await context.CreateTransactionAsync(IsolationLevel.ReadUncommitted))
|
||||
{
|
||||
var data = await context.tWbms.AsNoTracking().FirstOrDefaultAsync(x => x.cProductID.ToLower() == request.ProductID.ToLower());
|
||||
await context.CloseTransactionAsync(transaction);
|
||||
if (data != null)
|
||||
{
|
||||
if(response.Wbms is not null)
|
||||
{
|
||||
response.Wbms.Add(data);
|
||||
}
|
||||
|
||||
response.Result = WebApiResult.Success.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
response.Wbms = null;
|
||||
response.Result = WebApiResult.Failed.ToString();
|
||||
response.Message = $"Not exist productID: {request.ProductID}";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
response.Wbms = null;
|
||||
response.Result = WebApiResult.Failed.ToString();
|
||||
response.Message = $"Not exist productID: {request.ProductID}";
|
||||
|
||||
LogXnet.WriteLine($"GetWbmsMeta By ProductID Transaction Error::{guid}", LogXLabel.Error);
|
||||
LogXnet.WriteLine(e);
|
||||
}
|
||||
}
|
||||
else //invalid shard id
|
||||
{
|
||||
LogXnet.WriteLine($"ShardID Error::{guid}", LogXLabel.Error);
|
||||
response.Result = WebApiResult.Failed.ToString();
|
||||
response.Message = "Invalid shard id";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<Response_GetWbms> GetWbmsMeta(Request_GetWbmsMetaByMacAddress request, string guid = "")
|
||||
{
|
||||
Response_GetWbms response = new Response_GetWbms();
|
||||
response.Wbms = new List<tWbms>();
|
||||
|
||||
if (request != null)
|
||||
{
|
||||
using (var scope = _scopeFactory.CreateScope())
|
||||
{
|
||||
int shardId = request.ShardID;
|
||||
if (shardId <= 0)
|
||||
shardId = 1;
|
||||
|
||||
var provider = scope.ServiceProvider.GetRequiredService<DbContextProvider>();
|
||||
using (var context = GetCPMetaDBContext(provider, shardId))
|
||||
{
|
||||
if (context is not null)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var transaction = await context.CreateTransactionAsync(IsolationLevel.ReadUncommitted))
|
||||
{
|
||||
var mac1 = await context.tWbms.AsNoTracking().FirstOrDefaultAsync(x => x.cMacAddress1.ToLower() == request.MacAddress.ToLower());
|
||||
var mac2 = await context.tWbms.AsNoTracking().FirstOrDefaultAsync(x => x.cMacAddress2.ToLower() == request.MacAddress.ToLower());
|
||||
await context.CloseTransactionAsync(transaction);
|
||||
if (mac1 is not null)
|
||||
{
|
||||
if(response.Wbms is not null)
|
||||
{
|
||||
response.Wbms.Add(mac1);
|
||||
}
|
||||
response.Result = WebApiResult.Success.ToString();
|
||||
}
|
||||
|
||||
if(mac2 is not null)
|
||||
{
|
||||
if (response.Wbms is not null)
|
||||
{
|
||||
response.Wbms.Add(mac2);
|
||||
}
|
||||
response.Result = WebApiResult.Success.ToString();
|
||||
}
|
||||
|
||||
if(response.Wbms?.Count <= 0)
|
||||
{
|
||||
response.Wbms = null;
|
||||
response.Result = WebApiResult.Failed.ToString();
|
||||
response.Message = $"Not exist MacAddress: {request.MacAddress}";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
response.Wbms = null;
|
||||
response.Result = WebApiResult.Failed.ToString();
|
||||
response.Message = $"Not exist MacAddrss: {request.MacAddress}";
|
||||
|
||||
LogXnet.WriteLine($"GetWbmsMeta By MacAddress Transaction Error::{guid}", LogXLabel.Error);
|
||||
LogXnet.WriteLine(e);
|
||||
}
|
||||
}
|
||||
else //invalid shard id
|
||||
{
|
||||
LogXnet.WriteLine($"ShardID Error::{guid}", LogXLabel.Error);
|
||||
response.Result = WebApiResult.Failed.ToString();
|
||||
response.Message = "Invalid shard id";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
private CPMetaContext? GetCPMetaDBContext(DbContextProvider provider, int dbID)
|
||||
{
|
||||
var connectionString = _configService?.GetConfig()?.DataBase?.Find(x => x.DBID == dbID);
|
||||
if(connectionString is not null)
|
||||
return provider?.GetDBContext<CPMetaContext>((int)connectionString?.DBID);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user