using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using MMDAL.DTO.Scheduling; using MMDAL.Query.Scheduling; using static GB5Shared.DTO.GOP.GBGatewayDTO; namespace MMDAL.CustomCode.Scheduling { public class CandidateDAL : ICandidateDAL { private readonly IQueryExecutor _QueryExecutor; public CandidateDAL(IQueryExecutor queryExecutor) { _QueryExecutor = queryExecutor; } public async Task> GetMachinesForWorkCenterAsync( int workCenterId, LoginDTO loginDTO, CancellationToken ct = default) { try { return await _QueryExecutor.QueryAsync( loginDTO, CandidateQB.GET_MACHINES_FOR_WORKCENTER, new { WorkCenterId = workCenterId, TenantId=loginDTO.ClientId }, cancellationToken: ct).ConfigureAwait(false); } catch (Exception) { throw; } } public async Task> GetPatternCompatibilityAsync( int machineId, int processId, int itemId, int skuId, LoginDTO loginDTO, CancellationToken ct = default) { try { return await _QueryExecutor.QueryAsync( loginDTO, CandidateQB.GET_PATTERN_COMPATIBILITY, new { MachineId = machineId, ProcessId = processId, ItemId = itemId, SkuId = skuId, TenantId = loginDTO.ClientId }, cancellationToken: ct).ConfigureAwait(false); } catch (Exception) { throw; } } public async Task GetLastMountedPatternAsync( int machineId, LoginDTO loginDTO, CancellationToken ct = default) { try { var result = await _QueryExecutor.QuerySingleAsync( loginDTO, CandidateQB.GET_LAST_MOUNTED_PATTERN, new { MachineId = machineId, TenantId = loginDTO.ClientId }, cancellationToken: ct).ConfigureAwait(false); return result?.PatternId; } catch (Exception) { throw; } } public async Task> GetRCCPCapacityAsync( IEnumerable workCenterIds, DateTime horizonFrom, DateTime horizonTo, int tenantId, LoginDTO loginDTO, CancellationToken ct = default) { try { return await _QueryExecutor.QueryAsync( loginDTO, SchedulingRunQB.GET_RCCP_CAPACITY_BY_WC, new { WorkCenterIds = workCenterIds, HorizonFrom = horizonFrom, HorizonTo = horizonTo, TenantId = tenantId }, cancellationToken: ct).ConfigureAwait(false); } catch (Exception) { throw; } } } }