Expose error message using ProducesResponseType
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
using OI.Metrology.Wafer.Counter.Models;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Models;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using OI.Metrology.Wafer.Counter.Models;
|
||||
using System.Globalization;
|
||||
|
||||
namespace OI.Metrology.Wafer.Counter.Repository;
|
||||
@ -145,38 +145,48 @@ public class WaferCounterRepository : IWaferCounterRepository
|
||||
return results;
|
||||
}
|
||||
|
||||
private static WaferCounter GetLastQuantityAndSlotMap(string waferSize, HttpClient httpClient, NginxFileSystemSortable nginxFileSystemSortable)
|
||||
private static WaferCounter? GetLastQuantityAndSlotMap(string waferSize, HttpClient httpClient, NginxFileSystemSortable nginxFileSystemSortable)
|
||||
{
|
||||
WaferCounter result;
|
||||
string text = string.Empty;
|
||||
WaferCounter? result;
|
||||
Task<string> value = httpClient.GetStringAsync(nginxFileSystemSortable.Uri);
|
||||
value.Wait();
|
||||
string[] lines = value.Result.Split("\r\n");
|
||||
if (lines.Length <= 1)
|
||||
throw new Exception("Incomplete file length!");
|
||||
string[] segments = nginxFileSystemSortable.Name.Split('-');
|
||||
Record record = GetRecord(lines[0], lines[1]);
|
||||
string equipmentId = segments.Length <= 1 ? nginxFileSystemSortable.Name : segments[1].Split('.')[0];
|
||||
if (string.IsNullOrEmpty(record.SlotMap) || record.SlotMap.Length != 25)
|
||||
throw new Exception("Wrong length for slot-map!");
|
||||
if (record.Total != record.Check)
|
||||
throw new Exception($"Checksum has failed. {record.Total} != {record.Check}");
|
||||
result = new(nginxFileSystemSortable.DateTime, nginxFileSystemSortable.DateTime.ToString("yyyy-MM-dd hh:mm tt"), $"WC{waferSize}{equipmentId}", text, record.Total, record.SlotMap);
|
||||
if (lines.Length < 3)
|
||||
result = WaferCounter.GetWaferCounter("Incomplete file length!");
|
||||
else
|
||||
{
|
||||
string text = string.Empty;
|
||||
string[] segments = nginxFileSystemSortable.Name.Split('-');
|
||||
Record record = GetRecord(lines[^3], lines[^2]);
|
||||
string equipmentId = segments.Length <= 1 ? nginxFileSystemSortable.Name : segments[1].Split('.')[0];
|
||||
if (string.IsNullOrEmpty(record.SlotMap) || record.SlotMap.Length != 25)
|
||||
result = WaferCounter.GetWaferCounter("Wrong length for slot-map!");
|
||||
else
|
||||
{
|
||||
if (record.Total != record.Check)
|
||||
result = WaferCounter.GetWaferCounter($"Checksum has failed. {record.Total} != {record.Check}");
|
||||
else
|
||||
result = new(nginxFileSystemSortable.DateTime, nginxFileSystemSortable.DateTime.ToString("yyyy-MM-dd hh:mm tt"), $"WC{waferSize}{equipmentId}", string.Empty, text, record.Total, record.SlotMap);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
WaferCounter IWaferCounterRepository.GetLastQuantityAndSlotMap(string area, string waferSize)
|
||||
WaferCounter? IWaferCounterRepository.GetLastQuantityAndSlotMap(string area, string waferSize)
|
||||
{
|
||||
WaferCounter result;
|
||||
WaferCounter? result;
|
||||
Uri waferSizeUri = GetWaferSizeUri(area, waferSize);
|
||||
HttpClient httpClient = _HttpClientFactory.CreateClient();
|
||||
string waferSizeDirectory = GetWaferSizeDirectory(area, waferSize, destination: false);
|
||||
List<NginxFileSystemSortable> nginxFileSystemSortableCollection = GetNginxFileSystemSortableCollection(httpClient, waferSizeUri);
|
||||
if (nginxFileSystemSortableCollection.Count < 1)
|
||||
throw new Exception("No files!");
|
||||
result = GetLastQuantityAndSlotMap(waferSize, httpClient, nginxFileSystemSortableCollection[0]);
|
||||
for (int i = 0; i < nginxFileSystemSortableCollection.Count; i++)
|
||||
MoveFile(waferSizeDirectory, nginxFileSystemSortableCollection[i]);
|
||||
result = WaferCounter.GetWaferCounter("No files!");
|
||||
else
|
||||
{
|
||||
result = GetLastQuantityAndSlotMap(waferSize, httpClient, nginxFileSystemSortableCollection[0]);
|
||||
for (int i = 0; i < nginxFileSystemSortableCollection.Count; i++)
|
||||
MoveFile(waferSizeDirectory, nginxFileSystemSortableCollection[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user