From 947d35308603754eb04818ec2f98afed51c01ee0 Mon Sep 17 00:00:00 2001 From: Maciej Rybarczyk Date: Fri, 10 Nov 2023 14:12:13 +0100 Subject: [PATCH] Check sheet --- src/Phoenix.Services/Reports/Plcs/ClimatixPlcProcessor.cs | 8 +++++++- src/Phoenix.Services/Reports/Plcs/KamstrupPlcProcessor.cs | 8 +++++++- src/Phoenix.Services/Reports/Plcs/Rvd145PlcProcessor.cs | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Phoenix.Services/Reports/Plcs/ClimatixPlcProcessor.cs b/src/Phoenix.Services/Reports/Plcs/ClimatixPlcProcessor.cs index 3a5b11b..cfb793b 100644 --- a/src/Phoenix.Services/Reports/Plcs/ClimatixPlcProcessor.cs +++ b/src/Phoenix.Services/Reports/Plcs/ClimatixPlcProcessor.cs @@ -30,7 +30,13 @@ public async Task FillDataAsync(UnitOfWork uow, ExcelWorksheets sheets, DateOnly IReadOnlyDictionary plcData = await PlcHandlerHelper.GetPlcDataAsync(uow.Climatix, range, typeProcessor, ClimatixMappings.ToClimatixReportDto, cancellationToken); foreach (KeyValuePair plc in plcData) { - FillData(sheets[plc.Key.ToString()], plc.Value, typeProcessor); + ExcelWorksheet? sheet = sheets.FirstOrDefault(x => x.Name == plc.Key.ToString()); + if (sheet is null) + { + continue; + } + + FillData(sheet, plc.Value, typeProcessor); } } diff --git a/src/Phoenix.Services/Reports/Plcs/KamstrupPlcProcessor.cs b/src/Phoenix.Services/Reports/Plcs/KamstrupPlcProcessor.cs index 624867e..d5bd001 100644 --- a/src/Phoenix.Services/Reports/Plcs/KamstrupPlcProcessor.cs +++ b/src/Phoenix.Services/Reports/Plcs/KamstrupPlcProcessor.cs @@ -30,8 +30,14 @@ public async Task FillDataAsync(UnitOfWork uow, ExcelWorksheets sheets, DateOnly IReadOnlyDictionary plcData = await PlcHandlerHelper.GetPlcDataAsync(uow.Kamstrup, range, typeProcessor, KamstrupMappings.ToKamstrupReportDto, cancellationToken); foreach (KeyValuePair plc in plcData) { + ExcelWorksheet? sheet = sheets.FirstOrDefault(x => x.Name == plc.Key.ToString()); + if (sheet is null) + { + continue; + } + KamstrupDto before = await GetBeforeDataAsync(uow, plc.Key, range.Item1, cancellationToken); - FillData(sheets[plc.Key.ToString()], before, plc.Value, typeProcessor); + FillData(sheet, before, plc.Value, typeProcessor); } } diff --git a/src/Phoenix.Services/Reports/Plcs/Rvd145PlcProcessor.cs b/src/Phoenix.Services/Reports/Plcs/Rvd145PlcProcessor.cs index 942ae35..c3dc441 100644 --- a/src/Phoenix.Services/Reports/Plcs/Rvd145PlcProcessor.cs +++ b/src/Phoenix.Services/Reports/Plcs/Rvd145PlcProcessor.cs @@ -31,7 +31,13 @@ public async Task FillDataAsync(UnitOfWork uow, ExcelWorksheets sheets, DateOnly IReadOnlyDictionary plcData = await PlcHandlerHelper.GetPlcDataAsync(uow.Rvd145, range, typeProcessor, Rvd145Mappings.ToRvd145ReportDto, cancellationToken); foreach (KeyValuePair plc in plcData) { - FillData(sheets[plc.Key.ToString()], plc.Value, typeProcessor); + ExcelWorksheet? sheet = sheets.FirstOrDefault(x => x.Name == plc.Key.ToString()); + if (sheet is null) + { + continue; + } + + FillData(sheet, plc.Value, typeProcessor); } }