diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c5fcada --- /dev/null +++ b/.gitignore @@ -0,0 +1,55 @@ +# These are some examples of commonly ignored file patterns. +# You should customize this list as applicable to your project. +# Learn more about .gitignore: +# https://www.atlassian.com/git/tutorials/saving-changes/gitignore + +# Node artifact files +node_modules/ +dist/ + +# Compiled Java class files +*.class + +# Compiled Python bytecode +*.py[cod] + +# Log files +*.log + +# Package files +*.jar + +# Maven +target/ +dist/ + +# JetBrains IDE +.idea/ + +# Unit test reports +TEST*.xml + +# Generated by MacOS +.DS_Store + +# Generated by Windows +Thumbs.db + +# Applications +*.app +*.exe +*.war + +# Large media files +*.mp4 +*.tiff +*.avi +*.flv +*.mov +*.wmv + +.vs +*/bin +*/obj +Drab/.config +Drab/drab.db diff --git a/Drab.Core/Configuration/DrabSettings.cs b/Drab.Core/Configuration/DrabSettings.cs new file mode 100644 index 0000000..5fdd3e0 --- /dev/null +++ b/Drab.Core/Configuration/DrabSettings.cs @@ -0,0 +1,9 @@ +namespace Drab.Core.Configuration; + +public class DrabSettings : IDrabSettings +{ + public const string SectionName = "DrabSettings"; + public int DbPollingFrequencyInSeconds { get; set; } + public int PrinterTimeoutSeconds { get; set; } + public string IgnoreOrdersBefore { get; set; } +} \ No newline at end of file diff --git a/Drab.Core/Configuration/IDrabSettings.cs b/Drab.Core/Configuration/IDrabSettings.cs new file mode 100644 index 0000000..8a42878 --- /dev/null +++ b/Drab.Core/Configuration/IDrabSettings.cs @@ -0,0 +1,8 @@ +namespace Drab.Core.Configuration; + +public interface IDrabSettings +{ + int DbPollingFrequencyInSeconds { get; } + int PrinterTimeoutSeconds { get; } + public string IgnoreOrdersBefore { get; set; } +} \ No newline at end of file diff --git a/Drab.Core/Configuration/LocalDbConfiguration.cs b/Drab.Core/Configuration/LocalDbConfiguration.cs new file mode 100644 index 0000000..cfa3026 --- /dev/null +++ b/Drab.Core/Configuration/LocalDbConfiguration.cs @@ -0,0 +1,9 @@ +using Drab.LocalDb.IoC; + +namespace Drab.Core.Configuration; + +public class LocalDbConfiguration : ILocalDbConfiguration +{ + public const string SectionName = "LocalDbConnection"; + public string ConnectionString { get; set; } +} \ No newline at end of file diff --git a/Drab.Core/Configuration/PcmDbConfiguration.cs b/Drab.Core/Configuration/PcmDbConfiguration.cs new file mode 100644 index 0000000..966b943 --- /dev/null +++ b/Drab.Core/Configuration/PcmDbConfiguration.cs @@ -0,0 +1,13 @@ +using Pcm.Db.Ioc; + +namespace Drab.Core.Configuration; + +public class PcmDbConfiguration : IDbConfiguration +{ + public const string SectionName = "PcmDbSettings"; + public string Host { get; set; } + public string Port { get; set; } + public string User { get; set; } + public string Password { get; set; } + public string Database { get; set; } +} \ No newline at end of file diff --git a/Drab.Core/Drab.Core.csproj b/Drab.Core/Drab.Core.csproj new file mode 100644 index 0000000..8c03505 --- /dev/null +++ b/Drab.Core/Drab.Core.csproj @@ -0,0 +1,17 @@ + + + + net9.0-windows + false + + + + + + + + + + + + diff --git a/Drab.Core/Ioc/IocCoreRegister.cs b/Drab.Core/Ioc/IocCoreRegister.cs new file mode 100644 index 0000000..7b73f85 --- /dev/null +++ b/Drab.Core/Ioc/IocCoreRegister.cs @@ -0,0 +1,13 @@ +using Drab.Core.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace Drab.Core.Ioc; + +public static class IocCoreRegister +{ + public static IServiceCollection AddDrabCore(this IServiceCollection services, IDrabSettings settings) + { + services.AddSingleton(settings); + return services; + } +} \ No newline at end of file diff --git a/Drab.Core/Models/Result.cs b/Drab.Core/Models/Result.cs new file mode 100644 index 0000000..4231941 --- /dev/null +++ b/Drab.Core/Models/Result.cs @@ -0,0 +1,82 @@ +using System; + +namespace Drab.Core.Models; + +public class Result +{ + private TBad _error; + private TOk _ok; + public bool IsOk { get; } + public bool IsNotOk => !IsOk; + + public Result(bool isOk, TOk ok, TBad bad) + { + IsOk = isOk; + + if (IsOk) + { + if (ok == null) + throw new ArgumentNullException(nameof(ok), "If IsOk flag is set to true parameter 'ok' needs to be non null"); + + Value = ok; + } + else + { + if (bad == null) + throw new ArgumentNullException(nameof(bad), "If IsOk flag is set to false parameter 'bad' needs to be non null"); + + Error = bad; + } + } + + public TBad Error + { + get + { + if (IsOk) + throw new InvalidOperationException("Result has IsOk flag set to true only Value property is available"); + return _error; + } + private set => _error = value; + } + + public TOk Value + { + get + { + if (!IsOk) + throw new InvalidOperationException("Result has IsOk flag set to false only Error property is available"); + return _ok; + } + private set => _ok = value; + } + + public Result Map(Func map) where TNew : class + { + if (IsOk) + return new Result(IsOk, map(Value), default); + else + return new Result(false, default, Error); + } + + public TOk ValueWithDefault(Func defaultCreator) => IsOk ? Value : defaultCreator(Error); + + public void Do(Action action) + { + if (IsOk) + action(Value); + } +} + +public class Result +{ + public static Result Failed(TK wrong) + { + return new Result(false, default(T), wrong); + } + + public static Result Ok(T ok) + { + return new Result(true, ok, default(TK)); + } +} \ No newline at end of file diff --git a/Drab.LocalDb/Drab.LocalDb.csproj b/Drab.LocalDb/Drab.LocalDb.csproj new file mode 100644 index 0000000..b2b8cb4 --- /dev/null +++ b/Drab.LocalDb/Drab.LocalDb.csproj @@ -0,0 +1,19 @@ + + + + net9.0-windows + false + + + + + + + + + + + + + + diff --git a/Drab.LocalDb/Entities/OrderDb.cs b/Drab.LocalDb/Entities/OrderDb.cs new file mode 100644 index 0000000..6dc9376 --- /dev/null +++ b/Drab.LocalDb/Entities/OrderDb.cs @@ -0,0 +1,16 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace Drab.LocalDb.Entities; + +public class OrderDb +{ + [Key] + public long OrderId { get; set; } + public long DokId { get; set; } + public DateTime Created { get; set; } + public bool IsPrinted { get; set; } + public string Filename { get; set; } + public string Shop { get; set; } + public string OrderNumber { get; set; } +} \ No newline at end of file diff --git a/Drab.LocalDb/IoC/ILocalDbConfiguration.cs b/Drab.LocalDb/IoC/ILocalDbConfiguration.cs new file mode 100644 index 0000000..91f6b50 --- /dev/null +++ b/Drab.LocalDb/IoC/ILocalDbConfiguration.cs @@ -0,0 +1,6 @@ +namespace Drab.LocalDb.IoC; + +public interface ILocalDbConfiguration +{ + public string ConnectionString { get; set; } +} \ No newline at end of file diff --git a/Drab.LocalDb/IoC/IocLocalDbRegister.cs b/Drab.LocalDb/IoC/IocLocalDbRegister.cs new file mode 100644 index 0000000..b14e1ad --- /dev/null +++ b/Drab.LocalDb/IoC/IocLocalDbRegister.cs @@ -0,0 +1,13 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; + +namespace Drab.LocalDb.IoC; + +public static class IocLocalDbRegister +{ + public static IServiceCollection AddLocalDatabase(this IServiceCollection services, ILocalDbConfiguration localDbConfiguration) + { + services.AddDbContext(cx => cx.UseSqlite(localDbConfiguration.ConnectionString)); + return services; + } +} \ No newline at end of file diff --git a/Drab.LocalDb/LocalDbContext.cs b/Drab.LocalDb/LocalDbContext.cs new file mode 100644 index 0000000..cab5712 --- /dev/null +++ b/Drab.LocalDb/LocalDbContext.cs @@ -0,0 +1,18 @@ +using Drab.LocalDb.Entities; +using Microsoft.EntityFrameworkCore; + +namespace Drab.LocalDb; + +public class LocalDbContext : DbContext +{ + public LocalDbContext() + { + } + + public LocalDbContext(DbContextOptions options) + : base(options) + { + } + + public DbSet Orders { get; set; } +} \ No newline at end of file diff --git a/Drab.LocalDb/Migrations/20211101180516_Initial.Designer.cs b/Drab.LocalDb/Migrations/20211101180516_Initial.Designer.cs new file mode 100644 index 0000000..2d54a1d --- /dev/null +++ b/Drab.LocalDb/Migrations/20211101180516_Initial.Designer.cs @@ -0,0 +1,52 @@ +// +using System; +using Drab.LocalDb; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace Drab.LocalDb.Migrations +{ + [DbContext(typeof(LocalDbContext))] + [Migration("20211101180516_Initial")] + partial class Initial + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "5.0.11"); + + modelBuilder.Entity("Drab.LocalDb.Entities.OrderDb", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("DokId") + .HasColumnType("INTEGER"); + + b.Property("Filename") + .HasColumnType("TEXT"); + + b.Property("IsPrinted") + .HasColumnType("INTEGER"); + + b.Property("OrderNumber") + .HasColumnType("TEXT"); + + b.Property("Shop") + .HasColumnType("TEXT"); + + b.HasKey("OrderId"); + + b.ToTable("Orders"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Drab.LocalDb/Migrations/20211101180516_Initial.cs b/Drab.LocalDb/Migrations/20211101180516_Initial.cs new file mode 100644 index 0000000..736a739 --- /dev/null +++ b/Drab.LocalDb/Migrations/20211101180516_Initial.cs @@ -0,0 +1,35 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Drab.LocalDb.Migrations +{ + public partial class Initial : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Orders", + columns: table => new + { + OrderId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + DokId = table.Column(type: "INTEGER", nullable: false), + Created = table.Column(type: "TEXT", nullable: false), + IsPrinted = table.Column(type: "INTEGER", nullable: false), + Filename = table.Column(type: "TEXT", nullable: true), + Shop = table.Column(type: "TEXT", nullable: true), + OrderNumber = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Orders", x => x.OrderId); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Orders"); + } + } +} diff --git a/Drab.LocalDb/Migrations/LocalDbContextModelSnapshot.cs b/Drab.LocalDb/Migrations/LocalDbContextModelSnapshot.cs new file mode 100644 index 0000000..ca5fb17 --- /dev/null +++ b/Drab.LocalDb/Migrations/LocalDbContextModelSnapshot.cs @@ -0,0 +1,50 @@ +// +using System; +using Drab.LocalDb; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace Drab.LocalDb.Migrations +{ + [DbContext(typeof(LocalDbContext))] + partial class LocalDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "5.0.11"); + + modelBuilder.Entity("Drab.LocalDb.Entities.OrderDb", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("DokId") + .HasColumnType("INTEGER"); + + b.Property("Filename") + .HasColumnType("TEXT"); + + b.Property("IsPrinted") + .HasColumnType("INTEGER"); + + b.Property("OrderNumber") + .HasColumnType("TEXT"); + + b.Property("Shop") + .HasColumnType("TEXT"); + + b.HasKey("OrderId"); + + b.ToTable("Orders"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Drab.Logic/Constants.cs b/Drab.Logic/Constants.cs new file mode 100644 index 0000000..181dcce --- /dev/null +++ b/Drab.Logic/Constants.cs @@ -0,0 +1,11 @@ +using Drab.Logic.Services; +using System.IO; +using System.Reflection; + +namespace Drab.Logic; + +internal static class Constants +{ + internal static readonly string ReportsTemplatesPath = Path.Combine(Path.GetDirectoryName(Assembly.GetAssembly(typeof(OrderPdfGenerator)).Location), "Templates"); + internal static readonly string ReportsOutputPath = Path.Combine(Path.GetDirectoryName(Assembly.GetAssembly(typeof(OrderPdfGenerator)).Location), "Orders"); +} \ No newline at end of file diff --git a/Drab.Logic/Drab.Logic.csproj b/Drab.Logic/Drab.Logic.csproj new file mode 100644 index 0000000..848c1b8 --- /dev/null +++ b/Drab.Logic/Drab.Logic.csproj @@ -0,0 +1,42 @@ + + + + net9.0-windows + false + + + + ./System.Printing.dll + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + diff --git a/Drab.Logic/Dtos/DokDto.cs b/Drab.Logic/Dtos/DokDto.cs new file mode 100644 index 0000000..a61b2a0 --- /dev/null +++ b/Drab.Logic/Dtos/DokDto.cs @@ -0,0 +1,32 @@ +using Pcm.Db.Entities; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Drab.Logic.Dtos; + +public class DokDto +{ + public long DokId { get; set; } + public string NrDok { get; set; } + public DateTime Data { get; set; } + public string Sklep { get; set; } + public IEnumerable PozDok { get; set; } + public string Opis { get; set; } +} + +internal static class DokExtensions +{ + internal static DokDto ToDokDto(this Dok dok) + { + return new DokDto + { + DokId = (long)dok.DokId, + Data = dok.Zmiana, + NrDok = dok.NrDok, + Sklep = dok.DokKontr.Kontr.Nazwa, + Opis = string.Join(' ', dok.TekstDoks.Select(x => x.Tekst)), + PozDok = dok.PozDoks.Select(x => x.ToPozDokDto()).ToList() + }; + } +} \ No newline at end of file diff --git a/Drab.Logic/Dtos/MagDto.cs b/Drab.Logic/Dtos/MagDto.cs new file mode 100644 index 0000000..9222b99 --- /dev/null +++ b/Drab.Logic/Dtos/MagDto.cs @@ -0,0 +1,23 @@ +using Pcm.Db.Entities; + +namespace Drab.Logic.Dtos; + +public class MagDto +{ + public long MagId { get; set; } + public string Nazwa { get; set; } + public short Numer { get; set; } +} + +internal static class MagazynExtensions +{ + internal static MagDto ToMagDto(this Magazyn magazyn) + { + return new MagDto + { + MagId = (long)magazyn.MagId, + Numer = magazyn.Numer ?? 0, + Nazwa = magazyn.Nazwa + }; + } +} \ No newline at end of file diff --git a/Drab.Logic/Dtos/PozDokDto.cs b/Drab.Logic/Dtos/PozDokDto.cs new file mode 100644 index 0000000..61d1730 --- /dev/null +++ b/Drab.Logic/Dtos/PozDokDto.cs @@ -0,0 +1,26 @@ +using System.Linq; +using Pcm.Db.Entities; + +namespace Drab.Logic.Dtos; + +public class PozDokDto +{ + public long DokId { get; set; } + public TowarDto Towar { get; set; } + public decimal Ilosc { get; set; } + public string Komentarz { get; set; } +} + +internal static class PozDokExtensions +{ + internal static PozDokDto ToPozDokDto(this PozDok pozDok) + { + return new PozDokDto + { + DokId = (long)pozDok.DokId, + Ilosc = pozDok.IloscPlus, + Towar = pozDok.Tow.ToTowarDto(), + Komentarz = string.Join("; ", pozDok.TekstPozs.Select(x => x.Tekst.Trim())) + }; + } +} \ No newline at end of file diff --git a/Drab.Logic/Dtos/TowarDto.cs b/Drab.Logic/Dtos/TowarDto.cs new file mode 100644 index 0000000..e0bea02 --- /dev/null +++ b/Drab.Logic/Dtos/TowarDto.cs @@ -0,0 +1,25 @@ +using Pcm.Db.Entities; + +namespace Drab.Logic.Dtos; + +public class TowarDto +{ + public long TowId { get; set; } + public string Nazwa { get; set; } + public string Kod { get; set; } + public string Jm { get; set; } +} + +internal static class TowarExtension +{ + internal static TowarDto ToTowarDto(this Towar towar) + { + return new TowarDto + { + TowId = (long)towar.TowId, + Nazwa = towar.Nazwa, + Kod = towar.Kod, + Jm = towar.Jm.Nazwa + }; + } +} \ No newline at end of file diff --git a/Drab.Logic/Interfaces/IDbFetcher.cs b/Drab.Logic/Interfaces/IDbFetcher.cs new file mode 100644 index 0000000..f817294 --- /dev/null +++ b/Drab.Logic/Interfaces/IDbFetcher.cs @@ -0,0 +1,8 @@ +using System.Threading.Tasks; + +namespace Drab.Logic.Interfaces; + +public interface IDbFetcher +{ + Task Start(); +} \ No newline at end of file diff --git a/Drab.Logic/Interfaces/ILocalOrderStore.cs b/Drab.Logic/Interfaces/ILocalOrderStore.cs new file mode 100644 index 0000000..96f35dd --- /dev/null +++ b/Drab.Logic/Interfaces/ILocalOrderStore.cs @@ -0,0 +1,12 @@ +using Drab.LocalDb.Entities; +using Drab.Logic.Dtos; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Drab.Logic.Interfaces; + +public interface ILocalOrderStore +{ + public Task> GetAll(); + public Task GetOrderById(long dokId); +} \ No newline at end of file diff --git a/Drab.Logic/Interfaces/IOrderPdfGenerator.cs b/Drab.Logic/Interfaces/IOrderPdfGenerator.cs new file mode 100644 index 0000000..8c5e53e --- /dev/null +++ b/Drab.Logic/Interfaces/IOrderPdfGenerator.cs @@ -0,0 +1,9 @@ +using Drab.Logic.Dtos; +using System.Threading.Tasks; + +namespace Drab.Logic.Interfaces; + +public interface IOrderPdfGenerator +{ + Task GenerateOrder(DokDto order); +} \ No newline at end of file diff --git a/Drab.Logic/Interfaces/IOrderProcessor.cs b/Drab.Logic/Interfaces/IOrderProcessor.cs new file mode 100644 index 0000000..7e948e2 --- /dev/null +++ b/Drab.Logic/Interfaces/IOrderProcessor.cs @@ -0,0 +1,9 @@ +using Drab.Logic.Dtos; +using System.Threading.Tasks; + +namespace Drab.Logic.Interfaces; + +public interface IOrderProcessor +{ + Task ProcessOrder(DokDto order); +} \ No newline at end of file diff --git a/Drab.Logic/Interfaces/IOrderStore.cs b/Drab.Logic/Interfaces/IOrderStore.cs new file mode 100644 index 0000000..92af7ae --- /dev/null +++ b/Drab.Logic/Interfaces/IOrderStore.cs @@ -0,0 +1,12 @@ +using Drab.Core.Models; +using Drab.Logic.Dtos; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Drab.Logic.Interfaces; + +public interface IOrdersStore : IDisposable +{ + Task, string>> FetchOrders(); +} \ No newline at end of file diff --git a/Drab.Logic/Interfaces/IPrintService.cs b/Drab.Logic/Interfaces/IPrintService.cs new file mode 100644 index 0000000..8c5b044 --- /dev/null +++ b/Drab.Logic/Interfaces/IPrintService.cs @@ -0,0 +1,9 @@ +using Drab.Logic.Models; +using System.Threading.Tasks; + +namespace Drab.Logic.Interfaces; + +public interface IPrintService +{ + Task PrintPdf(PrintDocumentRequest request); +} \ No newline at end of file diff --git a/Drab.Logic/Ioc/IocLogicRegister.cs b/Drab.Logic/Ioc/IocLogicRegister.cs new file mode 100644 index 0000000..7021f62 --- /dev/null +++ b/Drab.Logic/Ioc/IocLogicRegister.cs @@ -0,0 +1,21 @@ +using Drab.Logic.Interfaces; +using Drab.Logic.Services; +using Drab.Logic.Utils; +using Microsoft.Extensions.DependencyInjection; + +namespace Drab.Logic.Ioc; + +public static class IocLogicRegister +{ + public static IServiceCollection AddDrabLogic(this IServiceCollection services) + { + services.AddSingleton(); + services.AddSingleton(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddHostedService(); + services.AddTransient(); + return services; + } +} \ No newline at end of file diff --git a/Drab.Logic/Models/PrintDocument.cs b/Drab.Logic/Models/PrintDocument.cs new file mode 100644 index 0000000..0115232 --- /dev/null +++ b/Drab.Logic/Models/PrintDocument.cs @@ -0,0 +1,7 @@ +using System.Drawing; + +namespace Drab.Logic.Models; + +public record PrintDocumentRequest(string FilePath, long DokId); + +public record PrintDocumentResult(bool IsSuccess, string Message); \ No newline at end of file diff --git a/Drab.Logic/Services/LocalOrderStore.cs b/Drab.Logic/Services/LocalOrderStore.cs new file mode 100644 index 0000000..c25fd41 --- /dev/null +++ b/Drab.Logic/Services/LocalOrderStore.cs @@ -0,0 +1,47 @@ +using System; +using Drab.LocalDb; +using Drab.LocalDb.Entities; +using Drab.Logic.Dtos; +using Drab.Logic.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using NLog; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Drab.Logic.Services; + +public class LocalOrderStore : ILocalOrderStore +{ + + private readonly ILogger _logger; + private readonly IServiceScopeFactory _serviceScopeFactory; + + public LocalOrderStore(IServiceScopeFactory serviceScopeFactory) + { + _logger = LogManager.GetCurrentClassLogger(); + _serviceScopeFactory = serviceScopeFactory; + } + + public async Task> GetAll() + { + using var scope = _serviceScopeFactory.CreateScope(); + await using var dbContext = scope.ServiceProvider.GetService(); + var fromDate = DateTime.UtcNow.AddDays(-30); + + var orders = dbContext.Orders + .Where(x => x.Created >= fromDate) + .OrderByDescending(x => x.Created) + .ToList(); + return orders; + } + + public async Task GetOrderById(long dokId) + { + using var scope = _serviceScopeFactory.CreateScope(); + await using var dbContext = scope.ServiceProvider.GetService(); + var order = dbContext.Orders.FirstOrDefault(x => x.DokId == dokId); + + return new DokDto(); + } +} \ No newline at end of file diff --git a/Drab.Logic/Services/OldOrdersCleanupService.cs b/Drab.Logic/Services/OldOrdersCleanupService.cs new file mode 100644 index 0000000..3266a09 --- /dev/null +++ b/Drab.Logic/Services/OldOrdersCleanupService.cs @@ -0,0 +1,58 @@ +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Drab.LocalDb; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace Drab.Logic.Services; + +public class OldOrdersCleanupService : BackgroundService +{ + private readonly IServiceProvider _services; + private readonly ILogger _logger; + private readonly TimeSpan _interval = TimeSpan.FromHours(24); + + public OldOrdersCleanupService(IServiceProvider services, ILogger logger) + { + _services = services; + _logger = logger; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + while (!stoppingToken.IsCancellationRequested) + { + try + { + using var scope = _services.CreateScope(); + var dbContext = scope.ServiceProvider.GetRequiredService(); + + var threshold = DateTime.Now.AddDays(-45); + var oldOrders = dbContext.Orders + .Where(o => o.Created < threshold) + .ToList(); + + if (oldOrders.Count != 0) + { + dbContext.Orders.RemoveRange(oldOrders); + await dbContext.SaveChangesAsync(stoppingToken); + + _logger.LogInformation("Usunięto {OldOrdersCount} starych zamówień.", oldOrders.Count); + } + else + { + _logger.LogInformation("Nie znaleziono starych zamówień do usunięcia."); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Błąd podczas usuwania starych zamówień."); + } + + await Task.Delay(_interval, stoppingToken); + } + } +} \ No newline at end of file diff --git a/Drab.Logic/Services/OrderEventBus.cs b/Drab.Logic/Services/OrderEventBus.cs new file mode 100644 index 0000000..d9132f1 --- /dev/null +++ b/Drab.Logic/Services/OrderEventBus.cs @@ -0,0 +1,13 @@ +using System; + +namespace Drab.Logic.Services; + +public class OrderEventBus +{ + public event Action? OrdersChanged; + + public void NotifyOrdersChanged() + { + OrdersChanged?.Invoke(); + } +} \ No newline at end of file diff --git a/Drab.Logic/Services/OrderPdfGenerator.cs b/Drab.Logic/Services/OrderPdfGenerator.cs new file mode 100644 index 0000000..78903e4 --- /dev/null +++ b/Drab.Logic/Services/OrderPdfGenerator.cs @@ -0,0 +1,51 @@ +using Drab.Logic.Dtos; +using Drab.Logic.Interfaces; +using FastReport; +using FastReport.Export.PdfSimple; +using NLog; +using System; +using System.IO; +using System.Reflection; +using System.Threading.Tasks; + +namespace Drab.Logic.Services; + +internal class OrderPdfGenerator : IOrderPdfGenerator +{ + private readonly ILogger _logger; + + public OrderPdfGenerator() + { + _logger = LogManager.GetCurrentClassLogger(); + } + + public Task GenerateOrder(DokDto order) + { + _logger.Info($"Generate pdf document: {order.NrDok}"); + var cleanFilename = order.NrDok.Replace('/', '-'); + var orderFilename = $"Zam_{cleanFilename}_{order.Data:yyyy-MM-dd}_{order.Sklep}_{order.DokId}.pdf"; + var templatePath = Path.Combine(Constants.ReportsTemplatesPath, "Order.frx"); + var outputFile = Path.Combine(Constants.ReportsOutputPath, orderFilename); + var version = Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion; + var generatedAt = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}"; + + var data = new[] { order }; + try + { + var report = new Report(); + report.Load(templatePath); + report.SetParameterValue("generatedAt", generatedAt); + report.SetParameterValue("version", version); + report.RegisterData(data, "Order"); + report.Prepare(); + var pdfExport = new PDFSimpleExport(); + pdfExport.Export(report, outputFile); + return Task.FromResult(orderFilename); + } + catch (Exception e) + { + _logger.Error(e, "Error on generating order document: {OrderNo}", order.NrDok); + return Task.FromResult(string.Empty); + } + } +} \ No newline at end of file diff --git a/Drab.Logic/Services/OrderProcessor.cs b/Drab.Logic/Services/OrderProcessor.cs new file mode 100644 index 0000000..65959e1 --- /dev/null +++ b/Drab.Logic/Services/OrderProcessor.cs @@ -0,0 +1,154 @@ +using Drab.LocalDb; +using Drab.LocalDb.Entities; +using Drab.Logic.Dtos; +using Drab.Logic.Interfaces; +using Drab.Logic.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using NLog; +using System; +using System.IO; +using System.Threading.Tasks; + +namespace Drab.Logic.Services; + +public class OrderProcessor : IOrderProcessor +{ + private readonly ILogger _logger; + private readonly IServiceScopeFactory _serviceScopeFactory; + private readonly IPrintService _printService; + private readonly IOrderPdfGenerator _orderPdfGenerator; + private readonly OrderEventBus _eventBus; + + public OrderProcessor(IServiceScopeFactory serviceScopeFactory, + IPrintService printService, + IOrderPdfGenerator orderPdfGenerator, + OrderEventBus eventBus) + { + _logger = LogManager.GetCurrentClassLogger(); + _serviceScopeFactory = serviceScopeFactory; + _printService = printService; + _orderPdfGenerator = orderPdfGenerator; + _eventBus = eventBus; + } + + public async Task ProcessOrder(DokDto order) + { + var dok = await GetOrCreateOrder(order); + + if (dok.IsPrinted) + return; + + var filePath = await EnsureOrderPdfExists(order, dok); + + var printResult = await PrintOrder(order, filePath); + + if (printResult.IsSuccess) + { + dok.IsPrinted = true; + await SaveOrderIfChanged(dok); + } + } + + private async Task GetOrCreateOrder(DokDto order) + { + var dok = await GetOrder(order.DokId); + + if (dok != null) + return dok; + + _logger.Info("Creating new order - {OrderNo}", order.NrDok); + + dok = new OrderDb + { + DokId = order.DokId, + Created = order.Data, + OrderId = order.DokId, + Filename = string.Empty, + IsPrinted = false, + Shop = order.Sklep, + OrderNumber = order.NrDok + }; + + await SaveOrderIfChanged(dok); + return dok; + } + + private async Task EnsureOrderPdfExists(DokDto order, OrderDb dok) + { + if (!string.IsNullOrEmpty(dok.Filename)) + { + var fullPath = Path.Combine(Constants.ReportsOutputPath, dok.Filename); + if (File.Exists(fullPath)) + return fullPath; + } + + _logger.Info("Generating order file: {OrderNo}", order.NrDok); + + var generatedFilename = await _orderPdfGenerator.GenerateOrder(order); + var newPath = Path.Combine(Constants.ReportsOutputPath, generatedFilename); + + if (string.Equals(dok.Filename, generatedFilename, StringComparison.OrdinalIgnoreCase)) + return newPath; + dok.Filename = generatedFilename; + await SaveOrderIfChanged(dok); + + return newPath; + } + + private async Task PrintOrder(DokDto order, string filePath) + { + _logger.Info("Printing order: {OrderNo}", order.NrDok); + + var result = await _printService.PrintPdf(new PrintDocumentRequest(filePath, order.DokId)); + + _logger.Info("Printing result - OrderNo: {OrderNo}, Success: {IsSuccess}, Message: {Message}", + order.NrDok, result.IsSuccess, result.Message); + + return result; + } + + private async Task GetOrder(long dokId) + { + try + { + using var scope = _serviceScopeFactory.CreateScope(); + var context = scope.ServiceProvider.GetRequiredService(); + + return await context.Orders + .FirstOrDefaultAsync(x => x.DokId == dokId); + } + catch (Exception e) + { + _logger.Error(e, "Error retrieving order from database"); + return null; + } + } + + private async Task SaveOrderIfChanged(OrderDb order) + { + using var scope = _serviceScopeFactory.CreateScope(); + var context = scope.ServiceProvider.GetRequiredService(); + + var existing = await context.Orders.FirstOrDefaultAsync(x => x.DokId == order.DokId); + + if (existing == null) + { + await context.Orders.AddAsync(order); + await context.SaveChangesAsync(); + _eventBus.NotifyOrdersChanged(); + return; + } + + if (existing.IsPrinted == order.IsPrinted && existing.Filename == order.Filename) + return; + + existing.IsPrinted = order.IsPrinted; + existing.Filename = order.Filename; + + context.Orders.Update(existing); + await context.SaveChangesAsync(); + + _eventBus.NotifyOrdersChanged(); + } +} diff --git a/Drab.Logic/Services/OrdersStore.cs b/Drab.Logic/Services/OrdersStore.cs new file mode 100644 index 0000000..5284a33 --- /dev/null +++ b/Drab.Logic/Services/OrdersStore.cs @@ -0,0 +1,78 @@ +using Drab.Core.Models; +using Drab.Logic.Dtos; +using Drab.Logic.Interfaces; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using NLog; +using Pcm.Db; +using Pcm.Db.Enums; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Threading.Tasks; +using Drab.Core.Configuration; + +namespace Drab.Logic.Services; + +public class OrdersStore : IOrdersStore, IDisposable +{ + private readonly ILogger _logger; + private readonly IServiceScopeFactory _serviceScopeFactory; + private readonly IDrabSettings _drabSettings; + + public OrdersStore(IServiceScopeFactory serviceScopeFactory, IDrabSettings drabSettings) + { + _serviceScopeFactory = serviceScopeFactory; + _drabSettings = drabSettings; + _logger = LogManager.GetCurrentClassLogger(); + } + + public async Task, string>> FetchOrders() + { + _logger.Info("Fetch new orders"); + + DateTime date; + try + { + date = DateTime.ParseExact(_drabSettings.IgnoreOrdersBefore, "yyyy-MM-dd", CultureInfo.InvariantCulture); + } + catch + { + date = DateTime.Now - TimeSpan.FromDays(30); + } + + using var scope = _serviceScopeFactory.CreateScope(); + await using var dbContext = scope.ServiceProvider.GetService(); + try + { + var orders = await dbContext.Dokumenty + .Where(x => x.Aktywny == 1 + && x.TypDok == (short)TypDok.RejestracjaZamowieniaOdOdbiorcy + && x.Opcja1 == 0 + && x.Data >= date) + .Include(x => x.DokKontr) + .ThenInclude(x => x.Kontr) + .Include(x => x.TekstDoks.Where(y => + y.Znaczenie == (short)TekstDokZnaczenie.InfoDoZamowienia || + y.Znaczenie == (short)TekstDokZnaczenie.TekstDod2)) + .Include(x => x.PozDoks) + .ThenInclude(x => x.TekstPozs.Where(y => y.Znaczenie == 0 || y.Znaczenie == 13)) + .Include(x => x.PozDoks) + .ThenInclude(x => x.Tow) + .ThenInclude(x => x.Jm) + .ToListAsync(); + + return Result.Ok, string>(orders.Select(x => x.ToDokDto()).ToList()); + } + catch (Exception e) + { + _logger.Error(e, "Error on fetching orders"); + return Result.Failed, string>(e.Message); + } + } + + public void Dispose() + { + } +} \ No newline at end of file diff --git a/Drab.Logic/Services/PrintService.cs b/Drab.Logic/Services/PrintService.cs new file mode 100644 index 0000000..145eb20 --- /dev/null +++ b/Drab.Logic/Services/PrintService.cs @@ -0,0 +1,71 @@ +using Drab.Core.Configuration; +using Drab.Logic.Interfaces; +using Drab.Logic.Models; +using PdfiumViewer; +using System; +using System.Collections.Generic; +using System.Drawing.Printing; +using System.IO; +using System.Linq; +using System.Printing; +using System.Threading.Tasks; + +namespace Drab.Logic.Services; + +public class PrintService : IPrintService +{ + private readonly IDrabSettings _drabSettings; + + public PrintService(IDrabSettings drabSettings) + { + _drabSettings = drabSettings; + } + + public async Task PrintPdf(PrintDocumentRequest request) + { + try + { + var oldJobs = GetPrintJobs(request.DokId.ToString()); + if (oldJobs.Any(x => !x.IsRetained)) + { + oldJobs.ForEach(x => x.Cancel()); + await Task.Delay(TimeSpan.FromSeconds(2)); + } + + var (filePath, dokId) = request; + using (var document = PdfDocument.Load(filePath)) + { + using (var printDocument = document.CreatePrintDocument()) + { + var fileName = Path.GetFileName(filePath); + + printDocument.PrinterSettings.PrintFileName = fileName; + printDocument.DocumentName = dokId.ToString(); + printDocument.PrintController = new StandardPrintController(); + printDocument.Print(); + } + } + + await Task.Delay(TimeSpan.FromSeconds(_drabSettings.PrinterTimeoutSeconds)); + + var jobs = GetPrintJobs(request.DokId.ToString()); + if (jobs.Count == 0) + return new PrintDocumentResult(true, "Print success."); + + jobs.ForEach(x => x.Cancel()); + return new PrintDocumentResult(false, "Print failed - timeout expired."); + } + catch (Exception e) + { + return new PrintDocumentResult(false, $"Print failed - {e.Message}"); + } + } + + private static List GetPrintJobs(string jobName) + { + var printQueue = LocalPrintServer.GetDefaultPrintQueue(); + return printQueue.GetPrintJobInfoCollection() + .Where(x => x.Name == jobName) + .ToList(); + } +} \ No newline at end of file diff --git a/Drab.Logic/System.Printing.dll b/Drab.Logic/System.Printing.dll new file mode 100644 index 0000000..d2bc9b7 Binary files /dev/null and b/Drab.Logic/System.Printing.dll differ diff --git a/Drab.Logic/Templates/Order.frx b/Drab.Logic/Templates/Order.frx new file mode 100644 index 0000000..53694e6 --- /dev/null +++ b/Drab.Logic/Templates/Order.frx @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Drab.Logic/Utils/DbFetcher.cs b/Drab.Logic/Utils/DbFetcher.cs new file mode 100644 index 0000000..2accdbf --- /dev/null +++ b/Drab.Logic/Utils/DbFetcher.cs @@ -0,0 +1,62 @@ +using Drab.Core.Configuration; +using Drab.Logic.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using NLog; +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; + +namespace Drab.Logic.Utils; + +public class DbFetcher : BackgroundService +{ + private readonly IDrabSettings _drabSettings; + private readonly IServiceScopeFactory _serviceScopeFactory; + private readonly IOrderProcessor _orderProcessor; + private readonly ILogger _logger; + + public DbFetcher(IDrabSettings drabSettings, IServiceScopeFactory serviceScopeFactory, IOrderProcessor orderProcessor) + { + _drabSettings = drabSettings; + _serviceScopeFactory = serviceScopeFactory; + _orderProcessor = orderProcessor; + _logger = LogManager.GetCurrentClassLogger(); + } + + protected override Task ExecuteAsync(CancellationToken stoppingToken) + { + Start(); + return Task.CompletedTask; + } + + public async Task Start() + { + await Task.Delay(TimeSpan.FromSeconds(2)); + while (true) + { + _logger.Info("Fetch database for new orders"); + try + { + using var scope = _serviceScopeFactory.CreateScope(); + using var orderStore = scope.ServiceProvider.GetService(); + var result = await orderStore.FetchOrders(); + + if (result.IsNotOk) + _logger.Warn($"Fetch orders result failed: {result.Error}"); + + result.Value.ToList() + .ForEach(x => _orderProcessor.ProcessOrder(x)); + } + catch (Exception e) + { + _logger.Error(e, "Error on fetching new orders data:"); + } + finally + { + await Task.Delay(TimeSpan.FromSeconds(_drabSettings.DbPollingFrequencyInSeconds)); + } + } + } +} \ No newline at end of file diff --git a/Drab.sln b/Drab.sln new file mode 100644 index 0000000..2023bc8 --- /dev/null +++ b/Drab.sln @@ -0,0 +1,49 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31729.503 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Drab", "Drab\Drab.csproj", "{64D48CEF-6B5E-42CA-A6AB-10FCC15E1288}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pcm.Db", "Pcm.Db\Pcm.Db.csproj", "{3A449E77-3320-491D-805F-FB8DDFBD4FE2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Drab.Core", "Drab.Core\Drab.Core.csproj", "{FCA29186-6444-4532-AB25-E67446CAA060}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Drab.Logic", "Drab.Logic\Drab.Logic.csproj", "{60CB71F2-798C-4E0E-B68F-9C29D8E2934A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Drab.LocalDb", "Drab.LocalDb\Drab.LocalDb.csproj", "{FAFD1123-326B-40D6-A440-4CBBD783CA45}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {64D48CEF-6B5E-42CA-A6AB-10FCC15E1288}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {64D48CEF-6B5E-42CA-A6AB-10FCC15E1288}.Debug|Any CPU.Build.0 = Debug|Any CPU + {64D48CEF-6B5E-42CA-A6AB-10FCC15E1288}.Release|Any CPU.ActiveCfg = Release|Any CPU + {64D48CEF-6B5E-42CA-A6AB-10FCC15E1288}.Release|Any CPU.Build.0 = Release|Any CPU + {3A449E77-3320-491D-805F-FB8DDFBD4FE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A449E77-3320-491D-805F-FB8DDFBD4FE2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A449E77-3320-491D-805F-FB8DDFBD4FE2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A449E77-3320-491D-805F-FB8DDFBD4FE2}.Release|Any CPU.Build.0 = Release|Any CPU + {FCA29186-6444-4532-AB25-E67446CAA060}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FCA29186-6444-4532-AB25-E67446CAA060}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FCA29186-6444-4532-AB25-E67446CAA060}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FCA29186-6444-4532-AB25-E67446CAA060}.Release|Any CPU.Build.0 = Release|Any CPU + {60CB71F2-798C-4E0E-B68F-9C29D8E2934A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {60CB71F2-798C-4E0E-B68F-9C29D8E2934A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {60CB71F2-798C-4E0E-B68F-9C29D8E2934A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {60CB71F2-798C-4E0E-B68F-9C29D8E2934A}.Release|Any CPU.Build.0 = Release|Any CPU + {FAFD1123-326B-40D6-A440-4CBBD783CA45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FAFD1123-326B-40D6-A440-4CBBD783CA45}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FAFD1123-326B-40D6-A440-4CBBD783CA45}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FAFD1123-326B-40D6-A440-4CBBD783CA45}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {29279B5D-113E-4BB7-8E30-1E255A164BF2} + EndGlobalSection +EndGlobal diff --git a/Drab.sln.DotSettings.user b/Drab.sln.DotSettings.user new file mode 100644 index 0000000..c1c2984 --- /dev/null +++ b/Drab.sln.DotSettings.user @@ -0,0 +1,4 @@ + + ForceIncluded + ForceIncluded + ForceIncluded \ No newline at end of file diff --git a/Drab/Drab.csproj b/Drab/Drab.csproj new file mode 100644 index 0000000..ebf66be --- /dev/null +++ b/Drab/Drab.csproj @@ -0,0 +1,35 @@ + + + + false + net9.0-windows + enable + enable + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + \ No newline at end of file diff --git a/Drab/Drab.csproj.user b/Drab/Drab.csproj.user new file mode 100644 index 0000000..2e7e1de --- /dev/null +++ b/Drab/Drab.csproj.user @@ -0,0 +1,10 @@ + + + + ProjectDebugger + + + Drab + C:\__Repozytorium\DRAB\Drab\Properties\PublishProfiles\FolderProfile.pubxml + + \ No newline at end of file diff --git a/Drab/FileController.cs b/Drab/FileController.cs new file mode 100644 index 0000000..da36a9b --- /dev/null +++ b/Drab/FileController.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Drab; + +[ApiController] +public class FileController : ControllerBase +{ + [HttpGet("/pdf/{filename}")] + public IActionResult Get([FromRoute] string filename) + { + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Orders", filename); + + if (!System.IO.File.Exists(filePath)) + return NotFound(); + + return File(System.IO.File.OpenRead(filePath), "application/pdf"); + } +} \ No newline at end of file diff --git a/Drab/Program.cs b/Drab/Program.cs new file mode 100644 index 0000000..844172b --- /dev/null +++ b/Drab/Program.cs @@ -0,0 +1,79 @@ +using System.Net; +using Drab.Core.Configuration; +using Drab.Core.Ioc; +using Drab.LocalDb; +using Drab.LocalDb.IoC; +using Drab.Logic.Ioc; +using Drab.Logic.Services; +using Drab.Ui; +using Microsoft.EntityFrameworkCore; +using NLog.Extensions.Logging; +using Pcm.Db.Ioc; +using Radzen; + +var builder = WebApplication.CreateBuilder(args); + +var configurationBuilder = new ConfigurationBuilder() + .SetBasePath(AppDomain.CurrentDomain.BaseDirectory) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); +var configuration = configurationBuilder.Build(); + +var port = int.Parse(builder.WebHost.GetSetting("ListenPort") ?? "5010"); + +builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); + +builder.Services.AddLogging(loggingBuilder => +{ + loggingBuilder.ClearProviders(); + loggingBuilder.AddConfiguration(configuration.GetSection("Logging")); + loggingBuilder.AddNLog("nlog.config"); +}); + +var drabSettings = configuration.GetSection(DrabSettings.SectionName).Get(); +var localDbSettings = configuration.GetSection(LocalDbConfiguration.SectionName).Get(); +builder.Services.AddLocalDatabase(localDbSettings); +var dbConfig = configuration.GetSection(PcmDbConfiguration.SectionName).Get(); + +builder.Services.AddPcmDatabase(dbConfig); +builder.Services.AddDrabCore(drabSettings); +builder.Services.AddDrabLogic(); +builder.Services.AddHostedService(); + +builder.Services.AddRadzenComponents(); +builder.Services.AddControllers().AddControllersAsServices(); +builder.WebHost + .UseKestrel(options => + { + options.Listen(IPAddress.Any, port); + }) + .UseContentRoot(Directory.GetCurrentDirectory()); + +var app = builder.Build(); + +if (!app.Environment.IsDevelopment()) +{ + app.UseExceptionHandler("/Error", createScopeForErrors: true); + app.UseHsts(); +} + +app.UseStaticFiles(); +app.UseRouting(); +app.UseAntiforgery(); +app.MapControllers(); +app.MapRazorComponents() + .AddInteractiveServerRenderMode(); + +if (!Directory.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Orders"))) +{ + Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Orders")); +} + +var scope = app.Services.GetService(); +using (var scopeProvider = scope.CreateScope()) +{ + await using var context = scopeProvider.ServiceProvider.GetRequiredService(); + await context.Database.MigrateAsync(); +} + +app.Run(); \ No newline at end of file diff --git a/Drab/Properties/PublishProfiles/FolderProfile.pubxml b/Drab/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 0000000..75fff6b --- /dev/null +++ b/Drab/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,24 @@ + + + + + true + false + true + Release + Any CPU + FileSystem + bin\Release\publish\ + FileSystem + <_TargetId>Folder + + net6.0-windows + win-x64 + false + true + 64d48cef-6b5e-42ca-a6ab-10fcc15e1288 + true + + \ No newline at end of file diff --git a/Drab/Properties/PublishProfiles/FolderProfile.pubxml.user b/Drab/Properties/PublishProfiles/FolderProfile.pubxml.user new file mode 100644 index 0000000..4ccec35 --- /dev/null +++ b/Drab/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -0,0 +1,11 @@ + + + + + <_PublishTargetUrl>C:\__Repozytorium\DRAB\Drab\bin\Release\publish\ + True|2023-02-21T14:54:18.7590581Z;True|2023-02-18T14:13:57.9596803+01:00;False|2023-02-18T14:12:47.7973484+01:00;False|2023-02-18T14:11:56.4748109+01:00; + + + \ No newline at end of file diff --git a/Drab/Properties/launchSettings.json b/Drab/Properties/launchSettings.json new file mode 100644 index 0000000..adb5013 --- /dev/null +++ b/Drab/Properties/launchSettings.json @@ -0,0 +1,28 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:26177", + "sslPort": 44338 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Drab": { + "commandName": "Project", + "dotnetRunMessages": "true", + "launchBrowser": false, + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Drab/Ui/App.razor b/Drab/Ui/App.razor new file mode 100644 index 0000000..cc6f78e --- /dev/null +++ b/Drab/Ui/App.razor @@ -0,0 +1,25 @@ +@using Drab.Ui.components +@using Microsoft.AspNetCore.Components.Web +@using Radzen + + + + + + + + + + + + Brzęczek - Zamówienia + + + + + + + + + + diff --git a/Drab/Ui/Pages/Index.razor b/Drab/Ui/Pages/Index.razor new file mode 100644 index 0000000..0f57055 --- /dev/null +++ b/Drab/Ui/Pages/Index.razor @@ -0,0 +1,109 @@ +@page "/" +@using Drab.LocalDb +@using Drab.LocalDb.Entities +@using Drab.Logic.Services +@using Drab.Ui.components +@using Radzen +@inject LocalDbContext LocalDbContext +@inject DialogService DialogService +@inject OrderEventBus EventBus + +@implements IDisposable + + + + + + + + @if (order.IsPrinted) + { + + } + else + { + + } + + + + + + +@code { + IQueryable _orders; + private RadzenDataGrid? _dataGridRef; + + protected override void OnInitialized() + { + EventBus.OrdersChanged += OnOrdersChanged; + _orders = LocalDbContext.Orders; + } + + private async Task RowClick(DataGridRowMouseEventArgs obj) + { + await DialogService.OpenAsync($"Zamówienie {obj.Data.OrderNumber} - Sklep {obj.Data.Shop}", + new Dictionary() {{nameof(PdfViewer.Filename), obj.Data.Filename}}, + new DialogOptions() + { + CloseDialogOnEsc = true, + CloseDialogOnOverlayClick = true, + Resizable = false, + Draggable = false, + Width = "80%", + Height = "90vh" + }); + } + + private void OnOrdersChanged() + { + InvokeAsync(() => + { + _orders = LocalDbContext.Orders; + _dataGridRef?.Reload(); + StateHasChanged(); + return Task.CompletedTask; + }); + } + + public void Dispose() + { + EventBus.OrdersChanged -= OnOrdersChanged; + LocalDbContext?.Dispose(); + DialogService?.Dispose(); + } + +} \ No newline at end of file diff --git a/Drab/Ui/_Imports.razor b/Drab/Ui/_Imports.razor new file mode 100644 index 0000000..395a465 --- /dev/null +++ b/Drab/Ui/_Imports.razor @@ -0,0 +1 @@ +@using Radzen.Blazor \ No newline at end of file diff --git a/Drab/Ui/components/MainLayout.razor b/Drab/Ui/components/MainLayout.razor new file mode 100644 index 0000000..5328d82 --- /dev/null +++ b/Drab/Ui/components/MainLayout.razor @@ -0,0 +1,18 @@ +@inherits LayoutComponentBase + + + + + @Body + + + + + An unhandled error has occurred. + Reload + 🗙 + + + + + \ No newline at end of file diff --git a/Drab/Ui/components/PdfViewer.razor b/Drab/Ui/components/PdfViewer.razor new file mode 100644 index 0000000..726186c --- /dev/null +++ b/Drab/Ui/components/PdfViewer.razor @@ -0,0 +1,9 @@ + + + +@code { + [Parameter] + public string Filename { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/Drab/Ui/components/Routes.razor b/Drab/Ui/components/Routes.razor new file mode 100644 index 0000000..c61efcd --- /dev/null +++ b/Drab/Ui/components/Routes.razor @@ -0,0 +1,12 @@ +@using Microsoft.AspNetCore.Components.Routing + + + + + + + + 404 – nie znaleziono strony + + + \ No newline at end of file diff --git a/Drab/add migration.txt b/Drab/add migration.txt new file mode 100644 index 0000000..566d1f8 --- /dev/null +++ b/Drab/add migration.txt @@ -0,0 +1 @@ +dotnet ef migrations add Initial --project ..\Drab.LocalDb\Drab.LocalDb.csproj --context LocalDbContext \ No newline at end of file diff --git a/Drab/appsettings.Development.json b/Drab/appsettings.Development.json new file mode 100644 index 0000000..5173757 --- /dev/null +++ b/Drab/appsettings.Development.json @@ -0,0 +1,10 @@ +{ + "DetailedErrors": true, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/Drab/appsettings.json b/Drab/appsettings.json new file mode 100644 index 0000000..5c7776b --- /dev/null +++ b/Drab/appsettings.json @@ -0,0 +1,26 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "ListenPort": 80, + "AllowedHosts": "*", + "DrabSettings": { + "DbPollingFrequencyInSeconds": 180, + "PrinterTimeoutSeconds": 30, + "IgnoreOrdersBefore": "2025-07-11" + }, + "PcmDbSettings": { + "Host": "192.168.200.6", + "Port": "1433", + "User": "sa", + "Password": "10Coma123", + "Database": "BRZECZEK" + }, + "LocalDbConnection": { + "ConnectionString": "Data Source=.\\drab.db" + } +} diff --git a/Drab/nlog.config b/Drab/nlog.config new file mode 100644 index 0000000..20129e0 --- /dev/null +++ b/Drab/nlog.config @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Drab/wwwroot/css/common.css b/Drab/wwwroot/css/common.css new file mode 100644 index 0000000..b21699d --- /dev/null +++ b/Drab/wwwroot/css/common.css @@ -0,0 +1,37 @@ +html, body { + font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; + background-image: none !important; + width: 100% !important; + margin: auto; +} + +.blazor-error-boundary { + background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; + padding: 1rem 1rem 1rem 3.7rem; + color: white; +} + +.blazor-error-boundary::after { + content: "An error has occurred." +} + +#blazor-error-ui { + color-scheme: light only; + background: lightyellow; + bottom: 0; + box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); + box-sizing: border-box; + display: none; + left: 0; + padding: 0.6rem 1.25rem 0.7rem 1.25rem; + position: fixed; + width: 100%; + z-index: 1000; +} + +#blazor-error-ui .dismiss { + cursor: pointer; + position: absolute; + right: 0.75rem; + top: 0.5rem; +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Akwizytor.cs b/Pcm.Db/Entities/Akwizytor.cs new file mode 100644 index 0000000..3be5cfc --- /dev/null +++ b/Pcm.Db/Entities/Akwizytor.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class Akwizytor +{ + public Akwizytor() + { + Kontrahents = new HashSet(); + } + + public decimal AkwId { get; set; } + public string Nazwisko { get; set; } + public string Opis { get; set; } + public decimal Prowizja { get; set; } + + public virtual ICollection Kontrahents { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Artykul.cs b/Pcm.Db/Entities/Artykul.cs new file mode 100644 index 0000000..02fd1b8 --- /dev/null +++ b/Pcm.Db/Entities/Artykul.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class Artykul +{ + public Artykul() + { + Towars = new HashSet(); + } + + public decimal ArtId { get; set; } + public string ArtNazwa { get; set; } + public decimal? CentrArtId { get; set; } + public decimal? GlownyTowId { get; set; } + + public virtual Towar GlownyTow { get; set; } + public virtual ICollection Towars { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Asort.cs b/Pcm.Db/Entities/Asort.cs new file mode 100644 index 0000000..203bc56 --- /dev/null +++ b/Pcm.Db/Entities/Asort.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class Asort +{ + public Asort() + { + Marzowniks = new HashSet(); + Przydzials = new HashSet(); + RegulaAsorts = new HashSet(); + SklepPrzydzials = new HashSet(); + Towars = new HashSet(); + } + + public decimal AsId { get; set; } + public string Nazwa { get; set; } + public decimal Marza { get; set; } + public short OpcjaMarzy { get; set; } + public decimal HurtRabat { get; set; } + public short OpcjaRabatu { get; set; } + public decimal NocNarzut { get; set; } + public short OpcjaNarzutu { get; set; } + public decimal? CentrAsId { get; set; } + public short? UkrytyNaPanelach { get; set; } + public short? UkrytyNaBonowniku { get; set; } + public short? BezAutoEtykiet { get; set; } + public decimal? Param1 { get; set; } + + [JsonIgnore] + public virtual ICollection Marzowniks { get; set; } + [JsonIgnore] + public virtual ICollection Przydzials { get; set; } + [JsonIgnore] + public virtual ICollection RegulaAsorts { get; set; } + [JsonIgnore] + public virtual ICollection SklepPrzydzials { get; set; } + [JsonIgnore] + public virtual ICollection Towars { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Bank.cs b/Pcm.Db/Entities/Bank.cs new file mode 100644 index 0000000..dd7a5c6 --- /dev/null +++ b/Pcm.Db/Entities/Bank.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class Bank +{ + public Bank() + { + KontoBankoweKontrs = new HashSet(); + KontoBankowes = new HashSet(); + } + + public decimal BankId { get; set; } + public string Nazwa { get; set; } + public string Adres { get; set; } + public short Aktywny { get; set; } + public DateTime Zmiana { get; set; } + public decimal? CentrBankId { get; set; } + public string NrRozliBank { get; set; } + + public virtual ICollection KontoBankoweKontrs { get; set; } + public virtual ICollection KontoBankowes { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Blokadum.cs b/Pcm.Db/Entities/Blokadum.cs new file mode 100644 index 0000000..11d5fa9 --- /dev/null +++ b/Pcm.Db/Entities/Blokadum.cs @@ -0,0 +1,14 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class Blokadum +{ + public decimal SesjaId { get; set; } + public decimal TowId { get; set; } + public decimal MagId { get; set; } + public decimal Ilosc { get; set; } + + public virtual Istw Istw { get; set; } + public virtual SesjaAktywna Sesja { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/CentrStanZgody.cs b/Pcm.Db/Entities/CentrStanZgody.cs new file mode 100644 index 0000000..0843241 --- /dev/null +++ b/Pcm.Db/Entities/CentrStanZgody.cs @@ -0,0 +1,19 @@ +using System; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class CentrStanZgody +{ + public decimal KontrId { get; set; } + public decimal ZgId { get; set; } + public short Status { get; set; } + public string Kiedy { get; set; } + public string Wersja { get; set; } + public short? FormaDec { get; set; } + public DateTime? DataDec { get; set; } + + public virtual Kontrahent Kontr { get; set; } + public virtual Zgodum Zg { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Cza.cs b/Pcm.Db/Entities/Cza.cs new file mode 100644 index 0000000..d814dc4 --- /dev/null +++ b/Pcm.Db/Entities/Cza.cs @@ -0,0 +1,20 @@ +using System; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class Cza +{ + public decimal CzasId { get; set; } + public decimal? DzienTygodnia { get; set; } + public decimal? DzienMiesiaca { get; set; } + public decimal? Dzien { get; set; } + public decimal? TydzienRoku { get; set; } + public decimal? Tydzien { get; set; } + public decimal? MiesiacRoku { get; set; } + public decimal? Miesiac { get; set; } + public decimal? Weekend { get; set; } + public decimal? Rok { get; set; } + public DateTime? Data { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/DefinicjaKodu.cs b/Pcm.Db/Entities/DefinicjaKodu.cs new file mode 100644 index 0000000..4e8f53e --- /dev/null +++ b/Pcm.Db/Entities/DefinicjaKodu.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class DefinicjaKodu +{ + public DefinicjaKodu() + { + SkladnikDefinicjiKodus = new HashSet(); + } + + public decimal Dkid { get; set; } + public short Typ { get; set; } + public string Nazwa { get; set; } + public DateTime? DataOd { get; set; } + public DateTime? DataDo { get; set; } + public short Aktywny { get; set; } + public DateTime Zmiana { get; set; } + public decimal? CentrDkid { get; set; } + + public virtual ICollection SkladnikDefinicjiKodus { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Dok.cs b/Pcm.Db/Entities/Dok.cs new file mode 100644 index 0000000..02bbc50 --- /dev/null +++ b/Pcm.Db/Entities/Dok.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class Dok +{ + public Dok() + { + DokDodKths = new HashSet(); + DokKontoBankowes = new HashSet(); + DokKurs = new HashSet(); + DokPunkties = new HashSet(); + DokWaluta = new HashSet(); + Phrozliczenies = new HashSet(); + PozDoks = new HashSet(); + RegulaDoks = new HashSet(); + RozbicieDoks = new HashSet(); + RozliczaDoks = new HashSet(); + RozliczaRozliczanyDoks = new HashSet(); + SklepDoks = new HashSet(); + TekstDoks = new HashSet(); + ZaleznoscPoprzedniDoks = new HashSet(); + } + + public decimal DokId { get; set; } + public decimal UzId { get; set; } + public decimal MagId { get; set; } + public DateTime Data { get; set; } + public int KolejnyWdniu { get; set; } + public DateTime DataDod { get; set; } + public DateTime DataPom { get; set; } + public string NrDok { get; set; } + public short TypDok { get; set; } + public short Aktywny { get; set; } + public short Opcja1 { get; set; } + public short Opcja2 { get; set; } + public short Opcja3 { get; set; } + public short Opcja4 { get; set; } + public short CenyZakBrutto { get; set; } + public short CenySpBrutto { get; set; } + public short FormaPlat { get; set; } + public short TerminPlat { get; set; } + public short PoziomCen { get; set; } + public decimal RabatProc { get; set; } + public decimal Netto { get; set; } + public decimal Podatek { get; set; } + public decimal NettoUslugi { get; set; } + public decimal PodatekUslugi { get; set; } + public decimal NettoDet { get; set; } + public decimal PodatekDet { get; set; } + public decimal NettoDetUslugi { get; set; } + public decimal PodatekDetUslugi { get; set; } + public decimal NettoMag { get; set; } + public decimal PodatekMag { get; set; } + public decimal NettoMagUslugi { get; set; } + public decimal PodatekMagUslugi { get; set; } + public decimal Razem { get; set; } + public decimal DoZaplaty { get; set; } + public decimal Zaplacono { get; set; } + public decimal Kwota1 { get; set; } + public decimal Kwota2 { get; set; } + public decimal Kwota3 { get; set; } + public decimal Kwota4 { get; set; } + public decimal Kwota5 { get; set; } + public decimal Kwota6 { get; set; } + public decimal Kwota7 { get; set; } + public decimal Kwota8 { get; set; } + public decimal Kwota9 { get; set; } + public decimal Kwota10 { get; set; } + public int Param1 { get; set; } + public int Param2 { get; set; } + public int Param3 { get; set; } + public int Param4 { get; set; } + public short EksportFk { get; set; } + public DateTime Zmiana { get; set; } + public int? NrKolejny { get; set; } + public int? NrKolejnyMag { get; set; } + public int? Param5 { get; set; } + public int? Param6 { get; set; } + public decimal? Kwota11 { get; set; } + public decimal? Kwota12 { get; set; } + public decimal? WalId { get; set; } + public decimal? Kurs { get; set; } + public decimal? CentrDokId { get; set; } + public short? Opcja5 { get; set; } + public short? Opcja6 { get; set; } + public short? Opcja7 { get; set; } + public short? Opcja8 { get; set; } + public DateTime? ZmianaPkt { get; set; } + public decimal? ZaplaconoPodatek { get; set; } + public decimal? ZaplaconoWkasie { get; set; } + [JsonIgnore] + public virtual Magazyn Mag { get; set; } + [JsonIgnore] + public virtual Uzytkownik Uz { get; set; } + [JsonIgnore] + public virtual Walutum Wal { get; set; } + [JsonIgnore] + public virtual DokKasa DokKasa { get; set; } + public virtual DokKontr DokKontr { get; set; } + [JsonIgnore] + public virtual Zaleznosc ZaleznoscDok { get; set; } + [JsonIgnore] + public virtual ICollection DokDodKths { get; set; } + [JsonIgnore] + public virtual ICollection DokKontoBankowes { get; set; } + [JsonIgnore] + public virtual ICollection DokKurs { get; set; } + [JsonIgnore] + public virtual ICollection DokPunkties { get; set; } + [JsonIgnore] + public virtual ICollection DokWaluta { get; set; } + [JsonIgnore] + public virtual ICollection Phrozliczenies { get; set; } + public virtual ICollection PozDoks { get; set; } + [JsonIgnore] + public virtual ICollection RegulaDoks { get; set; } + [JsonIgnore] + public virtual ICollection RozbicieDoks { get; set; } + [JsonIgnore] + public virtual ICollection RozliczaDoks { get; set; } + [JsonIgnore] + public virtual ICollection RozliczaRozliczanyDoks { get; set; } + [JsonIgnore] + public virtual ICollection SklepDoks { get; set; } + [JsonIgnore] + public virtual ICollection TekstDoks { get; set; } + [JsonIgnore] + public virtual ICollection ZaleznoscPoprzedniDoks { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/DokDodKth.cs b/Pcm.Db/Entities/DokDodKth.cs new file mode 100644 index 0000000..0c92a53 --- /dev/null +++ b/Pcm.Db/Entities/DokDodKth.cs @@ -0,0 +1,13 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class DokDodKth +{ + public decimal DokId { get; set; } + public short Znaczenie { get; set; } + public decimal KontrId { get; set; } + + public virtual Dok Dok { get; set; } + public virtual Kontrahent Kontr { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/DokKasa.cs b/Pcm.Db/Entities/DokKasa.cs new file mode 100644 index 0000000..a12c261 --- /dev/null +++ b/Pcm.Db/Entities/DokKasa.cs @@ -0,0 +1,12 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class DokKasa +{ + public decimal DokId { get; set; } + public decimal KasaId { get; set; } + + public virtual Dok Dok { get; set; } + public virtual Kasa Kasa { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/DokKontoBankowe.cs b/Pcm.Db/Entities/DokKontoBankowe.cs new file mode 100644 index 0000000..6def16b --- /dev/null +++ b/Pcm.Db/Entities/DokKontoBankowe.cs @@ -0,0 +1,12 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class DokKontoBankowe +{ + public decimal DokId { get; set; } + public decimal Kbid { get; set; } + + public virtual Dok Dok { get; set; } + public virtual KontoBankowe Kb { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/DokKontr.cs b/Pcm.Db/Entities/DokKontr.cs new file mode 100644 index 0000000..24fb0aa --- /dev/null +++ b/Pcm.Db/Entities/DokKontr.cs @@ -0,0 +1,15 @@ +using System.Text.Json.Serialization; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class DokKontr +{ + public decimal DokId { get; set; } + public decimal KontrId { get; set; } + + [JsonIgnore] + public virtual Dok Dok { get; set; } + public virtual Kontrahent Kontr { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/DokKur.cs b/Pcm.Db/Entities/DokKur.cs new file mode 100644 index 0000000..5362abe --- /dev/null +++ b/Pcm.Db/Entities/DokKur.cs @@ -0,0 +1,18 @@ +using System; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class DokKur +{ + public decimal DokId { get; set; } + public short Znaczenie { get; set; } + public decimal WalId { get; set; } + public decimal? Kurs { get; set; } + public DateTime? Data { get; set; } + public string NrTabeli { get; set; } + + public virtual Dok Dok { get; set; } + public virtual Walutum Wal { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/DokPunkty.cs b/Pcm.Db/Entities/DokPunkty.cs new file mode 100644 index 0000000..4eec404 --- /dev/null +++ b/Pcm.Db/Entities/DokPunkty.cs @@ -0,0 +1,15 @@ +using System; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class DokPunkty +{ + public decimal DokId { get; set; } + public short Typ { get; set; } + public DateTime Kiedy { get; set; } + public decimal Kwota { get; set; } + + public virtual Dok Dok { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/DokWalutum.cs b/Pcm.Db/Entities/DokWalutum.cs new file mode 100644 index 0000000..a798da3 --- /dev/null +++ b/Pcm.Db/Entities/DokWalutum.cs @@ -0,0 +1,15 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class DokWalutum +{ + public decimal DokId { get; set; } + public decimal WalId { get; set; } + public decimal WalKwota { get; set; } + public decimal Kurs { get; set; } + public decimal DokKwota { get; set; } + + public virtual Dok Dok { get; set; } + public virtual Walutum Wal { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/DostProd.cs b/Pcm.Db/Entities/DostProd.cs new file mode 100644 index 0000000..2cc0ec4 --- /dev/null +++ b/Pcm.Db/Entities/DostProd.cs @@ -0,0 +1,13 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class DostProd +{ + public decimal DostId { get; set; } + public decimal ProdId { get; set; } + public decimal RabatProd { get; set; } + + public virtual Kontrahent Dost { get; set; } + public virtual Kontrahent Prod { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Dostawca.cs b/Pcm.Db/Entities/Dostawca.cs new file mode 100644 index 0000000..7b63ad5 --- /dev/null +++ b/Pcm.Db/Entities/Dostawca.cs @@ -0,0 +1,15 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class Dostawca +{ + public decimal KontrId { get; set; } + public decimal TowId { get; set; } + public decimal CenaZak { get; set; } + public decimal RabatOdWart { get; set; } + public short? Narzucany { get; set; } + + public virtual Kontrahent Kontr { get; set; } + public virtual Towar Tow { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/DzienRozl.cs b/Pcm.Db/Entities/DzienRozl.cs new file mode 100644 index 0000000..5c211dd --- /dev/null +++ b/Pcm.Db/Entities/DzienRozl.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class DzienRozl +{ + public DzienRozl() + { + DzienRozlParams = new HashSet(); + StanPrtMags = new HashSet(); + } + + public DateTime Dzien { get; set; } + public short Status { get; set; } + public DateTime Zmiana { get; set; } + + public virtual ICollection DzienRozlParams { get; set; } + public virtual ICollection StanPrtMags { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/DzienRozlParam.cs b/Pcm.Db/Entities/DzienRozlParam.cs new file mode 100644 index 0000000..fbcee45 --- /dev/null +++ b/Pcm.Db/Entities/DzienRozlParam.cs @@ -0,0 +1,14 @@ +using System; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class DzienRozlParam +{ + public DateTime Dzien { get; set; } + public short Znaczenie { get; set; } + public string Wartosc { get; set; } + + public virtual DzienRozl DzienNavigation { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/FormZgod.cs b/Pcm.Db/Entities/FormZgod.cs new file mode 100644 index 0000000..b198c25 --- /dev/null +++ b/Pcm.Db/Entities/FormZgod.cs @@ -0,0 +1,14 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class FormZgod +{ + public decimal TypOsId { get; set; } + public decimal ZgId { get; set; } + public short Kolejnosc { get; set; } + public short? Wymagana { get; set; } + + public virtual TypO TypOs { get; set; } + public virtual Zgodum Zg { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/FormaPlatnPos7.cs b/Pcm.Db/Entities/FormaPlatnPos7.cs new file mode 100644 index 0000000..d24dfa0 --- /dev/null +++ b/Pcm.Db/Entities/FormaPlatnPos7.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class FormaPlatnPos7 +{ + public FormaPlatnPos7() + { + KasaFormaPlatns = new HashSet(); + } + + public decimal FormaId { get; set; } + public string Nazwa { get; set; } + public short Typ { get; set; } + public short Reszta { get; set; } + public short? Autoryzacja { get; set; } + public string SerwisPlatniczy { get; set; } + public short Aktywny { get; set; } + public DateTime Zmiana { get; set; } + public decimal? CentrFormaId { get; set; } + public decimal? Kolejnosc { get; set; } + + public virtual ICollection KasaFormaPlatns { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/FormaPlatnosci.cs b/Pcm.Db/Entities/FormaPlatnosci.cs new file mode 100644 index 0000000..081680d --- /dev/null +++ b/Pcm.Db/Entities/FormaPlatnosci.cs @@ -0,0 +1,11 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class FormaPlatnosci +{ + public short FormaPlat { get; set; } + public string Tekst { get; set; } + public short MinTermPlat { get; set; } + public short MaxTermPlat { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/GrWartosc.cs b/Pcm.Db/Entities/GrWartosc.cs new file mode 100644 index 0000000..9052d64 --- /dev/null +++ b/Pcm.Db/Entities/GrWartosc.cs @@ -0,0 +1,13 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class GrWartosc +{ + public decimal GrId { get; set; } + public decimal ParId { get; set; } + public int Wartosc { get; set; } + + public virtual GrupaTow Gr { get; set; } + public virtual Parametr Par { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/GrupaAkcyzowa.cs b/Pcm.Db/Entities/GrupaAkcyzowa.cs new file mode 100644 index 0000000..f1b451e --- /dev/null +++ b/Pcm.Db/Entities/GrupaAkcyzowa.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class GrupaAkcyzowa +{ + public GrupaAkcyzowa() + { + PozAkcyzas = new HashSet(); + TabelaAkcyzowas = new HashSet(); + TowAkcyzas = new HashSet(); + } + + public decimal GrAkcId { get; set; } + public string Kod { get; set; } + public string Nazwa { get; set; } + public string AkcJm { get; set; } + public string OpcjeWzoru { get; set; } + public string PrefiksyCn { get; set; } + public string Opis { get; set; } + public decimal? CentrGrAkcId { get; set; } + public DateTime Zmiana { get; set; } + public string DodJm { get; set; } + public decimal? IleDodJmwakcJm { get; set; } + + public virtual ICollection PozAkcyzas { get; set; } + public virtual ICollection TabelaAkcyzowas { get; set; } + public virtual ICollection TowAkcyzas { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/GrupaTow.cs b/Pcm.Db/Entities/GrupaTow.cs new file mode 100644 index 0000000..bce45c7 --- /dev/null +++ b/Pcm.Db/Entities/GrupaTow.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class GrupaTow +{ + public GrupaTow() + { + GrWartoscs = new HashSet(); + } + + public decimal GrId { get; set; } + public string Nazwa { get; set; } + public string Opis { get; set; } + + public virtual ICollection GrWartoscs { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/GrupaUz.cs b/Pcm.Db/Entities/GrupaUz.cs new file mode 100644 index 0000000..e57f640 --- /dev/null +++ b/Pcm.Db/Entities/GrupaUz.cs @@ -0,0 +1,12 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class GrupaUz +{ + public decimal UzId { get; set; } + public decimal RolaId { get; set; } + + public virtual Uzytkownik Rola { get; set; } + public virtual Uzytkownik Uz { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/HarmCeny.cs b/Pcm.Db/Entities/HarmCeny.cs new file mode 100644 index 0000000..398bacc --- /dev/null +++ b/Pcm.Db/Entities/HarmCeny.cs @@ -0,0 +1,22 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class HarmCeny +{ + public decimal HarmId { get; set; } + public decimal TowId { get; set; } + public decimal? CenaDet { get; set; } + public decimal? CenaHurt { get; set; } + public decimal? CenaDod { get; set; } + public decimal? CenaNoc { get; set; } + public decimal? Cena5 { get; set; } + public decimal? Cena6 { get; set; } + public decimal? ProgPromocji { get; set; } + public short? CenaOtwarta { get; set; } + public string Inne { get; set; } + public short? Stawka { get; set; } + + public virtual HarmWpi Harm { get; set; } + public virtual Towar Tow { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/HarmCykl.cs b/Pcm.Db/Entities/HarmCykl.cs new file mode 100644 index 0000000..a7062c0 --- /dev/null +++ b/Pcm.Db/Entities/HarmCykl.cs @@ -0,0 +1,16 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class HarmCykl +{ + public decimal HarmId { get; set; } + public short OdDnia { get; set; } + public short OdGodz { get; set; } + public short OdMin { get; set; } + public short? DoDnia { get; set; } + public short? DoGodz { get; set; } + public short? DoMin { get; set; } + + public virtual HarmWpi Harm { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/HarmHarm.cs b/Pcm.Db/Entities/HarmHarm.cs new file mode 100644 index 0000000..3d30481 --- /dev/null +++ b/Pcm.Db/Entities/HarmHarm.cs @@ -0,0 +1,13 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class HarmHarm +{ + public decimal HarmId { get; set; } + public short Znaczenie { get; set; } + public decimal PoprzHarmId { get; set; } + + public virtual HarmWpi Harm { get; set; } + public virtual HarmWpi PoprzHarm { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/HarmWpi.cs b/Pcm.Db/Entities/HarmWpi.cs new file mode 100644 index 0000000..55edfe4 --- /dev/null +++ b/Pcm.Db/Entities/HarmWpi.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class HarmWpi +{ + public HarmWpi() + { + HarmCenies = new HashSet(); + HarmCykls = new HashSet(); + HarmHarmHarms = new HashSet(); + HarmHarmPoprzHarms = new HashSet(); + } + + public decimal HarmId { get; set; } + public short HarmTyp { get; set; } + public string Nazwa { get; set; } + public string Opcje { get; set; } + public short Aktywny { get; set; } + public short Uwzgledniony { get; set; } + public DateTime Zmiana { get; set; } + public decimal? PolId { get; set; } + public decimal? CentrHarmId { get; set; } + public DateTime? WaznyOd { get; set; } + public DateTime? WaznyDo { get; set; } + public decimal? KrajId { get; set; } + public short? CenyBrutto { get; set; } + + public virtual Kraj Kraj { get; set; } + public virtual Polityka Pol { get; set; } + public virtual ICollection HarmCenies { get; set; } + public virtual ICollection HarmCykls { get; set; } + public virtual ICollection HarmHarmHarms { get; set; } + public virtual ICollection HarmHarmPoprzHarms { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Istw.cs b/Pcm.Db/Entities/Istw.cs new file mode 100644 index 0000000..a684354 --- /dev/null +++ b/Pcm.Db/Entities/Istw.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class Istw +{ + public Istw() + { + Blokada = new HashSet(); + } + + public decimal TowId { get; set; } + public decimal MagId { get; set; } + public decimal StanMag { get; set; } + public decimal BlokadaMag { get; set; } + public decimal CenaMag { get; set; } + public decimal StanMin { get; set; } + public decimal StanMax { get; set; } + public decimal? RezerwacjaMag { get; set; } + + public virtual Magazyn Mag { get; set; } + public virtual Towar Tow { get; set; } + public virtual ICollection Blokada { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Jm.cs b/Pcm.Db/Entities/Jm.cs new file mode 100644 index 0000000..c909c13 --- /dev/null +++ b/Pcm.Db/Entities/Jm.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class Jm +{ + public Jm() + { + KodWazonies = new HashSet(); + Towars = new HashSet(); + } + + public decimal Jmid { get; set; } + public string Nazwa { get; set; } + public short Precyzja { get; set; } + public decimal? CentrJmid { get; set; } + + public virtual ICollection KodWazonies { get; set; } + public virtual ICollection Towars { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/KartaLoj.cs b/Pcm.Db/Entities/KartaLoj.cs new file mode 100644 index 0000000..6edcdef --- /dev/null +++ b/Pcm.Db/Entities/KartaLoj.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class KartaLoj +{ + public KartaLoj() + { + NrRejKarta = new HashSet(); + ZdarzLojs = new HashSet(); + } + + public decimal KartaId { get; set; } + public decimal KontoId { get; set; } + public short TypKarty { get; set; } + public string KodKarty { get; set; } + public DateTime? WaznaOd { get; set; } + public DateTime? WaznaDo { get; set; } + public DateTime? Uniewazniono { get; set; } + public string Posiadacz { get; set; } + public string Opis1 { get; set; } + public string Opis2 { get; set; } + public decimal? CentrKartaId { get; set; } + + public virtual KontoLoj Konto { get; set; } + public virtual ICollection NrRejKarta { get; set; } + public virtual ICollection ZdarzLojs { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/KasKod.cs b/Pcm.Db/Entities/KasKod.cs new file mode 100644 index 0000000..904ccd1 --- /dev/null +++ b/Pcm.Db/Entities/KasKod.cs @@ -0,0 +1,30 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class KasKod +{ + public decimal KasaId { get; set; } + public decimal TowId { get; set; } + public short Kolejnosc { get; set; } + public string Kod { get; set; } + public short Status { get; set; } + public short ZmianyCen { get; set; } + public short ZmianyInne { get; set; } + public short BylyZmianyCen { get; set; } + public short BylyZmianyInne { get; set; } + public int? KasPrefPlu { get; set; } + public int? Plu { get; set; } + public short? DodIndeks { get; set; } + public short? Stawka { get; set; } + public short? TypTowaru { get; set; } + public decimal? IleWkodzie { get; set; } + public short? PoziomCen { get; set; } + public string Skrot { get; set; } + public string KodOpak { get; set; } + public int? Pluopak { get; set; } + public string Rezerwa { get; set; } + + public virtual Kasa Kasa { get; set; } + public virtual Towar Tow { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/KasPar.cs b/Pcm.Db/Entities/KasPar.cs new file mode 100644 index 0000000..48a0b9d --- /dev/null +++ b/Pcm.Db/Entities/KasPar.cs @@ -0,0 +1,12 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class KasPar +{ + public decimal KasaId { get; set; } + public string ParNazwa { get; set; } + public string ParWartosc { get; set; } + + public virtual Kasa Kasa { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/KasTow.cs b/Pcm.Db/Entities/KasTow.cs new file mode 100644 index 0000000..ec79af5 --- /dev/null +++ b/Pcm.Db/Entities/KasTow.cs @@ -0,0 +1,20 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class KasTow +{ + public decimal KasaId { get; set; } + public string KodWyslany { get; set; } + public decimal TowId { get; set; } + public short TypTowaru { get; set; } + public short Dodatkowy { get; set; } + public int Plu { get; set; } + public short DodIndeks { get; set; } + public short ZmianyCen { get; set; } + public short ZmianyInne { get; set; } + public short FlagaExp { get; set; } + + public virtual Kasa Kasa { get; set; } + public virtual Towar Tow { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Kasa.cs b/Pcm.Db/Entities/Kasa.cs new file mode 100644 index 0000000..f15ab4b --- /dev/null +++ b/Pcm.Db/Entities/Kasa.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class Kasa +{ + public Kasa() + { + DokKasas = new HashSet(); + KasKods = new HashSet(); + KasPars = new HashSet(); + KasTows = new HashSet(); + KasaFormaPlatns = new HashSet(); + Paragons = new HashSet(); + ProfilKasas = new HashSet(); + Przydzials = new HashSet(); + Zlecenies = new HashSet(); + } + + public decimal KasaId { get; set; } + public decimal MagId { get; set; } + public short Numer { get; set; } + public string Nazwa { get; set; } + public short Rodzaj { get; set; } + public string Typ { get; set; } + public short Aktywny { get; set; } + public string Stanowisko { get; set; } + + public virtual Magazyn Mag { get; set; } + public virtual ICollection DokKasas { get; set; } + public virtual ICollection KasKods { get; set; } + public virtual ICollection KasPars { get; set; } + public virtual ICollection KasTows { get; set; } + public virtual ICollection KasaFormaPlatns { get; set; } + public virtual ICollection Paragons { get; set; } + public virtual ICollection ProfilKasas { get; set; } + public virtual ICollection Przydzials { get; set; } + public virtual ICollection Zlecenies { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/KasaFormaPlatn.cs b/Pcm.Db/Entities/KasaFormaPlatn.cs new file mode 100644 index 0000000..e477a05 --- /dev/null +++ b/Pcm.Db/Entities/KasaFormaPlatn.cs @@ -0,0 +1,13 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class KasaFormaPlatn +{ + public decimal FormaId { get; set; } + public decimal KasaId { get; set; } + public short Aktywny { get; set; } + + public virtual FormaPlatnPos7 Forma { get; set; } + public virtual Kasa Kasa { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/KatParam.cs b/Pcm.Db/Entities/KatParam.cs new file mode 100644 index 0000000..270fa8e --- /dev/null +++ b/Pcm.Db/Entities/KatParam.cs @@ -0,0 +1,14 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class KatParam +{ + public decimal KatId { get; set; } + public decimal ParId { get; set; } + public short Kolejnosc { get; set; } + public int WartDom { get; set; } + + public virtual Kategorium Kat { get; set; } + public virtual Parametr Par { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Kategorium.cs b/Pcm.Db/Entities/Kategorium.cs new file mode 100644 index 0000000..c9598c1 --- /dev/null +++ b/Pcm.Db/Entities/Kategorium.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class Kategorium +{ + public Kategorium() + { + KatParams = new HashSet(); + Towars = new HashSet(); + } + + public decimal KatId { get; set; } + public string Nazwa { get; set; } + public decimal? CentrKatId { get; set; } + + public virtual ICollection KatParams { get; set; } + public virtual ICollection Towars { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/KodDod.cs b/Pcm.Db/Entities/KodDod.cs new file mode 100644 index 0000000..de66f76 --- /dev/null +++ b/Pcm.Db/Entities/KodDod.cs @@ -0,0 +1,19 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class KodDod +{ + public decimal TowId { get; set; } + public short Kolejnosc { get; set; } + public string Skrot { get; set; } + public string Kod { get; set; } + public short PoziomCen { get; set; } + public int PrefPlu { get; set; } + public decimal? IleWkodzie { get; set; } + public short? TypKodu { get; set; } + public string SubsysKoduDod { get; set; } + public short? KodCentralny { get; set; } + + public virtual Towar Tow { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/KodWazony.cs b/Pcm.Db/Entities/KodWazony.cs new file mode 100644 index 0000000..3f35572 --- /dev/null +++ b/Pcm.Db/Entities/KodWazony.cs @@ -0,0 +1,18 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class KodWazony +{ + public decimal Kwid { get; set; } + public short Prefix { get; set; } + public string Nazwa { get; set; } + public short CzescStala { get; set; } + public short WartoscWkodzie { get; set; } + public short DodKontrola { get; set; } + public short PrecyzjaWkodzie { get; set; } + public decimal? CentrKwid { get; set; } + public decimal? Jmid { get; set; } + + public virtual Jm Jm { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Komentarz.cs b/Pcm.Db/Entities/Komentarz.cs new file mode 100644 index 0000000..8a87ebe --- /dev/null +++ b/Pcm.Db/Entities/Komentarz.cs @@ -0,0 +1,11 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class Komentarz +{ + public decimal ZmId { get; set; } + public string Opis { get; set; } + + public virtual Zmiana Zm { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Konfig.cs b/Pcm.Db/Entities/Konfig.cs new file mode 100644 index 0000000..3517acc --- /dev/null +++ b/Pcm.Db/Entities/Konfig.cs @@ -0,0 +1,10 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class Konfig +{ + public string ParGrupa { get; set; } + public string ParNazwa { get; set; } + public string ParWartosc { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/KontoBankowe.cs b/Pcm.Db/Entities/KontoBankowe.cs new file mode 100644 index 0000000..8c4ba85 --- /dev/null +++ b/Pcm.Db/Entities/KontoBankowe.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class KontoBankowe +{ + public KontoBankowe() + { + DokKontoBankowes = new HashSet(); + Oplata = new HashSet(); + } + + public decimal Kbid { get; set; } + public string Nazwa { get; set; } + public string Numer { get; set; } + public short Domyslne { get; set; } + public short Typ { get; set; } + public string Sufix { get; set; } + public decimal BankId { get; set; } + public decimal WalId { get; set; } + public decimal? PowKbid { get; set; } + public decimal? MagId { get; set; } + public short Aktywne { get; set; } + public DateTime Zmiana { get; set; } + public decimal? CentrKbid { get; set; } + + public virtual Bank Bank { get; set; } + public virtual Magazyn Mag { get; set; } + public virtual Walutum Wal { get; set; } + public virtual ICollection DokKontoBankowes { get; set; } + public virtual ICollection Oplata { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/KontoBankoweKontr.cs b/Pcm.Db/Entities/KontoBankoweKontr.cs new file mode 100644 index 0000000..3c3a4e0 --- /dev/null +++ b/Pcm.Db/Entities/KontoBankoweKontr.cs @@ -0,0 +1,23 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class KontoBankoweKontr +{ + public decimal Kbkid { get; set; } + public string Numer { get; set; } + public decimal KontrId { get; set; } + public string Nazwa { get; set; } + public short Typ { get; set; } + public short Domyslne { get; set; } + public short Aktywne { get; set; } + public short WykazVat { get; set; } + public decimal? PowKbkid { get; set; } + public decimal? BankId { get; set; } + public decimal WalId { get; set; } + public decimal? CentrKbkid { get; set; } + + public virtual Bank Bank { get; set; } + public virtual Kontrahent Kontr { get; set; } + public virtual Walutum Wal { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/KontoLoj.cs b/Pcm.Db/Entities/KontoLoj.cs new file mode 100644 index 0000000..3305b23 --- /dev/null +++ b/Pcm.Db/Entities/KontoLoj.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class KontoLoj +{ + public KontoLoj() + { + KartaLojs = new HashSet(); + PowKontLojNoweKontos = new HashSet(); + PowKontLojStareKontos = new HashSet(); + RegulaDoks = new HashSet(); + RegulaPars = new HashSet(); + SklepKontoLojs = new HashSet(); + SklepRegulaDoks = new HashSet(); + SklepRegulaPars = new HashSet(); + ZdarzLojs = new HashSet(); + } + + public decimal KontoId { get; set; } + public decimal KontrId { get; set; } + public short TypKonta { get; set; } + public short Aktywne { get; set; } + public string Nazwa { get; set; } + public decimal StanPocz { get; set; } + public decimal Stan { get; set; } + public DateTime ZmianaStanu { get; set; } + public DateTime Zmiana { get; set; } + public decimal? CentrKontoId { get; set; } + + public virtual Kontrahent Kontr { get; set; } + public virtual ICollection KartaLojs { get; set; } + public virtual ICollection PowKontLojNoweKontos { get; set; } + public virtual ICollection PowKontLojStareKontos { get; set; } + public virtual ICollection RegulaDoks { get; set; } + public virtual ICollection RegulaPars { get; set; } + public virtual ICollection SklepKontoLojs { get; set; } + public virtual ICollection SklepRegulaDoks { get; set; } + public virtual ICollection SklepRegulaPars { get; set; } + public virtual ICollection ZdarzLojs { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/KontrOpi.cs b/Pcm.Db/Entities/KontrOpi.cs new file mode 100644 index 0000000..e5f697f --- /dev/null +++ b/Pcm.Db/Entities/KontrOpi.cs @@ -0,0 +1,12 @@ +#nullable disable + +namespace Pcm.Db.Entities; + +public class KontrOpi +{ + public decimal KontrId { get; set; } + public short Znaczenie { get; set; } + public string Tekst { get; set; } + + public virtual Kontrahent Kontr { get; set; } +} \ No newline at end of file diff --git a/Pcm.Db/Entities/Kontrahent.cs b/Pcm.Db/Entities/Kontrahent.cs new file mode 100644 index 0000000..339f80c --- /dev/null +++ b/Pcm.Db/Entities/Kontrahent.cs @@ -0,0 +1,155 @@ +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; + +#nullable disable + +namespace Pcm.Db.Entities; + +public class Kontrahent +{ + public Kontrahent() + { + CentrStanZgodies = new HashSet(); + DokDodKths = new HashSet(); + DokKontrs = new HashSet(); + DostProdDosts = new HashSet(); + DostProdProds = new HashSet(); + Dostawcas = new HashSet(); + KontoBankoweKontrs = new HashSet(); + KontoLojs = new HashSet(); + KontrOpis = new HashSet(); + KthTypOs = new HashSet(); + KthWartoscs = new HashSet(); + NrRejs = new HashSet(); + OdbProdOdbs = new HashSet(); + OdbProdProds = new HashSet(); + Odbiorcas = new HashSet(); + OfSlowniks = new HashSet(); + Oferta = new HashSet(); + Osobas = new HashSet(); + PcfUserPcfCustomers = new HashSet(); + PcfUserPcfLoyaltyCustomers = new HashSet(); + PcfUserPcfPstations = new HashSet(); + Phodbiorcas = new HashSet(); + Phs = new HashSet(); + SklepKontrSkleps = new HashSet(); + SklepKontrs = new HashSet(); + SklepNarzDosts = new HashSet(); + StanZgodies = new HashSet(); + Towars = new HashSet(); + ZdarzOs = new HashSet(); + } + + public decimal KontrId { get; set; } + public decimal? AkwId { get; set; } + public string Nazwa { get; set; } + public string NaPrzelewie1 { get; set; } + public string NaPrzelewie2 { get; set; } + public string Skrot { get; set; } + public string Ulica { get; set; } + public string Kod { get; set; } + public string Miasto { get; set; } + public string Telefon { get; set; } + public string Fax { get; set; } + public string Email { get; set; } + public string Bank { get; set; } + public string Konto { get; set; } + public string Nip { get; set; } + public short Staly { get; set; } + public short Dostawca { get; set; } + public decimal RabatDost { get; set; } + public short FormaPlatDost { get; set; } + public short TermPlatDost { get; set; } + public short CzasRealZam { get; set; } + public short Producent { get; set; } + public short Odbiorca { get; set; } + public decimal RabatOdb { get; set; } + public short FormaPlatOdb { get; set; } + public short TermPlatOdb { get; set; } + public decimal MaxKredyt { get; set; } + public short MaxPoTermPlat { get; set; } + public string KodKarty { get; set; } + public short KartaAktywna { get; set; } + public DateTime TermWaznKarty { get; set; } + public short PoziomRabatu { get; set; } + public string NrAnalityki { get; set; } + public string KodKontr { get; set; } + public short ZakPracChron { get; set; } + public short Aktywny { get; set; } + public string Rezerwa1 { get; set; } + public string Rezerwa2 { get; set; } + public decimal? CentrKontrId { get; set; } + public DateTime Zmiana { get; set; } + public string IndeksCentr { get; set; } + public decimal? KontrKrajId { get; set; } + public string Poczta { get; set; } + public string NrDomu { get; set; } + public string NrLokalu { get; set; } + public short? Osoba { get; set; } + + [JsonIgnore] + public virtual Akwizytor Akw { get; set; } + [JsonIgnore] + public virtual Kraj KontrKraj { get; set; } + [JsonIgnore] + public virtual Sklep Sklep { get; set; } + [JsonIgnore] + public virtual ICollection CentrStanZgodies { get; set; } + [JsonIgnore] + public virtual ICollection DokDodKths { get; set; } + [JsonIgnore] + public virtual ICollection DokKontrs { get; set; } + [JsonIgnore] + public virtual ICollection DostProdDosts { get; set; } + [JsonIgnore] + public virtual ICollection DostProdProds { get; set; } + [JsonIgnore] + public virtual ICollection Dostawcas { get; set; } + [JsonIgnore] + public virtual ICollection KontoBankoweKontrs { get; set; } + [JsonIgnore] + public virtual ICollection KontoLojs { get; set; } + [JsonIgnore] + public virtual ICollection KontrOpis { get; set; } + [JsonIgnore] + public virtual ICollection KthTypOs { get; set; } + [JsonIgnore] + public virtual ICollection KthWartoscs { get; set; } + [JsonIgnore] + public virtual ICollection NrRejs { get; set; } + [JsonIgnore] + public virtual ICollection OdbProdOdbs { get; set; } + [JsonIgnore] + public virtual ICollection OdbProdProds { get; set; } + [JsonIgnore] + public virtual ICollection Odbiorcas { get; set; } + [JsonIgnore] + public virtual ICollection OfSlowniks { get; set; } + [JsonIgnore] + public virtual ICollection
404 – nie znaleziono strony