| | 1 | | using ReportingServices.Shared.HelperClasses; |
| | 2 | | using ReportingServices.Shared.Models.ProductionReport; |
| | 3 | | using ReportingServices.Shared.ViewModels.ProductionReport; |
| | 4 | | using System.Text.Json; |
| | 5 | | using System.Web; |
| | 6 | |
|
| | 7 | | namespace ReportingServices.Shared.Repositories |
| | 8 | | { |
| | 9 | | public class FabTimeReportingRepository : IFabTimeReportingRepository |
| | 10 | | { |
| 0 | 11 | | 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~R5 |
| | 12 | |
|
| | 13 | | public async Task<List<ReactorOutsByRDS>> GetMovesTrendData(string startDate = "", string endDate = "") |
| 0 | 14 | | { |
| 0 | 15 | | string url = APIHelperFunctions.GenerateURLWithParameters(startDate: startDate, endDate: endDate, chart: "MO |
| | 16 | |
|
| 0 | 17 | | return await GetJsonData<List<ReactorOutsByRDS>>(url); |
| 0 | 18 | | } |
| | 19 | |
|
| | 20 | | public async Task<List<EquipmentStateByDay>> GetToolStateTrendData(string toolType) |
| 0 | 21 | | { |
| 0 | 22 | | string url = APIHelperFunctions.GenerateURLWithParameters(chart: "TOOLSTATE", periodLen: "24", capacityTypes |
| | 23 | |
|
| 0 | 24 | | return await GetJsonData<List<EquipmentStateByDay>>(url); |
| 0 | 25 | | } |
| | 26 | |
|
| | 27 | | public async Task<List<ToolStateCurrent>> GetToolStateData(string toolType) |
| 0 | 28 | | { |
| 0 | 29 | | string capacityFilter = toolType == "ASM" ? toolType + "%2CASM%2B" : toolType; |
| 0 | 30 | | string startDate = HttpUtility.UrlEncode(APIHelperFunctions.GetDateWithOffsetAsAPIString(DateTime.Now.ToStri |
| | 31 | |
|
| 0 | 32 | | string url = APIHelperFunctions.GenerateURLWithParameters(chart: "ToolStateGantt", periodLen: "24", |
| 0 | 33 | | capacityTypesLike: capacityFilter, toolsLike: _toolFilter, startDate: startDate); |
| | 34 | |
|
| 0 | 35 | | return await GetJsonData<List<ToolStateCurrent>>(url); |
| 0 | 36 | | } |
| | 37 | |
|
| | 38 | | public async Task<T> GetJsonData<T>(string url) |
| 0 | 39 | | { |
| | 40 | | T deserializedJson; |
| | 41 | |
|
| 0 | 42 | | using (var client = new HttpClient()) |
| 0 | 43 | | { |
| 0 | 44 | | using (HttpResponseMessage response = await client.GetAsync(url)) |
| 0 | 45 | | { |
| 0 | 46 | | string apiResponse = await response.Content.ReadAsStringAsync(); |
| 0 | 47 | | deserializedJson = JsonSerializer.Deserialize<T>(apiResponse); |
| 0 | 48 | | } |
| 0 | 49 | | } |
| | 50 | |
|
| 0 | 51 | | return deserializedJson; |
| 0 | 52 | | } |
| | 53 | |
|
| | 54 | |
|
| | 55 | | } |
| | 56 | | } |