MailQueue
This commit is contained in:
20
StandManager.Domain/Entita/MailQueue.cs
Normal file
20
StandManager.Domain/Entita/MailQueue.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using StandManager.Domain.Entita.Base;
|
||||
|
||||
namespace StandManager.Domain.Entita;
|
||||
|
||||
public class MailQueue : EntitaBase
|
||||
{
|
||||
public string Subject { get; set; }
|
||||
public string Body { get; set; }
|
||||
public string ToList { get; set; }
|
||||
public string? Args { get; set; }
|
||||
public MailFrom From { get; set; }
|
||||
public bool Sent { get; set; }
|
||||
public string? Error { get; set; }
|
||||
}
|
||||
|
||||
public enum MailFrom
|
||||
{
|
||||
Invitation = 0,
|
||||
Confirmation = 1
|
||||
}
|
||||
@ -17,6 +17,7 @@ public class StandManagerDbContext : OAServiceContext
|
||||
public DbSet<Evento> Evento { get; set; }
|
||||
public DbSet<InvitoEvento> InvitoEvento { get; set; }
|
||||
public DbSet<IscrizioneEvento> IscrizioneEvento { get; set; }
|
||||
public DbSet<MailQueue> MailQueue { get; set; }
|
||||
public DbSet<Permission> Permission { get; set; }
|
||||
public DbSet<ProvinciaIstat> Province { get; set; }
|
||||
public DbSet<Referente> Referente { get; set; }
|
||||
|
||||
1278
StandManager.Infrastructure/Migrations/20260109133732_MailQueue.Designer.cs
generated
Normal file
1278
StandManager.Infrastructure/Migrations/20260109133732_MailQueue.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace StandManager.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class MailQueue : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "MailQueue",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Subject = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Body = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
ToList = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Args = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
From = table.Column<int>(type: "int", nullable: false),
|
||||
Sent = table.Column<bool>(type: "bit", nullable: false),
|
||||
Error = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
DataCreazione = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
DataModifica = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
Eliminato = table.Column<bool>(type: "bit", nullable: false),
|
||||
IdUtenteCreazione = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
IdUtenteModifica = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_MailQueue", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_MailQueue_Utente_IdUtenteCreazione",
|
||||
column: x => x.IdUtenteCreazione,
|
||||
principalTable: "Utente",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_MailQueue_Utente_IdUtenteModifica",
|
||||
column: x => x.IdUtenteModifica,
|
||||
principalTable: "Utente",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MailQueue_IdUtenteCreazione",
|
||||
table: "MailQueue",
|
||||
column: "IdUtenteCreazione");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MailQueue_IdUtenteModifica",
|
||||
table: "MailQueue",
|
||||
column: "IdUtenteModifica");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "MailQueue");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -508,6 +508,60 @@ namespace StandManager.Infrastructure.Migrations
|
||||
b.ToTable("IscrizioneEvento");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("StandManager.Domain.Entita.MailQueue", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Args")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Body")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("DataCreazione")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DataModifica")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<bool>("Eliminato")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("Error")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("From")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<Guid?>("IdUtenteCreazione")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("IdUtenteModifica")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<bool>("Sent")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("Subject")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("ToList")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IdUtenteCreazione");
|
||||
|
||||
b.HasIndex("IdUtenteModifica");
|
||||
|
||||
b.ToTable("MailQueue");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("StandManager.Domain.Entita.Permission", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@ -1030,6 +1084,21 @@ namespace StandManager.Infrastructure.Migrations
|
||||
b.Navigation("UtenteModifica");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("StandManager.Domain.Entita.MailQueue", b =>
|
||||
{
|
||||
b.HasOne("StandManager.Domain.Entita.Utente", "UtenteCreazione")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdUtenteCreazione");
|
||||
|
||||
b.HasOne("StandManager.Domain.Entita.Utente", "UtenteModifica")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdUtenteModifica");
|
||||
|
||||
b.Navigation("UtenteCreazione");
|
||||
|
||||
b.Navigation("UtenteModifica");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("StandManager.Domain.Entita.Permission", b =>
|
||||
{
|
||||
b.HasOne("StandManager.Domain.Entita.Feature", "Feature")
|
||||
|
||||
18
StandManager.MailProcessor/MailProcessor.cs
Normal file
18
StandManager.MailProcessor/MailProcessor.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using StandManager.Service.Interfaces;
|
||||
|
||||
public class MailProcessor
|
||||
{
|
||||
private readonly IManagerService _managerService;
|
||||
|
||||
public MailProcessor(IManagerService managerService)
|
||||
{
|
||||
_managerService = managerService;
|
||||
}
|
||||
|
||||
public async Task Process()
|
||||
{
|
||||
var list = await _managerService.MailQueueService.RicercaQueryable(x =>
|
||||
x.Eliminato == false && x.Sent == false);
|
||||
var a = list;
|
||||
}
|
||||
}
|
||||
38
StandManager.MailProcessor/Program.cs
Normal file
38
StandManager.MailProcessor/Program.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System.Reflection;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using StandManager.Infrastructure.DAL.Context;
|
||||
using StandManager.Service;
|
||||
using StandManager.Service.Interfaces;
|
||||
using StandManager.Service.Repository;
|
||||
|
||||
var host = Host.CreateDefaultBuilder(args)
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
//DI
|
||||
var types = Assembly.Load("StandManager.Service").GetTypes();
|
||||
var allProviderTypes = types.Where(t => t.Namespace != null && (t.FullName?.EndsWith("Service") ?? false)).ToList();
|
||||
foreach (var intfc in allProviderTypes.Where(t => t.IsInterface))
|
||||
{
|
||||
var impl = allProviderTypes.FirstOrDefault(c => c.IsClass && intfc.Name[1..] == c.Name);
|
||||
if (impl != null) services.AddScoped(intfc, impl);
|
||||
}
|
||||
//Database
|
||||
var connectionString = context.Configuration.GetConnectionString("ConnectionString");
|
||||
services.AddDbContext<StandManagerDbContext>(options =>
|
||||
options.UseSqlServer(connectionString)
|
||||
);
|
||||
|
||||
services.AddScoped(typeof(IStandManagerGenericRepository<>), typeof(StandManagerGenericRepository<>));
|
||||
services.AddScoped<IStandManagerUnitOfWork, StandManagerUnitOfWork>();
|
||||
services.AddScoped<IManagerService, ManagerService>();
|
||||
|
||||
services.AddScoped<MailProcessor>();
|
||||
})
|
||||
.Build();
|
||||
|
||||
using var scope = host.Services.CreateScope();
|
||||
var processor = scope.ServiceProvider.GetRequiredService<MailProcessor>();
|
||||
processor.Process();
|
||||
40
StandManager.MailProcessor/StandManager.MailProcessor.csproj
Normal file
40
StandManager.MailProcessor/StandManager.MailProcessor.csproj
Normal file
@ -0,0 +1,40 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\StandManager.Infrastructure\StandManager.Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\StandManager.Service\StandManager.Service.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="OAService.Domain">
|
||||
<HintPath>..\Libs\OAService.Domain.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OAService.Infrastructure">
|
||||
<HintPath>..\Libs\OAService.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OAService.Service">
|
||||
<HintPath>..\Libs\OAService.Service.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.1.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.11" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.11" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.11" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
12
StandManager.MailProcessor/appsettings.json
Normal file
12
StandManager.MailProcessor/appsettings.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"ConnectionString": "Data Source=192.168.0.233\\SQL2019;Initial Catalog=DAC_StandManager;Persist Security Info=True;User ID=dac_user;Password=KZ4ZrUPzJV;TrustServerCertificate=True"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
8
StandManager.Service/Interfaces/IMailQueueService.cs
Normal file
8
StandManager.Service/Interfaces/IMailQueueService.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using OAService.Service.Servizi.Interfacce;
|
||||
using StandManager.Domain.Entita;
|
||||
|
||||
namespace StandManager.Service.Interfaces;
|
||||
|
||||
public interface IMailQueueService : ITService<MailQueue>
|
||||
{
|
||||
}
|
||||
@ -9,6 +9,7 @@
|
||||
public IFeatureService FeatureService{ get; set; }
|
||||
public IInvitoEventoService InvitoEventoService{ get; set; }
|
||||
public IIscrizioneEventoService IscrizioneEventoService{ get; set; }
|
||||
public IMailQueueService MailQueueService{ get; set; }
|
||||
public IPermissionService PermissionService{ get; set; }
|
||||
public IProvinciaIstatService ProvinciaIstatService{ get; set; }
|
||||
public IReferenteService ReferenteService{ get; set; }
|
||||
|
||||
16
StandManager.Service/MailQueueService.cs
Normal file
16
StandManager.Service/MailQueueService.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using OAService.Service.Servizi.Implementazioni;
|
||||
using StandManager.Domain.Entita;
|
||||
using StandManager.Service.Interfaces;
|
||||
using StandManager.Service.Repository;
|
||||
|
||||
namespace StandManager.Service;
|
||||
|
||||
public class MailQueueService : TService<MailQueue>, IMailQueueService
|
||||
{
|
||||
private readonly IStandManagerUnitOfWork _unitOfWork;
|
||||
|
||||
public MailQueueService(IStandManagerUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ public class ManagerService : IManagerService
|
||||
public ManagerService(IUtenteService utenteService, IClienteService clienteService, IComuneIstatService comuneIstatService, IDestinazioneService destinazioneService,
|
||||
IEventoService eventoService, IInvitoEventoService invitoEventoService, IIscrizioneEventoService iscrizioneEventoService, IReferenteService referenteService,
|
||||
ITipologiaClienteService tipologiaClienteService, IFeatureService featureService, IPermissionService permissionService, IRuoloService ruoloService,
|
||||
ISezioneService sezioneService, IProvinciaIstatService provinciaIstatService)
|
||||
ISezioneService sezioneService, IProvinciaIstatService provinciaIstatService, IMailQueueService mailQueueService)
|
||||
{
|
||||
UtenteService = utenteService;
|
||||
ClienteService = clienteService;
|
||||
@ -23,6 +23,7 @@ public class ManagerService : IManagerService
|
||||
RuoloService = ruoloService;
|
||||
SezioneService = sezioneService;
|
||||
ProvinciaIstatService = provinciaIstatService;
|
||||
MailQueueService = mailQueueService;
|
||||
}
|
||||
|
||||
public IUtenteService UtenteService { get; set; }
|
||||
@ -32,6 +33,7 @@ public class ManagerService : IManagerService
|
||||
public IFeatureService FeatureService { get; set; }
|
||||
public IInvitoEventoService InvitoEventoService{ get; set; }
|
||||
public IIscrizioneEventoService IscrizioneEventoService { get; set; }
|
||||
public IMailQueueService MailQueueService { get; set; }
|
||||
public IPermissionService PermissionService { get; set; }
|
||||
public IProvinciaIstatService ProvinciaIstatService { get; set; }
|
||||
public IReferenteService ReferenteService { get; set; }
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<Solution>
|
||||
<Project Path="StandManager.Domain/StandManager.Domain.csproj" />
|
||||
<Project Path="StandManager.Infrastructure/StandManager.Infrastructure.csproj" />
|
||||
<Project Path="StandManager.MailProcessor/StandManager.MailProcessor.csproj" />
|
||||
<Project Path="StandManager.Service/StandManager.Service.csproj" />
|
||||
<Project Path="StandManager/StandManager.csproj" />
|
||||
</Solution>
|
||||
|
||||
Reference in New Issue
Block a user