From b80a528f990d97ae42f6cc02eca9f0c37b937e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Sat, 1 Feb 2025 19:30:30 +0100 Subject: [PATCH] 02.2025 imports --- WebAPI/Controllers/DataInboxController.cs | 322 +++++++++--------- .../Admin-Monthly/CreateImportWorker.sql | 20 +- .../Admin-Monthly/CreateImportWorkerD1.sql | 10 +- .../Admin-Monthly/CreateImportWorkerFK2.sql | 15 +- ...eProcessWorker-T3MultiSourceSummary-AA.sql | 4 +- .../CreateProcessWorker-T3SingleSource.sql | 7 +- .../CreateProcessWorker-T4SingleSource.sql | 6 +- .../CreateProcessWorker-T5LastValue.sql | 6 +- WebAPI/Models/DataInbox.cs | 34 +- WebAPI/appsettings.Development.json | 2 +- 10 files changed, 217 insertions(+), 209 deletions(-) diff --git a/WebAPI/Controllers/DataInboxController.cs b/WebAPI/Controllers/DataInboxController.cs index a036493..5161685 100644 --- a/WebAPI/Controllers/DataInboxController.cs +++ b/WebAPI/Controllers/DataInboxController.cs @@ -1,162 +1,162 @@ -using System.Data; -using System.Text; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Data.SqlClient; -using WebAPI.Models; - -namespace WebAPI.Controllers; - -[ApiController] -[Route("api/[controller]")] -public class DataInboxController : Controller -{ - private readonly AppDbContext _db; - private readonly IConfiguration _configuration; - private readonly LogsController _logsController; - - public DataInboxController( - AppDbContext db, - GoogleSheetsHelper googleSheetsHelper, - IConfiguration configuration) - { - _db = db; - _configuration = configuration; - _logsController = new LogsController(googleSheetsHelper, _configuration); - } - - [HttpPut] - [Route("Add/{apiKey}")] - [AllowAnonymous] - public IActionResult Add(string apiKey, [FromBody] DataInbox dataInbox) - { - if (apiKey != _configuration["apiKey"]) - { - _logsController.AddEntry(new LogEntry - { - Title = $"Unauthorized request - wrong apiKey ({dataInbox.Source})", - Type = LogEntryType.Warning, - LogType = LogType.DataInbox, - CreatedAt = DateTime.UtcNow - }); - return Unauthorized(); - } - - try - { - if ( - !Request.Headers.TryGetValue("Authorization", out var authHeader)) - { - _logsController.AddEntry(new LogEntry - { - Title = $"Unauthorized request - no authorization header ({dataInbox.Source})", - Type = LogEntryType.Warning, - LogType = LogType.DataInbox, - CreatedAt = DateTime.UtcNow - }); - return Unauthorized(); - } - - var credentialsArr = authHeader.ToString().Split(" "); - if (credentialsArr.Length != 2) - { - _logsController.AddEntry(new LogEntry - { - Title = $"Unauthorized request - wrong auth header format ({dataInbox.Source})", - Type = LogEntryType.Warning, - LogType = LogType.DataInbox, - CreatedAt = DateTime.UtcNow - }); - return Unauthorized(); - } - - var authValue = Encoding.UTF8.GetString(Convert.FromBase64String(credentialsArr[1])); - var username = authValue.Split(':')[0]; - var password = authValue.Split(':')[1]; - if (username != _configuration["morska-user"] || password != _configuration["morska-pass"]) - { - _logsController.AddEntry(new LogEntry - { - Title = $"Unauthorized request - bad credentials ({dataInbox.Source})", - Type = LogEntryType.Warning, - LogType = LogType.DataInbox, - CreatedAt = DateTime.UtcNow - }); - return Unauthorized(); - } - - // check if datainbox.data is base64 encoded value - if (!string.IsNullOrEmpty(dataInbox.Data) && !IsBase64String(dataInbox.Data)) - { - _logsController.AddEntry(new LogEntry - { - Title = $"Invalid data format - not base64 encoded ({dataInbox.Source})", - Type = LogEntryType.Warning, - LogType = LogType.DataInbox, - CreatedAt = DateTime.UtcNow - }); - return BadRequest("Invalid data format - not base64 encoded"); - } - - - dataInbox.Id = Guid.NewGuid(); - dataInbox.CreatedAt = DateTime.UtcNow; - _db.DataInbox.Add(dataInbox); - _db.SaveChanges(); - - _logsController.AddEntry(new LogEntry - { - Title = $"Insert success: {dataInbox.Source}, {dataInbox.Name}", - Type = LogEntryType.Info, - LogType = LogType.DataInbox, - CreatedAt = DateTime.UtcNow - }); - - return Ok(); - } - catch (Exception e) - { - _logsController.AddEntry(new LogEntry - { - Title = $"Insert error: {dataInbox.Source}, {dataInbox.Name}", - Type = LogEntryType.Error, - LogType = LogType.DataInbox, - Message = e.ToString(), - CreatedAt = DateTime.UtcNow - }); - return BadRequest(e.ToString()); - } - } - - [HttpGet] - public IActionResult GetAll() - { - return Ok(_db.DataInbox); - } - - // helpers - private bool IsBase64String(string data) - { - if (string.IsNullOrEmpty(data)) - { - return false; - } - try - { - var base64Bytes = Convert.FromBase64String(data); - - var utf8String = Encoding.UTF8.GetString(base64Bytes); - - var reEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(utf8String)); - return data.TrimEnd('=') == reEncoded.TrimEnd('='); - } - catch (FormatException) - { - return false; - } - catch (DecoderFallbackException) - { - return false; - } - } +using System.Data; +using System.Text; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Data.SqlClient; +using WebAPI.Models; + +namespace WebAPI.Controllers; + +[ApiController] +[Route("api/[controller]")] +public class DataInboxController : Controller +{ + private readonly AppDbContext _db; + private readonly IConfiguration _configuration; + private readonly LogsController _logsController; + + public DataInboxController( + AppDbContext db, + GoogleSheetsHelper googleSheetsHelper, + IConfiguration configuration) + { + _db = db; + _configuration = configuration; + _logsController = new LogsController(googleSheetsHelper, _configuration); + } + + [HttpPut] + [Route("Add/{apiKey}")] + [AllowAnonymous] + public IActionResult Add(string apiKey, [FromBody] DataInbox dataInbox) + { + if (apiKey != _configuration["apiKey"]) + { + _logsController.AddEntry(new LogEntry + { + Title = $"Unauthorized request - wrong apiKey ({dataInbox.Source})", + Type = LogEntryType.Warning, + LogType = LogType.DataInbox, + CreatedAt = DateTime.UtcNow + }); + return Unauthorized(); + } + + try + { + if ( + !Request.Headers.TryGetValue("Authorization", out var authHeader)) + { + _logsController.AddEntry(new LogEntry + { + Title = $"Unauthorized request - no authorization header ({dataInbox.Source})", + Type = LogEntryType.Warning, + LogType = LogType.DataInbox, + CreatedAt = DateTime.UtcNow + }); + return Unauthorized(); + } + + var credentialsArr = authHeader.ToString().Split(" "); + if (credentialsArr.Length != 2) + { + _logsController.AddEntry(new LogEntry + { + Title = $"Unauthorized request - wrong auth header format ({dataInbox.Source})", + Type = LogEntryType.Warning, + LogType = LogType.DataInbox, + CreatedAt = DateTime.UtcNow + }); + return Unauthorized(); + } + + var authValue = Encoding.UTF8.GetString(Convert.FromBase64String(credentialsArr[1])); + var username = authValue.Split(':')[0]; + var password = authValue.Split(':')[1]; + if (username != _configuration["morska-user"] || password != _configuration["morska-pass"]) + { + _logsController.AddEntry(new LogEntry + { + Title = $"Unauthorized request - bad credentials ({dataInbox.Source})", + Type = LogEntryType.Warning, + LogType = LogType.DataInbox, + CreatedAt = DateTime.UtcNow + }); + return Unauthorized(); + } + + // check if datainbox.data is base64 encoded value + if (!string.IsNullOrEmpty(dataInbox.Data) && !IsBase64String(dataInbox.Data)) + { + _logsController.AddEntry(new LogEntry + { + Title = $"Invalid data format - not base64 encoded ({dataInbox.Source})", + Type = LogEntryType.Warning, + LogType = LogType.DataInbox, + CreatedAt = DateTime.UtcNow + }); + return BadRequest("Invalid data format - not base64 encoded"); + } + + + dataInbox.Id = Guid.NewGuid(); + dataInbox.CreatedAt = DateTime.UtcNow; + _db.DataInbox.Add(dataInbox); + _db.SaveChanges(); + + _logsController.AddEntry(new LogEntry + { + Title = $"Insert success: {dataInbox.Source}, {dataInbox.Name}", + Type = LogEntryType.Info, + LogType = LogType.DataInbox, + CreatedAt = DateTime.UtcNow + }); + + return Ok(); + } + catch (Exception e) + { + _logsController.AddEntry(new LogEntry + { + Title = $"Insert error: {dataInbox.Source}, {dataInbox.Name}", + Type = LogEntryType.Error, + LogType = LogType.DataInbox, + Message = e.ToString(), + CreatedAt = DateTime.UtcNow + }); + return BadRequest(e.ToString()); + } + } + + [HttpGet] + public IActionResult GetAll() + { + return Ok(_db.DataInbox); + } + + // helpers + private bool IsBase64String(string data) + { + if (string.IsNullOrEmpty(data)) + { + return false; + } + try + { + var base64Bytes = Convert.FromBase64String(data); + + var utf8String = Encoding.UTF8.GetString(base64Bytes); + + var reEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(utf8String)); + return data.TrimEnd('=') == reEncoded.TrimEnd('='); + } + catch (FormatException) + { + return false; + } + catch (DecoderFallbackException) + { + return false; + } + } } \ No newline at end of file diff --git a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorker.sql b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorker.sql index 1278066..7cc73c7 100644 --- a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorker.sql +++ b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorker.sql @@ -1,4 +1,8 @@ --- MORSKA: K5, PU, AK, FK +-- MORSKA: +-- K5: 1ZzndU8HjYqz5VKCcrVHBOFW8fqpYfwquclznX9q39Yk +-- PU: 1gnJhqdlL622GOJEuAiVzxJu1N1ZlSb4a-JvGB1rwHAo +-- AK: 1epk7AdNNvTyN4TKIIOqan-h5A8HYGbRVM_OS-Ns-Qlg +-- FK: 1k_frcE49O-J_n5MaNiVLKq62-OTCJku1qutGb8YF9M0 -- ADD IMPORT LAYER DECLARE @LayerId UNIQUEIDENTIFIER; @@ -7,17 +11,17 @@ SET @LayerId = NEWID(); INSERT INTO [diunabi-morska].[dbo].[Layers] ([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [CreatedById], [ModifiedById], [Type]) -VALUES ((SELECT @LayerId), 4133, 'L4133-A-IW_K5-2025/01-202412302138', +VALUES ((SELECT @LayerId), 4906, 'L4906-A-IW_FK-2025/02-202501301737', GETDATE(), GETDATE(), 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'StartDate', '2024.12.29', +VALUES ((SELECT NEWID()), 'StartDate', '2025.01.29', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'EndDate', '2025.02.05', +VALUES ((SELECT NEWID()), 'EndDate', '2025.03.05', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] @@ -27,12 +31,12 @@ VALUES ((SELECT NEWID()), 'Source', 'GoogleSheet', INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'SheetTabName', 'Styczen_2025', +VALUES ((SELECT NEWID()), 'SheetTabName', 'Luty_2025', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'SheetId', '1ZzndU8HjYqz5VKCcrVHBOFW8fqpYfwquclznX9q39Yk', +VALUES ((SELECT NEWID()), 'SheetId', '1k_frcE49O-J_n5MaNiVLKq62-OTCJku1qutGb8YF9M0', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] @@ -42,12 +46,12 @@ VALUES ((SELECT NEWID()), 'DataRange', 'E4:DA5', INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'ImportName', 'K5', +VALUES ((SELECT NEWID()), 'ImportName', 'FK', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'ImportMonth', '01', +VALUES ((SELECT NEWID()), 'ImportMonth', '02', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] diff --git a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorkerD1.sql b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorkerD1.sql index d6995e3..33dfa7a 100644 --- a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorkerD1.sql +++ b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorkerD1.sql @@ -5,17 +5,17 @@ SET @LayerId = NEWID(); INSERT INTO [diunabi-morska].[dbo].[Layers] ([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [CreatedById], [ModifiedById], [Type]) -VALUES ((SELECT @LayerId), 4138, 'L4138-A-IW_D1-2024/12-202412302225', +VALUES ((SELECT @LayerId), 4907, 'L4907-A-IW_D1-2024/12-202501201247', GETDATE(), GETDATE(), 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'StartDate', '2024.10.15', +VALUES ((SELECT NEWID()), 'StartDate', '2025.01.01', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'EndDate', '2024.10.30', +VALUES ((SELECT NEWID()), 'EndDate', '2025.01.30', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] @@ -25,7 +25,7 @@ GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'SheetTabName', 'Wrzesien_2024', +VALUES ((SELECT NEWID()), 'SheetTabName', 'Grudzien_2024', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] @@ -50,7 +50,7 @@ VALUES ((SELECT NEWID()), 'ImportYear', '2024', INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'ImportMonth', '11', +VALUES ((SELECT NEWID()), 'ImportMonth', '12', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] diff --git a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorkerFK2.sql b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorkerFK2.sql index 9e1525a..63cffb6 100644 --- a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorkerFK2.sql +++ b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateImportWorkerFK2.sql @@ -1,3 +1,6 @@ +-- MORSKA: +-- FK: 1k_frcE49O-J_n5MaNiVLKq62-OTCJku1qutGb8YF9M0 + -- ADD IMPORT LAYER DECLARE @LayerId UNIQUEIDENTIFIER; SET @LayerId = NEWID(); @@ -5,17 +8,17 @@ SET @LayerId = NEWID(); INSERT INTO [diunabi-morska].[dbo].[Layers] ([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [CreatedById], [ModifiedById], [Type]) -VALUES ((SELECT @LayerId), 4137, 'L4138-A-IW_FK2-2025/01-202412302201', +VALUES ((SELECT @LayerId), 4907, 'L4907-A-IW_FK2-2025/02-202501301739', GETDATE(), GETDATE(), 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'StartDate', '2024.12.29', +VALUES ((SELECT NEWID()), 'StartDate', '2025.01.29', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'EndDate', '2025.02.05', +VALUES ((SELECT NEWID()), 'EndDate', '2025.03.05', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] @@ -25,7 +28,7 @@ VALUES ((SELECT NEWID()), 'Source', 'GoogleSheet', INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'SheetTabName', 'Styczen_2025', +VALUES ((SELECT NEWID()), 'SheetTabName', 'Luty_2025', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] @@ -45,12 +48,12 @@ VALUES ((SELECT NEWID()), 'ImportName', 'FK2', INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'ImportMonth', '01', +VALUES ((SELECT NEWID()), 'ImportMonth', '02', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'ImportYear', '2024', +VALUES ((SELECT NEWID()), 'ImportYear', '2025', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] diff --git a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3MultiSourceSummary-AA.sql b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3MultiSourceSummary-AA.sql index b28aca3..7f9d298 100644 --- a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3MultiSourceSummary-AA.sql +++ b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3MultiSourceSummary-AA.sql @@ -5,7 +5,7 @@ SET @LayerId = NEWID(); INSERT INTO [diunabi-morska].[dbo].[Layers] ([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [CreatedById], [ModifiedById], [Type]) -VALUES ((SELECT @LayerId), 4166, 'L4166-A-PW_AA-2025/01-202412311420', +VALUES ((SELECT @LayerId), 4912, 'L4912-A-PW_AA-2025/02-202501301745', GETDATE(), GETDATE(), 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); INSERT INTO [diunabi-morska].[dbo].[Records] @@ -50,7 +50,7 @@ VALUES ((SELECT NEWID()), 'Year', '2025', INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'Month', '01', +VALUES ((SELECT NEWID()), 'Month', '02', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] diff --git a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3SingleSource.sql b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3SingleSource.sql index 47a79c2..5a993b9 100644 --- a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3SingleSource.sql +++ b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T3SingleSource.sql @@ -1,12 +1,13 @@ --ADD PROCESS LAYERS (K5, PU, AK, FK) -- T3-SingleSource + DECLARE @LayerId UNIQUEIDENTIFIER; SET @LayerId = NEWID(); INSERT INTO [diunabi-morska].[dbo].[Layers] ([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [CreatedById], [ModifiedById], [Type]) -VALUES ((SELECT @LayerId), 4165, 'L4165-A-PW_FK-2025/01-202412311419', +VALUES ((SELECT @LayerId), 4911, 'L4911-A-PW_FK-2025/02-202501301745', GETDATE(), GETDATE(), 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); INSERT INTO [diunabi-morska].[dbo].[Records] @@ -16,7 +17,7 @@ VALUES ((SELECT NEWID()), 'Source', 'FK', INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'SourceLayer', 'L4136-A-IW_FK-2025/01-202412302145', +VALUES ((SELECT NEWID()), 'SourceLayer', 'L4906-A-IW_FK-2025/02-202501301737', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] @@ -41,5 +42,5 @@ VALUES ((SELECT NEWID()), 'Year', '2025', INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'Month', '01', +VALUES ((SELECT NEWID()), 'Month', '02', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); diff --git a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T4SingleSource.sql b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T4SingleSource.sql index 41acb39..b720c80 100644 --- a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T4SingleSource.sql +++ b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T4SingleSource.sql @@ -6,7 +6,7 @@ SET @LayerId = newid(); INSERT INTO [diunabi-morska].[dbo].[Layers] ([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [CreatedById], [ModifiedById], [Type]) -VALUES ((SELECT @LayerId), 4167, 'L4167-A-PW_FK2-2025/01-202412311422', +VALUES ((SELECT @LayerId), 4913, 'L4913-A-PW_FK2-2025/02-202501301746', GETDATE(), GETDATE(), 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); INSERT INTO [diunabi-morska].[dbo].[Records] @@ -16,7 +16,7 @@ VALUES ((SELECT NEWID()), 'Source', 'FK2', INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'SourceLayer', 'L4138-A-IW_FK2-2025/01-202412302201', +VALUES ((SELECT NEWID()), 'SourceLayer', 'L4907-A-IW_FK2-2025/02-202501301739', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] @@ -41,5 +41,5 @@ VALUES ((SELECT NEWID()), 'Year', '2025', INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'Month', '01', +VALUES ((SELECT NEWID()), 'Month', '02', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); diff --git a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T5LastValue.sql b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T5LastValue.sql index 63c37fb..dc59070 100644 --- a/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T5LastValue.sql +++ b/WebAPI/Helpers/DbSeed/Admin-Monthly/CreateProcessWorker-T5LastValue.sql @@ -7,7 +7,7 @@ SET @LayerId = NEWID(); INSERT INTO [diunabi-morska].[dbo].[Layers] ([Id], [Number], [Name], [CreatedAt], [ModifiedAt], [IsDeleted], [CreatedById], [ModifiedById], [Type]) -VALUES ((SELECT @LayerId), 4168, 'L4168-A-PW_D1-2025/01-202412181946', +VALUES ((SELECT @LayerId), 4658, 'L4658-A-PW_D1-2024/12-202501201252', GETDATE(), GETDATE(), 0, '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 2); INSERT INTO [diunabi-morska].[dbo].[Records] @@ -17,7 +17,7 @@ VALUES ((SELECT NEWID()), 'Source', 'D1', INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'SourceLayer', 'L2989-A-IW_D1-2024/09-202410172040', +VALUES ((SELECT NEWID()), 'SourceLayer', 'L4657-A-IW_D1-2024/12-202501201247', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); INSERT INTO [diunabi-morska].[dbo].[Records] @@ -42,5 +42,5 @@ VALUES ((SELECT NEWID()), 'Year', '2024', INSERT INTO [diunabi-morska].[dbo].[Records] ([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId]) -VALUES ((SELECT NEWID()), 'Month', '09', +VALUES ((SELECT NEWID()), 'Month', '12', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, (SELECT @LayerId)); diff --git a/WebAPI/Models/DataInbox.cs b/WebAPI/Models/DataInbox.cs index c9a9503..bce62e0 100644 --- a/WebAPI/Models/DataInbox.cs +++ b/WebAPI/Models/DataInbox.cs @@ -1,18 +1,18 @@ -using System.ComponentModel.DataAnnotations; - -namespace WebAPI.Models; - -public class DataInbox -{ - #region Properties - [Key] - public Guid Id { get; set; } - [StringLength(50)] - public required string Name { get; init; } - [StringLength(50)] - public required string Source { get; set; } - [StringLength(int.MaxValue)] - public required string Data { get; init; } - public DateTime CreatedAt { get; set; } - #endregion +using System.ComponentModel.DataAnnotations; + +namespace WebAPI.Models; + +public class DataInbox +{ + #region Properties + [Key] + public Guid Id { get; set; } + [StringLength(50)] + public required string Name { get; init; } + [StringLength(50)] + public required string Source { get; set; } + [StringLength(int.MaxValue)] + public required string Data { get; init; } + public DateTime CreatedAt { get; set; } + #endregion } \ No newline at end of file diff --git a/WebAPI/appsettings.Development.json b/WebAPI/appsettings.Development.json index eac3c01..b025ae4 100644 --- a/WebAPI/appsettings.Development.json +++ b/WebAPI/appsettings.Development.json @@ -8,7 +8,7 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "SQLDatabase": "Server=tcp:127.0.0.1,1433;Initial Catalog=diunabi-morska;Persist Security Info=False;User ID=SA;Password=$&#ojoOOKEJ223;MultipleActiveResultSets=False;Encrypt=False;TrustServerCertificate=False;Connection Timeout=30;" + "SQLDatabase": "Server=tcp:127.0.0.1,1433;Initial Catalog=diunabi-morska;Persist Security Info=False;User ID=SA;Password=v](8Lc|RfG;MultipleActiveResultSets=False;Encrypt=False;TrustServerCertificate=False;Connection Timeout=30;" }, "GoogleClientId": "107631825312-bkfe438ehr9k9ecb2h76g802tj6advma.apps.googleusercontent.com", "Secret": "8393AF8EAEF8478CB738D44858690F9C7E2D19F65896DD9FBAA3EB2A6F493E80",