New lines fixes
All checks were successful
Build Docker Images / test (push) Successful in 1m20s
Build Docker Images / build-and-push (push) Successful in 1m38s

This commit is contained in:
2025-11-18 20:38:35 +01:00
parent a66e2a86da
commit c6a777c245
30 changed files with 2207 additions and 2207 deletions

View File

@@ -1,51 +1,51 @@
using DiunaBI.API.Services; using DiunaBI.API.Services;
using DiunaBI.Domain.Entities; using DiunaBI.Domain.Entities;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace DiunaBI.API.Controllers; namespace DiunaBI.API.Controllers;
[ApiController] [ApiController]
[Route("[controller]")] [Route("[controller]")]
public class AuthController( public class AuthController(
GoogleAuthService googleAuthService, GoogleAuthService googleAuthService,
JwtTokenService jwtTokenService, JwtTokenService jwtTokenService,
ILogger<AuthController> logger) ILogger<AuthController> logger)
: ControllerBase : ControllerBase
{ {
[HttpPost("apiToken")] [HttpPost("apiToken")]
public async Task<IActionResult> ApiToken([FromBody] string idToken) public async Task<IActionResult> ApiToken([FromBody] string idToken)
{ {
try try
{ {
if (string.IsNullOrEmpty(idToken)) if (string.IsNullOrEmpty(idToken))
{ {
logger.LogWarning("Empty idToken received"); logger.LogWarning("Empty idToken received");
return BadRequest("IdToken is required"); return BadRequest("IdToken is required");
} }
var (isValid, user, error) = await googleAuthService.ValidateGoogleTokenAsync(idToken); var (isValid, user, error) = await googleAuthService.ValidateGoogleTokenAsync(idToken);
if (!isValid || user == null) if (!isValid || user == null)
{ {
logger.LogWarning("Google token validation failed: {Error}", error); logger.LogWarning("Google token validation failed: {Error}", error);
return Unauthorized(); return Unauthorized();
} }
var jwt = jwtTokenService.GenerateToken(user); var jwt = jwtTokenService.GenerateToken(user);
logger.LogInformation("User authenticated successfully: {Email}", user.Email); logger.LogInformation("User authenticated successfully: {Email}", user.Email);
return Ok(new return Ok(new
{ {
token = jwt, token = jwt,
id = user.Id, id = user.Id,
expirationTime = DateTime.UtcNow.AddDays(7) // z JwtSettings expirationTime = DateTime.UtcNow.AddDays(7) // z JwtSettings
}); });
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.LogError(ex, "Error during authentication"); logger.LogError(ex, "Error during authentication");
return StatusCode(500, "Internal server error"); return StatusCode(500, "Internal server error");
} }
} }
} }

View File

@@ -1,131 +1,131 @@
using System.Text; using System.Text;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using DiunaBI.Infrastructure.Data; using DiunaBI.Infrastructure.Data;
using DiunaBI.Domain.Entities; using DiunaBI.Domain.Entities;
namespace DiunaBI.API.Controllers; namespace DiunaBI.API.Controllers;
[ApiController] [ApiController]
[Route("[controller]")] [Route("[controller]")]
public class DataInboxController : Controller public class DataInboxController : Controller
{ {
private readonly AppDbContext _db; private readonly AppDbContext _db;
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
private readonly ILogger<DataInboxController> _logger; private readonly ILogger<DataInboxController> _logger;
public DataInboxController( public DataInboxController(
AppDbContext db, AppDbContext db,
IConfiguration configuration, IConfiguration configuration,
ILogger<DataInboxController> logger) ILogger<DataInboxController> logger)
{ {
_db = db; _db = db;
_configuration = configuration; _configuration = configuration;
_logger = logger; _logger = logger;
} }
[HttpPut] [HttpPut]
[Route("Add/{apiKey}")] [Route("Add/{apiKey}")]
[AllowAnonymous] [AllowAnonymous]
public IActionResult Add(string apiKey, [FromBody] DataInbox dataInbox) public IActionResult Add(string apiKey, [FromBody] DataInbox dataInbox)
{ {
if (apiKey != _configuration["apiKey"]) if (apiKey != _configuration["apiKey"])
{ {
_logger.LogWarning("DataInbox: Unauthorized request - wrong apiKey for source {Source}", dataInbox.Source); _logger.LogWarning("DataInbox: Unauthorized request - wrong apiKey for source {Source}", dataInbox.Source);
return Unauthorized(); return Unauthorized();
} }
try try
{ {
if (!Request.Headers.TryGetValue("Authorization", out var authHeader)) if (!Request.Headers.TryGetValue("Authorization", out var authHeader))
{ {
_logger.LogWarning("DataInbox: Unauthorized request - no authorization header for source {Source}", dataInbox.Source); _logger.LogWarning("DataInbox: Unauthorized request - no authorization header for source {Source}", dataInbox.Source);
return Unauthorized(); return Unauthorized();
} }
var credentialsArr = authHeader.ToString().Split(" "); var credentialsArr = authHeader.ToString().Split(" ");
if (credentialsArr.Length != 2) if (credentialsArr.Length != 2)
{ {
_logger.LogWarning("DataInbox: Unauthorized request - wrong auth header format for source {Source}", dataInbox.Source); _logger.LogWarning("DataInbox: Unauthorized request - wrong auth header format for source {Source}", dataInbox.Source);
return Unauthorized(); return Unauthorized();
} }
var authValue = Encoding.UTF8.GetString(Convert.FromBase64String(credentialsArr[1])); var authValue = Encoding.UTF8.GetString(Convert.FromBase64String(credentialsArr[1]));
var username = authValue.Split(':')[0]; var username = authValue.Split(':')[0];
var password = authValue.Split(':')[1]; var password = authValue.Split(':')[1];
if (username != _configuration["morska-user"] || password != _configuration["morska-pass"]) if (username != _configuration["morska-user"] || password != _configuration["morska-pass"])
{ {
_logger.LogWarning("DataInbox: Unauthorized request - bad credentials for source {Source}", dataInbox.Source); _logger.LogWarning("DataInbox: Unauthorized request - bad credentials for source {Source}", dataInbox.Source);
return Unauthorized(); return Unauthorized();
} }
// check if datainbox.data is base64 encoded value // check if datainbox.data is base64 encoded value
if (!string.IsNullOrEmpty(dataInbox.Data) && !IsBase64String(dataInbox.Data)) if (!string.IsNullOrEmpty(dataInbox.Data) && !IsBase64String(dataInbox.Data))
{ {
_logger.LogWarning("DataInbox: Invalid data format - not base64 encoded for source {Source}", dataInbox.Source); _logger.LogWarning("DataInbox: Invalid data format - not base64 encoded for source {Source}", dataInbox.Source);
return BadRequest("Invalid data format - not base64 encoded"); return BadRequest("Invalid data format - not base64 encoded");
} }
dataInbox.Id = Guid.NewGuid(); dataInbox.Id = Guid.NewGuid();
dataInbox.CreatedAt = DateTime.UtcNow; dataInbox.CreatedAt = DateTime.UtcNow;
_db.DataInbox.Add(dataInbox); _db.DataInbox.Add(dataInbox);
_db.SaveChanges(); _db.SaveChanges();
_logger.LogInformation("DataInbox: Insert success for source {Source}, name {Name}", dataInbox.Source, dataInbox.Name); _logger.LogInformation("DataInbox: Insert success for source {Source}, name {Name}", dataInbox.Source, dataInbox.Name);
if (dataInbox.Name == "morska.d3.importer") if (dataInbox.Name == "morska.d3.importer")
{ {
_logger.LogDebug("DataInbox: Detected morska.d3.importer - processing will be handled by AutoImport"); _logger.LogDebug("DataInbox: Detected morska.d3.importer - processing will be handled by AutoImport");
// AutoImport będzie obsługiwać ten typ danych // AutoImport będzie obsługiwać ten typ danych
} }
return Ok(); return Ok();
} }
catch (Exception e) catch (Exception e)
{ {
_logger.LogError(e, "DataInbox: Insert error for source {Source}, name {Name}", dataInbox.Source, dataInbox.Name); _logger.LogError(e, "DataInbox: Insert error for source {Source}, name {Name}", dataInbox.Source, dataInbox.Name);
return BadRequest(e.ToString()); return BadRequest(e.ToString());
} }
} }
[HttpGet] [HttpGet]
public IActionResult GetAll() public IActionResult GetAll()
{ {
try try
{ {
var dataInbox = _db.DataInbox.AsNoTracking().ToList(); var dataInbox = _db.DataInbox.AsNoTracking().ToList();
_logger.LogDebug("DataInbox: Retrieved {Count} records", dataInbox.Count); _logger.LogDebug("DataInbox: Retrieved {Count} records", dataInbox.Count);
return Ok(dataInbox); return Ok(dataInbox);
} }
catch (Exception e) catch (Exception e)
{ {
_logger.LogError(e, "DataInbox: Error retrieving records"); _logger.LogError(e, "DataInbox: Error retrieving records");
return BadRequest(e.ToString()); return BadRequest(e.ToString());
} }
} }
// helpers // helpers
private bool IsBase64String(string data) private bool IsBase64String(string data)
{ {
if (string.IsNullOrEmpty(data)) if (string.IsNullOrEmpty(data))
{ {
return false; return false;
} }
try try
{ {
var base64Bytes = Convert.FromBase64String(data); var base64Bytes = Convert.FromBase64String(data);
var utf8String = Encoding.UTF8.GetString(base64Bytes); var utf8String = Encoding.UTF8.GetString(base64Bytes);
var reEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(utf8String)); var reEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(utf8String));
return data.TrimEnd('=') == reEncoded.TrimEnd('='); return data.TrimEnd('=') == reEncoded.TrimEnd('=');
} }
catch (FormatException) catch (FormatException)
{ {
return false; return false;
} }
catch (DecoderFallbackException) catch (DecoderFallbackException)
{ {
return false; return false;
} }
} }
} }

View File

@@ -1,50 +1,50 @@
using DiunaBI.Infrastructure.Services; using DiunaBI.Infrastructure.Services;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace DiunaBI.API.Controllers; namespace DiunaBI.API.Controllers;
[ApiController] [ApiController]
[Route("[controller]")] [Route("[controller]")]
[Authorize] [Authorize]
public class TestsController : Controller public class TestsController : Controller
{ {
private readonly PluginManager _pluginManager; private readonly PluginManager _pluginManager;
private readonly ILogger<LayersController> _logger; private readonly ILogger<LayersController> _logger;
public TestsController( public TestsController(
PluginManager pluginManager, PluginManager pluginManager,
ILogger<LayersController> logger) ILogger<LayersController> logger)
{ {
_pluginManager = pluginManager; _pluginManager = pluginManager;
_logger = logger; _logger = logger;
} }
[HttpGet] [HttpGet]
[Route("Ping")] [Route("Ping")]
[AllowAnonymous] [AllowAnonymous]
public IActionResult Ping() public IActionResult Ping()
{ {
var tmp = new var tmp = new
{ {
a = 2, a = 2,
b = "test" b = "test"
}; };
var tmp2 = new var tmp2 = new
{ {
a = 2, a = 2,
b = "test" b = "test"
}; };
var user = User.Identity; var user = User.Identity;
_logger.LogInformation("LogTest: OldValue {tmp}, NewValue {tmp2}, ChangedBy: {user}", tmp, tmp2, user?.Name); _logger.LogInformation("LogTest: OldValue {tmp}, NewValue {tmp2}, ChangedBy: {user}", tmp, tmp2, user?.Name);
return Ok("Pong"); return Ok("Pong");
} }
[HttpGet] [HttpGet]
[Route("Plugins")] [Route("Plugins")]
[AllowAnonymous] [AllowAnonymous]
public IActionResult GetPlugins() public IActionResult GetPlugins()
{ {
var plugins = _pluginManager.GetPluginsCount(); var plugins = _pluginManager.GetPluginsCount();
return Ok(plugins); return Ok(plugins);
} }
} }

View File

@@ -1,45 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>DiunaBI.WebAPI</RootNamespace> <RootNamespace>DiunaBI.WebAPI</RootNamespace>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Google.Cloud.Firestore" Version="3.4.0" /> <PackageReference Include="Google.Cloud.Firestore" Version="3.4.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0" /> <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0" />
<PackageReference Include="Google.Apis.Auth" Version="1.68.0" /> <PackageReference Include="Google.Apis.Auth" Version="1.68.0" />
<PackageReference Include="Google.Apis.Drive.v3" Version="1.68.0.3627" /> <PackageReference Include="Google.Apis.Drive.v3" Version="1.68.0.3627" />
<PackageReference Include="Google.Apis.Sheets.v4" Version="1.68.0.3624" /> <PackageReference Include="Google.Apis.Sheets.v4" Version="1.68.0.3624" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" /> <PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" /> <PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="9.0.0" /> <PackageReference Include="Serilog.Sinks.Seq" Version="9.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" /> <PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\DiunaBI.Infrastructure\DiunaBI.Infrastructure.csproj" /> <ProjectReference Include="..\DiunaBI.Infrastructure\DiunaBI.Infrastructure.csproj" />
<ProjectReference Include="..\DiunaBI.Application\DiunaBI.Application.csproj" /> <ProjectReference Include="..\DiunaBI.Application\DiunaBI.Application.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Update="client_secrets.Development.json"> <Content Update="client_secrets.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content> </Content>
</ItemGroup> </ItemGroup>
<Target Name="CopyPlugins" AfterTargets="Build"> <Target Name="CopyPlugins" AfterTargets="Build">
<MSBuild Projects="../DiunaBI.Plugins.Morska/DiunaBI.Plugins.Morska.csproj" Properties="Configuration=$(Configuration);TargetFramework=$(TargetFramework)" /> <MSBuild Projects="../DiunaBI.Plugins.Morska/DiunaBI.Plugins.Morska.csproj" Properties="Configuration=$(Configuration);TargetFramework=$(TargetFramework)" />
<ItemGroup> <ItemGroup>
<PluginFiles Include="../DiunaBI.Plugins.Morska/bin/$(Configuration)/$(TargetFramework)/DiunaBI.Plugins.Morska.dll" /> <PluginFiles Include="../DiunaBI.Plugins.Morska/bin/$(Configuration)/$(TargetFramework)/DiunaBI.Plugins.Morska.dll" />
</ItemGroup> </ItemGroup>
<MakeDir Directories="$(OutputPath)Plugins" /> <MakeDir Directories="$(OutputPath)Plugins" />
<Copy SourceFiles="@(PluginFiles)" DestinationFolder="$(OutputPath)Plugins" /> <Copy SourceFiles="@(PluginFiles)" DestinationFolder="$(OutputPath)Plugins" />
</Target> </Target>
</Project> </Project>

View File

@@ -1,23 +1,23 @@
{ {
"$schema": "https://json.schemastore.org/launchsettings.json", "$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": { "profiles": {
"http": { "http": {
"commandName": "Project", "commandName": "Project",
"dotnetRunMessages": true, "dotnetRunMessages": true,
"launchBrowser": false, "launchBrowser": false,
"applicationUrl": "http://localhost:5163", "applicationUrl": "http://localhost:5163",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }
}, },
"https": { "https": {
"commandName": "Project", "commandName": "Project",
"dotnetRunMessages": true, "dotnetRunMessages": true,
"launchBrowser": false, "launchBrowser": false,
"applicationUrl": "https://localhost:7148;http://localhost:5163", "applicationUrl": "https://localhost:7148;http://localhost:5163",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }
} }
} }
} }

View File

@@ -1,47 +1,47 @@
{ {
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
}, },
"Serilog": { "Serilog": {
"MinimumLevel": { "MinimumLevel": {
"Default": "Information", "Default": "Information",
"Override": { "Override": {
"Microsoft.AspNetCore": "Warning", "Microsoft.AspNetCore": "Warning",
"Microsoft.EntityFrameworkCore.Database.Command": "Warning", "Microsoft.EntityFrameworkCore.Database.Command": "Warning",
"Microsoft.EntityFrameworkCore.Infrastructure": "Warning", "Microsoft.EntityFrameworkCore.Infrastructure": "Warning",
"System.Net.Http.HttpClient": "Warning", "System.Net.Http.HttpClient": "Warning",
"Google.Apis": "Warning", "Google.Apis": "Warning",
"DiunaBI.Core.Services.PluginManager": "Information" "DiunaBI.Core.Services.PluginManager": "Information"
} }
}, },
"WriteTo": [ "WriteTo": [
{ {
"Name": "Console", "Name": "Console",
"Args": { "Args": {
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}" "outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
} }
}, },
{ {
"Name": "File", "Name": "File",
"Args": { "Args": {
"path": "/var/log/diunabi/app-.log", "path": "/var/log/diunabi/app-.log",
"rollingInterval": "Day", "rollingInterval": "Day",
"retainedFileCountLimit": 30, "retainedFileCountLimit": 30,
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext} {Message:lj} {Properties:j}{NewLine}{Exception}" "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext} {Message:lj} {Properties:j}{NewLine}{Exception}"
} }
} }
], ],
"Enrich": ["FromLogContext", "WithMachineName", "WithThreadId"] "Enrich": ["FromLogContext", "WithMachineName", "WithThreadId"]
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"Kestrel": { "Kestrel": {
"Endpoints": { "Endpoints": {
"Http": { "Http": {
"Url": "http://0.0.0.0:7142" "Url": "http://0.0.0.0:7142"
} }
} }
} }
} }

View File

@@ -1,15 +1,15 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace DiunaBI.Domain.Entities; namespace DiunaBI.Domain.Entities;
public class DataInbox public class DataInbox
{ {
#region Properties #region Properties
public Guid Id { get; set; } public Guid Id { get; set; }
public required string Name { get; init; } public required string Name { get; init; }
public required string Source { get; set; } public required string Source { get; set; }
public required string Data { get; init; } public required string Data { get; init; }
public DateTime CreatedAt { get; set; } public DateTime CreatedAt { get; set; }
#endregion #endregion
} }

View File

@@ -1,34 +1,34 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace DiunaBI.Domain.Entities; namespace DiunaBI.Domain.Entities;
public enum LayerType public enum LayerType
{ {
Import, Import,
Processed, Processed,
Administration, Administration,
Dictionary, Dictionary,
} }
public class Layer public class Layer
{ {
#region Properties #region Properties
public Guid Id { get; init; } public Guid Id { get; init; }
public int Number { get; init; } public int Number { get; init; }
public string? Name { get; set; } public string? Name { get; set; }
public LayerType Type { get; init; } public LayerType Type { get; init; }
public DateTime CreatedAt { get; set; } public DateTime CreatedAt { get; set; }
public DateTime ModifiedAt { get; set; } public DateTime ModifiedAt { get; set; }
public bool IsDeleted { get; init; } = false; public bool IsDeleted { get; init; } = false;
public bool IsCancelled { get; init; } = false; public bool IsCancelled { get; init; } = false;
#endregion #endregion
#region Relations #region Relations
public ICollection<Record>? Records { get; init; } public ICollection<Record>? Records { get; init; }
public Guid CreatedById { get; set; } public Guid CreatedById { get; set; }
public User? CreatedBy { get; init; } public User? CreatedBy { get; init; }
public Guid ModifiedById { get; set; } public Guid ModifiedById { get; set; }
public User? ModifiedBy { get; init; } public User? ModifiedBy { get; init; }
public Guid? ParentId { get; init; } public Guid? ParentId { get; init; }
#endregion #endregion
} }

View File

@@ -1,13 +1,13 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace DiunaBI.Domain.Entities; namespace DiunaBI.Domain.Entities;
public class ProcessSource public class ProcessSource
{ {
#region Relations #region Relations
public Guid LayerId { get; init; } public Guid LayerId { get; init; }
public Guid SourceId { get; init; } public Guid SourceId { get; init; }
public Layer? Source { get; init; } public Layer? Source { get; init; }
#endregion #endregion
} }

View File

@@ -1,14 +1,14 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace DiunaBI.Domain.Entities; namespace DiunaBI.Domain.Entities;
public class User public class User
{ {
#region Properties #region Properties
public Guid Id { get; init; } public Guid Id { get; init; }
public string? Email { get; init; } public string? Email { get; init; }
public string? UserName { get; set; } public string? UserName { get; set; }
public DateTime CreatedAt { get; init; } public DateTime CreatedAt { get; init; }
#endregion #endregion
} }

View File

@@ -1,183 +1,183 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using DiunaBI.Domain.Entities; using DiunaBI.Domain.Entities;
namespace DiunaBI.Infrastructure.Data; namespace DiunaBI.Infrastructure.Data;
public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options) public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
{ {
public DbSet<User> Users { get; init; } public DbSet<User> Users { get; init; }
public DbSet<Layer> Layers { get; init; } public DbSet<Layer> Layers { get; init; }
public DbSet<Record> Records { get; init; } public DbSet<Record> Records { get; init; }
public DbSet<ProcessSource> ProcessSources { get; init; } public DbSet<ProcessSource> ProcessSources { get; init; }
public DbSet<DataInbox> DataInbox { get; init; } public DbSet<DataInbox> DataInbox { get; init; }
public DbSet<QueueJob> QueueJobs { get; init; } public DbSet<QueueJob> QueueJobs { get; init; }
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {
modelBuilder.Entity<User>().HasKey(x => x.Id); modelBuilder.Entity<User>().HasKey(x => x.Id);
modelBuilder.Entity<User>().Property(x => x.Email).HasMaxLength(50); modelBuilder.Entity<User>().Property(x => x.Email).HasMaxLength(50);
modelBuilder.Entity<User>().Property(x => x.UserName).HasMaxLength(50); modelBuilder.Entity<User>().Property(x => x.UserName).HasMaxLength(50);
modelBuilder.Entity<Layer>().HasKey(x => x.Id); modelBuilder.Entity<Layer>().HasKey(x => x.Id);
modelBuilder.Entity<Layer>().Property(x => x.Number).IsRequired(); modelBuilder.Entity<Layer>().Property(x => x.Number).IsRequired();
modelBuilder.Entity<Layer>().Property(x => x.Name).IsRequired().HasMaxLength(50); modelBuilder.Entity<Layer>().Property(x => x.Name).IsRequired().HasMaxLength(50);
modelBuilder.Entity<Layer>().Property(x => x.Type).IsRequired().HasConversion<int>(); modelBuilder.Entity<Layer>().Property(x => x.Type).IsRequired().HasConversion<int>();
modelBuilder.Entity<Layer>().Property(x => x.CreatedAt).IsRequired(); modelBuilder.Entity<Layer>().Property(x => x.CreatedAt).IsRequired();
modelBuilder.Entity<Layer>().Property(x => x.ModifiedAt).IsRequired(); modelBuilder.Entity<Layer>().Property(x => x.ModifiedAt).IsRequired();
modelBuilder.Entity<Layer>().Property(x => x.IsDeleted).IsRequired().HasDefaultValue(false); modelBuilder.Entity<Layer>().Property(x => x.IsDeleted).IsRequired().HasDefaultValue(false);
modelBuilder.Entity<Layer>().Property(x => x.IsCancelled).IsRequired(); modelBuilder.Entity<Layer>().Property(x => x.IsCancelled).IsRequired();
modelBuilder.Entity<Layer>().Property(x => x.CreatedById).IsRequired(); modelBuilder.Entity<Layer>().Property(x => x.CreatedById).IsRequired();
modelBuilder.Entity<Layer>().Property(x => x.ModifiedById).IsRequired(); modelBuilder.Entity<Layer>().Property(x => x.ModifiedById).IsRequired();
modelBuilder.Entity<Layer>() modelBuilder.Entity<Layer>()
.HasOne(x => x.CreatedBy) .HasOne(x => x.CreatedBy)
.WithMany() .WithMany()
.HasForeignKey(x => x.CreatedById) .HasForeignKey(x => x.CreatedById)
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<Layer>() modelBuilder.Entity<Layer>()
.HasOne(x => x.ModifiedBy) .HasOne(x => x.ModifiedBy)
.WithMany() .WithMany()
.HasForeignKey(x => x.ModifiedById) .HasForeignKey(x => x.ModifiedById)
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<Layer>() modelBuilder.Entity<Layer>()
.HasMany(x => x.Records) .HasMany(x => x.Records)
.WithOne() .WithOne()
.HasForeignKey(r => r.LayerId) .HasForeignKey(r => r.LayerId)
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<Record>().HasKey(x => x.Id); modelBuilder.Entity<Record>().HasKey(x => x.Id);
modelBuilder.Entity<Record>().Property(x => x.Code).IsRequired().HasMaxLength(50); modelBuilder.Entity<Record>().Property(x => x.Code).IsRequired().HasMaxLength(50);
modelBuilder.Entity<Record>().Property(x => x.Desc1).HasMaxLength(10000); modelBuilder.Entity<Record>().Property(x => x.Desc1).HasMaxLength(10000);
modelBuilder.Entity<Record>().Property(x => x.CreatedAt); modelBuilder.Entity<Record>().Property(x => x.CreatedAt);
modelBuilder.Entity<Record>().Property(x => x.ModifiedAt); modelBuilder.Entity<Record>().Property(x => x.ModifiedAt);
modelBuilder.Entity<Record>().Property(x => x.IsDeleted); modelBuilder.Entity<Record>().Property(x => x.IsDeleted);
modelBuilder.Entity<Record>().Property(x => x.CreatedById).IsRequired(); modelBuilder.Entity<Record>().Property(x => x.CreatedById).IsRequired();
modelBuilder.Entity<Record>().Property(x => x.ModifiedById).IsRequired(); modelBuilder.Entity<Record>().Property(x => x.ModifiedById).IsRequired();
modelBuilder.Entity<Record>().Property(x => x.LayerId).IsRequired(); modelBuilder.Entity<Record>().Property(x => x.LayerId).IsRequired();
modelBuilder.Entity<Record>() modelBuilder.Entity<Record>()
.HasOne(x => x.CreatedBy) .HasOne(x => x.CreatedBy)
.WithMany() .WithMany()
.HasForeignKey(x => x.CreatedById) .HasForeignKey(x => x.CreatedById)
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<Record>() modelBuilder.Entity<Record>()
.HasOne(x => x.ModifiedBy) .HasOne(x => x.ModifiedBy)
.WithMany() .WithMany()
.HasForeignKey(x => x.ModifiedById) .HasForeignKey(x => x.ModifiedById)
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<Record>() modelBuilder.Entity<Record>()
.HasOne<Layer>() .HasOne<Layer>()
.WithMany(l => l.Records!) .WithMany(l => l.Records!)
.HasForeignKey(x => x.LayerId) .HasForeignKey(x => x.LayerId)
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<ProcessSource>().HasKey(x => new { x.LayerId, x.SourceId }); modelBuilder.Entity<ProcessSource>().HasKey(x => new { x.LayerId, x.SourceId });
modelBuilder.Entity<ProcessSource>().Property(x => x.LayerId).IsRequired(); modelBuilder.Entity<ProcessSource>().Property(x => x.LayerId).IsRequired();
modelBuilder.Entity<ProcessSource>().Property(x => x.SourceId).IsRequired(); modelBuilder.Entity<ProcessSource>().Property(x => x.SourceId).IsRequired();
modelBuilder.Entity<ProcessSource>() modelBuilder.Entity<ProcessSource>()
.HasOne<Layer>() .HasOne<Layer>()
.WithMany() .WithMany()
.HasForeignKey(x => x.LayerId) .HasForeignKey(x => x.LayerId)
.OnDelete(DeleteBehavior.Cascade); .OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<ProcessSource>() modelBuilder.Entity<ProcessSource>()
.HasOne(x => x.Source) .HasOne(x => x.Source)
.WithMany() .WithMany()
.HasForeignKey(x => x.SourceId) .HasForeignKey(x => x.SourceId)
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<DataInbox>().HasKey(x => x.Id); modelBuilder.Entity<DataInbox>().HasKey(x => x.Id);
modelBuilder.Entity<DataInbox>().Property(x => x.Name).IsRequired().HasMaxLength(50); modelBuilder.Entity<DataInbox>().Property(x => x.Name).IsRequired().HasMaxLength(50);
modelBuilder.Entity<DataInbox>().Property(x => x.Source).IsRequired().HasMaxLength(50); modelBuilder.Entity<DataInbox>().Property(x => x.Source).IsRequired().HasMaxLength(50);
modelBuilder.Entity<DataInbox>().Property(x => x.Data).IsRequired(); modelBuilder.Entity<DataInbox>().Property(x => x.Data).IsRequired();
modelBuilder.Entity<DataInbox>().Property(x => x.CreatedAt); modelBuilder.Entity<DataInbox>().Property(x => x.CreatedAt);
modelBuilder.Entity<QueueJob>().HasKey(x => x.Id); modelBuilder.Entity<QueueJob>().HasKey(x => x.Id);
modelBuilder.Entity<QueueJob>().Property(x => x.LayerId).IsRequired(); modelBuilder.Entity<QueueJob>().Property(x => x.LayerId).IsRequired();
modelBuilder.Entity<QueueJob>().Property(x => x.LayerName).IsRequired().HasMaxLength(200); modelBuilder.Entity<QueueJob>().Property(x => x.LayerName).IsRequired().HasMaxLength(200);
modelBuilder.Entity<QueueJob>().Property(x => x.PluginName).IsRequired().HasMaxLength(100); modelBuilder.Entity<QueueJob>().Property(x => x.PluginName).IsRequired().HasMaxLength(100);
modelBuilder.Entity<QueueJob>().Property(x => x.JobType).IsRequired().HasConversion<int>(); modelBuilder.Entity<QueueJob>().Property(x => x.JobType).IsRequired().HasConversion<int>();
modelBuilder.Entity<QueueJob>().Property(x => x.Priority); modelBuilder.Entity<QueueJob>().Property(x => x.Priority);
modelBuilder.Entity<QueueJob>().Property(x => x.CreatedAt).IsRequired(); modelBuilder.Entity<QueueJob>().Property(x => x.CreatedAt).IsRequired();
modelBuilder.Entity<QueueJob>().Property(x => x.RetryCount); modelBuilder.Entity<QueueJob>().Property(x => x.RetryCount);
modelBuilder.Entity<QueueJob>().Property(x => x.MaxRetries); modelBuilder.Entity<QueueJob>().Property(x => x.MaxRetries);
modelBuilder.Entity<QueueJob>().Property(x => x.Status).IsRequired().HasConversion<int>(); modelBuilder.Entity<QueueJob>().Property(x => x.Status).IsRequired().HasConversion<int>();
modelBuilder.Entity<QueueJob>().Property(x => x.LastError).HasMaxLength(1000); modelBuilder.Entity<QueueJob>().Property(x => x.LastError).HasMaxLength(1000);
modelBuilder.Entity<QueueJob>().Property(x => x.LastAttemptAt); modelBuilder.Entity<QueueJob>().Property(x => x.LastAttemptAt);
modelBuilder.Entity<QueueJob>().Property(x => x.CompletedAt); modelBuilder.Entity<QueueJob>().Property(x => x.CompletedAt);
modelBuilder.Entity<QueueJob>().Property(x => x.CreatedById).IsRequired(); modelBuilder.Entity<QueueJob>().Property(x => x.CreatedById).IsRequired();
modelBuilder.Entity<QueueJob>().Property(x => x.CreatedAtUtc).IsRequired(); modelBuilder.Entity<QueueJob>().Property(x => x.CreatedAtUtc).IsRequired();
modelBuilder.Entity<QueueJob>().Property(x => x.ModifiedById).IsRequired(); modelBuilder.Entity<QueueJob>().Property(x => x.ModifiedById).IsRequired();
modelBuilder.Entity<QueueJob>().Property(x => x.ModifiedAtUtc).IsRequired(); modelBuilder.Entity<QueueJob>().Property(x => x.ModifiedAtUtc).IsRequired();
// Configure automatic timestamps for entities with CreatedAt/ModifiedAt // Configure automatic timestamps for entities with CreatedAt/ModifiedAt
ConfigureTimestamps(modelBuilder); ConfigureTimestamps(modelBuilder);
} }
private void ConfigureTimestamps(ModelBuilder modelBuilder) private void ConfigureTimestamps(ModelBuilder modelBuilder)
{ {
foreach (var entityType in modelBuilder.Model.GetEntityTypes()) foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{ {
// Check if entity has CreatedAt property // Check if entity has CreatedAt property
var createdAtProperty = entityType.FindProperty("CreatedAt"); var createdAtProperty = entityType.FindProperty("CreatedAt");
if (createdAtProperty != null) if (createdAtProperty != null)
{ {
modelBuilder.Entity(entityType.ClrType) modelBuilder.Entity(entityType.ClrType)
.Property("CreatedAt") .Property("CreatedAt")
.HasDefaultValueSql("NOW()"); .HasDefaultValueSql("NOW()");
} }
// Check if entity has ModifiedAt property // Check if entity has ModifiedAt property
var modifiedAtProperty = entityType.FindProperty("ModifiedAt"); var modifiedAtProperty = entityType.FindProperty("ModifiedAt");
if (modifiedAtProperty != null) if (modifiedAtProperty != null)
{ {
modelBuilder.Entity(entityType.ClrType) modelBuilder.Entity(entityType.ClrType)
.Property("ModifiedAt") .Property("ModifiedAt")
.HasDefaultValueSql("NOW()"); .HasDefaultValueSql("NOW()");
} }
} }
} }
public override int SaveChanges() public override int SaveChanges()
{ {
UpdateTimestamps(); UpdateTimestamps();
return base.SaveChanges(); return base.SaveChanges();
} }
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default) public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
{ {
UpdateTimestamps(); UpdateTimestamps();
return base.SaveChangesAsync(cancellationToken); return base.SaveChangesAsync(cancellationToken);
} }
private void UpdateTimestamps() private void UpdateTimestamps()
{ {
var entities = ChangeTracker.Entries() var entities = ChangeTracker.Entries()
.Where(e => e.State == EntityState.Added || e.State == EntityState.Modified); .Where(e => e.State == EntityState.Added || e.State == EntityState.Modified);
foreach (var entity in entities) foreach (var entity in entities)
{ {
// Try to set CreatedAt for new entities // Try to set CreatedAt for new entities
if (entity.State == EntityState.Added) if (entity.State == EntityState.Added)
{ {
var createdAtProperty = entity.Properties.FirstOrDefault(p => p.Metadata.Name == "CreatedAt"); var createdAtProperty = entity.Properties.FirstOrDefault(p => p.Metadata.Name == "CreatedAt");
if (createdAtProperty != null) if (createdAtProperty != null)
{ {
createdAtProperty.CurrentValue = DateTime.UtcNow; createdAtProperty.CurrentValue = DateTime.UtcNow;
} }
} }
// Always update ModifiedAt // Always update ModifiedAt
var modifiedAtProperty = entity.Properties.FirstOrDefault(p => p.Metadata.Name == "ModifiedAt"); var modifiedAtProperty = entity.Properties.FirstOrDefault(p => p.Metadata.Name == "ModifiedAt");
if (modifiedAtProperty != null) if (modifiedAtProperty != null)
{ {
modifiedAtProperty.CurrentValue = DateTime.UtcNow; modifiedAtProperty.CurrentValue = DateTime.UtcNow;
} }
} }
} }
} }

View File

@@ -1,52 +1,52 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using DiunaBI.Domain.Entities; using DiunaBI.Domain.Entities;
using DiunaBI.Infrastructure.Data; using DiunaBI.Infrastructure.Data;
#nullable disable #nullable disable
namespace DiunaBI.Infrastructure.Migrations namespace DiunaBI.Infrastructure.Migrations
{ {
[DbContext(typeof(AppDbContext))] [DbContext(typeof(AppDbContext))]
[Migration("20221205190148_Initial")] [Migration("20221205190148_Initial")]
partial class Initial partial class Initial
{ {
/// <inheritdoc /> /// <inheritdoc />
protected void BuildTargetModel(ModelBuilder modelBuilder) protected void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "7.0.0") .HasAnnotation("ProductVersion", "7.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("WebAPI.Models.User", b => modelBuilder.Entity("WebAPI.Models.User", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("UserName") b.Property<string>("UserName")
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(50)");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Users"); b.ToTable("Users");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }
} }

View File

@@ -1,36 +1,36 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable
namespace DiunaBI.Infrastructure.Migrations namespace DiunaBI.Infrastructure.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class Initial : Migration public partial class Initial : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Users", name: "Users",
columns: table => new columns: table => new
{ {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: true), Email = table.Column<string>(type: "nvarchar(max)", nullable: true),
UserName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true), UserName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false) CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Users", x => x.Id); table.PrimaryKey("PK_Users", x => x.Id);
}); });
} }
/// <inheritdoc /> /// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Users"); name: "Users");
} }
} }
} }

View File

@@ -1,193 +1,193 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using DiunaBI.Domain.Entities; using DiunaBI.Domain.Entities;
using DiunaBI.Infrastructure.Data; using DiunaBI.Infrastructure.Data;
#nullable disable #nullable disable
namespace DiunaBI.Infrastructure.Migrations namespace DiunaBI.Infrastructure.Migrations
{ {
[DbContext(typeof(AppDbContext))] [DbContext(typeof(AppDbContext))]
[Migration("20221211210507_DataSetsAndDataRows")] [Migration("20221211210507_DataSetsAndDataRows")]
partial class DataSetsAndDataRows partial class DataSetsAndDataRows
{ {
/// <inheritdoc /> /// <inheritdoc />
protected void BuildTargetModel(ModelBuilder modelBuilder) protected void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "7.0.0") .HasAnnotation("ProductVersion", "7.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("WebAPI.Models.DataRow", b => modelBuilder.Entity("WebAPI.Models.DataRow", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("CreatedById") b.Property<Guid>("CreatedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<Guid?>("DataSetId") b.Property<Guid?>("DataSetId")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Desc1") b.Property<string>("Desc1")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc2") b.Property<string>("Desc2")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc3") b.Property<string>("Desc3")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc4") b.Property<string>("Desc4")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc5") b.Property<string>("Desc5")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted") b.Property<bool>("IsDeleted")
.HasColumnType("bit"); .HasColumnType("bit");
b.Property<string>("MPK") b.Property<string>("MPK")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<DateTime>("ModifiedAt") b.Property<DateTime>("ModifiedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("ModifiedById") b.Property<Guid>("ModifiedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<float>("Value") b.Property<float>("Value")
.HasColumnType("real"); .HasColumnType("real");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CreatedById"); b.HasIndex("CreatedById");
b.HasIndex("DataSetId"); b.HasIndex("DataSetId");
b.HasIndex("ModifiedById"); b.HasIndex("ModifiedById");
b.ToTable("DataRows"); b.ToTable("DataRows");
}); });
modelBuilder.Entity("WebAPI.Models.DataSet", b => modelBuilder.Entity("WebAPI.Models.DataSet", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("CreatedById") b.Property<Guid>("CreatedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted") b.Property<bool>("IsDeleted")
.HasColumnType("bit"); .HasColumnType("bit");
b.Property<DateTime>("ModifiedAt") b.Property<DateTime>("ModifiedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("ModifiedById") b.Property<Guid>("ModifiedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Number") b.Property<string>("Number")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CreatedById"); b.HasIndex("CreatedById");
b.HasIndex("ModifiedById"); b.HasIndex("ModifiedById");
b.ToTable("DataSets"); b.ToTable("DataSets");
}); });
modelBuilder.Entity("WebAPI.Models.User", b => modelBuilder.Entity("WebAPI.Models.User", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("UserName") b.Property<string>("UserName")
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(50)");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("WebAPI.Models.DataRow", b => modelBuilder.Entity("WebAPI.Models.DataRow", b =>
{ {
b.HasOne("WebAPI.Models.User", "CreatedBy") b.HasOne("WebAPI.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById") .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("WebAPI.Models.DataSet", null) b.HasOne("WebAPI.Models.DataSet", null)
.WithMany("DataRows") .WithMany("DataRows")
.HasForeignKey("DataSetId"); .HasForeignKey("DataSetId");
b.HasOne("WebAPI.Models.User", "ModifiedBy") b.HasOne("WebAPI.Models.User", "ModifiedBy")
.WithMany() .WithMany()
.HasForeignKey("ModifiedById") .HasForeignKey("ModifiedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
b.Navigation("ModifiedBy"); b.Navigation("ModifiedBy");
}); });
modelBuilder.Entity("WebAPI.Models.DataSet", b => modelBuilder.Entity("WebAPI.Models.DataSet", b =>
{ {
b.HasOne("WebAPI.Models.User", "CreatedBy") b.HasOne("WebAPI.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById") .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("WebAPI.Models.User", "ModifiedBy") b.HasOne("WebAPI.Models.User", "ModifiedBy")
.WithMany() .WithMany()
.HasForeignKey("ModifiedById") .HasForeignKey("ModifiedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
b.Navigation("ModifiedBy"); b.Navigation("ModifiedBy");
}); });
modelBuilder.Entity("WebAPI.Models.DataSet", b => modelBuilder.Entity("WebAPI.Models.DataSet", b =>
{ {
b.Navigation("DataRows"); b.Navigation("DataRows");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }
} }

View File

@@ -1,121 +1,121 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable
namespace DiunaBI.Infrastructure.Migrations namespace DiunaBI.Infrastructure.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class DataSetsAndDataRows : Migration public partial class DataSetsAndDataRows : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "DataSets", name: "DataSets",
columns: table => new columns: table => new
{ {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Number = table.Column<string>(type: "nvarchar(max)", nullable: false), Number = table.Column<string>(type: "nvarchar(max)", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true), Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false), CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: false), ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false), IsDeleted = table.Column<bool>(type: "bit", nullable: false),
CreatedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false), CreatedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ModifiedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false) ModifiedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_DataSets", x => x.Id); table.PrimaryKey("PK_DataSets", x => x.Id);
table.ForeignKey( table.ForeignKey(
name: "FK_DataSets_Users_CreatedById", name: "FK_DataSets_Users_CreatedById",
column: x => x.CreatedById, column: x => x.CreatedById,
principalTable: "Users", principalTable: "Users",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.NoAction); onDelete: ReferentialAction.NoAction);
table.ForeignKey( table.ForeignKey(
name: "FK_DataSets_Users_ModifiedById", name: "FK_DataSets_Users_ModifiedById",
column: x => x.ModifiedById, column: x => x.ModifiedById,
principalTable: "Users", principalTable: "Users",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.NoAction); onDelete: ReferentialAction.NoAction);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "DataRows", name: "DataRows",
columns: table => new columns: table => new
{ {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
MPK = table.Column<string>(type: "nvarchar(max)", nullable: false), MPK = table.Column<string>(type: "nvarchar(max)", nullable: false),
Value = table.Column<float>(type: "real", nullable: false), Value = table.Column<float>(type: "real", nullable: false),
Desc1 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc1 = table.Column<string>(type: "nvarchar(max)", nullable: true),
Desc2 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc2 = table.Column<string>(type: "nvarchar(max)", nullable: true),
Desc3 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc3 = table.Column<string>(type: "nvarchar(max)", nullable: true),
Desc4 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc4 = table.Column<string>(type: "nvarchar(max)", nullable: true),
Desc5 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc5 = table.Column<string>(type: "nvarchar(max)", nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false), CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: false), ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false), IsDeleted = table.Column<bool>(type: "bit", nullable: false),
CreatedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false), CreatedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ModifiedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false), ModifiedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
DataSetId = table.Column<Guid>(type: "uniqueidentifier", nullable: true) DataSetId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_DataRows", x => x.Id); table.PrimaryKey("PK_DataRows", x => x.Id);
table.ForeignKey( table.ForeignKey(
name: "FK_DataRows_DataSets_DataSetId", name: "FK_DataRows_DataSets_DataSetId",
column: x => x.DataSetId, column: x => x.DataSetId,
principalTable: "DataSets", principalTable: "DataSets",
principalColumn: "Id"); principalColumn: "Id");
table.ForeignKey( table.ForeignKey(
name: "FK_DataRows_Users_CreatedById", name: "FK_DataRows_Users_CreatedById",
column: x => x.CreatedById, column: x => x.CreatedById,
principalTable: "Users", principalTable: "Users",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.NoAction); onDelete: ReferentialAction.NoAction);
table.ForeignKey( table.ForeignKey(
name: "FK_DataRows_Users_ModifiedById", name: "FK_DataRows_Users_ModifiedById",
column: x => x.ModifiedById, column: x => x.ModifiedById,
principalTable: "Users", principalTable: "Users",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.NoAction); onDelete: ReferentialAction.NoAction);
}); });
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DataRows_CreatedById", name: "IX_DataRows_CreatedById",
table: "DataRows", table: "DataRows",
column: "CreatedById"); column: "CreatedById");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DataRows_DataSetId", name: "IX_DataRows_DataSetId",
table: "DataRows", table: "DataRows",
column: "DataSetId"); column: "DataSetId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DataRows_ModifiedById", name: "IX_DataRows_ModifiedById",
table: "DataRows", table: "DataRows",
column: "ModifiedById"); column: "ModifiedById");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DataSets_CreatedById", name: "IX_DataSets_CreatedById",
table: "DataSets", table: "DataSets",
column: "CreatedById"); column: "CreatedById");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DataSets_ModifiedById", name: "IX_DataSets_ModifiedById",
table: "DataSets", table: "DataSets",
column: "ModifiedById"); column: "ModifiedById");
} }
/// <inheritdoc /> /// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "DataRows"); name: "DataRows");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "DataSets"); name: "DataSets");
} }
} }
} }

View File

@@ -1,198 +1,198 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using DiunaBI.Domain.Entities; using DiunaBI.Domain.Entities;
using DiunaBI.Infrastructure.Data; using DiunaBI.Infrastructure.Data;
#nullable disable #nullable disable
namespace DiunaBI.Infrastructure.Migrations namespace DiunaBI.Infrastructure.Migrations
{ {
[DbContext(typeof(AppDbContext))] [DbContext(typeof(AppDbContext))]
[Migration("20221219163620_RenameFields")] [Migration("20221219163620_RenameFields")]
partial class RenameFields partial class RenameFields
{ {
/// <inheritdoc /> /// <inheritdoc />
protected void BuildTargetModel(ModelBuilder modelBuilder) protected void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "7.0.0") .HasAnnotation("ProductVersion", "7.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("WebAPI.Models.DataRow", b => modelBuilder.Entity("WebAPI.Models.DataRow", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Code") b.Property<string>("Code")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("CreatedById") b.Property<Guid>("CreatedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<Guid?>("DataSetId") b.Property<Guid?>("DataSetId")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Desc1") b.Property<string>("Desc1")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc2") b.Property<string>("Desc2")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc3") b.Property<string>("Desc3")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc4") b.Property<string>("Desc4")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc5") b.Property<string>("Desc5")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted") b.Property<bool>("IsDeleted")
.HasColumnType("bit"); .HasColumnType("bit");
b.Property<DateTime>("ModifiedAt") b.Property<DateTime>("ModifiedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("ModifiedById") b.Property<Guid>("ModifiedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<float>("Value") b.Property<float>("Value")
.HasColumnType("real"); .HasColumnType("real");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CreatedById"); b.HasIndex("CreatedById");
b.HasIndex("DataSetId"); b.HasIndex("DataSetId");
b.HasIndex("ModifiedById"); b.HasIndex("ModifiedById");
b.ToTable("DataRows"); b.ToTable("DataRows");
}); });
modelBuilder.Entity("WebAPI.Models.DataSet", b => modelBuilder.Entity("WebAPI.Models.DataSet", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("CreatedById") b.Property<Guid>("CreatedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted") b.Property<bool>("IsDeleted")
.HasColumnType("bit"); .HasColumnType("bit");
b.Property<DateTime>("ModifiedAt") b.Property<DateTime>("ModifiedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("ModifiedById") b.Property<Guid>("ModifiedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int?>("Number") b.Property<int?>("Number")
.IsRequired() .IsRequired()
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("Source") b.Property<string>("Source")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CreatedById"); b.HasIndex("CreatedById");
b.HasIndex("ModifiedById"); b.HasIndex("ModifiedById");
b.ToTable("DataSets"); b.ToTable("DataSets");
}); });
modelBuilder.Entity("WebAPI.Models.User", b => modelBuilder.Entity("WebAPI.Models.User", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("UserName") b.Property<string>("UserName")
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(50)");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("WebAPI.Models.DataRow", b => modelBuilder.Entity("WebAPI.Models.DataRow", b =>
{ {
b.HasOne("WebAPI.Models.User", "CreatedBy") b.HasOne("WebAPI.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById") .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("WebAPI.Models.DataSet", null) b.HasOne("WebAPI.Models.DataSet", null)
.WithMany("DataRows") .WithMany("DataRows")
.HasForeignKey("DataSetId"); .HasForeignKey("DataSetId");
b.HasOne("WebAPI.Models.User", "ModifiedBy") b.HasOne("WebAPI.Models.User", "ModifiedBy")
.WithMany() .WithMany()
.HasForeignKey("ModifiedById") .HasForeignKey("ModifiedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
b.Navigation("ModifiedBy"); b.Navigation("ModifiedBy");
}); });
modelBuilder.Entity("WebAPI.Models.DataSet", b => modelBuilder.Entity("WebAPI.Models.DataSet", b =>
{ {
b.HasOne("WebAPI.Models.User", "CreatedBy") b.HasOne("WebAPI.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById") .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("WebAPI.Models.User", "ModifiedBy") b.HasOne("WebAPI.Models.User", "ModifiedBy")
.WithMany() .WithMany()
.HasForeignKey("ModifiedById") .HasForeignKey("ModifiedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
b.Navigation("ModifiedBy"); b.Navigation("ModifiedBy");
}); });
modelBuilder.Entity("WebAPI.Models.DataSet", b => modelBuilder.Entity("WebAPI.Models.DataSet", b =>
{ {
b.Navigation("DataRows"); b.Navigation("DataRows");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }
} }

View File

@@ -1,73 +1,73 @@
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable
namespace DiunaBI.Infrastructure.Migrations namespace DiunaBI.Infrastructure.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class RenameFields : Migration public partial class RenameFields : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.RenameColumn( migrationBuilder.RenameColumn(
name: "MPK", name: "MPK",
table: "DataRows", table: "DataRows",
newName: "Code"); newName: "Code");
migrationBuilder.AlterColumn<int>( migrationBuilder.AlterColumn<int>(
name: "Number", name: "Number",
table: "DataSets", table: "DataSets",
type: "int", type: "int",
nullable: false, nullable: false,
oldClrType: typeof(string), oldClrType: typeof(string),
oldType: "nvarchar(max)"); oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<string>( migrationBuilder.AlterColumn<string>(
name: "Name", name: "Name",
table: "DataSets", table: "DataSets",
type: "nvarchar(max)", type: "nvarchar(max)",
nullable: false, nullable: false,
defaultValue: "", defaultValue: "",
oldClrType: typeof(string), oldClrType: typeof(string),
oldType: "nvarchar(max)", oldType: "nvarchar(max)",
oldNullable: true); oldNullable: true);
migrationBuilder.AddColumn<string>( migrationBuilder.AddColumn<string>(
name: "Source", name: "Source",
table: "DataSets", table: "DataSets",
type: "nvarchar(max)", type: "nvarchar(max)",
nullable: false, nullable: false,
defaultValue: ""); defaultValue: "");
} }
/// <inheritdoc /> /// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropColumn( migrationBuilder.DropColumn(
name: "Source", name: "Source",
table: "DataSets"); table: "DataSets");
migrationBuilder.RenameColumn( migrationBuilder.RenameColumn(
name: "Code", name: "Code",
table: "DataRows", table: "DataRows",
newName: "MPK"); newName: "MPK");
migrationBuilder.AlterColumn<string>( migrationBuilder.AlterColumn<string>(
name: "Number", name: "Number",
table: "DataSets", table: "DataSets",
type: "nvarchar(max)", type: "nvarchar(max)",
nullable: false, nullable: false,
oldClrType: typeof(int), oldClrType: typeof(int),
oldType: "int"); oldType: "int");
migrationBuilder.AlterColumn<string>( migrationBuilder.AlterColumn<string>(
name: "Name", name: "Name",
table: "DataSets", table: "DataSets",
type: "nvarchar(max)", type: "nvarchar(max)",
nullable: true, nullable: true,
oldClrType: typeof(string), oldClrType: typeof(string),
oldType: "nvarchar(max)"); oldType: "nvarchar(max)");
} }
} }
} }

View File

@@ -1,200 +1,200 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using DiunaBI.Domain.Entities; using DiunaBI.Domain.Entities;
using DiunaBI.Infrastructure.Data; using DiunaBI.Infrastructure.Data;
#nullable disable #nullable disable
namespace DiunaBI.Infrastructure.Migrations namespace DiunaBI.Infrastructure.Migrations
{ {
[DbContext(typeof(AppDbContext))] [DbContext(typeof(AppDbContext))]
[Migration("20221221165749_DataSetIdOnDataRow")] [Migration("20221221165749_DataSetIdOnDataRow")]
partial class DataSetIdOnDataRow partial class DataSetIdOnDataRow
{ {
/// <inheritdoc /> /// <inheritdoc />
protected void BuildTargetModel(ModelBuilder modelBuilder) protected void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "7.0.0") .HasAnnotation("ProductVersion", "7.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("WebAPI.Models.DataRow", b => modelBuilder.Entity("WebAPI.Models.DataRow", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Code") b.Property<string>("Code")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("CreatedById") b.Property<Guid>("CreatedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<Guid>("DataSetId") b.Property<Guid>("DataSetId")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Desc1") b.Property<string>("Desc1")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc2") b.Property<string>("Desc2")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc3") b.Property<string>("Desc3")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc4") b.Property<string>("Desc4")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc5") b.Property<string>("Desc5")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted") b.Property<bool>("IsDeleted")
.HasColumnType("bit"); .HasColumnType("bit");
b.Property<DateTime>("ModifiedAt") b.Property<DateTime>("ModifiedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("ModifiedById") b.Property<Guid>("ModifiedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<float>("Value") b.Property<float>("Value")
.HasColumnType("real"); .HasColumnType("real");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CreatedById"); b.HasIndex("CreatedById");
b.HasIndex("DataSetId"); b.HasIndex("DataSetId");
b.HasIndex("ModifiedById"); b.HasIndex("ModifiedById");
b.ToTable("DataRows"); b.ToTable("DataRows");
}); });
modelBuilder.Entity("WebAPI.Models.DataSet", b => modelBuilder.Entity("WebAPI.Models.DataSet", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("CreatedById") b.Property<Guid>("CreatedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted") b.Property<bool>("IsDeleted")
.HasColumnType("bit"); .HasColumnType("bit");
b.Property<DateTime>("ModifiedAt") b.Property<DateTime>("ModifiedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("ModifiedById") b.Property<Guid>("ModifiedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int?>("Number") b.Property<int?>("Number")
.IsRequired() .IsRequired()
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("Source") b.Property<string>("Source")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CreatedById"); b.HasIndex("CreatedById");
b.HasIndex("ModifiedById"); b.HasIndex("ModifiedById");
b.ToTable("DataSets"); b.ToTable("DataSets");
}); });
modelBuilder.Entity("WebAPI.Models.User", b => modelBuilder.Entity("WebAPI.Models.User", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("UserName") b.Property<string>("UserName")
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(50)");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("WebAPI.Models.DataRow", b => modelBuilder.Entity("WebAPI.Models.DataRow", b =>
{ {
b.HasOne("WebAPI.Models.User", "CreatedBy") b.HasOne("WebAPI.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById") .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("WebAPI.Models.DataSet", null) b.HasOne("WebAPI.Models.DataSet", null)
.WithMany("DataRows") .WithMany("DataRows")
.HasForeignKey("DataSetId") .HasForeignKey("DataSetId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("WebAPI.Models.User", "ModifiedBy") b.HasOne("WebAPI.Models.User", "ModifiedBy")
.WithMany() .WithMany()
.HasForeignKey("ModifiedById") .HasForeignKey("ModifiedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
b.Navigation("ModifiedBy"); b.Navigation("ModifiedBy");
}); });
modelBuilder.Entity("WebAPI.Models.DataSet", b => modelBuilder.Entity("WebAPI.Models.DataSet", b =>
{ {
b.HasOne("WebAPI.Models.User", "CreatedBy") b.HasOne("WebAPI.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById") .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("WebAPI.Models.User", "ModifiedBy") b.HasOne("WebAPI.Models.User", "ModifiedBy")
.WithMany() .WithMany()
.HasForeignKey("ModifiedById") .HasForeignKey("ModifiedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
b.Navigation("ModifiedBy"); b.Navigation("ModifiedBy");
}); });
modelBuilder.Entity("WebAPI.Models.DataSet", b => modelBuilder.Entity("WebAPI.Models.DataSet", b =>
{ {
b.Navigation("DataRows"); b.Navigation("DataRows");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }
} }

View File

@@ -1,80 +1,80 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable
namespace DiunaBI.Infrastructure.Migrations namespace DiunaBI.Infrastructure.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class DataSetIdOnDataRow : Migration public partial class DataSetIdOnDataRow : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropForeignKey( migrationBuilder.DropForeignKey(
name: "FK_DataRows_DataSets_DataSetId", name: "FK_DataRows_DataSets_DataSetId",
table: "DataRows"); table: "DataRows");
// DODAJ: Usuń index przed zmianą kolumny // DODAJ: Usuń index przed zmianą kolumny
migrationBuilder.DropIndex( migrationBuilder.DropIndex(
name: "IX_DataRows_DataSetId", name: "IX_DataRows_DataSetId",
table: "DataRows"); table: "DataRows");
migrationBuilder.AlterColumn<Guid>( migrationBuilder.AlterColumn<Guid>(
name: "DataSetId", name: "DataSetId",
table: "DataRows", table: "DataRows",
type: "uniqueidentifier", type: "uniqueidentifier",
nullable: false, nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid), oldClrType: typeof(Guid),
oldType: "uniqueidentifier", oldType: "uniqueidentifier",
oldNullable: true); oldNullable: true);
// DODAJ: Odtwórz index po zmianie kolumny // DODAJ: Odtwórz index po zmianie kolumny
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DataRows_DataSetId", name: "IX_DataRows_DataSetId",
table: "DataRows", table: "DataRows",
column: "DataSetId"); column: "DataSetId");
migrationBuilder.AddForeignKey( migrationBuilder.AddForeignKey(
name: "FK_DataRows_DataSets_DataSetId", name: "FK_DataRows_DataSets_DataSetId",
table: "DataRows", table: "DataRows",
column: "DataSetId", column: "DataSetId",
principalTable: "DataSets", principalTable: "DataSets",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
} }
/// <inheritdoc /> /// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropForeignKey( migrationBuilder.DropForeignKey(
name: "FK_DataRows_DataSets_DataSetId", name: "FK_DataRows_DataSets_DataSetId",
table: "DataRows"); table: "DataRows");
migrationBuilder.DropIndex( migrationBuilder.DropIndex(
name: "IX_DataRows_DataSetId", name: "IX_DataRows_DataSetId",
table: "DataRows"); table: "DataRows");
migrationBuilder.AlterColumn<Guid>( migrationBuilder.AlterColumn<Guid>(
name: "DataSetId", name: "DataSetId",
table: "DataRows", table: "DataRows",
type: "uniqueidentifier", type: "uniqueidentifier",
nullable: true, nullable: true,
oldClrType: typeof(Guid), oldClrType: typeof(Guid),
oldType: "uniqueidentifier"); oldType: "uniqueidentifier");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DataRows_DataSetId", name: "IX_DataRows_DataSetId",
table: "DataRows", table: "DataRows",
column: "DataSetId"); column: "DataSetId");
migrationBuilder.AddForeignKey( migrationBuilder.AddForeignKey(
name: "FK_DataRows_DataSets_DataSetId", name: "FK_DataRows_DataSets_DataSetId",
table: "DataRows", table: "DataRows",
column: "DataSetId", column: "DataSetId",
principalTable: "DataSets", principalTable: "DataSets",
principalColumn: "Id"); principalColumn: "Id");
} }
} }
} }

View File

@@ -1,200 +1,200 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using DiunaBI.Domain.Entities; using DiunaBI.Domain.Entities;
using DiunaBI.Infrastructure.Data; using DiunaBI.Infrastructure.Data;
#nullable disable #nullable disable
namespace DiunaBI.Infrastructure.Migrations namespace DiunaBI.Infrastructure.Migrations
{ {
[DbContext(typeof(AppDbContext))] [DbContext(typeof(AppDbContext))]
[Migration("20230106095427_RenameModels")] [Migration("20230106095427_RenameModels")]
partial class RenameModels partial class RenameModels
{ {
/// <inheritdoc /> /// <inheritdoc />
protected void BuildTargetModel(ModelBuilder modelBuilder) protected void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "7.0.0") .HasAnnotation("ProductVersion", "7.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("WebAPI.Models.Layer", b => modelBuilder.Entity("WebAPI.Models.Layer", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("CreatedById") b.Property<Guid>("CreatedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted") b.Property<bool>("IsDeleted")
.HasColumnType("bit"); .HasColumnType("bit");
b.Property<DateTime>("ModifiedAt") b.Property<DateTime>("ModifiedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("ModifiedById") b.Property<Guid>("ModifiedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int?>("Number") b.Property<int?>("Number")
.IsRequired() .IsRequired()
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("Source") b.Property<string>("Source")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CreatedById"); b.HasIndex("CreatedById");
b.HasIndex("ModifiedById"); b.HasIndex("ModifiedById");
b.ToTable("Layers"); b.ToTable("Layers");
}); });
modelBuilder.Entity("WebAPI.Models.Record", b => modelBuilder.Entity("WebAPI.Models.Record", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Code") b.Property<string>("Code")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("CreatedById") b.Property<Guid>("CreatedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Desc1") b.Property<string>("Desc1")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc2") b.Property<string>("Desc2")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc3") b.Property<string>("Desc3")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc4") b.Property<string>("Desc4")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Desc5") b.Property<string>("Desc5")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted") b.Property<bool>("IsDeleted")
.HasColumnType("bit"); .HasColumnType("bit");
b.Property<Guid>("LayerId") b.Property<Guid>("LayerId")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<DateTime>("ModifiedAt") b.Property<DateTime>("ModifiedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<Guid>("ModifiedById") b.Property<Guid>("ModifiedById")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<float>("Value") b.Property<float>("Value")
.HasColumnType("real"); .HasColumnType("real");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CreatedById"); b.HasIndex("CreatedById");
b.HasIndex("LayerId"); b.HasIndex("LayerId");
b.HasIndex("ModifiedById"); b.HasIndex("ModifiedById");
b.ToTable("Records"); b.ToTable("Records");
}); });
modelBuilder.Entity("WebAPI.Models.User", b => modelBuilder.Entity("WebAPI.Models.User", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<string>("Email") b.Property<string>("Email")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("UserName") b.Property<string>("UserName")
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(50)");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("WebAPI.Models.Layer", b => modelBuilder.Entity("WebAPI.Models.Layer", b =>
{ {
b.HasOne("WebAPI.Models.User", "CreatedBy") b.HasOne("WebAPI.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById") .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("WebAPI.Models.User", "ModifiedBy") b.HasOne("WebAPI.Models.User", "ModifiedBy")
.WithMany() .WithMany()
.HasForeignKey("ModifiedById") .HasForeignKey("ModifiedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
b.Navigation("ModifiedBy"); b.Navigation("ModifiedBy");
}); });
modelBuilder.Entity("WebAPI.Models.Record", b => modelBuilder.Entity("WebAPI.Models.Record", b =>
{ {
b.HasOne("WebAPI.Models.User", "CreatedBy") b.HasOne("WebAPI.Models.User", "CreatedBy")
.WithMany() .WithMany()
.HasForeignKey("CreatedById") .HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("WebAPI.Models.Layer", null) b.HasOne("WebAPI.Models.Layer", null)
.WithMany("Records") .WithMany("Records")
.HasForeignKey("LayerId") .HasForeignKey("LayerId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("WebAPI.Models.User", "ModifiedBy") b.HasOne("WebAPI.Models.User", "ModifiedBy")
.WithMany() .WithMany()
.HasForeignKey("ModifiedById") .HasForeignKey("ModifiedById")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("CreatedBy"); b.Navigation("CreatedBy");
b.Navigation("ModifiedBy"); b.Navigation("ModifiedBy");
}); });
modelBuilder.Entity("WebAPI.Models.Layer", b => modelBuilder.Entity("WebAPI.Models.Layer", b =>
{ {
b.Navigation("Records"); b.Navigation("Records");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }
} }

View File

@@ -1,227 +1,227 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable
namespace DiunaBI.Infrastructure.Migrations namespace DiunaBI.Infrastructure.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class RenameModels : Migration public partial class RenameModels : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "DataRows"); name: "DataRows");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "DataSets"); name: "DataSets");
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Layers", name: "Layers",
columns: table => new columns: table => new
{ {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Number = table.Column<int>(type: "int", nullable: false), Number = table.Column<int>(type: "int", nullable: false),
Source = table.Column<string>(type: "nvarchar(max)", nullable: false), Source = table.Column<string>(type: "nvarchar(max)", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false), Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false), CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: false), ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false), IsDeleted = table.Column<bool>(type: "bit", nullable: false),
CreatedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false), CreatedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ModifiedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false) ModifiedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Layers", x => x.Id); table.PrimaryKey("PK_Layers", x => x.Id);
table.ForeignKey( table.ForeignKey(
name: "FK_Layers_Users_CreatedById", name: "FK_Layers_Users_CreatedById",
column: x => x.CreatedById, column: x => x.CreatedById,
principalTable: "Users", principalTable: "Users",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.NoAction); onDelete: ReferentialAction.NoAction);
table.ForeignKey( table.ForeignKey(
name: "FK_Layers_Users_ModifiedById", name: "FK_Layers_Users_ModifiedById",
column: x => x.ModifiedById, column: x => x.ModifiedById,
principalTable: "Users", principalTable: "Users",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.NoAction); onDelete: ReferentialAction.NoAction);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Records", name: "Records",
columns: table => new columns: table => new
{ {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Code = table.Column<string>(type: "nvarchar(max)", nullable: false), Code = table.Column<string>(type: "nvarchar(max)", nullable: false),
Value = table.Column<float>(type: "real", nullable: false), Value = table.Column<float>(type: "real", nullable: false),
Desc1 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc1 = table.Column<string>(type: "nvarchar(max)", nullable: true),
Desc2 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc2 = table.Column<string>(type: "nvarchar(max)", nullable: true),
Desc3 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc3 = table.Column<string>(type: "nvarchar(max)", nullable: true),
Desc4 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc4 = table.Column<string>(type: "nvarchar(max)", nullable: true),
Desc5 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc5 = table.Column<string>(type: "nvarchar(max)", nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false), CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: false), ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false), IsDeleted = table.Column<bool>(type: "bit", nullable: false),
CreatedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false), CreatedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ModifiedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false), ModifiedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LayerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false) LayerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Records", x => x.Id); table.PrimaryKey("PK_Records", x => x.Id);
table.ForeignKey( table.ForeignKey(
name: "FK_Records_Layers_LayerId", name: "FK_Records_Layers_LayerId",
column: x => x.LayerId, column: x => x.LayerId,
principalTable: "Layers", principalTable: "Layers",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.NoAction); onDelete: ReferentialAction.NoAction);
table.ForeignKey( table.ForeignKey(
name: "FK_Records_Users_CreatedById", name: "FK_Records_Users_CreatedById",
column: x => x.CreatedById, column: x => x.CreatedById,
principalTable: "Users", principalTable: "Users",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.NoAction); onDelete: ReferentialAction.NoAction);
table.ForeignKey( table.ForeignKey(
name: "FK_Records_Users_ModifiedById", name: "FK_Records_Users_ModifiedById",
column: x => x.ModifiedById, column: x => x.ModifiedById,
principalTable: "Users", principalTable: "Users",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.NoAction); onDelete: ReferentialAction.NoAction);
}); });
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Layers_CreatedById", name: "IX_Layers_CreatedById",
table: "Layers", table: "Layers",
column: "CreatedById"); column: "CreatedById");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Layers_ModifiedById", name: "IX_Layers_ModifiedById",
table: "Layers", table: "Layers",
column: "ModifiedById"); column: "ModifiedById");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Records_CreatedById", name: "IX_Records_CreatedById",
table: "Records", table: "Records",
column: "CreatedById"); column: "CreatedById");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Records_LayerId", name: "IX_Records_LayerId",
table: "Records", table: "Records",
column: "LayerId"); column: "LayerId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Records_ModifiedById", name: "IX_Records_ModifiedById",
table: "Records", table: "Records",
column: "ModifiedById"); column: "ModifiedById");
} }
/// <inheritdoc /> /// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Records"); name: "Records");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Layers"); name: "Layers");
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "DataSets", name: "DataSets",
columns: table => new columns: table => new
{ {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
CreatedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false), CreatedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ModifiedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false), ModifiedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false), CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
IsDeleted = table.Column<bool>(type: "bit", nullable: false), IsDeleted = table.Column<bool>(type: "bit", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: false), ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false), Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Number = table.Column<int>(type: "int", nullable: false), Number = table.Column<int>(type: "int", nullable: false),
Source = table.Column<string>(type: "nvarchar(max)", nullable: false) Source = table.Column<string>(type: "nvarchar(max)", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_DataSets", x => x.Id); table.PrimaryKey("PK_DataSets", x => x.Id);
table.ForeignKey( table.ForeignKey(
name: "FK_DataSets_Users_CreatedById", name: "FK_DataSets_Users_CreatedById",
column: x => x.CreatedById, column: x => x.CreatedById,
principalTable: "Users", principalTable: "Users",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.NoAction); onDelete: ReferentialAction.NoAction);
table.ForeignKey( table.ForeignKey(
name: "FK_DataSets_Users_ModifiedById", name: "FK_DataSets_Users_ModifiedById",
column: x => x.ModifiedById, column: x => x.ModifiedById,
principalTable: "Users", principalTable: "Users",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.NoAction); onDelete: ReferentialAction.NoAction);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "DataRows", name: "DataRows",
columns: table => new columns: table => new
{ {
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
CreatedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false), CreatedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ModifiedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false), ModifiedById = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Code = table.Column<string>(type: "nvarchar(max)", nullable: false), Code = table.Column<string>(type: "nvarchar(max)", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false), CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
DataSetId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), DataSetId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Desc1 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc1 = table.Column<string>(type: "nvarchar(max)", nullable: true),
Desc2 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc2 = table.Column<string>(type: "nvarchar(max)", nullable: true),
Desc3 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc3 = table.Column<string>(type: "nvarchar(max)", nullable: true),
Desc4 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc4 = table.Column<string>(type: "nvarchar(max)", nullable: true),
Desc5 = table.Column<string>(type: "nvarchar(max)", nullable: true), Desc5 = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false), IsDeleted = table.Column<bool>(type: "bit", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: false), ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
Value = table.Column<float>(type: "real", nullable: false) Value = table.Column<float>(type: "real", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_DataRows", x => x.Id); table.PrimaryKey("PK_DataRows", x => x.Id);
table.ForeignKey( table.ForeignKey(
name: "FK_DataRows_DataSets_DataSetId", name: "FK_DataRows_DataSets_DataSetId",
column: x => x.DataSetId, column: x => x.DataSetId,
principalTable: "DataSets", principalTable: "DataSets",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.NoAction); onDelete: ReferentialAction.NoAction);
table.ForeignKey( table.ForeignKey(
name: "FK_DataRows_Users_CreatedById", name: "FK_DataRows_Users_CreatedById",
column: x => x.CreatedById, column: x => x.CreatedById,
principalTable: "Users", principalTable: "Users",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.NoAction); onDelete: ReferentialAction.NoAction);
table.ForeignKey( table.ForeignKey(
name: "FK_DataRows_Users_ModifiedById", name: "FK_DataRows_Users_ModifiedById",
column: x => x.ModifiedById, column: x => x.ModifiedById,
principalTable: "Users", principalTable: "Users",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.NoAction); onDelete: ReferentialAction.NoAction);
}); });
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DataRows_CreatedById", name: "IX_DataRows_CreatedById",
table: "DataRows", table: "DataRows",
column: "CreatedById"); column: "CreatedById");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DataRows_DataSetId", name: "IX_DataRows_DataSetId",
table: "DataRows", table: "DataRows",
column: "DataSetId"); column: "DataSetId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DataRows_ModifiedById", name: "IX_DataRows_ModifiedById",
table: "DataRows", table: "DataRows",
column: "ModifiedById"); column: "ModifiedById");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DataSets_CreatedById", name: "IX_DataSets_CreatedById",
table: "DataSets", table: "DataSets",
column: "CreatedById"); column: "CreatedById");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_DataSets_ModifiedById", name: "IX_DataSets_ModifiedById",
table: "DataSets", table: "DataSets",
column: "ModifiedById"); column: "ModifiedById");
} }
} }
} }

View File

@@ -1,38 +1,38 @@
using Google.Apis.Auth.OAuth2; using Google.Apis.Auth.OAuth2;
using Google.Apis.Drive.v3; using Google.Apis.Drive.v3;
using Google.Apis.Services; using Google.Apis.Services;
namespace DiunaBI.Infrastructure.Services; namespace DiunaBI.Infrastructure.Services;
public class GoogleDriveHelper public class GoogleDriveHelper
{ {
public DriveService? Service { get; private set; } public DriveService? Service { get; private set; }
private const string ApplicationName = "Diuna"; private const string ApplicationName = "Diuna";
private static readonly string[] Scopes = [DriveService.Scope.Drive]; private static readonly string[] Scopes = [DriveService.Scope.Drive];
public GoogleDriveHelper() public GoogleDriveHelper()
{ {
InitializeService(); InitializeService();
} }
private void InitializeService() private void InitializeService()
{ {
var credential = GetCredentialsFromFile(); var credential = GetCredentialsFromFile();
Service = new DriveService(new BaseClientService.Initializer Service = new DriveService(new BaseClientService.Initializer
{ {
HttpClientInitializer = credential, HttpClientInitializer = credential,
ApplicationName = ApplicationName ApplicationName = ApplicationName
}); });
} }
private static GoogleCredential GetCredentialsFromFile() private static GoogleCredential GetCredentialsFromFile()
{ {
#if DEBUG #if DEBUG
using var stream = new FileStream("client_secrets.Development.json", FileMode.Open, FileAccess.Read); using var stream = new FileStream("client_secrets.Development.json", FileMode.Open, FileAccess.Read);
return GoogleCredential.FromStream(stream).CreateScoped(Scopes); return GoogleCredential.FromStream(stream).CreateScoped(Scopes);
#else #else
var json = Environment.GetEnvironmentVariable("GOOGLE_SERVICE_ACCOUNT_JSON"); var json = Environment.GetEnvironmentVariable("GOOGLE_SERVICE_ACCOUNT_JSON");
if (string.IsNullOrWhiteSpace(json)) if (string.IsNullOrWhiteSpace(json))
throw new InvalidOperationException("GOOGLE_SERVICE_ACCOUNT_JSON environment variable is not set."); throw new InvalidOperationException("GOOGLE_SERVICE_ACCOUNT_JSON environment variable is not set.");
json = json.Replace("\\n", "\n"); json = json.Replace("\\n", "\n");
return GoogleCredential.FromJson(json).CreateScoped(Scopes); return GoogleCredential.FromJson(json).CreateScoped(Scopes);
#endif #endif
} }
} }

View File

@@ -1,38 +1,38 @@
using Google.Apis.Auth.OAuth2; using Google.Apis.Auth.OAuth2;
using Google.Apis.Services; using Google.Apis.Services;
using Google.Apis.Sheets.v4; using Google.Apis.Sheets.v4;
namespace DiunaBI.Infrastructure.Services; namespace DiunaBI.Infrastructure.Services;
public class GoogleSheetsHelper public class GoogleSheetsHelper
{ {
public SheetsService? Service { get; private set; } public SheetsService? Service { get; private set; }
private const string ApplicationName = "Diuna"; private const string ApplicationName = "Diuna";
private static readonly string[] Scopes = [SheetsService.Scope.Spreadsheets]; private static readonly string[] Scopes = [SheetsService.Scope.Spreadsheets];
public GoogleSheetsHelper() public GoogleSheetsHelper()
{ {
InitializeService(); InitializeService();
} }
private void InitializeService() private void InitializeService()
{ {
var credential = GetCredentialsFromFile(); var credential = GetCredentialsFromFile();
Service = new SheetsService(new BaseClientService.Initializer Service = new SheetsService(new BaseClientService.Initializer
{ {
HttpClientInitializer = credential, HttpClientInitializer = credential,
ApplicationName = ApplicationName ApplicationName = ApplicationName
}); });
} }
private static GoogleCredential GetCredentialsFromFile() private static GoogleCredential GetCredentialsFromFile()
{ {
#if DEBUG #if DEBUG
using var stream = new FileStream("client_secrets.Development.json", FileMode.Open, FileAccess.Read); using var stream = new FileStream("client_secrets.Development.json", FileMode.Open, FileAccess.Read);
return GoogleCredential.FromStream(stream).CreateScoped(Scopes); return GoogleCredential.FromStream(stream).CreateScoped(Scopes);
#else #else
var json = Environment.GetEnvironmentVariable("GOOGLE_SERVICE_ACCOUNT_JSON"); var json = Environment.GetEnvironmentVariable("GOOGLE_SERVICE_ACCOUNT_JSON");
if (string.IsNullOrWhiteSpace(json)) if (string.IsNullOrWhiteSpace(json))
throw new InvalidOperationException("GOOGLE_SERVICE_ACCOUNT_JSON environment variable is not set."); throw new InvalidOperationException("GOOGLE_SERVICE_ACCOUNT_JSON environment variable is not set.");
json = json.Replace("\\n", "\n"); json = json.Replace("\\n", "\n");
return GoogleCredential.FromJson(json).CreateScoped(Scopes); return GoogleCredential.FromJson(json).CreateScoped(Scopes);
#endif #endif
} }
} }

View File

@@ -1,30 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk.Razor"> <Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<SupportedPlatform Include="browser"/> <SupportedPlatform Include="browser"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.17"/> <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.17"/>
<PackageReference Include="MudBlazor" Version="7.0.0"/> <PackageReference Include="MudBlazor" Version="7.0.0"/>
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="8.0.0" /> <PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\DiunaBI.Application\DiunaBI.Application.csproj" /> <ProjectReference Include="..\DiunaBI.Application\DiunaBI.Application.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Interfaces\" /> <Folder Include="Interfaces\" />
<Folder Include="wwwroot\" /> <Folder Include="wwwroot\" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -1,12 +1,12 @@
@using System.Net.Http @using System.Net.Http
@using System.Net.Http.Json @using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web
@using static Microsoft.AspNetCore.Components.Web.RenderMode @using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.AspNetCore.Components.Web.Virtualization @using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop @using Microsoft.JSInterop
@using DiunaBI.UI.Shared @using DiunaBI.UI.Shared
@using DiunaBI.UI.Shared.Components @using DiunaBI.UI.Shared.Components
@using DiunaBI.Application.DTOModels @using DiunaBI.Application.DTOModels
@using MudBlazor @using MudBlazor

View File

@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MudBlazor" Version="7.0.0"/> <PackageReference Include="MudBlazor" Version="7.0.0"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\DiunaBI.UI.Shared\DiunaBI.UI.Shared.csproj"/> <ProjectReference Include="..\DiunaBI.UI.Shared\DiunaBI.UI.Shared.csproj"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -1,37 +1,37 @@
using DiunaBI.UI.Shared; using DiunaBI.UI.Shared;
using DiunaBI.UI.Shared.Extensions; using DiunaBI.UI.Shared.Extensions;
using DiunaBI.UI.Shared.Services; using DiunaBI.UI.Shared.Services;
using DiunaBI.UI.Web.Components; using DiunaBI.UI.Web.Components;
using MudBlazor.Services; using MudBlazor.Services;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorComponents() builder.Services.AddRazorComponents()
.AddInteractiveServerComponents(); .AddInteractiveServerComponents();
builder.Services.AddMudServices(); builder.Services.AddMudServices();
var apiBaseUrl = builder.Configuration["ApiSettings:BaseUrl"] var apiBaseUrl = builder.Configuration["ApiSettings:BaseUrl"]
?? throw new InvalidOperationException("ApiSettings:BaseUrl is not configured"); ?? throw new InvalidOperationException("ApiSettings:BaseUrl is not configured");
builder.Services.AddSharedServices(apiBaseUrl); builder.Services.AddSharedServices(apiBaseUrl);
builder.Services.AddScoped<AuthService>(); builder.Services.AddScoped<AuthService>();
var app = builder.Build(); var app = builder.Build();
if (!app.Environment.IsDevelopment()) if (!app.Environment.IsDevelopment())
{ {
app.UseExceptionHandler("/Error", createScopeForErrors: true); app.UseExceptionHandler("/Error", createScopeForErrors: true);
app.UseHsts(); app.UseHsts();
} }
app.UseHttpsRedirection(); app.UseHttpsRedirection();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseAntiforgery(); app.UseAntiforgery();
app.MapGet("/health", () => Results.Ok(new { status = "OK", timestamp = DateTime.UtcNow })); app.MapGet("/health", () => Results.Ok(new { status = "OK", timestamp = DateTime.UtcNow }));
app.MapRazorComponents<App>() app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode() .AddInteractiveServerRenderMode()
.AddAdditionalAssemblies(typeof(MainLayout).Assembly); .AddAdditionalAssemblies(typeof(MainLayout).Assembly);
app.Run(); app.Run();

View File

@@ -1,13 +1,13 @@
{ {
"profiles": { "profiles": {
"dev": { "dev": {
"commandName": "Project", "commandName": "Project",
"dotnetRunMessages": true, "dotnetRunMessages": true,
"launchBrowser": true, "launchBrowser": true,
"applicationUrl": "https://localhost:7246;http://localhost:5246", "applicationUrl": "https://localhost:7246;http://localhost:5246",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }
} }
} }
} }

View File

@@ -1,51 +1,51 @@
html, body { html, body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
} }
a, .btn-link { a, .btn-link {
color: #006bb7; color: #006bb7;
} }
.btn-primary { .btn-primary {
color: #fff; color: #fff;
background-color: #1b6ec2; background-color: #1b6ec2;
border-color: #1861ac; border-color: #1861ac;
} }
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
} }
.content { .content {
padding-top: 1.1rem; padding-top: 1.1rem;
} }
h1:focus { h1:focus {
outline: none; outline: none;
} }
.valid.modified:not([type=checkbox]) { .valid.modified:not([type=checkbox]) {
outline: 1px solid #26b050; outline: 1px solid #26b050;
} }
.invalid { .invalid {
outline: 1px solid #e50000; outline: 1px solid #e50000;
} }
.validation-message { .validation-message {
color: #e50000; color: #e50000;
} }
.blazor-error-boundary { .blazor-error-boundary {
background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
padding: 1rem 1rem 1rem 3.7rem; padding: 1rem 1rem 1rem 3.7rem;
color: white; color: white;
} }
.blazor-error-boundary::after { .blazor-error-boundary::after {
content: "An error has occurred." content: "An error has occurred."
} }
.darker-border-checkbox.form-check-input { .darker-border-checkbox.form-check-input {
border-color: #929292; border-color: #929292;
} }

View File

@@ -1,3 +1,3 @@
### ###
GET http://localhost:5400/api/Layers/AutoImport/10763478CB738D4ecb2h76g803478CB738D4e/D3- GET http://localhost:5400/Layers/AutoImport/10763478CB738D4ecb2h76g803478CB738D4e/K5-