R1/R2 refactor
This commit is contained in:
2
.idea/.idea.DiunaBI/.idea/sqldialects.xml
generated
2
.idea/.idea.DiunaBI/.idea/sqldialects.xml
generated
@@ -7,5 +7,7 @@
|
||||
<file url="file://$PROJECT_DIR$/WebAPI/Helpers/DbSeed/CreateProcessWorker-T1-R3.sql" dialect="TSQL" />
|
||||
<file url="file://$PROJECT_DIR$/WebAPI/Helpers/DbSeed/CreateProcessWorker-T3MultiSourceSummary-AA.sql" dialect="TSQL" />
|
||||
<file url="file://$PROJECT_DIR$/WebAPI/Helpers/DbSeed/CreateProcessWorker-T5LastValue.sql" dialect="TSQL" />
|
||||
<file url="file://$PROJECT_DIR$/WebAPI/Helpers/DbSeed/CreateRecord.sql" dialect="TSQL" />
|
||||
<file url="PROJECT" dialect="TSQL" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -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');
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user