Removed all references to FabTime
This commit is contained in:
@ -1,106 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ReportingServices.Shared.HelperClasses;
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
using ReportingServices.Shared.ViewModels.ProductionReport;
|
||||
using System.Text.Json;
|
||||
using System.Web;
|
||||
|
||||
namespace ReportingServices.Shared.Repositories
|
||||
{
|
||||
public class FabTimeReportingRepository : IFabTimeReportingRepository
|
||||
{
|
||||
private readonly string _toolFilter = "~R76%2C%20~R78%2C%20~R25%2C%20~R67%2C%20~R69%2C%20~R71%2C%20~R47%2C%20~R51%2C%20~R28";
|
||||
private readonly ILogger<FabTimeReportingRepository> _logger;
|
||||
|
||||
public FabTimeReportingRepository(ILogger<FabTimeReportingRepository> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<List<ReactorOutsByRDS>> GetMovesTrendData(string startDate = "", string endDate = "")
|
||||
{
|
||||
string url = APIHelperFunctions.GenerateURLWithParameters(startDate: startDate, endDate: endDate, chart: "MOVESLOTLIST", areasLike: "CLEANROOM", operationsLike: "1UNLOAD");
|
||||
|
||||
_logger.LogInformation("FabTime URL: {url}", url);
|
||||
|
||||
try
|
||||
{
|
||||
return await GetJsonData<List<ReactorOutsByRDS>>(url);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogCritical(ex, "Error in API call.");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<EquipmentStateByDay>> GetToolStateTrendData(string toolType)
|
||||
{
|
||||
string url = APIHelperFunctions.GenerateURLWithParameters(chart: "TOOLSTATE", periodLen: "24", capacityTypesLike: toolType, toolsLike: _toolFilter);
|
||||
|
||||
_logger.LogInformation("FabTime URL: {url}", url);
|
||||
|
||||
try
|
||||
{
|
||||
return await GetJsonData<List<EquipmentStateByDay>>(url);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogCritical(ex, "Error in API call.");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task<List<ToolStateCurrent>> GetToolStateData(string toolType)
|
||||
{
|
||||
string capacityFilter = toolType == "ASM" ? toolType + "%2CASM%2B" : toolType;
|
||||
string startDate = HttpUtility.UrlEncode(APIHelperFunctions.GetDateWithOffsetAsAPIString(DateTime.Now.ToString(), -12.5f));
|
||||
|
||||
string url = APIHelperFunctions.GenerateURLWithParameters(chart: "ToolStateGantt", periodLen: "24",
|
||||
capacityTypesLike: capacityFilter, toolsLike: _toolFilter, startDate: startDate);
|
||||
|
||||
_logger.LogInformation("FabTime URL: {url}", url);
|
||||
|
||||
try
|
||||
{
|
||||
return await GetJsonData<List<ToolStateCurrent>>(url);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogCritical(ex, "Error in API call.");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task<T> GetJsonData<T>(string url)
|
||||
{
|
||||
T deserializedJson = default(T);
|
||||
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
using (HttpResponseMessage response = await client.GetAsync(url))
|
||||
{
|
||||
string apiResponse = await response.Content.ReadAsStringAsync();
|
||||
|
||||
_logger.LogInformation("API Response: {response}" + apiResponse);
|
||||
|
||||
try
|
||||
{
|
||||
deserializedJson = JsonSerializer.Deserialize<T>(apiResponse);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogCritical(ex, "Failed to deserialize Json object.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return deserializedJson;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user