using Newtonsoft.Json; using System; using SystemX.Core.Communication; using SystemX.Core.Services; using Web.Operation.Packet; using WebClient.Library.Config; namespace Web.Operation.Services { public class CPMetaService { private readonly IServiceScopeFactory _scopeFactory; private readonly ConfigService? _configService; private string ApiHost = string.Empty; public CPMetaService(IServiceProvider serviceProvider, IServiceScopeFactory scopeFactory, ConfigService configService) { _scopeFactory = scopeFactory; _configService = configService; ApiHost = _configService.GetConfig()?.Api.Find(x => x.Id == 1)?.Host; } public async Task GetWbmsMeta(DateOnly? startDate, DateOnly? endDate, string host) { string requestUrl = $"https://{host}/CPMeta/GetWbmsMeta?"; requestUrl += $"startDate={startDate}&"; requestUrl += $"endDate={endDate}&"; requestUrl += $"ShardID=1"; Http http = new Http(); var res = await http.GetJsonAsync($"{requestUrl}"); LogXnet.WriteLine($"{res.ToJson()}", LogXLabel.HTTP); return res; } public async Task GetWbmsMetaByProductID(string productId, string host) { string requestUrl = $"https://{host}/CPMeta/GetWbmsMetaByProductID?"; requestUrl += $"ProductID={productId}&"; requestUrl += $"ShardID=1"; Http http = new Http(); var res = await http.GetJsonAsync($"{requestUrl}"); LogXnet.WriteLine($"{res.ToJson()}", LogXLabel.HTTP); return res; } public async Task GetWbmsMetaByMacAddress(string macAddress, string host) { string requestUrl = $"https://{host}/CPMeta/GetWbmsMetaByMacAddress?"; requestUrl += $"MacAddress={macAddress}&"; requestUrl += $"ShardID=1"; Http http = new Http(); var res = await http.GetJsonAsync($"{requestUrl}"); LogXnet.WriteLine($"{res.ToJson()}", LogXLabel.HTTP); return res; } } }