diff --git a/.idea/.idea.DiunaBI/.idea/sqldialects.xml b/.idea/.idea.DiunaBI/.idea/sqldialects.xml
index 8981d61..3d822f4 100644
--- a/.idea/.idea.DiunaBI/.idea/sqldialects.xml
+++ b/.idea/.idea.DiunaBI/.idea/sqldialects.xml
@@ -7,5 +7,7 @@
+
+
\ No newline at end of file
diff --git a/WebAPI/Helpers/DbSeed/CreateRecord.sql b/WebAPI/Helpers/DbSeed/CreateRecord.sql
index 52f9f98..9c1271b 100644
--- a/WebAPI/Helpers/DbSeed/CreateRecord.sql
+++ b/WebAPI/Helpers/DbSeed/CreateRecord.sql
@@ -1,7 +1,5 @@
-
-
INSERT INTO [diunabi-morska].[dbo].[Records]
([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId])
-VALUES ((SELECT NEWID()), 'Source', 'FK',
+VALUES ((SELECT NEWID()), 'GoogleSheetName-Invoices', 'Raport_R2_Faktury_2024',
GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0,
'e5315187-5bcb-496a-8c63-4c6575e7e04c');
diff --git a/WebAPI/dataProcessors/t1.r1.processor.cs b/WebAPI/dataProcessors/t1.r1.processor.cs
index c4e9399..ffb1de0 100644
--- a/WebAPI/dataProcessors/t1.r1.processor.cs
+++ b/WebAPI/dataProcessors/t1.r1.processor.cs
@@ -179,18 +179,23 @@ public class T1R1Processor(
controller.SaveRecords(processedLayer.Id, newRecords, Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D"));
db.SaveChanges();
- UpdateReport();
+ var sheetName = processWorker.Records?.SingleOrDefault(x => x.Code == "GoogleSheetName")?.Desc1;
+ if (sheetName == null)
+ {
+ throw new Exception("GoogleSheetName record not found");
+ }
+
+ UpdateReport(processedLayer.Id, sheetName);
}
- private void UpdateReport()
+ private void UpdateReport(Guid sourceId, string sheetName)
{
const string sheetId = "1pph-XowjlK5CIaCEV_A5buK4ceJ0Z0YoUlDI4VMkhhA";
- const string sheetName = "Raport_R1_Eksport";
var request = googleSheetValues.Get(sheetId, $"{sheetName}!C4:CQ4");
var response = request.Execute();
var r1 = db.Layers
- .Where(x => x.Number == 2286)
+ .Where(x => x.Id == sourceId)
.Include(x => x.Records)
.FirstOrDefault();
diff --git a/WebAPI/dataProcessors/t4.r2.processor.cs b/WebAPI/dataProcessors/t4.r2.processor.cs
index 7bc35dc..650a45b 100644
--- a/WebAPI/dataProcessors/t4.r2.processor.cs
+++ b/WebAPI/dataProcessors/t4.r2.processor.cs
@@ -193,19 +193,28 @@ public class T4R2Processor(
controller.SaveRecords(processedLayer.Id, newRecords, Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D"));
db.SaveChanges();
- UpdateReport();
+ var reportSheetName = processWorker.Records?.SingleOrDefault(x => x.Code == "GoogleSheetName")?.Desc1;
+ if (reportSheetName == null)
+ {
+ throw new Exception("GoogleSheetName record not found");
+ }
+
+ var invoicesSheetName = processWorker.Records?.SingleOrDefault(x => x.Code == "GoogleSheetName-Invoices")?.Desc1;
+ if (invoicesSheetName == null)
+ {
+ throw new Exception("GoogleSheetName-Invoices record not found");
+ }
+ UpdateReport(processedLayer.Id, reportSheetName, invoicesSheetName);
}
- private void UpdateReport()
+ private void UpdateReport(Guid sourceId, string reportSheetName, string invoicesSheetName)
{
const string sheetId = "1FsUmk_YRIeeGzFCX9tuUJCaLyRtjutX2ZGAEU1DMfJQ";
- const string reportSheetName = "Raport_R2_Sprzedaz";
- const string invoicesSheetName = "Raport_R2_Faktury";
var request = googleSheetValues.Get(sheetId, "C4:Z4");
var response = request.Execute();
var r2 = db.Layers
- .Where(x => x.Number == 1501)
+ .Where(x => x.Id == sourceId)
.Include(x => x.Records)
.FirstOrDefault();