From 6dc7a1674dfedfa1594db9253df478b816e0b808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ben=C3=AD=C4=8Dek?= Date: Mon, 15 Jan 2024 11:09:26 +0100 Subject: [PATCH] added Value Types endpoint for RTD8TM --- Controllers/RTDDataAcquisitionController.cs | 21 ++++++++++++++ Services/RTDDataAcquisitionService.cs | 32 +++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/Controllers/RTDDataAcquisitionController.cs b/Controllers/RTDDataAcquisitionController.cs index dd73afe..357cffd 100644 --- a/Controllers/RTDDataAcquisitionController.cs +++ b/Controllers/RTDDataAcquisitionController.cs @@ -117,5 +117,26 @@ namespace API_SequentMicrosystems.Controllers _RTDDAservice.SetCalibrationData(data); } + //GET api/RTDDA/ValueTypes + /// + /// Get ValueTypes data + /// + /// Sorted List of ValueTypes data responded with data by Ids of SortedList and array + [HttpGet("ValueTypes")] + public SortedList GetValueTypes() + { + return _RTDDAservice.LoadValueTypes(); + } + + //POST api/RTDDA/ValueTypes + /// + /// Post ValueTypes data + /// + /// Sorted List of Value types data responded with data by Ids of SortedList and array + [HttpPost("ValueTypes")] + public void PostValueTypes([FromBody] SortedList data) + { + _RTDDAservice.SaveValueTypes(data); + } } } diff --git a/Services/RTDDataAcquisitionService.cs b/Services/RTDDataAcquisitionService.cs index e7e2ba5..df4acf9 100644 --- a/Services/RTDDataAcquisitionService.cs +++ b/Services/RTDDataAcquisitionService.cs @@ -274,5 +274,37 @@ namespace API_SequentMicrosystems.Services #endregion + #region ValueTypes + + /// + /// Save ValueTypes data to File + /// + public void SaveValueTypes(SortedList data) + { + File.WriteAllText("RTDDA/ValueTypes.json", JsonConvert.SerializeObject(data)); + } + + /// + /// Load ValueTypes data from File + /// + /// + public SortedList LoadValueTypes() + { + try + { +#pragma warning disable CS8603 // Může jít o vrácený odkaz null. + return JsonConvert.DeserializeObject>(File.ReadAllText("RTDDA/ValueTypes.json")); +#pragma warning restore CS8603 // Může jít o vrácený odkaz null. + } + catch + { + return new(); + } + } + + + #endregion + + } }