diff --git a/Utils/getProductionDatabase.sh b/Utils/getProductionDatabase.sh index 6e229e1..8ff18a7 100644 --- a/Utils/getProductionDatabase.sh +++ b/Utils/getProductionDatabase.sh @@ -15,23 +15,23 @@ DOCKER_BACKUP_PATH=${DOCKER_BACKUP_DIR}/${BACKUP_FILE} #SERVER VARIABLES REMOTE_HOST="bim-it.pl" REMOTE_USER="mz" -REMOTE_SA_PASSWORD="v](8Lc|RfG" +REMOTE_SA_PASSWORD="9832&^*&huihj" REMOTE_BACKUP_DIR="/tmp" ssh ${REMOTE_USER}@${REMOTE_HOST} "sudo rm ${REMOTE_BACKUP_DIR}/${BACKUP_FILE}" ssh ${REMOTE_USER}@${REMOTE_HOST} "/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '${REMOTE_SA_PASSWORD}' -Q \"BACKUP DATABASE [${DB_NAME}] TO DISK = '${REMOTE_BACKUP_DIR}/${BACKUP_FILE}'\"" scp ${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_BACKUP_DIR}/${BACKUP_FILE} ${LOCAL_BACKUP_DIR}/ -docker exec -i ${DOCKER_CONTAINER_NAME} mkdir -p ${DOCKER_BACKUP_DIR} -docker cp "${LOCAL_BACKUP_PATH}" "${DOCKER_CONTAINER_NAME}:${DOCKER_BACKUP_PATH}" -docker exec --user=root -i ${DOCKER_CONTAINER_NAME} chown mssql:mssql "$DOCKER_BACKUP_PATH" +podman exec -i ${DOCKER_CONTAINER_NAME} mkdir -p ${DOCKER_BACKUP_DIR} +podman cp "${LOCAL_BACKUP_PATH}" "${DOCKER_CONTAINER_NAME}:${DOCKER_BACKUP_PATH}" +podman exec --user=root -i ${DOCKER_CONTAINER_NAME} chown mssql:mssql "$DOCKER_BACKUP_PATH" -LOGICAL_FILE_INFO=$(docker exec -i ${DOCKER_CONTAINER_NAME} ${DOCKER_SQLCMD} -C -S localhost -U SA -P "${DOCKER_SA_PASSWORD}" -Q "RESTORE FILELISTONLY FROM DISK = '${DOCKER_BACKUP_PATH}'" 2>&1) +LOGICAL_FILE_INFO=$(podman exec -i ${DOCKER_CONTAINER_NAME} ${DOCKER_SQLCMD} -C -S localhost -U SA -P "${DOCKER_SA_PASSWORD}" -Q "RESTORE FILELISTONLY FROM DISK = '${DOCKER_BACKUP_PATH}'" 2>&1) DATA_FILE=$(echo "$LOGICAL_FILE_INFO" | awk 'NR==3 {print $1}' | tr -d '[:space:]') LOG_FILE=$(echo "$LOGICAL_FILE_INFO" | awk 'NR==4 {print $1}' | tr -d '[:space:]') RESTORE_OUTPUT=$( - docker exec -i ${DOCKER_CONTAINER_NAME} ${DOCKER_SQLCMD} -C -S localhost -U SA -P "${DOCKER_SA_PASSWORD}" -Q " + podman exec -i ${DOCKER_CONTAINER_NAME} ${DOCKER_SQLCMD} -C -S localhost -U SA -P "${DOCKER_SA_PASSWORD}" -Q " IF EXISTS (SELECT name FROM sys.databases WHERE name = '${DB_NAME}') BEGIN PRINT 'Database ${DB_NAME} exists. Dropping the database.'; diff --git a/src/Backend/DiunaBI.WebAPI/Controllers/AuthController.cs b/src/Backend/DiunaBI.API/Controllers/AuthController.cs similarity index 93% rename from src/Backend/DiunaBI.WebAPI/Controllers/AuthController.cs rename to src/Backend/DiunaBI.API/Controllers/AuthController.cs index 3bb10b0..e0efd42 100644 --- a/src/Backend/DiunaBI.WebAPI/Controllers/AuthController.cs +++ b/src/Backend/DiunaBI.API/Controllers/AuthController.cs @@ -1,60 +1,60 @@ -using Google.Apis.Auth; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using Microsoft.IdentityModel.Tokens; -using System.IdentityModel.Tokens.Jwt; -using System.Security.Claims; -using System.Text; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; - -namespace DiunaBI.WebAPI.Controllers; - -[ApiController] -[Route("api/[controller]")] -// [Authorize] -public class AuthController : Controller -{ - private readonly AppDbContext _db; - private readonly IConfiguration _configuration; - public AuthController( - AppDbContext db, IConfiguration configuration) - { _db = db; _configuration = configuration; } - - [HttpPost] - [Route("apiToken")] - public async Task ApiToken([FromBody] string credential) - { - var settings = new GoogleJsonWebSignature.ValidationSettings - { - Audience = new List { _configuration.GetValue("GoogleClientId")! } - }; - var payload = await GoogleJsonWebSignature.ValidateAsync(credential, settings); - var user = _db.Users.AsNoTracking().FirstOrDefault(x => x.Email == payload.Email); - return user != null ? (IActionResult)Ok(JwtGenerator(user)) : Unauthorized(); - } - - private dynamic JwtGenerator(User user) - { - var key = Encoding.ASCII.GetBytes(_configuration.GetValue("Secret")!); - var expirationTime = DateTime.UtcNow.AddMinutes(5); - var tokenDescriptor = new SecurityTokenDescriptor - { - Subject = new ClaimsIdentity(new[] - { - new Claim("Id", Guid.NewGuid().ToString()), - new Claim(JwtRegisteredClaimNames.Sub, user.Id.ToString()), - new Claim(JwtRegisteredClaimNames.Jti, - Guid.NewGuid().ToString()) - }), - Expires = expirationTime, - SigningCredentials = new SigningCredentials - (new SymmetricSecurityKey(key), - SecurityAlgorithms.HmacSha512Signature) - }; - var tokenHandler = new JwtSecurityTokenHandler(); - var token = tokenHandler.CreateToken(tokenDescriptor); - var stringToken = tokenHandler.WriteToken(token); - return new { token = stringToken, id = user.Id, expirationTime }; - } +using Google.Apis.Auth; +using Microsoft.AspNetCore.Mvc; +using Microsoft.IdentityModel.Tokens; +using System.IdentityModel.Tokens.Jwt; +using System.Security.Claims; +using System.Text; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using Microsoft.EntityFrameworkCore; + +namespace DiunaBI.API.Controllers; + +[ApiController] +[Route("api/[controller]")] +// [Authorize] +public class AuthController : Controller +{ + private readonly AppDbContext _db; + private readonly IConfiguration _configuration; + public AuthController( + AppDbContext db, IConfiguration configuration) + { _db = db; _configuration = configuration; } + + [HttpPost] + [Route("apiToken")] + public async Task ApiToken([FromBody] string credential) + { + var settings = new GoogleJsonWebSignature.ValidationSettings + { + Audience = new List { _configuration.GetValue("GoogleClientId")! } + }; + var payload = await GoogleJsonWebSignature.ValidateAsync(credential, settings); + var user = _db.Users.AsNoTracking().FirstOrDefault(x => x.Email == payload.Email); + return user != null ? (IActionResult)Ok(JwtGenerator(user)) : Unauthorized(); + } + + private dynamic JwtGenerator(User user) + { + var key = Encoding.ASCII.GetBytes(_configuration.GetValue("Secret")!); + var expirationTime = DateTime.UtcNow.AddMinutes(5); + var tokenDescriptor = new SecurityTokenDescriptor + { + Subject = new ClaimsIdentity(new[] + { + new Claim("Id", Guid.NewGuid().ToString()), + new Claim(JwtRegisteredClaimNames.Sub, user.Id.ToString()), + new Claim(JwtRegisteredClaimNames.Jti, + Guid.NewGuid().ToString()) + }), + Expires = expirationTime, + SigningCredentials = new SigningCredentials + (new SymmetricSecurityKey(key), + SecurityAlgorithms.HmacSha512Signature) + }; + var tokenHandler = new JwtSecurityTokenHandler(); + var token = tokenHandler.CreateToken(tokenDescriptor); + var stringToken = tokenHandler.WriteToken(token); + return new { token = stringToken, id = user.Id, expirationTime }; + } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.WebAPI/Controllers/DataInboxController.cs b/src/Backend/DiunaBI.API/Controllers/DataInboxController.cs similarity index 94% rename from src/Backend/DiunaBI.WebAPI/Controllers/DataInboxController.cs rename to src/Backend/DiunaBI.API/Controllers/DataInboxController.cs index 27cf379..659673f 100644 --- a/src/Backend/DiunaBI.WebAPI/Controllers/DataInboxController.cs +++ b/src/Backend/DiunaBI.API/Controllers/DataInboxController.cs @@ -1,132 +1,131 @@ -using System.Text; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; -using DiunaBI.Core.Database.Context; -using DiunaBI.Core.Models; - -namespace DiunaBI.WebAPI.Controllers; - -[ApiController] -[Route("api/[controller]")] -public class DataInboxController : Controller -{ - private readonly AppDbContext _db; - private readonly IConfiguration _configuration; - private readonly ILogger _logger; - - public DataInboxController( - AppDbContext db, - IConfiguration configuration, - ILogger logger) - { - _db = db; - _configuration = configuration; - _logger = logger; - } - - [HttpPut] - [Route("Add/{apiKey}")] - [AllowAnonymous] - public IActionResult Add(string apiKey, [FromBody] DataInbox dataInbox) - { - if (apiKey != _configuration["apiKey"]) - { - _logger.LogWarning("DataInbox: Unauthorized request - wrong apiKey for source {Source}", dataInbox.Source); - return Unauthorized(); - } - - try - { - if (!Request.Headers.TryGetValue("Authorization", out var authHeader)) - { - _logger.LogWarning("DataInbox: Unauthorized request - no authorization header for source {Source}", dataInbox.Source); - return Unauthorized(); - } - - var credentialsArr = authHeader.ToString().Split(" "); - if (credentialsArr.Length != 2) - { - _logger.LogWarning("DataInbox: Unauthorized request - wrong auth header format for source {Source}", dataInbox.Source); - return Unauthorized(); - } - - var authValue = Encoding.UTF8.GetString(Convert.FromBase64String(credentialsArr[1])); - var username = authValue.Split(':')[0]; - var password = authValue.Split(':')[1]; - if (username != _configuration["morska-user"] || password != _configuration["morska-pass"]) - { - _logger.LogWarning("DataInbox: Unauthorized request - bad credentials for source {Source}", dataInbox.Source); - return Unauthorized(); - } - - // check if datainbox.data is base64 encoded value - if (!string.IsNullOrEmpty(dataInbox.Data) && !IsBase64String(dataInbox.Data)) - { - _logger.LogWarning("DataInbox: Invalid data format - not base64 encoded for source {Source}", dataInbox.Source); - return BadRequest("Invalid data format - not base64 encoded"); - } - - dataInbox.Id = Guid.NewGuid(); - dataInbox.CreatedAt = DateTime.UtcNow; - _db.DataInbox.Add(dataInbox); - _db.SaveChanges(); - - _logger.LogInformation("DataInbox: Insert success for source {Source}, name {Name}", dataInbox.Source, dataInbox.Name); - - if (dataInbox.Name == "morska.d3.importer") - { - _logger.LogDebug("DataInbox: Detected morska.d3.importer - processing will be handled by AutoImport"); - // AutoImport będzie obsługiwać ten typ danych - } - - return Ok(); - } - catch (Exception e) - { - _logger.LogError(e, "DataInbox: Insert error for source {Source}, name {Name}", dataInbox.Source, dataInbox.Name); - return BadRequest(e.ToString()); - } - } - - [HttpGet] - public IActionResult GetAll() - { - try - { - var dataInbox = _db.DataInbox.AsNoTracking().ToList(); - _logger.LogDebug("DataInbox: Retrieved {Count} records", dataInbox.Count); - return Ok(dataInbox); - } - catch (Exception e) - { - _logger.LogError(e, "DataInbox: Error retrieving records"); - return BadRequest(e.ToString()); - } - } - - // helpers - private bool IsBase64String(string data) - { - if (string.IsNullOrEmpty(data)) - { - return false; - } - try - { - var base64Bytes = Convert.FromBase64String(data); - var utf8String = Encoding.UTF8.GetString(base64Bytes); - var reEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(utf8String)); - return data.TrimEnd('=') == reEncoded.TrimEnd('='); - } - catch (FormatException) - { - return false; - } - catch (DecoderFallbackException) - { - return false; - } - } +using System.Text; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Domain.Entities; + +namespace DiunaBI.API.Controllers; + +[ApiController] +[Route("api/[controller]")] +public class DataInboxController : Controller +{ + private readonly AppDbContext _db; + private readonly IConfiguration _configuration; + private readonly ILogger _logger; + + public DataInboxController( + AppDbContext db, + IConfiguration configuration, + ILogger logger) + { + _db = db; + _configuration = configuration; + _logger = logger; + } + + [HttpPut] + [Route("Add/{apiKey}")] + [AllowAnonymous] + public IActionResult Add(string apiKey, [FromBody] DataInbox dataInbox) + { + if (apiKey != _configuration["apiKey"]) + { + _logger.LogWarning("DataInbox: Unauthorized request - wrong apiKey for source {Source}", dataInbox.Source); + return Unauthorized(); + } + + try + { + if (!Request.Headers.TryGetValue("Authorization", out var authHeader)) + { + _logger.LogWarning("DataInbox: Unauthorized request - no authorization header for source {Source}", dataInbox.Source); + return Unauthorized(); + } + + var credentialsArr = authHeader.ToString().Split(" "); + if (credentialsArr.Length != 2) + { + _logger.LogWarning("DataInbox: Unauthorized request - wrong auth header format for source {Source}", dataInbox.Source); + return Unauthorized(); + } + + var authValue = Encoding.UTF8.GetString(Convert.FromBase64String(credentialsArr[1])); + var username = authValue.Split(':')[0]; + var password = authValue.Split(':')[1]; + if (username != _configuration["morska-user"] || password != _configuration["morska-pass"]) + { + _logger.LogWarning("DataInbox: Unauthorized request - bad credentials for source {Source}", dataInbox.Source); + return Unauthorized(); + } + + // check if datainbox.data is base64 encoded value + if (!string.IsNullOrEmpty(dataInbox.Data) && !IsBase64String(dataInbox.Data)) + { + _logger.LogWarning("DataInbox: Invalid data format - not base64 encoded for source {Source}", dataInbox.Source); + return BadRequest("Invalid data format - not base64 encoded"); + } + + dataInbox.Id = Guid.NewGuid(); + dataInbox.CreatedAt = DateTime.UtcNow; + _db.DataInbox.Add(dataInbox); + _db.SaveChanges(); + + _logger.LogInformation("DataInbox: Insert success for source {Source}, name {Name}", dataInbox.Source, dataInbox.Name); + + if (dataInbox.Name == "morska.d3.importer") + { + _logger.LogDebug("DataInbox: Detected morska.d3.importer - processing will be handled by AutoImport"); + // AutoImport będzie obsługiwać ten typ danych + } + + return Ok(); + } + catch (Exception e) + { + _logger.LogError(e, "DataInbox: Insert error for source {Source}, name {Name}", dataInbox.Source, dataInbox.Name); + return BadRequest(e.ToString()); + } + } + + [HttpGet] + public IActionResult GetAll() + { + try + { + var dataInbox = _db.DataInbox.AsNoTracking().ToList(); + _logger.LogDebug("DataInbox: Retrieved {Count} records", dataInbox.Count); + return Ok(dataInbox); + } + catch (Exception e) + { + _logger.LogError(e, "DataInbox: Error retrieving records"); + return BadRequest(e.ToString()); + } + } + + // helpers + private bool IsBase64String(string data) + { + if (string.IsNullOrEmpty(data)) + { + return false; + } + try + { + var base64Bytes = Convert.FromBase64String(data); + var utf8String = Encoding.UTF8.GetString(base64Bytes); + var reEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(utf8String)); + return data.TrimEnd('=') == reEncoded.TrimEnd('='); + } + catch (FormatException) + { + return false; + } + catch (DecoderFallbackException) + { + return false; + } + } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.WebAPI/Controllers/LayersController.cs b/src/Backend/DiunaBI.API/Controllers/LayersController.cs similarity index 99% rename from src/Backend/DiunaBI.WebAPI/Controllers/LayersController.cs rename to src/Backend/DiunaBI.API/Controllers/LayersController.cs index 8fccbbf..77f25e7 100644 --- a/src/Backend/DiunaBI.WebAPI/Controllers/LayersController.cs +++ b/src/Backend/DiunaBI.API/Controllers/LayersController.cs @@ -4,12 +4,11 @@ using Google.Apis.Sheets.v4; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; -using DiunaBI.Core.Services; -using DiunaBI.Core.Interfaces; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Infrastructure.Services; -namespace DiunaBI.WebAPI.Controllers; +namespace DiunaBI.API.Controllers; [ApiController] [Route("api/[controller]")] diff --git a/src/Backend/DiunaBI.WebAPI/Controllers/TestsController.cs b/src/Backend/DiunaBI.API/Controllers/TestsController.cs similarity index 90% rename from src/Backend/DiunaBI.WebAPI/Controllers/TestsController.cs rename to src/Backend/DiunaBI.API/Controllers/TestsController.cs index e04ba71..7be615a 100644 --- a/src/Backend/DiunaBI.WebAPI/Controllers/TestsController.cs +++ b/src/Backend/DiunaBI.API/Controllers/TestsController.cs @@ -1,50 +1,50 @@ -using DiunaBI.Core.Services; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace DiunaBI.WebAPI.Controllers; - -[ApiController] -[Route("api/[controller]")] -[Authorize] -public class TestsController : Controller -{ - private readonly PluginManager _pluginManager; - private readonly ILogger _logger; - public TestsController( - PluginManager pluginManager, - ILogger logger) - { - _pluginManager = pluginManager; - _logger = logger; - - } - - [HttpGet] - [Route("Ping")] - [AllowAnonymous] - public IActionResult Ping() - { - var tmp = new - { - a = 2, - b = "test" - }; - var tmp2 = new - { - a = 2, - b = "test" - }; - var user = User.Identity; - _logger.LogInformation("LogTest: OldValue {tmp}, NewValue {tmp2}, ChangedBy: {user}", tmp, tmp2, user?.Name); - return Ok("Pong"); - } - [HttpGet] - [Route("Plugins")] - [AllowAnonymous] - public IActionResult GetPlugins() - { - var plugins = _pluginManager.GetPluginsCount(); - return Ok(plugins); - } +using DiunaBI.Infrastructure.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace DiunaBI.API.Controllers; + +[ApiController] +[Route("api/[controller]")] +[Authorize] +public class TestsController : Controller +{ + private readonly PluginManager _pluginManager; + private readonly ILogger _logger; + public TestsController( + PluginManager pluginManager, + ILogger logger) + { + _pluginManager = pluginManager; + _logger = logger; + + } + + [HttpGet] + [Route("Ping")] + [AllowAnonymous] + public IActionResult Ping() + { + var tmp = new + { + a = 2, + b = "test" + }; + var tmp2 = new + { + a = 2, + b = "test" + }; + var user = User.Identity; + _logger.LogInformation("LogTest: OldValue {tmp}, NewValue {tmp2}, ChangedBy: {user}", tmp, tmp2, user?.Name); + return Ok("Pong"); + } + [HttpGet] + [Route("Plugins")] + [AllowAnonymous] + public IActionResult GetPlugins() + { + var plugins = _pluginManager.GetPluginsCount(); + return Ok(plugins); + } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.WebAPI/DiunaBI.WebAPI.csproj b/src/Backend/DiunaBI.API/DiunaBI.API.csproj similarity index 89% rename from src/Backend/DiunaBI.WebAPI/DiunaBI.WebAPI.csproj rename to src/Backend/DiunaBI.API/DiunaBI.API.csproj index 0917953..6e591e9 100644 --- a/src/Backend/DiunaBI.WebAPI/DiunaBI.WebAPI.csproj +++ b/src/Backend/DiunaBI.API/DiunaBI.API.csproj @@ -1,43 +1,45 @@ - - - net8.0 - enable - enable - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - true - PreserveNewest - - - - - - - - - - - - + + + net8.0 + enable + enable + DiunaBI.WebAPI + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + true + PreserveNewest + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Backend/DiunaBI.WebAPI/Program.cs b/src/Backend/DiunaBI.API/Program.cs similarity index 95% rename from src/Backend/DiunaBI.WebAPI/Program.cs rename to src/Backend/DiunaBI.API/Program.cs index 0c30a50..799aa23 100644 --- a/src/Backend/DiunaBI.WebAPI/Program.cs +++ b/src/Backend/DiunaBI.API/Program.cs @@ -1,170 +1,169 @@ -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.EntityFrameworkCore; -using Microsoft.IdentityModel.Tokens; -using System.IdentityModel.Tokens.Jwt; -using System.Reflection; -using System.Text; -using DiunaBI.Core.Database.Context; -using DiunaBI.Core.Services; -using Google.Apis.Sheets.v4; -using Serilog; -using DiunaBI.Core.Interfaces; - -var builder = WebApplication.CreateBuilder(args); - -if (builder.Environment.IsProduction()) -{ - builder.Host.UseSerilog((context, configuration) => - { - var instanceName = context.Configuration["InstanceName"] ?? "unknown"; - configuration - .ReadFrom.Configuration(context.Configuration) - .Enrich.FromLogContext() - .Enrich.WithProperty("Application", $"DiunaBI-{instanceName}") - .Enrich.WithProperty("Version", Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "unknown") - .Enrich.WithEnvironmentName() - .Enrich.WithMachineName(); - }); -} - -var connectionString = builder.Configuration.GetConnectionString("SQLDatabase"); - -builder.Services.AddDbContext(x => -{ - x.UseSqlServer(connectionString); - x.EnableSensitiveDataLogging(); -}); - -builder.Services.AddCors(options => -{ - options.AddPolicy("CORSPolicy", corsPolicyBuilder => - { - corsPolicyBuilder.WithOrigins("http://localhost:4200") - .AllowAnyMethod() - .AllowAnyHeader() - .AllowCredentials(); - - corsPolicyBuilder.WithOrigins("https://diuna.bim-it.pl") - .AllowAnyMethod() - .AllowAnyHeader() - .AllowCredentials(); - - corsPolicyBuilder.WithOrigins("https://morska.diunabi.com") - .AllowAnyMethod() - .AllowAnyHeader() - .AllowCredentials(); - }); -}); - -builder.Services.AddControllers(); - -builder.Services.AddAuthentication(options => -{ - options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; - options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; - options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; -}).AddJwtBearer(options => -{ - options.TokenValidationParameters = new TokenValidationParameters - { - ValidateIssuer = false, - ValidateAudience = false, - ValidateLifetime = true, - ValidateIssuerSigningKey = true, - IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Secret"]!)) - }; -}); - -// Google Sheets dependencies -Console.WriteLine("Adding Google Sheets dependencies..."); -builder.Services.AddSingleton(); -builder.Services.AddSingleton(); -builder.Services.AddSingleton(provider => -{ - var googleSheetsHelper = provider.GetRequiredService(); - var valuesResource = googleSheetsHelper.Service?.Spreadsheets.Values; - - if (valuesResource == null) - { - throw new InvalidOperationException("Google Sheets Service is not initialized properly"); - } - - return valuesResource; -}); - -builder.Services.AddSingleton(); - -var app = builder.Build(); - -if (app.Environment.IsProduction()) -{ - app.UseSerilogRequestLogging(options => - { - options.MessageTemplate = "HTTP {RequestMethod} {RequestPath} responded {StatusCode} in {Elapsed:0.0000} ms"; - options.EnrichDiagnosticContext = (diagnosticContext, httpContext) => - { - diagnosticContext.Set("RequestHost", httpContext.Request.Host.Value); - diagnosticContext.Set("RequestScheme", httpContext.Request.Scheme); - - var userAgent = httpContext.Request.Headers.UserAgent.FirstOrDefault(); - if (!string.IsNullOrEmpty(userAgent)) - { - diagnosticContext.Set("UserAgent", userAgent); - } - - diagnosticContext.Set("RemoteIP", httpContext.Connection.RemoteIpAddress?.ToString() ?? "unknown"); - diagnosticContext.Set("RequestContentType", httpContext.Request.ContentType ?? "none"); - }; - }); -} - -// Plugin initialization -var pluginManager = app.Services.GetRequiredService(); -var executablePath = Assembly.GetExecutingAssembly().Location; -var executableDir = Path.GetDirectoryName(executablePath)!; -var pluginsPath = Path.Combine(executableDir, "Plugins"); - -if (app.Environment.IsProduction()) -{ - Log.Information("Starting DiunaBI application"); - Log.Information("Loading plugins from: {PluginsPath}", pluginsPath); -} -else -{ - var logger = app.Services.GetRequiredService>(); - logger.LogInformation("Starting DiunaBI application (Development)"); - logger.LogInformation("Loading plugins from: {PluginsPath}", pluginsPath); -} - -pluginManager.LoadPluginsFromDirectory(pluginsPath); - -app.Use(async (context, next) => -{ - var token = context.Request.Headers.Authorization.ToString(); - if (token.Length > 0 - && !context.Request.Path.ToString().Contains("getForPowerBI") - && !context.Request.Path.ToString().Contains("getConfiguration") - && !context.Request.Path.ToString().Contains("DataInbox/Add")) - { - var handler = new JwtSecurityTokenHandler(); - var data = handler.ReadJwtToken(token.Split(' ')[1]); - context.Request.Headers.Append("UserId", new Microsoft.Extensions.Primitives.StringValues(data.Subject)); - } - await next(context); -}); - -app.UseCors("CORSPolicy"); - -app.UseAuthentication(); -app.UseAuthorization(); - -app.MapControllers(); - -app.Run(); - -if (app.Environment.IsProduction()) -{ - Log.CloseAndFlush(); -} -// for testing purposes +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.EntityFrameworkCore; +using Microsoft.IdentityModel.Tokens; +using System.IdentityModel.Tokens.Jwt; +using System.Reflection; +using System.Text; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Infrastructure.Services; +using Google.Apis.Sheets.v4; +using Serilog; + +var builder = WebApplication.CreateBuilder(args); + +if (builder.Environment.IsProduction()) +{ + builder.Host.UseSerilog((context, configuration) => + { + var instanceName = context.Configuration["InstanceName"] ?? "unknown"; + configuration + .ReadFrom.Configuration(context.Configuration) + .Enrich.FromLogContext() + .Enrich.WithProperty("Application", $"DiunaBI-{instanceName}") + .Enrich.WithProperty("Version", Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "unknown") + .Enrich.WithEnvironmentName() + .Enrich.WithMachineName(); + }); +} + +var connectionString = builder.Configuration.GetConnectionString("SQLDatabase"); + +builder.Services.AddDbContext(x => +{ + x.UseSqlServer(connectionString); + x.EnableSensitiveDataLogging(); +}); + +builder.Services.AddCors(options => +{ + options.AddPolicy("CORSPolicy", corsPolicyBuilder => + { + corsPolicyBuilder.WithOrigins("http://localhost:4200") + .AllowAnyMethod() + .AllowAnyHeader() + .AllowCredentials(); + + corsPolicyBuilder.WithOrigins("https://diuna.bim-it.pl") + .AllowAnyMethod() + .AllowAnyHeader() + .AllowCredentials(); + + corsPolicyBuilder.WithOrigins("https://morska.diunabi.com") + .AllowAnyMethod() + .AllowAnyHeader() + .AllowCredentials(); + }); +}); + +builder.Services.AddControllers(); + +builder.Services.AddAuthentication(options => +{ + options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; + options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; +}).AddJwtBearer(options => +{ + options.TokenValidationParameters = new TokenValidationParameters + { + ValidateIssuer = false, + ValidateAudience = false, + ValidateLifetime = true, + ValidateIssuerSigningKey = true, + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Secret"]!)) + }; +}); + +// Google Sheets dependencies +Console.WriteLine("Adding Google Sheets dependencies..."); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(provider => +{ + var googleSheetsHelper = provider.GetRequiredService(); + var valuesResource = googleSheetsHelper.Service?.Spreadsheets.Values; + + if (valuesResource == null) + { + throw new InvalidOperationException("Google Sheets Service is not initialized properly"); + } + + return valuesResource; +}); + +builder.Services.AddSingleton(); + +var app = builder.Build(); + +if (app.Environment.IsProduction()) +{ + app.UseSerilogRequestLogging(options => + { + options.MessageTemplate = "HTTP {RequestMethod} {RequestPath} responded {StatusCode} in {Elapsed:0.0000} ms"; + options.EnrichDiagnosticContext = (diagnosticContext, httpContext) => + { + diagnosticContext.Set("RequestHost", httpContext.Request.Host.Value); + diagnosticContext.Set("RequestScheme", httpContext.Request.Scheme); + + var userAgent = httpContext.Request.Headers.UserAgent.FirstOrDefault(); + if (!string.IsNullOrEmpty(userAgent)) + { + diagnosticContext.Set("UserAgent", userAgent); + } + + diagnosticContext.Set("RemoteIP", httpContext.Connection.RemoteIpAddress?.ToString() ?? "unknown"); + diagnosticContext.Set("RequestContentType", httpContext.Request.ContentType ?? "none"); + }; + }); +} + +// Plugin initialization +var pluginManager = app.Services.GetRequiredService(); +var executablePath = Assembly.GetExecutingAssembly().Location; +var executableDir = Path.GetDirectoryName(executablePath)!; +var pluginsPath = Path.Combine(executableDir, "Plugins"); + +if (app.Environment.IsProduction()) +{ + Log.Information("Starting DiunaBI application"); + Log.Information("Loading plugins from: {PluginsPath}", pluginsPath); +} +else +{ + var logger = app.Services.GetRequiredService>(); + logger.LogInformation("Starting DiunaBI application (Development)"); + logger.LogInformation("Loading plugins from: {PluginsPath}", pluginsPath); +} + +pluginManager.LoadPluginsFromDirectory(pluginsPath); + +app.Use(async (context, next) => +{ + var token = context.Request.Headers.Authorization.ToString(); + if (token.Length > 0 + && !context.Request.Path.ToString().Contains("getForPowerBI") + && !context.Request.Path.ToString().Contains("getConfiguration") + && !context.Request.Path.ToString().Contains("DataInbox/Add")) + { + var handler = new JwtSecurityTokenHandler(); + var data = handler.ReadJwtToken(token.Split(' ')[1]); + context.Request.Headers.Append("UserId", new Microsoft.Extensions.Primitives.StringValues(data.Subject)); + } + await next(context); +}); + +app.UseCors("CORSPolicy"); + +app.UseAuthentication(); +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); + +if (app.Environment.IsProduction()) +{ + Log.CloseAndFlush(); +} +// for testing purposes public partial class Program { } \ No newline at end of file diff --git a/src/Backend/DiunaBI.WebAPI/Properties/launchSettings.json b/src/Backend/DiunaBI.API/Properties/launchSettings.json similarity index 96% rename from src/Backend/DiunaBI.WebAPI/Properties/launchSettings.json rename to src/Backend/DiunaBI.API/Properties/launchSettings.json index c37a5a2..91252f2 100644 --- a/src/Backend/DiunaBI.WebAPI/Properties/launchSettings.json +++ b/src/Backend/DiunaBI.API/Properties/launchSettings.json @@ -1,23 +1,23 @@ -{ - "$schema": "https://json.schemastore.org/launchsettings.json", - "profiles": { - "http": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": false, - "applicationUrl": "http://localhost:5163", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "https": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": false, - "applicationUrl": "https://localhost:7148;http://localhost:5163", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5163", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7148;http://localhost:5163", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/Backend/DiunaBI.WebAPI/appsettings.json b/src/Backend/DiunaBI.API/appsettings.json similarity index 96% rename from src/Backend/DiunaBI.WebAPI/appsettings.json rename to src/Backend/DiunaBI.API/appsettings.json index 63dca8f..4f1cdbd 100644 --- a/src/Backend/DiunaBI.WebAPI/appsettings.json +++ b/src/Backend/DiunaBI.API/appsettings.json @@ -1,69 +1,69 @@ -{ - "PONG": "#{PING}#", - "app-version": "#{buildId}#", - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "Serilog": { - "MinimumLevel": { - "Default": "Information", - "Override": { - "Microsoft.AspNetCore": "Warning", - "Microsoft.EntityFrameworkCore.Database.Command": "Warning", - "Microsoft.EntityFrameworkCore.Infrastructure": "Warning", - "System.Net.Http.HttpClient": "Warning", - "Google.Apis": "Warning", - "DiunaBI.Core.Services.PluginManager": "Information" - } - }, - "WriteTo": [ - { - "Name": "Console", - "Args": { - "outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}" - } - }, - { - "Name": "File", - "Args": { - "path": "/var/log/diunabi/app-.log", - "rollingInterval": "Day", - "retainedFileCountLimit": 30, - "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext} {Message:lj} {Properties:j}{NewLine}{Exception}" - } - }, - { - "Name": "Seq", - "Args": { - "serverUrl": "http://localhost:5341", - "restrictedToMinimumLevel": "Information" - } - } - ], - "Enrich": ["FromLogContext", "WithMachineName", "WithThreadId"] - }, - "AllowedHosts": "*", - "ConnectionStrings": { - "SQLDatabase": "#{db-connection-string}#" - }, - "InstanceName": "#{app-environment}#", - "GoogleClientId": "#{google-backend-login-client-id}#", - "Secret": "#{google-backend-login-secret}#", - "apiKey": "#{api-key}#", - "powerBI-user": "#{powerBI-user}#", - "powerBI-pass": "#{powerBI-pass}#", - "morska-user": "#{morska-user}#", - "morska-pass": "#{morska-pass}#", - "exportDirectory": "#{export-directory}#", - "apiLocalUrl": "#{api-local-url}#", - "Kestrel": { - "Endpoints": { - "Http": { - "Url": "http://#{api-local-url}#" - } - } - } -} +{ + "PONG": "#{PING}#", + "app-version": "#{buildId}#", + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft.AspNetCore": "Warning", + "Microsoft.EntityFrameworkCore.Database.Command": "Warning", + "Microsoft.EntityFrameworkCore.Infrastructure": "Warning", + "System.Net.Http.HttpClient": "Warning", + "Google.Apis": "Warning", + "DiunaBI.Core.Services.PluginManager": "Information" + } + }, + "WriteTo": [ + { + "Name": "Console", + "Args": { + "outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "/var/log/diunabi/app-.log", + "rollingInterval": "Day", + "retainedFileCountLimit": 30, + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {SourceContext} {Message:lj} {Properties:j}{NewLine}{Exception}" + } + }, + { + "Name": "Seq", + "Args": { + "serverUrl": "http://localhost:5341", + "restrictedToMinimumLevel": "Information" + } + } + ], + "Enrich": ["FromLogContext", "WithMachineName", "WithThreadId"] + }, + "AllowedHosts": "*", + "ConnectionStrings": { + "SQLDatabase": "#{db-connection-string}#" + }, + "InstanceName": "#{app-environment}#", + "GoogleClientId": "#{google-backend-login-client-id}#", + "Secret": "#{google-backend-login-secret}#", + "apiKey": "#{api-key}#", + "powerBI-user": "#{powerBI-user}#", + "powerBI-pass": "#{powerBI-pass}#", + "morska-user": "#{morska-user}#", + "morska-pass": "#{morska-pass}#", + "exportDirectory": "#{export-directory}#", + "apiLocalUrl": "#{api-local-url}#", + "Kestrel": { + "Endpoints": { + "Http": { + "Url": "http://#{api-local-url}#" + } + } + } +} diff --git a/src/Backend/DiunaBI.WebAPI/client_secrets.Development.json b/src/Backend/DiunaBI.API/client_secrets.Development.json similarity index 100% rename from src/Backend/DiunaBI.WebAPI/client_secrets.Development.json rename to src/Backend/DiunaBI.API/client_secrets.Development.json diff --git a/src/Backend/DiunaBI.WebAPI/client_secrets.json b/src/Backend/DiunaBI.API/client_secrets.json similarity index 100% rename from src/Backend/DiunaBI.WebAPI/client_secrets.json rename to src/Backend/DiunaBI.API/client_secrets.json diff --git a/src/Backend/DiunaBI.Application/DiunaBI.Application.csproj b/src/Backend/DiunaBI.Application/DiunaBI.Application.csproj new file mode 100644 index 0000000..6d6a6b4 --- /dev/null +++ b/src/Backend/DiunaBI.Application/DiunaBI.Application.csproj @@ -0,0 +1,19 @@ + + + + net8.0 + enable + enable + 12.0 + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Backend/DiunaBI.Core/Database/Context/AppDbContext.cs b/src/Backend/DiunaBI.Core/Database/Context/AppDbContext.cs deleted file mode 100644 index 549d369..0000000 --- a/src/Backend/DiunaBI.Core/Database/Context/AppDbContext.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using DiunaBI.Core.Models; -using Microsoft.Extensions.Logging; - -namespace DiunaBI.Core.Database.Context; - -public class AppDbContext(DbContextOptions options) : DbContext(options) -{ - public DbSet Users { get; init; } - public DbSet Layers { get; init; } - public DbSet Records { get; init; } - public DbSet ProcessSources { get; init; } - public DbSet DataInbox { get; init; } - public DbSet QueueJobs { get; init; } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity().HasKey(x => new - { - x.LayerId, - x.SourceId - }); - } -} \ No newline at end of file diff --git a/src/Backend/DiunaBI.Core/DiunaBI.Core.csproj b/src/Backend/DiunaBI.Core/DiunaBI.Core.csproj deleted file mode 100644 index 0a2988e..0000000 --- a/src/Backend/DiunaBI.Core/DiunaBI.Core.csproj +++ /dev/null @@ -1,29 +0,0 @@ - - - net8.0 - enable - - - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - \ No newline at end of file diff --git a/src/Backend/DiunaBI.Domain/DiunaBI.Domain.csproj b/src/Backend/DiunaBI.Domain/DiunaBI.Domain.csproj new file mode 100644 index 0000000..95e85d4 --- /dev/null +++ b/src/Backend/DiunaBI.Domain/DiunaBI.Domain.csproj @@ -0,0 +1,10 @@ + + + + net8.0 + enable + enable + 12.0 + + + \ No newline at end of file diff --git a/src/Backend/DiunaBI.Core/Models/DataInbox.cs b/src/Backend/DiunaBI.Domain/Entities/DataInbox.cs similarity index 71% rename from src/Backend/DiunaBI.Core/Models/DataInbox.cs rename to src/Backend/DiunaBI.Domain/Entities/DataInbox.cs index bfea179..940c010 100644 --- a/src/Backend/DiunaBI.Core/Models/DataInbox.cs +++ b/src/Backend/DiunaBI.Domain/Entities/DataInbox.cs @@ -1,19 +1,15 @@ -using System; -using System.ComponentModel.DataAnnotations; - -namespace DiunaBI.Core.Models; - -public class DataInbox -{ - #region Properties - [Key] - public Guid Id { get; set; } - [StringLength(50)] - public required string Name { get; init; } - [StringLength(50)] - public required string Source { get; set; } - [StringLength(int.MaxValue)] - public required string Data { get; init; } - public DateTime CreatedAt { get; set; } - #endregion +using System; +using System.ComponentModel.DataAnnotations; + +namespace DiunaBI.Domain.Entities; + +public class DataInbox +{ + #region Properties + public Guid Id { get; set; } + public required string Name { get; init; } + public required string Source { get; set; } + public required string Data { get; init; } + public DateTime CreatedAt { get; set; } + #endregion } \ No newline at end of file diff --git a/src/Backend/DiunaBI.Core/Models/Layer.cs b/src/Backend/DiunaBI.Domain/Entities/Layer.cs similarity index 75% rename from src/Backend/DiunaBI.Core/Models/Layer.cs rename to src/Backend/DiunaBI.Domain/Entities/Layer.cs index e8782a3..8d98f2c 100644 --- a/src/Backend/DiunaBI.Core/Models/Layer.cs +++ b/src/Backend/DiunaBI.Domain/Entities/Layer.cs @@ -1,45 +1,34 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace DiunaBI.Core.Models; - -public enum LayerType -{ - Import, - Processed, - Administration, - Dictionary, -} -public class Layer -{ - #region Properties - [Key] - public Guid Id { get; init; } - [Required] - public int Number { get; init; } - [Required] - [MaxLength(50)] - public string? Name { get; set; } - [Required] - public LayerType Type { get; init; } - [Required] - public DateTime CreatedAt { get; set; } - [Required] - public DateTime ModifiedAt { get; set; } - [Required] - public bool IsDeleted { get; init; } = false; - [Required] - public bool IsCancelled { get; init; } = false; - #endregion - #region Relations - public ICollection? Records { get; init; } - [Required] - public Guid CreatedById { get; set; } - public User? CreatedBy { get; init; } - [Required] - public Guid ModifiedById { get; set; } - public User? ModifiedBy { get; init; } - public Guid? ParentId { get; init; } - #endregion +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace DiunaBI.Domain.Entities; + +public enum LayerType +{ + Import, + Processed, + Administration, + Dictionary, +} +public class Layer +{ + #region Properties + public Guid Id { get; init; } + public int Number { get; init; } + public string? Name { get; set; } + public LayerType Type { get; init; } + public DateTime CreatedAt { get; set; } + public DateTime ModifiedAt { get; set; } + public bool IsDeleted { get; init; } = false; + public bool IsCancelled { get; init; } = false; + #endregion + #region Relations + public ICollection? Records { get; init; } + public Guid CreatedById { get; set; } + public User? CreatedBy { get; init; } + public Guid ModifiedById { get; set; } + public User? ModifiedBy { get; init; } + public Guid? ParentId { get; init; } + #endregion } \ No newline at end of file diff --git a/src/Backend/DiunaBI.Core/Models/ProcessSource.cs b/src/Backend/DiunaBI.Domain/Entities/ProcessSource.cs similarity index 76% rename from src/Backend/DiunaBI.Core/Models/ProcessSource.cs rename to src/Backend/DiunaBI.Domain/Entities/ProcessSource.cs index 59d8c65..e4dd73a 100644 --- a/src/Backend/DiunaBI.Core/Models/ProcessSource.cs +++ b/src/Backend/DiunaBI.Domain/Entities/ProcessSource.cs @@ -1,15 +1,13 @@ -using System; -using System.ComponentModel.DataAnnotations; - -namespace DiunaBI.Core.Models; - -public class ProcessSource -{ - #region Relations - [Required] - public Guid LayerId { get; init; } - [Required] - public Guid SourceId { get; init; } - public Layer? Source { get; init; } - #endregion +using System; +using System.ComponentModel.DataAnnotations; + +namespace DiunaBI.Domain.Entities; + +public class ProcessSource +{ + #region Relations + public Guid LayerId { get; init; } + public Guid SourceId { get; init; } + public Layer? Source { get; init; } + #endregion } \ No newline at end of file diff --git a/src/Backend/DiunaBI.Core/Models/QueueJob.cs b/src/Backend/DiunaBI.Domain/Entities/QueueJob.cs similarity index 80% rename from src/Backend/DiunaBI.Core/Models/QueueJob.cs rename to src/Backend/DiunaBI.Domain/Entities/QueueJob.cs index e7a4a2c..bb44b7a 100644 --- a/src/Backend/DiunaBI.Core/Models/QueueJob.cs +++ b/src/Backend/DiunaBI.Domain/Entities/QueueJob.cs @@ -1,56 +1,26 @@ using System; using System.ComponentModel.DataAnnotations; -namespace DiunaBI.Core.Models; +namespace DiunaBI.Domain.Entities; public class QueueJob { - [Key] public Guid Id { get; set; } = Guid.NewGuid(); - - [Required] public Guid LayerId { get; set; } - - [Required] - [MaxLength(200)] public string LayerName { get; set; } = string.Empty; - - [Required] - [MaxLength(100)] public string PluginName { get; set; } = string.Empty; - - [Required] public JobType JobType { get; set; } - public int Priority { get; set; } = 0; // 0 = highest priority - - [Required] public DateTime CreatedAt { get; set; } = DateTime.UtcNow; - public int RetryCount { get; set; } = 0; - public int MaxRetries { get; set; } = 5; - - [Required] public JobStatus Status { get; set; } = JobStatus.Pending; - - [MaxLength(1000)] public string? LastError { get; set; } - public DateTime? LastAttemptAt { get; set; } - public DateTime? CompletedAt { get; set; } - - [Required] public Guid CreatedById { get; set; } - - [Required] public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow; - - [Required] public Guid ModifiedById { get; set; } - - [Required] public DateTime ModifiedAtUtc { get; set; } = DateTime.UtcNow; } diff --git a/src/Backend/DiunaBI.Core/Models/Record.cs b/src/Backend/DiunaBI.Domain/Entities/Record.cs similarity index 92% rename from src/Backend/DiunaBI.Core/Models/Record.cs rename to src/Backend/DiunaBI.Domain/Entities/Record.cs index a554c56..bd8f084 100644 --- a/src/Backend/DiunaBI.Core/Models/Record.cs +++ b/src/Backend/DiunaBI.Domain/Entities/Record.cs @@ -1,15 +1,12 @@ using System; using System.ComponentModel.DataAnnotations; -namespace DiunaBI.Core.Models; +namespace DiunaBI.Domain.Entities; public class Record { #region Properties - [Key] public Guid Id { get; set; } - [Required] - [StringLength(50)] public string? Code { get; init; } public double? Value1 { get; set; } public double? Value2 { get; set; } @@ -43,18 +40,14 @@ public class Record public double? Value30 { get; set; } public double? Value31 { get; set; } public double? Value32 { get; set; } - //Description fields - [StringLength(10000)] public string? Desc1 { get; set; } public DateTime CreatedAt { get; set; } public DateTime ModifiedAt { get; set; } public bool IsDeleted { get; init; } #endregion #region Relations - [Required] public Guid CreatedById { get; set; } public User? CreatedBy { get; init; } - [Required] public Guid ModifiedById { get; set; } public User? ModifiedBy { get; init; } public Guid LayerId { get; set; } diff --git a/src/Backend/DiunaBI.Core/Models/User.cs b/src/Backend/DiunaBI.Domain/Entities/User.cs similarity index 73% rename from src/Backend/DiunaBI.Core/Models/User.cs rename to src/Backend/DiunaBI.Domain/Entities/User.cs index ce23280..6b51b94 100644 --- a/src/Backend/DiunaBI.Core/Models/User.cs +++ b/src/Backend/DiunaBI.Domain/Entities/User.cs @@ -1,17 +1,14 @@ -using System; -using System.ComponentModel.DataAnnotations; - -namespace DiunaBI.Core.Models; - -public class User -{ - #region Properties - [Key] - public Guid Id { get; init; } - [StringLength(50)] - public string? Email { get; init; } - [StringLength(50)] - public string? UserName { get; init; } - public DateTime CreatedAt { get; init; } - #endregion +using System; +using System.ComponentModel.DataAnnotations; + +namespace DiunaBI.Domain.Entities; + +public class User +{ + #region Properties + public Guid Id { get; init; } + public string? Email { get; init; } + public string? UserName { get; init; } + public DateTime CreatedAt { get; init; } + #endregion } \ No newline at end of file diff --git a/src/Backend/DiunaBI.Infrastructure/Data/AppDbContext.cs b/src/Backend/DiunaBI.Infrastructure/Data/AppDbContext.cs new file mode 100644 index 0000000..687bc72 --- /dev/null +++ b/src/Backend/DiunaBI.Infrastructure/Data/AppDbContext.cs @@ -0,0 +1,183 @@ +using Microsoft.EntityFrameworkCore; +using DiunaBI.Domain.Entities; + +namespace DiunaBI.Infrastructure.Data; + +public class AppDbContext(DbContextOptions options) : DbContext(options) +{ + public DbSet Users { get; init; } + public DbSet Layers { get; init; } + public DbSet Records { get; init; } + public DbSet ProcessSources { get; init; } + public DbSet DataInbox { get; init; } + public DbSet QueueJobs { get; init; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(x => x.Id); + modelBuilder.Entity().Property(x => x.Email).HasMaxLength(50); + modelBuilder.Entity().Property(x => x.UserName).HasMaxLength(50); + + modelBuilder.Entity().HasKey(x => x.Id); + modelBuilder.Entity().Property(x => x.Number).IsRequired(); + modelBuilder.Entity().Property(x => x.Name).IsRequired().HasMaxLength(50); + modelBuilder.Entity().Property(x => x.Type).IsRequired().HasConversion(); + modelBuilder.Entity().Property(x => x.CreatedAt).IsRequired(); + modelBuilder.Entity().Property(x => x.ModifiedAt).IsRequired(); + modelBuilder.Entity().Property(x => x.IsDeleted).IsRequired().HasDefaultValue(false); + modelBuilder.Entity().Property(x => x.IsCancelled).IsRequired(); + modelBuilder.Entity().Property(x => x.CreatedById).IsRequired(); + modelBuilder.Entity().Property(x => x.ModifiedById).IsRequired(); + + modelBuilder.Entity() + .HasOne(x => x.CreatedBy) + .WithMany() + .HasForeignKey(x => x.CreatedById) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity() + .HasOne(x => x.ModifiedBy) + .WithMany() + .HasForeignKey(x => x.ModifiedById) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity() + .HasMany(x => x.Records) + .WithOne() + .HasForeignKey(r => r.LayerId) + .OnDelete(DeleteBehavior.Cascade); + + modelBuilder.Entity().HasKey(x => x.Id); + modelBuilder.Entity().Property(x => x.Code).IsRequired().HasMaxLength(50); + modelBuilder.Entity().Property(x => x.Desc1).HasMaxLength(10000); + modelBuilder.Entity().Property(x => x.CreatedAt); + modelBuilder.Entity().Property(x => x.ModifiedAt); + modelBuilder.Entity().Property(x => x.IsDeleted); + modelBuilder.Entity().Property(x => x.CreatedById).IsRequired(); + modelBuilder.Entity().Property(x => x.ModifiedById).IsRequired(); + modelBuilder.Entity().Property(x => x.LayerId).IsRequired(); + + modelBuilder.Entity() + .HasOne(x => x.CreatedBy) + .WithMany() + .HasForeignKey(x => x.CreatedById) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity() + .HasOne(x => x.ModifiedBy) + .WithMany() + .HasForeignKey(x => x.ModifiedById) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity() + .HasOne() + .WithMany(l => l.Records!) + .HasForeignKey(x => x.LayerId) + .OnDelete(DeleteBehavior.Cascade); + + modelBuilder.Entity().HasKey(x => new { x.LayerId, x.SourceId }); + modelBuilder.Entity().Property(x => x.LayerId).IsRequired(); + modelBuilder.Entity().Property(x => x.SourceId).IsRequired(); + + modelBuilder.Entity() + .HasOne() + .WithMany() + .HasForeignKey(x => x.LayerId) + .OnDelete(DeleteBehavior.Cascade); + + modelBuilder.Entity() + .HasOne(x => x.Source) + .WithMany() + .HasForeignKey(x => x.SourceId) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity().HasKey(x => x.Id); + modelBuilder.Entity().Property(x => x.Name).IsRequired().HasMaxLength(50); + modelBuilder.Entity().Property(x => x.Source).IsRequired().HasMaxLength(50); + modelBuilder.Entity().Property(x => x.Data).IsRequired(); + modelBuilder.Entity().Property(x => x.CreatedAt); + + modelBuilder.Entity().HasKey(x => x.Id); + modelBuilder.Entity().Property(x => x.LayerId).IsRequired(); + modelBuilder.Entity().Property(x => x.LayerName).IsRequired().HasMaxLength(200); + modelBuilder.Entity().Property(x => x.PluginName).IsRequired().HasMaxLength(100); + modelBuilder.Entity().Property(x => x.JobType).IsRequired().HasConversion(); + modelBuilder.Entity().Property(x => x.Priority); + modelBuilder.Entity().Property(x => x.CreatedAt).IsRequired(); + modelBuilder.Entity().Property(x => x.RetryCount); + modelBuilder.Entity().Property(x => x.MaxRetries); + modelBuilder.Entity().Property(x => x.Status).IsRequired().HasConversion(); + modelBuilder.Entity().Property(x => x.LastError).HasMaxLength(1000); + modelBuilder.Entity().Property(x => x.LastAttemptAt); + modelBuilder.Entity().Property(x => x.CompletedAt); + modelBuilder.Entity().Property(x => x.CreatedById).IsRequired(); + modelBuilder.Entity().Property(x => x.CreatedAtUtc).IsRequired(); + modelBuilder.Entity().Property(x => x.ModifiedById).IsRequired(); + modelBuilder.Entity().Property(x => x.ModifiedAtUtc).IsRequired(); + + // Configure automatic timestamps for entities with CreatedAt/ModifiedAt + ConfigureTimestamps(modelBuilder); + } + + private void ConfigureTimestamps(ModelBuilder modelBuilder) + { + foreach (var entityType in modelBuilder.Model.GetEntityTypes()) + { + // Check if entity has CreatedAt property + var createdAtProperty = entityType.FindProperty("CreatedAt"); + if (createdAtProperty != null) + { + modelBuilder.Entity(entityType.ClrType) + .Property("CreatedAt") + .HasDefaultValueSql("NOW()"); + } + + // Check if entity has ModifiedAt property + var modifiedAtProperty = entityType.FindProperty("ModifiedAt"); + if (modifiedAtProperty != null) + { + modelBuilder.Entity(entityType.ClrType) + .Property("ModifiedAt") + .HasDefaultValueSql("NOW()"); + } + } + } + + public override int SaveChanges() + { + UpdateTimestamps(); + return base.SaveChanges(); + } + + public override Task SaveChangesAsync(CancellationToken cancellationToken = default) + { + UpdateTimestamps(); + return base.SaveChangesAsync(cancellationToken); + } + + private void UpdateTimestamps() + { + var entities = ChangeTracker.Entries() + .Where(e => e.State == EntityState.Added || e.State == EntityState.Modified); + + foreach (var entity in entities) + { + // Try to set CreatedAt for new entities + if (entity.State == EntityState.Added) + { + var createdAtProperty = entity.Properties.FirstOrDefault(p => p.Metadata.Name == "CreatedAt"); + if (createdAtProperty != null) + { + createdAtProperty.CurrentValue = DateTime.UtcNow; + } + } + + // Always update ModifiedAt + var modifiedAtProperty = entity.Properties.FirstOrDefault(p => p.Metadata.Name == "ModifiedAt"); + if (modifiedAtProperty != null) + { + modifiedAtProperty.CurrentValue = DateTime.UtcNow; + } + } + } +} \ No newline at end of file diff --git a/src/Backend/DiunaBI.Core/Database/Context/DesignTimeDbContextFactory.cs b/src/Backend/DiunaBI.Infrastructure/Data/DesignTimeDbContextFactory.cs similarity index 93% rename from src/Backend/DiunaBI.Core/Database/Context/DesignTimeDbContextFactory.cs rename to src/Backend/DiunaBI.Infrastructure/Data/DesignTimeDbContextFactory.cs index 1da1ba1..197f59a 100644 --- a/src/Backend/DiunaBI.Core/Database/Context/DesignTimeDbContextFactory.cs +++ b/src/Backend/DiunaBI.Infrastructure/Data/DesignTimeDbContextFactory.cs @@ -4,14 +4,14 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.Extensions.Configuration; -namespace DiunaBI.Core.Database.Context; +namespace DiunaBI.Infrastructure.Data; public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory { public AppDbContext CreateDbContext(string[] args) { var configuration = new ConfigurationBuilder() - .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../DiunaBI.WebAPI")) + .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../DiunaBI.API")) .AddJsonFile("appsettings.json", optional: false) .AddJsonFile("appsettings.Development.json", optional: true) .Build(); diff --git a/src/Backend/DiunaBI.Infrastructure/DiunaBI.Infrastructure.csproj b/src/Backend/DiunaBI.Infrastructure/DiunaBI.Infrastructure.csproj new file mode 100644 index 0000000..038a8ec --- /dev/null +++ b/src/Backend/DiunaBI.Infrastructure/DiunaBI.Infrastructure.csproj @@ -0,0 +1,28 @@ + + + + + net8.0 + enable + enable + 12.0 + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + \ No newline at end of file diff --git a/src/Backend/DiunaBI.Core/Interfaces/IDataExporter.cs b/src/Backend/DiunaBI.Infrastructure/Interfaces/IDataExporter.cs similarity index 64% rename from src/Backend/DiunaBI.Core/Interfaces/IDataExporter.cs rename to src/Backend/DiunaBI.Infrastructure/Interfaces/IDataExporter.cs index 869a2b5..2038a4a 100644 --- a/src/Backend/DiunaBI.Core/Interfaces/IDataExporter.cs +++ b/src/Backend/DiunaBI.Infrastructure/Interfaces/IDataExporter.cs @@ -1,6 +1,6 @@ -using DiunaBI.Core.Models; +using DiunaBI.Domain.Entities; -namespace DiunaBI.Core.Interfaces; +namespace DiunaBI.Infrastructure.Interfaces; public interface IDataExporter { diff --git a/src/Backend/DiunaBI.Core/Interfaces/IDataImporter.cs b/src/Backend/DiunaBI.Infrastructure/Interfaces/IDataImporter.cs similarity index 66% rename from src/Backend/DiunaBI.Core/Interfaces/IDataImporter.cs rename to src/Backend/DiunaBI.Infrastructure/Interfaces/IDataImporter.cs index 4c77890..9c5db74 100644 --- a/src/Backend/DiunaBI.Core/Interfaces/IDataImporter.cs +++ b/src/Backend/DiunaBI.Infrastructure/Interfaces/IDataImporter.cs @@ -1,6 +1,6 @@ -using DiunaBI.Core.Models; +using DiunaBI.Domain.Entities; -namespace DiunaBI.Core.Interfaces; +namespace DiunaBI.Infrastructure.Interfaces; public interface IDataImporter { diff --git a/src/Backend/DiunaBI.Core/Interfaces/IDataProcessor.cs b/src/Backend/DiunaBI.Infrastructure/Interfaces/IDataProcessor.cs similarity index 67% rename from src/Backend/DiunaBI.Core/Interfaces/IDataProcessor.cs rename to src/Backend/DiunaBI.Infrastructure/Interfaces/IDataProcessor.cs index d48cd85..5a815f2 100644 --- a/src/Backend/DiunaBI.Core/Interfaces/IDataProcessor.cs +++ b/src/Backend/DiunaBI.Infrastructure/Interfaces/IDataProcessor.cs @@ -1,6 +1,6 @@ -using DiunaBI.Core.Models; +using DiunaBI.Domain.Entities; -namespace DiunaBI.Core.Interfaces; +namespace DiunaBI.Infrastructure.Interfaces; public interface IDataProcessor { diff --git a/src/Backend/DiunaBI.Core/Interfaces/IPlugin.cs b/src/Backend/DiunaBI.Infrastructure/Interfaces/IPlugin.cs similarity index 80% rename from src/Backend/DiunaBI.Core/Interfaces/IPlugin.cs rename to src/Backend/DiunaBI.Infrastructure/Interfaces/IPlugin.cs index a4f2ed4..04fb265 100644 --- a/src/Backend/DiunaBI.Core/Interfaces/IPlugin.cs +++ b/src/Backend/DiunaBI.Infrastructure/Interfaces/IPlugin.cs @@ -1,4 +1,4 @@ -namespace DiunaBI.Core.Interfaces; +namespace DiunaBI.Infrastructure.Interfaces; public interface IPlugin { diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20221205190148_Initial.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221205190148_Initial.Designer.cs similarity index 88% rename from src/Backend/DiunaBI.Core/Database/Migrations/20221205190148_Initial.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20221205190148_Initial.Designer.cs index c0baa9b..cc567ec 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20221205190148_Initial.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221205190148_Initial.Designer.cs @@ -1,52 +1,52 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; - -#nullable disable - -namespace DiunaBI.Core.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20221205190148_Initial")] - partial class Initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("WebAPI.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("UserName") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; + +#nullable disable + +namespace DiunaBI.Core.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20221205190148_Initial")] + partial class Initial + { + /// + protected void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("WebAPI.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20221205190148_Initial.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221205190148_Initial.cs similarity index 94% rename from src/Backend/DiunaBI.Core/Database/Migrations/20221205190148_Initial.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20221205190148_Initial.cs index c44a6ff..25c996b 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20221205190148_Initial.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221205190148_Initial.cs @@ -1,36 +1,36 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DiunaBI.Core.Migrations -{ - /// - public partial class Initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Email = table.Column(type: "nvarchar(max)", nullable: true), - UserName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), - CreatedAt = table.Column(type: "datetime2", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Users"); - } - } -} +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: true), + UserName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + CreatedAt = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Users"); + } + } +} diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20221211210507_DataSetsAndDataRows.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221211210507_DataSetsAndDataRows.Designer.cs similarity index 95% rename from src/Backend/DiunaBI.Core/Database/Migrations/20221211210507_DataSetsAndDataRows.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20221211210507_DataSetsAndDataRows.Designer.cs index e5ac00e..a534544 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20221211210507_DataSetsAndDataRows.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221211210507_DataSetsAndDataRows.Designer.cs @@ -1,193 +1,193 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; - -#nullable disable - -namespace DiunaBI.Core.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20221211210507_DataSetsAndDataRows")] - partial class DataSetsAndDataRows - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("WebAPI.Models.DataRow", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("DataSetId") - .HasColumnType("uniqueidentifier"); - - b.Property("Desc1") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc2") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc3") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc4") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc5") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("MPK") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Value") - .HasColumnType("real"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("DataSetId"); - - b.HasIndex("ModifiedById"); - - b.ToTable("DataRows"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Number") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("ModifiedById"); - - b.ToTable("DataSets"); - }); - - modelBuilder.Entity("WebAPI.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("UserName") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("WebAPI.Models.DataRow", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.DataSet", null) - .WithMany("DataRows") - .HasForeignKey("DataSetId"); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.Navigation("DataRows"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; + +#nullable disable + +namespace DiunaBI.Core.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20221211210507_DataSetsAndDataRows")] + partial class DataSetsAndDataRows + { + /// + protected void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("WebAPI.Models.DataRow", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("DataSetId") + .HasColumnType("uniqueidentifier"); + + b.Property("Desc1") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc2") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc3") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc4") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc5") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MPK") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("DataSetId"); + + b.HasIndex("ModifiedById"); + + b.ToTable("DataRows"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Number") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("ModifiedById"); + + b.ToTable("DataSets"); + }); + + modelBuilder.Entity("WebAPI.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("WebAPI.Models.DataRow", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.DataSet", null) + .WithMany("DataRows") + .HasForeignKey("DataSetId"); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.Navigation("DataRows"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20221211210507_DataSetsAndDataRows.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221211210507_DataSetsAndDataRows.cs similarity index 97% rename from src/Backend/DiunaBI.Core/Database/Migrations/20221211210507_DataSetsAndDataRows.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20221211210507_DataSetsAndDataRows.cs index 4827087..8b3b603 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20221211210507_DataSetsAndDataRows.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221211210507_DataSetsAndDataRows.cs @@ -1,121 +1,121 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DiunaBI.Core.Migrations -{ - /// - public partial class DataSetsAndDataRows : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "DataSets", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Number = table.Column(type: "nvarchar(max)", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: true), - CreatedAt = table.Column(type: "datetime2", nullable: false), - ModifiedAt = table.Column(type: "datetime2", nullable: false), - IsDeleted = table.Column(type: "bit", nullable: false), - CreatedById = table.Column(type: "uniqueidentifier", nullable: false), - ModifiedById = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_DataSets", x => x.Id); - table.ForeignKey( - name: "FK_DataSets_Users_CreatedById", - column: x => x.CreatedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_DataSets_Users_ModifiedById", - column: x => x.ModifiedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateTable( - name: "DataRows", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - MPK = table.Column(type: "nvarchar(max)", nullable: false), - Value = table.Column(type: "real", nullable: false), - Desc1 = table.Column(type: "nvarchar(max)", nullable: true), - Desc2 = table.Column(type: "nvarchar(max)", nullable: true), - Desc3 = table.Column(type: "nvarchar(max)", nullable: true), - Desc4 = table.Column(type: "nvarchar(max)", nullable: true), - Desc5 = table.Column(type: "nvarchar(max)", nullable: true), - CreatedAt = table.Column(type: "datetime2", nullable: false), - ModifiedAt = table.Column(type: "datetime2", nullable: false), - IsDeleted = table.Column(type: "bit", nullable: false), - CreatedById = table.Column(type: "uniqueidentifier", nullable: false), - ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), - DataSetId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_DataRows", x => x.Id); - table.ForeignKey( - name: "FK_DataRows_DataSets_DataSetId", - column: x => x.DataSetId, - principalTable: "DataSets", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_DataRows_Users_CreatedById", - column: x => x.CreatedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_DataRows_Users_ModifiedById", - column: x => x.ModifiedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateIndex( - name: "IX_DataRows_CreatedById", - table: "DataRows", - column: "CreatedById"); - - migrationBuilder.CreateIndex( - name: "IX_DataRows_DataSetId", - table: "DataRows", - column: "DataSetId"); - - migrationBuilder.CreateIndex( - name: "IX_DataRows_ModifiedById", - table: "DataRows", - column: "ModifiedById"); - - migrationBuilder.CreateIndex( - name: "IX_DataSets_CreatedById", - table: "DataSets", - column: "CreatedById"); - - migrationBuilder.CreateIndex( - name: "IX_DataSets_ModifiedById", - table: "DataSets", - column: "ModifiedById"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "DataRows"); - - migrationBuilder.DropTable( - name: "DataSets"); - } - } -} +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + /// + public partial class DataSetsAndDataRows : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "DataSets", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Number = table.Column(type: "nvarchar(max)", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: true), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + CreatedById = table.Column(type: "uniqueidentifier", nullable: false), + ModifiedById = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DataSets", x => x.Id); + table.ForeignKey( + name: "FK_DataSets_Users_CreatedById", + column: x => x.CreatedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_DataSets_Users_ModifiedById", + column: x => x.ModifiedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateTable( + name: "DataRows", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + MPK = table.Column(type: "nvarchar(max)", nullable: false), + Value = table.Column(type: "real", nullable: false), + Desc1 = table.Column(type: "nvarchar(max)", nullable: true), + Desc2 = table.Column(type: "nvarchar(max)", nullable: true), + Desc3 = table.Column(type: "nvarchar(max)", nullable: true), + Desc4 = table.Column(type: "nvarchar(max)", nullable: true), + Desc5 = table.Column(type: "nvarchar(max)", nullable: true), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + CreatedById = table.Column(type: "uniqueidentifier", nullable: false), + ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), + DataSetId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_DataRows", x => x.Id); + table.ForeignKey( + name: "FK_DataRows_DataSets_DataSetId", + column: x => x.DataSetId, + principalTable: "DataSets", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_DataRows_Users_CreatedById", + column: x => x.CreatedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_DataRows_Users_ModifiedById", + column: x => x.ModifiedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateIndex( + name: "IX_DataRows_CreatedById", + table: "DataRows", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_DataRows_DataSetId", + table: "DataRows", + column: "DataSetId"); + + migrationBuilder.CreateIndex( + name: "IX_DataRows_ModifiedById", + table: "DataRows", + column: "ModifiedById"); + + migrationBuilder.CreateIndex( + name: "IX_DataSets_CreatedById", + table: "DataSets", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_DataSets_ModifiedById", + table: "DataSets", + column: "ModifiedById"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "DataRows"); + + migrationBuilder.DropTable( + name: "DataSets"); + } + } +} diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20221219163620_RenameFields.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221219163620_RenameFields.Designer.cs similarity index 95% rename from src/Backend/DiunaBI.Core/Database/Migrations/20221219163620_RenameFields.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20221219163620_RenameFields.Designer.cs index 162b159..7a19929 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20221219163620_RenameFields.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221219163620_RenameFields.Designer.cs @@ -1,198 +1,198 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; - -#nullable disable - -namespace DiunaBI.Core.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20221219163620_RenameFields")] - partial class RenameFields - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("WebAPI.Models.DataRow", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("DataSetId") - .HasColumnType("uniqueidentifier"); - - b.Property("Desc1") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc2") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc3") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc4") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc5") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Value") - .HasColumnType("real"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("DataSetId"); - - b.HasIndex("ModifiedById"); - - b.ToTable("DataRows"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Number") - .IsRequired() - .HasColumnType("int"); - - b.Property("Source") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("ModifiedById"); - - b.ToTable("DataSets"); - }); - - modelBuilder.Entity("WebAPI.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("UserName") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("WebAPI.Models.DataRow", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.DataSet", null) - .WithMany("DataRows") - .HasForeignKey("DataSetId"); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.Navigation("DataRows"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; + +#nullable disable + +namespace DiunaBI.Core.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20221219163620_RenameFields")] + partial class RenameFields + { + /// + protected void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("WebAPI.Models.DataRow", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("DataSetId") + .HasColumnType("uniqueidentifier"); + + b.Property("Desc1") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc2") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc3") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc4") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc5") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("DataSetId"); + + b.HasIndex("ModifiedById"); + + b.ToTable("DataRows"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Number") + .IsRequired() + .HasColumnType("int"); + + b.Property("Source") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("ModifiedById"); + + b.ToTable("DataSets"); + }); + + modelBuilder.Entity("WebAPI.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("WebAPI.Models.DataRow", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.DataSet", null) + .WithMany("DataRows") + .HasForeignKey("DataSetId"); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.Navigation("DataRows"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20221219163620_RenameFields.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221219163620_RenameFields.cs similarity index 95% rename from src/Backend/DiunaBI.Core/Database/Migrations/20221219163620_RenameFields.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20221219163620_RenameFields.cs index 2570d7f..4989f50 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20221219163620_RenameFields.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221219163620_RenameFields.cs @@ -1,73 +1,73 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DiunaBI.Core.Migrations -{ - /// - public partial class RenameFields : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "MPK", - table: "DataRows", - newName: "Code"); - - migrationBuilder.AlterColumn( - name: "Number", - table: "DataSets", - type: "int", - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - - migrationBuilder.AlterColumn( - name: "Name", - table: "DataSets", - type: "nvarchar(max)", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true); - - migrationBuilder.AddColumn( - name: "Source", - table: "DataSets", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Source", - table: "DataSets"); - - migrationBuilder.RenameColumn( - name: "Code", - table: "DataRows", - newName: "MPK"); - - migrationBuilder.AlterColumn( - name: "Number", - table: "DataSets", - type: "nvarchar(max)", - nullable: false, - oldClrType: typeof(int), - oldType: "int"); - - migrationBuilder.AlterColumn( - name: "Name", - table: "DataSets", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - } - } -} +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + /// + public partial class RenameFields : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "MPK", + table: "DataRows", + newName: "Code"); + + migrationBuilder.AlterColumn( + name: "Number", + table: "DataSets", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "DataSets", + type: "nvarchar(max)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "Source", + table: "DataSets", + type: "nvarchar(max)", + nullable: false, + defaultValue: ""); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Source", + table: "DataSets"); + + migrationBuilder.RenameColumn( + name: "Code", + table: "DataRows", + newName: "MPK"); + + migrationBuilder.AlterColumn( + name: "Number", + table: "DataSets", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "DataSets", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + } + } +} diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20221221165749_DataSetIdOnDataRow.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221221165749_DataSetIdOnDataRow.Designer.cs similarity index 95% rename from src/Backend/DiunaBI.Core/Database/Migrations/20221221165749_DataSetIdOnDataRow.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20221221165749_DataSetIdOnDataRow.Designer.cs index 1fdce1c..ee6c460 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20221221165749_DataSetIdOnDataRow.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221221165749_DataSetIdOnDataRow.Designer.cs @@ -1,200 +1,200 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; - -#nullable disable - -namespace DiunaBI.Core.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20221221165749_DataSetIdOnDataRow")] - partial class DataSetIdOnDataRow - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("WebAPI.Models.DataRow", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("DataSetId") - .HasColumnType("uniqueidentifier"); - - b.Property("Desc1") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc2") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc3") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc4") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc5") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Value") - .HasColumnType("real"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("DataSetId"); - - b.HasIndex("ModifiedById"); - - b.ToTable("DataRows"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Number") - .IsRequired() - .HasColumnType("int"); - - b.Property("Source") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("ModifiedById"); - - b.ToTable("DataSets"); - }); - - modelBuilder.Entity("WebAPI.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("UserName") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("WebAPI.Models.DataRow", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.DataSet", null) - .WithMany("DataRows") - .HasForeignKey("DataSetId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.DataSet", b => - { - b.Navigation("DataRows"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; + +#nullable disable + +namespace DiunaBI.Core.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20221221165749_DataSetIdOnDataRow")] + partial class DataSetIdOnDataRow + { + /// + protected void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("WebAPI.Models.DataRow", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("DataSetId") + .HasColumnType("uniqueidentifier"); + + b.Property("Desc1") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc2") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc3") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc4") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc5") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("DataSetId"); + + b.HasIndex("ModifiedById"); + + b.ToTable("DataRows"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Number") + .IsRequired() + .HasColumnType("int"); + + b.Property("Source") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("ModifiedById"); + + b.ToTable("DataSets"); + }); + + modelBuilder.Entity("WebAPI.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("WebAPI.Models.DataRow", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.DataSet", null) + .WithMany("DataRows") + .HasForeignKey("DataSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.DataSet", b => + { + b.Navigation("DataRows"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20221221165749_DataSetIdOnDataRow.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20221221165749_DataSetIdOnDataRow.cs similarity index 95% rename from src/Backend/DiunaBI.Core/Database/Migrations/20221221165749_DataSetIdOnDataRow.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20221221165749_DataSetIdOnDataRow.cs index 6a23fba..233c8e0 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20221221165749_DataSetIdOnDataRow.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20221221165749_DataSetIdOnDataRow.cs @@ -1,60 +1,60 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DiunaBI.Core.Migrations -{ - /// - public partial class DataSetIdOnDataRow : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_DataRows_DataSets_DataSetId", - table: "DataRows"); - - migrationBuilder.AlterColumn( - name: "DataSetId", - table: "DataRows", - type: "uniqueidentifier", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - oldClrType: typeof(Guid), - oldType: "uniqueidentifier", - oldNullable: true); - - migrationBuilder.AddForeignKey( - name: "FK_DataRows_DataSets_DataSetId", - table: "DataRows", - column: "DataSetId", - principalTable: "DataSets", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_DataRows_DataSets_DataSetId", - table: "DataRows"); - - migrationBuilder.AlterColumn( - name: "DataSetId", - table: "DataRows", - type: "uniqueidentifier", - nullable: true, - oldClrType: typeof(Guid), - oldType: "uniqueidentifier"); - - migrationBuilder.AddForeignKey( - name: "FK_DataRows_DataSets_DataSetId", - table: "DataRows", - column: "DataSetId", - principalTable: "DataSets", - principalColumn: "Id"); - } - } -} +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + /// + public partial class DataSetIdOnDataRow : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_DataRows_DataSets_DataSetId", + table: "DataRows"); + + migrationBuilder.AlterColumn( + name: "DataSetId", + table: "DataRows", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uniqueidentifier", + oldNullable: true); + + migrationBuilder.AddForeignKey( + name: "FK_DataRows_DataSets_DataSetId", + table: "DataRows", + column: "DataSetId", + principalTable: "DataSets", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_DataRows_DataSets_DataSetId", + table: "DataRows"); + + migrationBuilder.AlterColumn( + name: "DataSetId", + table: "DataRows", + type: "uniqueidentifier", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uniqueidentifier"); + + migrationBuilder.AddForeignKey( + name: "FK_DataRows_DataSets_DataSetId", + table: "DataRows", + column: "DataSetId", + principalTable: "DataSets", + principalColumn: "Id"); + } + } +} diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20230106095427_RenameModels.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20230106095427_RenameModels.Designer.cs similarity index 95% rename from src/Backend/DiunaBI.Core/Database/Migrations/20230106095427_RenameModels.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20230106095427_RenameModels.Designer.cs index 07be6ad..ca2336d 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20230106095427_RenameModels.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20230106095427_RenameModels.Designer.cs @@ -1,200 +1,200 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; - -#nullable disable - -namespace DiunaBI.Core.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20230106095427_RenameModels")] - partial class RenameModels - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("WebAPI.Models.Layer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Number") - .IsRequired() - .HasColumnType("int"); - - b.Property("Source") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("ModifiedById"); - - b.ToTable("Layers"); - }); - - modelBuilder.Entity("WebAPI.Models.Record", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Code") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("CreatedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Desc1") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc2") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc3") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc4") - .HasColumnType("nvarchar(max)"); - - b.Property("Desc5") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LayerId") - .HasColumnType("uniqueidentifier"); - - b.Property("ModifiedAt") - .HasColumnType("datetime2"); - - b.Property("ModifiedById") - .HasColumnType("uniqueidentifier"); - - b.Property("Value") - .HasColumnType("real"); - - b.HasKey("Id"); - - b.HasIndex("CreatedById"); - - b.HasIndex("LayerId"); - - b.HasIndex("ModifiedById"); - - b.ToTable("Records"); - }); - - modelBuilder.Entity("WebAPI.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("UserName") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("WebAPI.Models.Layer", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.Record", b => - { - b.HasOne("WebAPI.Models.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.Layer", null) - .WithMany("Records") - .HasForeignKey("LayerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("WebAPI.Models.User", "ModifiedBy") - .WithMany() - .HasForeignKey("ModifiedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedBy"); - - b.Navigation("ModifiedBy"); - }); - - modelBuilder.Entity("WebAPI.Models.Layer", b => - { - b.Navigation("Records"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; + +#nullable disable + +namespace DiunaBI.Core.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230106095427_RenameModels")] + partial class RenameModels + { + /// + protected void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("WebAPI.Models.Layer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Number") + .IsRequired() + .HasColumnType("int"); + + b.Property("Source") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("ModifiedById"); + + b.ToTable("Layers"); + }); + + modelBuilder.Entity("WebAPI.Models.Record", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Desc1") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc2") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc3") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc4") + .HasColumnType("nvarchar(max)"); + + b.Property("Desc5") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LayerId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedById") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("LayerId"); + + b.HasIndex("ModifiedById"); + + b.ToTable("Records"); + }); + + modelBuilder.Entity("WebAPI.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("WebAPI.Models.Layer", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.Record", b => + { + b.HasOne("WebAPI.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.Layer", null) + .WithMany("Records") + .HasForeignKey("LayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebAPI.Models.User", "ModifiedBy") + .WithMany() + .HasForeignKey("ModifiedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("ModifiedBy"); + }); + + modelBuilder.Entity("WebAPI.Models.Layer", b => + { + b.Navigation("Records"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20230106095427_RenameModels.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20230106095427_RenameModels.cs similarity index 97% rename from src/Backend/DiunaBI.Core/Database/Migrations/20230106095427_RenameModels.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20230106095427_RenameModels.cs index 205fde2..0d003ef 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20230106095427_RenameModels.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20230106095427_RenameModels.cs @@ -1,227 +1,227 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DiunaBI.Core.Migrations -{ - /// - public partial class RenameModels : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "DataRows"); - - migrationBuilder.DropTable( - name: "DataSets"); - - migrationBuilder.CreateTable( - name: "Layers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Number = table.Column(type: "int", nullable: false), - Source = table.Column(type: "nvarchar(max)", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: false), - CreatedAt = table.Column(type: "datetime2", nullable: false), - ModifiedAt = table.Column(type: "datetime2", nullable: false), - IsDeleted = table.Column(type: "bit", nullable: false), - CreatedById = table.Column(type: "uniqueidentifier", nullable: false), - ModifiedById = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Layers", x => x.Id); - table.ForeignKey( - name: "FK_Layers_Users_CreatedById", - column: x => x.CreatedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_Layers_Users_ModifiedById", - column: x => x.ModifiedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateTable( - name: "Records", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Code = table.Column(type: "nvarchar(max)", nullable: false), - Value = table.Column(type: "real", nullable: false), - Desc1 = table.Column(type: "nvarchar(max)", nullable: true), - Desc2 = table.Column(type: "nvarchar(max)", nullable: true), - Desc3 = table.Column(type: "nvarchar(max)", nullable: true), - Desc4 = table.Column(type: "nvarchar(max)", nullable: true), - Desc5 = table.Column(type: "nvarchar(max)", nullable: true), - CreatedAt = table.Column(type: "datetime2", nullable: false), - ModifiedAt = table.Column(type: "datetime2", nullable: false), - IsDeleted = table.Column(type: "bit", nullable: false), - CreatedById = table.Column(type: "uniqueidentifier", nullable: false), - ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), - LayerId = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Records", x => x.Id); - table.ForeignKey( - name: "FK_Records_Layers_LayerId", - column: x => x.LayerId, - principalTable: "Layers", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_Records_Users_CreatedById", - column: x => x.CreatedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_Records_Users_ModifiedById", - column: x => x.ModifiedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateIndex( - name: "IX_Layers_CreatedById", - table: "Layers", - column: "CreatedById"); - - migrationBuilder.CreateIndex( - name: "IX_Layers_ModifiedById", - table: "Layers", - column: "ModifiedById"); - - migrationBuilder.CreateIndex( - name: "IX_Records_CreatedById", - table: "Records", - column: "CreatedById"); - - migrationBuilder.CreateIndex( - name: "IX_Records_LayerId", - table: "Records", - column: "LayerId"); - - migrationBuilder.CreateIndex( - name: "IX_Records_ModifiedById", - table: "Records", - column: "ModifiedById"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Records"); - - migrationBuilder.DropTable( - name: "Layers"); - - migrationBuilder.CreateTable( - name: "DataSets", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CreatedById = table.Column(type: "uniqueidentifier", nullable: false), - ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), - CreatedAt = table.Column(type: "datetime2", nullable: false), - IsDeleted = table.Column(type: "bit", nullable: false), - ModifiedAt = table.Column(type: "datetime2", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: false), - Number = table.Column(type: "int", nullable: false), - Source = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_DataSets", x => x.Id); - table.ForeignKey( - name: "FK_DataSets_Users_CreatedById", - column: x => x.CreatedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_DataSets_Users_ModifiedById", - column: x => x.ModifiedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateTable( - name: "DataRows", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - CreatedById = table.Column(type: "uniqueidentifier", nullable: false), - ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), - Code = table.Column(type: "nvarchar(max)", nullable: false), - CreatedAt = table.Column(type: "datetime2", nullable: false), - DataSetId = table.Column(type: "uniqueidentifier", nullable: false), - Desc1 = table.Column(type: "nvarchar(max)", nullable: true), - Desc2 = table.Column(type: "nvarchar(max)", nullable: true), - Desc3 = table.Column(type: "nvarchar(max)", nullable: true), - Desc4 = table.Column(type: "nvarchar(max)", nullable: true), - Desc5 = table.Column(type: "nvarchar(max)", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false), - ModifiedAt = table.Column(type: "datetime2", nullable: false), - Value = table.Column(type: "real", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_DataRows", x => x.Id); - table.ForeignKey( - name: "FK_DataRows_DataSets_DataSetId", - column: x => x.DataSetId, - principalTable: "DataSets", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_DataRows_Users_CreatedById", - column: x => x.CreatedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_DataRows_Users_ModifiedById", - column: x => x.ModifiedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateIndex( - name: "IX_DataRows_CreatedById", - table: "DataRows", - column: "CreatedById"); - - migrationBuilder.CreateIndex( - name: "IX_DataRows_DataSetId", - table: "DataRows", - column: "DataSetId"); - - migrationBuilder.CreateIndex( - name: "IX_DataRows_ModifiedById", - table: "DataRows", - column: "ModifiedById"); - - migrationBuilder.CreateIndex( - name: "IX_DataSets_CreatedById", - table: "DataSets", - column: "CreatedById"); - - migrationBuilder.CreateIndex( - name: "IX_DataSets_ModifiedById", - table: "DataSets", - column: "ModifiedById"); - } - } -} +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DiunaBI.Infrastructure.Migrations +{ + /// + public partial class RenameModels : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "DataRows"); + + migrationBuilder.DropTable( + name: "DataSets"); + + migrationBuilder.CreateTable( + name: "Layers", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Number = table.Column(type: "int", nullable: false), + Source = table.Column(type: "nvarchar(max)", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + CreatedById = table.Column(type: "uniqueidentifier", nullable: false), + ModifiedById = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Layers", x => x.Id); + table.ForeignKey( + name: "FK_Layers_Users_CreatedById", + column: x => x.CreatedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_Layers_Users_ModifiedById", + column: x => x.ModifiedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateTable( + name: "Records", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Code = table.Column(type: "nvarchar(max)", nullable: false), + Value = table.Column(type: "real", nullable: false), + Desc1 = table.Column(type: "nvarchar(max)", nullable: true), + Desc2 = table.Column(type: "nvarchar(max)", nullable: true), + Desc3 = table.Column(type: "nvarchar(max)", nullable: true), + Desc4 = table.Column(type: "nvarchar(max)", nullable: true), + Desc5 = table.Column(type: "nvarchar(max)", nullable: true), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + CreatedById = table.Column(type: "uniqueidentifier", nullable: false), + ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), + LayerId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Records", x => x.Id); + table.ForeignKey( + name: "FK_Records_Layers_LayerId", + column: x => x.LayerId, + principalTable: "Layers", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_Records_Users_CreatedById", + column: x => x.CreatedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_Records_Users_ModifiedById", + column: x => x.ModifiedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateIndex( + name: "IX_Layers_CreatedById", + table: "Layers", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_Layers_ModifiedById", + table: "Layers", + column: "ModifiedById"); + + migrationBuilder.CreateIndex( + name: "IX_Records_CreatedById", + table: "Records", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_Records_LayerId", + table: "Records", + column: "LayerId"); + + migrationBuilder.CreateIndex( + name: "IX_Records_ModifiedById", + table: "Records", + column: "ModifiedById"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Records"); + + migrationBuilder.DropTable( + name: "Layers"); + + migrationBuilder.CreateTable( + name: "DataSets", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CreatedById = table.Column(type: "uniqueidentifier", nullable: false), + ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Number = table.Column(type: "int", nullable: false), + Source = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DataSets", x => x.Id); + table.ForeignKey( + name: "FK_DataSets_Users_CreatedById", + column: x => x.CreatedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_DataSets_Users_ModifiedById", + column: x => x.ModifiedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateTable( + name: "DataRows", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CreatedById = table.Column(type: "uniqueidentifier", nullable: false), + ModifiedById = table.Column(type: "uniqueidentifier", nullable: false), + Code = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + DataSetId = table.Column(type: "uniqueidentifier", nullable: false), + Desc1 = table.Column(type: "nvarchar(max)", nullable: true), + Desc2 = table.Column(type: "nvarchar(max)", nullable: true), + Desc3 = table.Column(type: "nvarchar(max)", nullable: true), + Desc4 = table.Column(type: "nvarchar(max)", nullable: true), + Desc5 = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + Value = table.Column(type: "real", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DataRows", x => x.Id); + table.ForeignKey( + name: "FK_DataRows_DataSets_DataSetId", + column: x => x.DataSetId, + principalTable: "DataSets", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_DataRows_Users_CreatedById", + column: x => x.CreatedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_DataRows_Users_ModifiedById", + column: x => x.ModifiedById, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateIndex( + name: "IX_DataRows_CreatedById", + table: "DataRows", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_DataRows_DataSetId", + table: "DataRows", + column: "DataSetId"); + + migrationBuilder.CreateIndex( + name: "IX_DataRows_ModifiedById", + table: "DataRows", + column: "ModifiedById"); + + migrationBuilder.CreateIndex( + name: "IX_DataSets_CreatedById", + table: "DataSets", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_DataSets_ModifiedById", + table: "DataSets", + column: "ModifiedById"); + } + } +} diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20230626171614_LayerType.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20230626171614_LayerType.Designer.cs similarity index 97% rename from src/Backend/DiunaBI.Core/Database/Migrations/20230626171614_LayerType.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20230626171614_LayerType.Designer.cs index 517ba43..2f3b0d5 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20230626171614_LayerType.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20230626171614_LayerType.Designer.cs @@ -5,8 +5,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -17,7 +17,7 @@ namespace DiunaBI.Core.Migrations partial class LayerType { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20230626171614_LayerType.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20230626171614_LayerType.cs similarity index 94% rename from src/Backend/DiunaBI.Core/Database/Migrations/20230626171614_LayerType.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20230626171614_LayerType.cs index 0354276..fbfbfc3 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20230626171614_LayerType.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20230626171614_LayerType.cs @@ -2,7 +2,7 @@ #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class LayerType : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20230821105757_Record.Values.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20230821105757_Record.Values.Designer.cs similarity index 98% rename from src/Backend/DiunaBI.Core/Database/Migrations/20230821105757_Record.Values.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20230821105757_Record.Values.Designer.cs index ae1da37..4d20b06 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20230821105757_Record.Values.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20230821105757_Record.Values.Designer.cs @@ -5,8 +5,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -17,7 +17,7 @@ namespace DiunaBI.Core.Migrations partial class RecordValues { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20230821105757_Record.Values.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20230821105757_Record.Values.cs similarity index 99% rename from src/Backend/DiunaBI.Core/Database/Migrations/20230821105757_Record.Values.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20230821105757_Record.Values.cs index f5ecb89..13b179c 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20230821105757_Record.Values.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20230821105757_Record.Values.cs @@ -2,7 +2,7 @@ #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class RecordValues : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20230917110252_Layer.parent.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20230917110252_Layer.parent.Designer.cs similarity index 98% rename from src/Backend/DiunaBI.Core/Database/Migrations/20230917110252_Layer.parent.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20230917110252_Layer.parent.Designer.cs index c7afb66..d73f0eb 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20230917110252_Layer.parent.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20230917110252_Layer.parent.Designer.cs @@ -5,8 +5,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -17,7 +17,7 @@ namespace DiunaBI.Core.Migrations partial class Layerparent { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20230917110252_Layer.parent.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20230917110252_Layer.parent.cs similarity index 96% rename from src/Backend/DiunaBI.Core/Database/Migrations/20230917110252_Layer.parent.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20230917110252_Layer.parent.cs index 0020874..b9a2317 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20230917110252_Layer.parent.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20230917110252_Layer.parent.cs @@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class Layerparent : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20230918090621_ProcessSource.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20230918090621_ProcessSource.Designer.cs similarity index 98% rename from src/Backend/DiunaBI.Core/Database/Migrations/20230918090621_ProcessSource.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20230918090621_ProcessSource.Designer.cs index 37af610..a2e539b 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20230918090621_ProcessSource.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20230918090621_ProcessSource.Designer.cs @@ -5,8 +5,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -17,7 +17,7 @@ namespace DiunaBI.Core.Migrations partial class ProcessSource { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20230918090621_ProcessSource.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20230918090621_ProcessSource.cs similarity index 97% rename from src/Backend/DiunaBI.Core/Database/Migrations/20230918090621_ProcessSource.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20230918090621_ProcessSource.cs index e51c9c4..20a2f8a 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20230918090621_ProcessSource.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20230918090621_ProcessSource.cs @@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class ProcessSource : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20230918093055_TypeO.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20230918093055_TypeO.Designer.cs similarity index 98% rename from src/Backend/DiunaBI.Core/Database/Migrations/20230918093055_TypeO.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20230918093055_TypeO.Designer.cs index b19ab99..34df314 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20230918093055_TypeO.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20230918093055_TypeO.Designer.cs @@ -6,8 +6,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -18,7 +18,7 @@ namespace DiunaBI.Core.Migrations partial class TypeO { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20230918093055_TypeO.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20230918093055_TypeO.cs similarity index 97% rename from src/Backend/DiunaBI.Core/Database/Migrations/20230918093055_TypeO.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20230918093055_TypeO.cs index deac794..ff80e5f 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20230918093055_TypeO.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20230918093055_TypeO.cs @@ -2,7 +2,7 @@ #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class TypeO : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20231030142419_Record.Value32.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20231030142419_Record.Value32.Designer.cs similarity index 98% rename from src/Backend/DiunaBI.Core/Database/Migrations/20231030142419_Record.Value32.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20231030142419_Record.Value32.Designer.cs index 4b2411d..1b16cec 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20231030142419_Record.Value32.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20231030142419_Record.Value32.Designer.cs @@ -5,8 +5,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -17,7 +17,7 @@ namespace DiunaBI.Core.Migrations partial class RecordValue32 { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20231030142419_Record.Value32.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20231030142419_Record.Value32.cs similarity index 93% rename from src/Backend/DiunaBI.Core/Database/Migrations/20231030142419_Record.Value32.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20231030142419_Record.Value32.cs index 0d204f4..377b985 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20231030142419_Record.Value32.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20231030142419_Record.Value32.cs @@ -2,7 +2,7 @@ #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class RecordValue32 : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20240309075645_Change record value type.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20240309075645_Change record value type.Designer.cs similarity index 98% rename from src/Backend/DiunaBI.Core/Database/Migrations/20240309075645_Change record value type.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20240309075645_Change record value type.Designer.cs index e226d0c..f12e4f2 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20240309075645_Change record value type.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20240309075645_Change record value type.Designer.cs @@ -5,8 +5,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -17,7 +17,7 @@ namespace DiunaBI.Core.Migrations partial class Changerecordvaluetype { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20240309075645_Change record value type.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20240309075645_Change record value type.cs similarity index 99% rename from src/Backend/DiunaBI.Core/Database/Migrations/20240309075645_Change record value type.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20240309075645_Change record value type.cs index daaaa1b..847833d 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20240309075645_Change record value type.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20240309075645_Change record value type.cs @@ -2,7 +2,7 @@ #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class Changerecordvaluetype : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20240703171630_AfterCodeRefactor.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20240703171630_AfterCodeRefactor.Designer.cs similarity index 98% rename from src/Backend/DiunaBI.Core/Database/Migrations/20240703171630_AfterCodeRefactor.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20240703171630_AfterCodeRefactor.Designer.cs index 6ed6f16..6289a87 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20240703171630_AfterCodeRefactor.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20240703171630_AfterCodeRefactor.Designer.cs @@ -5,8 +5,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -17,7 +17,7 @@ namespace DiunaBI.Core.Migrations partial class AfterCodeRefactor { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20240703171630_AfterCodeRefactor.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20240703171630_AfterCodeRefactor.cs similarity index 98% rename from src/Backend/DiunaBI.Core/Database/Migrations/20240703171630_AfterCodeRefactor.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20240703171630_AfterCodeRefactor.cs index c1ab587..60a19f6 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20240703171630_AfterCodeRefactor.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20240703171630_AfterCodeRefactor.cs @@ -2,7 +2,7 @@ #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class AfterCodeRefactor : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20240703173337_DataInboxModel.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20240703173337_DataInboxModel.Designer.cs similarity index 98% rename from src/Backend/DiunaBI.Core/Database/Migrations/20240703173337_DataInboxModel.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20240703173337_DataInboxModel.Designer.cs index 5ab24ba..a61ba19 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20240703173337_DataInboxModel.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20240703173337_DataInboxModel.Designer.cs @@ -5,8 +5,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -17,7 +17,7 @@ namespace DiunaBI.Core.Migrations partial class DataInboxModel { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20240703173337_DataInboxModel.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20240703173337_DataInboxModel.cs similarity index 96% rename from src/Backend/DiunaBI.Core/Database/Migrations/20240703173337_DataInboxModel.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20240703173337_DataInboxModel.cs index 7c174d7..022042d 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20240703173337_DataInboxModel.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20240703173337_DataInboxModel.cs @@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class DataInboxModel : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20240825144443_QueueJobs.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20240825144443_QueueJobs.Designer.cs similarity index 98% rename from src/Backend/DiunaBI.Core/Database/Migrations/20240825144443_QueueJobs.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20240825144443_QueueJobs.Designer.cs index 803a714..254f5fc 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20240825144443_QueueJobs.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20240825144443_QueueJobs.Designer.cs @@ -5,8 +5,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -17,7 +17,7 @@ namespace DiunaBI.Core.Migrations partial class QueueJobs { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20240825144443_QueueJobs.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20240825144443_QueueJobs.cs similarity index 97% rename from src/Backend/DiunaBI.Core/Database/Migrations/20240825144443_QueueJobs.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20240825144443_QueueJobs.cs index 253dba5..5b23eaa 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20240825144443_QueueJobs.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20240825144443_QueueJobs.cs @@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class QueueJobs : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20250317114722_LongerDesc1.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20250317114722_LongerDesc1.Designer.cs similarity index 98% rename from src/Backend/DiunaBI.Core/Database/Migrations/20250317114722_LongerDesc1.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20250317114722_LongerDesc1.Designer.cs index a50b999..778207e 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20250317114722_LongerDesc1.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20250317114722_LongerDesc1.Designer.cs @@ -5,8 +5,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -17,7 +17,7 @@ namespace DiunaBI.Core.Migrations partial class LongerDesc1 { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20250317114722_LongerDesc1.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20250317114722_LongerDesc1.cs similarity index 96% rename from src/Backend/DiunaBI.Core/Database/Migrations/20250317114722_LongerDesc1.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20250317114722_LongerDesc1.cs index 7462942..a0d1e33 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20250317114722_LongerDesc1.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20250317114722_LongerDesc1.cs @@ -2,7 +2,7 @@ #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class LongerDesc1 : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20250529093632_LayersIsCancelled.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20250529093632_LayersIsCancelled.Designer.cs similarity index 98% rename from src/Backend/DiunaBI.Core/Database/Migrations/20250529093632_LayersIsCancelled.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20250529093632_LayersIsCancelled.Designer.cs index f2af26e..9c448b4 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20250529093632_LayersIsCancelled.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20250529093632_LayersIsCancelled.Designer.cs @@ -5,8 +5,8 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -17,7 +17,7 @@ namespace DiunaBI.Core.Migrations partial class LayersIsCancelled { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20250529093632_LayersIsCancelled.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20250529093632_LayersIsCancelled.cs similarity index 94% rename from src/Backend/DiunaBI.Core/Database/Migrations/20250529093632_LayersIsCancelled.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20250529093632_LayersIsCancelled.cs index f963b5e..62dc818 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20250529093632_LayersIsCancelled.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20250529093632_LayersIsCancelled.cs @@ -2,7 +2,7 @@ #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class LayersIsCancelled : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20250607084540_QueueJobRefactor.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20250607084540_QueueJobRefactor.Designer.cs similarity index 99% rename from src/Backend/DiunaBI.Core/Database/Migrations/20250607084540_QueueJobRefactor.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20250607084540_QueueJobRefactor.Designer.cs index aec761a..8b6f504 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20250607084540_QueueJobRefactor.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20250607084540_QueueJobRefactor.Designer.cs @@ -1,11 +1,12 @@ // using System; -using DiunaBI.Core.Database.Context; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -16,7 +17,7 @@ namespace DiunaBI.Core.Migrations partial class QueueJobRefactor { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20250607084540_QueueJobRefactor.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20250607084540_QueueJobRefactor.cs similarity index 99% rename from src/Backend/DiunaBI.Core/Database/Migrations/20250607084540_QueueJobRefactor.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20250607084540_QueueJobRefactor.cs index 895d2f1..cd20ea2 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20250607084540_QueueJobRefactor.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20250607084540_QueueJobRefactor.cs @@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class QueueJobRefactor : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20250725133501_DataInbox.LayerId.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20250725133501_DataInbox.LayerId.Designer.cs similarity index 99% rename from src/Backend/DiunaBI.Core/Database/Migrations/20250725133501_DataInbox.LayerId.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20250725133501_DataInbox.LayerId.Designer.cs index 8943b9c..321dbdc 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20250725133501_DataInbox.LayerId.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20250725133501_DataInbox.LayerId.Designer.cs @@ -1,11 +1,12 @@ // using System; -using DiunaBI.Core.Database.Context; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -16,7 +17,7 @@ namespace DiunaBI.Core.Migrations partial class DataInboxLayerId { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20250725133501_DataInbox.LayerId.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20250725133501_DataInbox.LayerId.cs similarity index 94% rename from src/Backend/DiunaBI.Core/Database/Migrations/20250725133501_DataInbox.LayerId.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20250725133501_DataInbox.LayerId.cs index c16f817..961f565 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20250725133501_DataInbox.LayerId.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20250725133501_DataInbox.LayerId.cs @@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class DataInboxLayerId : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20250726091001_Remove DataInbox.LayerId.Designer.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20250726091001_Remove DataInbox.LayerId.Designer.cs similarity index 99% rename from src/Backend/DiunaBI.Core/Database/Migrations/20250726091001_Remove DataInbox.LayerId.Designer.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20250726091001_Remove DataInbox.LayerId.Designer.cs index bc53e1c..49bc520 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20250726091001_Remove DataInbox.LayerId.Designer.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20250726091001_Remove DataInbox.LayerId.Designer.cs @@ -1,11 +1,12 @@ // using System; -using DiunaBI.Core.Database.Context; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; #nullable disable @@ -16,7 +17,7 @@ namespace DiunaBI.Core.Migrations partial class RemoveDataInboxLayerId { /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) + protected void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/20250726091001_Remove DataInbox.LayerId.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/20250726091001_Remove DataInbox.LayerId.cs similarity index 96% rename from src/Backend/DiunaBI.Core/Database/Migrations/20250726091001_Remove DataInbox.LayerId.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/20250726091001_Remove DataInbox.LayerId.cs index c50a662..5c4ce3a 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/20250726091001_Remove DataInbox.LayerId.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/20250726091001_Remove DataInbox.LayerId.cs @@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { /// public partial class RemoveDataInboxLayerId : Migration diff --git a/src/Backend/DiunaBI.Core/Database/Migrations/AppDbContextModelSnapshot.cs b/src/Backend/DiunaBI.Infrastructure/Migrations/AppDbContextModelSnapshot.cs similarity index 99% rename from src/Backend/DiunaBI.Core/Database/Migrations/AppDbContextModelSnapshot.cs rename to src/Backend/DiunaBI.Infrastructure/Migrations/AppDbContextModelSnapshot.cs index 1a764c7..4410fb3 100644 --- a/src/Backend/DiunaBI.Core/Database/Migrations/AppDbContextModelSnapshot.cs +++ b/src/Backend/DiunaBI.Infrastructure/Migrations/AppDbContextModelSnapshot.cs @@ -1,6 +1,6 @@ // using System; -using DiunaBI.Core.Database.Context; +using DiunaBI.Infrastructure.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; #nullable disable -namespace DiunaBI.Core.Migrations +namespace DiunaBI.Infrastructure.Migrations { [DbContext(typeof(AppDbContext))] partial class AppDbContextModelSnapshot : ModelSnapshot diff --git a/src/Backend/DiunaBI.Core/Services/Calculations/BaseCalc.cs b/src/Backend/DiunaBI.Infrastructure/Services/Calculations/BaseCalc.cs similarity index 97% rename from src/Backend/DiunaBI.Core/Services/Calculations/BaseCalc.cs rename to src/Backend/DiunaBI.Infrastructure/Services/Calculations/BaseCalc.cs index 0e2b494..e05e383 100644 --- a/src/Backend/DiunaBI.Core/Services/Calculations/BaseCalc.cs +++ b/src/Backend/DiunaBI.Infrastructure/Services/Calculations/BaseCalc.cs @@ -1,11 +1,8 @@ -using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; using AngouriMath; -using DiunaBI.Core.Models; +using DiunaBI.Domain.Entities; -namespace DiunaBI.Core.Services.Calculations; +namespace DiunaBI.Infrastructure.Services.Calculations; public class BaseCalc { diff --git a/src/Backend/DiunaBI.Core/Services/GoogleDriveHelper.cs b/src/Backend/DiunaBI.Infrastructure/Services/GoogleDriveHelper.cs similarity index 92% rename from src/Backend/DiunaBI.Core/Services/GoogleDriveHelper.cs rename to src/Backend/DiunaBI.Infrastructure/Services/GoogleDriveHelper.cs index 386bda1..e027c15 100644 --- a/src/Backend/DiunaBI.Core/Services/GoogleDriveHelper.cs +++ b/src/Backend/DiunaBI.Infrastructure/Services/GoogleDriveHelper.cs @@ -1,37 +1,36 @@ -using Google.Apis.Auth.OAuth2; -using Google.Apis.Drive.v3; -using Google.Apis.Services; -using System.IO; - -namespace DiunaBI.Core.Services; +using Google.Apis.Auth.OAuth2; +using Google.Apis.Drive.v3; +using Google.Apis.Services; -public class GoogleDriveHelper -{ - public DriveService? Service { get; private set; } - private const string ApplicationName = "Diuna"; - private static readonly string[] Scopes = [DriveService.Scope.Drive]; - public GoogleDriveHelper() - { - InitializeService(); - } - private void InitializeService() - { - var credential = GetCredentialsFromFile(); - Service = new DriveService(new BaseClientService.Initializer - { - HttpClientInitializer = credential, - ApplicationName = ApplicationName - }); - } - private static GoogleCredential GetCredentialsFromFile() - { - // ReSharper disable once RedundantAssignment - var fileName = "client_secrets.json"; -#if DEBUG - fileName = "client_secrets.Development.json"; -#endif - using var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read); - var credential = GoogleCredential.FromStream(stream).CreateScoped(Scopes); - return credential; - } +namespace DiunaBI.Infrastructure.Services; + +public class GoogleDriveHelper +{ + public DriveService? Service { get; private set; } + private const string ApplicationName = "Diuna"; + private static readonly string[] Scopes = [DriveService.Scope.Drive]; + public GoogleDriveHelper() + { + InitializeService(); + } + private void InitializeService() + { + var credential = GetCredentialsFromFile(); + Service = new DriveService(new BaseClientService.Initializer + { + HttpClientInitializer = credential, + ApplicationName = ApplicationName + }); + } + private static GoogleCredential GetCredentialsFromFile() + { + // ReSharper disable once RedundantAssignment + var fileName = "client_secrets.json"; +#if DEBUG + fileName = "client_secrets.Development.json"; +#endif + using var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read); + var credential = GoogleCredential.FromStream(stream).CreateScoped(Scopes); + return credential; + } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.Core/Services/GoogleSheetsHelper.cs b/src/Backend/DiunaBI.Infrastructure/Services/GoogleSheetsHelper.cs similarity index 92% rename from src/Backend/DiunaBI.Core/Services/GoogleSheetsHelper.cs rename to src/Backend/DiunaBI.Infrastructure/Services/GoogleSheetsHelper.cs index f7b4a2d..e6bc21c 100644 --- a/src/Backend/DiunaBI.Core/Services/GoogleSheetsHelper.cs +++ b/src/Backend/DiunaBI.Infrastructure/Services/GoogleSheetsHelper.cs @@ -1,36 +1,35 @@ -using Google.Apis.Auth.OAuth2; -using Google.Apis.Services; -using Google.Apis.Sheets.v4; -using System.IO; +using Google.Apis.Auth.OAuth2; +using Google.Apis.Services; +using Google.Apis.Sheets.v4; -namespace DiunaBI.Core.Services; +namespace DiunaBI.Infrastructure.Services; -public class GoogleSheetsHelper -{ - public SheetsService? Service { get; private set; } - private const string ApplicationName = "Diuna"; - private static readonly string[] Scopes = [SheetsService.Scope.Spreadsheets]; - public GoogleSheetsHelper() - { - InitializeService(); - } - private void InitializeService() - { - var credential = GetCredentialsFromFile(); - Service = new SheetsService(new BaseClientService.Initializer - { - HttpClientInitializer = credential, - ApplicationName = ApplicationName - }); - } - private static GoogleCredential GetCredentialsFromFile() - { - var fileName = "client_secrets.json"; -#if DEBUG - fileName = "client_secrets.Development.json"; -#endif - using var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read); - var credential = GoogleCredential.FromStream(stream).CreateScoped(Scopes); - return credential; - } +public class GoogleSheetsHelper +{ + public SheetsService? Service { get; private set; } + private const string ApplicationName = "Diuna"; + private static readonly string[] Scopes = [SheetsService.Scope.Spreadsheets]; + public GoogleSheetsHelper() + { + InitializeService(); + } + private void InitializeService() + { + var credential = GetCredentialsFromFile(); + Service = new SheetsService(new BaseClientService.Initializer + { + HttpClientInitializer = credential, + ApplicationName = ApplicationName + }); + } + private static GoogleCredential GetCredentialsFromFile() + { + var fileName = "client_secrets.json"; +#if DEBUG + fileName = "client_secrets.Development.json"; +#endif + using var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read); + var credential = GoogleCredential.FromStream(stream).CreateScoped(Scopes); + return credential; + } } \ No newline at end of file diff --git a/src/Backend/DiunaBI.Core/Services/PluginManager.cs b/src/Backend/DiunaBI.Infrastructure/Services/PluginManager.cs similarity index 96% rename from src/Backend/DiunaBI.Core/Services/PluginManager.cs rename to src/Backend/DiunaBI.Infrastructure/Services/PluginManager.cs index 8934dc3..710c234 100644 --- a/src/Backend/DiunaBI.Core/Services/PluginManager.cs +++ b/src/Backend/DiunaBI.Infrastructure/Services/PluginManager.cs @@ -1,13 +1,9 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; using System.Reflection; -using DiunaBI.Core.Interfaces; +using DiunaBI.Infrastructure.Interfaces; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace DiunaBI.Core.Services; +namespace DiunaBI.Infrastructure.Services; public class PluginManager { diff --git a/src/Backend/DiunaBI.Core/Services/ProcessHelper.cs b/src/Backend/DiunaBI.Infrastructure/Services/ProcessHelper.cs similarity index 97% rename from src/Backend/DiunaBI.Core/Services/ProcessHelper.cs rename to src/Backend/DiunaBI.Infrastructure/Services/ProcessHelper.cs index dcb3c8d..0620e86 100644 --- a/src/Backend/DiunaBI.Core/Services/ProcessHelper.cs +++ b/src/Backend/DiunaBI.Infrastructure/Services/ProcessHelper.cs @@ -1,9 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using DiunaBI.Core.Models; +using System.Text.RegularExpressions; +using DiunaBI.Domain.Entities; -namespace DiunaBI.Core.Services; +namespace DiunaBI.Infrastructure.Services; public static class ProcessHelper { diff --git a/src/Backend/DiunaBI.Plugins.Morska/DiunaBI.Plugins.Morska.csproj b/src/Backend/DiunaBI.Plugins.Morska/DiunaBI.Plugins.Morska.csproj index a3345a5..a610c9b 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/DiunaBI.Plugins.Morska.csproj +++ b/src/Backend/DiunaBI.Plugins.Morska/DiunaBI.Plugins.Morska.csproj @@ -11,6 +11,7 @@ - + + \ No newline at end of file diff --git a/src/Backend/DiunaBI.Plugins.Morska/Exporters/MorskaBaseExporter.cs b/src/Backend/DiunaBI.Plugins.Morska/Exporters/MorskaBaseExporter.cs index 841be69..de10e91 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Exporters/MorskaBaseExporter.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Exporters/MorskaBaseExporter.cs @@ -1,5 +1,5 @@ -using DiunaBI.Core.Interfaces; -using DiunaBI.Core.Models; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Interfaces; namespace DiunaBI.Plugins.Morska.Exporters; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Exporters/googleSheet.export.cs b/src/Backend/DiunaBI.Plugins.Morska/Exporters/googleSheet.export.cs index ceaf99d..61b5a88 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Exporters/googleSheet.export.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Exporters/googleSheet.export.cs @@ -1,11 +1,11 @@ using System.Globalization; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Services; using Google.Apis.Sheets.v4; using Google.Apis.Sheets.v4.Data; -using DiunaBI.Core.Models; using Microsoft.Extensions.Configuration; -using DiunaBI.Plugins.Morska.Exporters; -namespace DiunaBI.Core.Services.Exports; +namespace DiunaBI.Plugins.Morska.Exporters; public class GoogleSheetExport : MorskaBaseExporter { diff --git a/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaBaseImporter.cs b/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaBaseImporter.cs index c70f0d8..8189177 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaBaseImporter.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaBaseImporter.cs @@ -1,5 +1,5 @@ -using DiunaBI.Core.Interfaces; -using DiunaBI.Core.Models; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Interfaces; namespace DiunaBI.Plugins.Morska.Importers; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaD1Importer.cs b/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaD1Importer.cs index 021e7c5..36ec0e6 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaD1Importer.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaD1Importer.cs @@ -1,9 +1,10 @@ using System.Globalization; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; using Google.Apis.Sheets.v4; using Microsoft.Extensions.Logging; using Microsoft.EntityFrameworkCore; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; + namespace DiunaBI.Plugins.Morska.Importers; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaD3Importer.cs b/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaD3Importer.cs index d2942e9..38a90ea 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaD3Importer.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaD3Importer.cs @@ -1,11 +1,11 @@ using System.Globalization; using System.Text; using System.Text.Json; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Infrastructure.Services; using Microsoft.Extensions.Logging; using Microsoft.EntityFrameworkCore; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; -using DiunaBI.Core.Services; using Google.Apis.Sheets.v4; using Google.Apis.Sheets.v4.Data; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaFK2Importer.cs b/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaFK2Importer.cs index e4ccda7..0a5c5ab 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaFK2Importer.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaFK2Importer.cs @@ -1,9 +1,9 @@ using System.Globalization; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; using Google.Apis.Sheets.v4; using Microsoft.Extensions.Logging; using Microsoft.EntityFrameworkCore; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; namespace DiunaBI.Plugins.Morska.Importers; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaStandardImporter.cs b/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaStandardImporter.cs index 49a9b5e..5d3c767 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaStandardImporter.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Importers/MorskaStandardImporter.cs @@ -1,9 +1,10 @@ using System.Globalization; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; using Google.Apis.Sheets.v4; using Microsoft.Extensions.Logging; using Microsoft.EntityFrameworkCore; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; + namespace DiunaBI.Plugins.Morska.Importers; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaBaseProcessor.cs b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaBaseProcessor.cs index 677ec5a..7e01f2c 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaBaseProcessor.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaBaseProcessor.cs @@ -1,6 +1,5 @@ -using DiunaBI.Core.Interfaces; -using DiunaBI.Core.Models; -using Microsoft.Extensions.Logging; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Interfaces; namespace DiunaBI.Plugins.Morska.Processors; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaD6Processor.cs b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaD6Processor.cs index 247c126..56e4921 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaD6Processor.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaD6Processor.cs @@ -1,12 +1,11 @@ using System.Globalization; using System.Text.RegularExpressions; -using DiunaBI.Core.Services; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Infrastructure.Services.Calculations; using Google.Apis.Sheets.v4; using Google.Apis.Sheets.v4.Data; using Microsoft.EntityFrameworkCore; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; -using DiunaBI.Core.Services.Calculations; using Microsoft.Extensions.Logging; namespace DiunaBI.Plugins.Morska.Processors; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT1R1Processor.cs b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT1R1Processor.cs index 2d31aac..4bb625f 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT1R1Processor.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT1R1Processor.cs @@ -1,11 +1,11 @@ using System.Globalization; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Infrastructure.Services; +using DiunaBI.Infrastructure.Services.Calculations; using Google.Apis.Sheets.v4; using Google.Apis.Sheets.v4.Data; using Microsoft.EntityFrameworkCore; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; -using DiunaBI.Core.Services; -using DiunaBI.Core.Services.Calculations; using Microsoft.Extensions.Logging; namespace DiunaBI.Plugins.Morska.Processors; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT1R3Processor.cs b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT1R3Processor.cs index f25f468..de21c61 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT1R3Processor.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT1R3Processor.cs @@ -1,11 +1,11 @@ using System.Globalization; using System.Text.RegularExpressions; -using DiunaBI.Core.Services; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Infrastructure.Services; using Google.Apis.Sheets.v4; using Google.Apis.Sheets.v4.Data; using Microsoft.EntityFrameworkCore; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; using Microsoft.Extensions.Logging; namespace DiunaBI.Plugins.Morska.Processors; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceCopySelectedCodesProcessor-TO_REMOVE.cs b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceCopySelectedCodesProcessor-TO_REMOVE.cs index cccb5da..2b65d00 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceCopySelectedCodesProcessor-TO_REMOVE.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceCopySelectedCodesProcessor-TO_REMOVE.cs @@ -1,7 +1,7 @@ -using DiunaBI.Core.Services; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Infrastructure.Services; using Microsoft.EntityFrameworkCore; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; using Microsoft.Extensions.Logging; namespace DiunaBI.Plugins.Morska.Processors; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceCopySelectedCodesYearSummaryProcessor-TO_REMOVE.cs b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceCopySelectedCodesYearSummaryProcessor-TO_REMOVE.cs index b309ab2..8523f4f 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceCopySelectedCodesYearSummaryProcessor-TO_REMOVE.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceCopySelectedCodesYearSummaryProcessor-TO_REMOVE.cs @@ -1,7 +1,7 @@ -using DiunaBI.Core.Services; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Infrastructure.Services; using Microsoft.EntityFrameworkCore; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; using Microsoft.Extensions.Logging; namespace DiunaBI.Plugins.Morska.Processors; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceSummaryProcessor.cs b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceSummaryProcessor.cs index d70486a..4988407 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceSummaryProcessor.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceSummaryProcessor.cs @@ -1,9 +1,9 @@ -using DiunaBI.Core.Services; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Infrastructure.Services; +using DiunaBI.Infrastructure.Services.Calculations; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; -using DiunaBI.Core.Services.Calculations; namespace DiunaBI.Plugins.Morska.Processors; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceYearSummaryProcessor.cs b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceYearSummaryProcessor.cs index 06bd7ba..42805aa 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceYearSummaryProcessor.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3MultiSourceYearSummaryProcessor.cs @@ -1,9 +1,9 @@ -using Microsoft.EntityFrameworkCore; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Infrastructure.Services; +using DiunaBI.Infrastructure.Services.Calculations; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; -using DiunaBI.Core.Services; -using DiunaBI.Core.Services.Calculations; namespace DiunaBI.Plugins.Morska.Processors; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3SingleSourceProcessor.cs b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3SingleSourceProcessor.cs index 15e7602..4ddc5d5 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3SingleSourceProcessor.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3SingleSourceProcessor.cs @@ -1,7 +1,7 @@ -using Microsoft.EntityFrameworkCore; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; -using DiunaBI.Core.Services; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Infrastructure.Services; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Google.Apis.Sheets.v4; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3SourceYearSummaryProcessor.cs b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3SourceYearSummaryProcessor.cs index 2280cc7..df2ee73 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3SourceYearSummaryProcessor.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT3SourceYearSummaryProcessor.cs @@ -1,9 +1,9 @@ -using Microsoft.EntityFrameworkCore; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Infrastructure.Services; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Google.Apis.Sheets.v4; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; -using DiunaBI.Core.Services; namespace DiunaBI.Plugins.Morska.Processors; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT4R2Processor.cs b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT4R2Processor.cs index d16d107..c0bf4ee 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT4R2Processor.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT4R2Processor.cs @@ -1,11 +1,11 @@ using System.Globalization; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Infrastructure.Services; using Google.Apis.Sheets.v4; using Google.Apis.Sheets.v4.Data; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; -using DiunaBI.Core.Services; namespace DiunaBI.Plugins.Morska.Processors; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT4SingleSourceProcessor.cs b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT4SingleSourceProcessor.cs index c4bd66e..320eed0 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT4SingleSourceProcessor.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT4SingleSourceProcessor.cs @@ -1,8 +1,8 @@ -using Microsoft.EntityFrameworkCore; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Google.Apis.Sheets.v4; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; namespace DiunaBI.Plugins.Morska.Processors; diff --git a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT5LastValuesProcessor.cs b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT5LastValuesProcessor.cs index d4d98a4..2d0d999 100644 --- a/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT5LastValuesProcessor.cs +++ b/src/Backend/DiunaBI.Plugins.Morska/Processors/MorskaT5LastValuesProcessor.cs @@ -1,7 +1,7 @@ -using DiunaBI.Core.Services; +using DiunaBI.Domain.Entities; +using DiunaBI.Infrastructure.Data; +using DiunaBI.Infrastructure.Services; using Microsoft.EntityFrameworkCore; -using DiunaBI.Core.Models; -using DiunaBI.Core.Database.Context; using Microsoft.Extensions.Logging; namespace DiunaBI.Plugins.Morska.Processors; diff --git a/src/Backend/DiunaBI.Tests/DiunaBI.Tests.csproj b/src/Backend/DiunaBI.Tests/DiunaBI.Tests.csproj index 8c99a7d..f31e06e 100644 --- a/src/Backend/DiunaBI.Tests/DiunaBI.Tests.csproj +++ b/src/Backend/DiunaBI.Tests/DiunaBI.Tests.csproj @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/src/Backend/DiunaBI.sln b/src/Backend/DiunaBI.sln index f97b921..fe2ec1d 100644 --- a/src/Backend/DiunaBI.sln +++ b/src/Backend/DiunaBI.sln @@ -3,14 +3,18 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiunaBI.WebAPI", "DiunaBI.WebAPI\DiunaBI.WebAPI.csproj", "{D468D3FD-2B0F-4E1E-9BFC-AE32DD3BB4C6}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiunaBI.Core", "DiunaBI.Core\DiunaBI.Core.csproj", "{0282E3CC-3BE1-4610-B65F-BC266A2FCA6E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiunaBI.API", "DiunaBI.API\DiunaBI.API.csproj", "{D468D3FD-2B0F-4E1E-9BFC-AE32DD3BB4C6}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiunaBI.Plugins.Morska", "DiunaBI.Plugins.Morska\DiunaBI.Plugins.Morska.csproj", "{B5416A3F-550A-468D-852F-20B24243FD68}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiunaBI.Tests", "DiunaBI.Tests\DiunaBI.Tests.csproj", "{7D99AF7E-1FC7-4EC0-A320-F1A81D396F93}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiunaBI.Domain", "DiunaBI.Domain\DiunaBI.Domain.csproj", "{8C701560-EF39-4203-8EB9-16AB32CA2CAB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiunaBI.Application", "DiunaBI.Application\DiunaBI.Application.csproj", "{5F8C40E9-F51E-48A5-840F-4309C873C6C6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiunaBI.Infrastructure", "DiunaBI.Infrastructure\DiunaBI.Infrastructure.csproj", "{0B2E03F3-A1F7-4C7F-BCA7-386979C93346}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -24,10 +28,6 @@ Global {D468D3FD-2B0F-4E1E-9BFC-AE32DD3BB4C6}.Debug|Any CPU.Build.0 = Debug|Any CPU {D468D3FD-2B0F-4E1E-9BFC-AE32DD3BB4C6}.Release|Any CPU.ActiveCfg = Release|Any CPU {D468D3FD-2B0F-4E1E-9BFC-AE32DD3BB4C6}.Release|Any CPU.Build.0 = Release|Any CPU - {0282E3CC-3BE1-4610-B65F-BC266A2FCA6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0282E3CC-3BE1-4610-B65F-BC266A2FCA6E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0282E3CC-3BE1-4610-B65F-BC266A2FCA6E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0282E3CC-3BE1-4610-B65F-BC266A2FCA6E}.Release|Any CPU.Build.0 = Release|Any CPU {B5416A3F-550A-468D-852F-20B24243FD68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B5416A3F-550A-468D-852F-20B24243FD68}.Debug|Any CPU.Build.0 = Debug|Any CPU {B5416A3F-550A-468D-852F-20B24243FD68}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -40,5 +40,17 @@ Global {7D99AF7E-1FC7-4EC0-A320-F1A81D396F93}.Debug|Any CPU.Build.0 = Debug|Any CPU {7D99AF7E-1FC7-4EC0-A320-F1A81D396F93}.Release|Any CPU.ActiveCfg = Release|Any CPU {7D99AF7E-1FC7-4EC0-A320-F1A81D396F93}.Release|Any CPU.Build.0 = Release|Any CPU + {8C701560-EF39-4203-8EB9-16AB32CA2CAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8C701560-EF39-4203-8EB9-16AB32CA2CAB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8C701560-EF39-4203-8EB9-16AB32CA2CAB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C701560-EF39-4203-8EB9-16AB32CA2CAB}.Release|Any CPU.Build.0 = Release|Any CPU + {5F8C40E9-F51E-48A5-840F-4309C873C6C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5F8C40E9-F51E-48A5-840F-4309C873C6C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F8C40E9-F51E-48A5-840F-4309C873C6C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5F8C40E9-F51E-48A5-840F-4309C873C6C6}.Release|Any CPU.Build.0 = Release|Any CPU + {0B2E03F3-A1F7-4C7F-BCA7-386979C93346}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0B2E03F3-A1F7-4C7F-BCA7-386979C93346}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0B2E03F3-A1F7-4C7F-BCA7-386979C93346}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0B2E03F3-A1F7-4C7F-BCA7-386979C93346}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal