2020-10-06 11:38:15 +00:00
|
|
|
|
using ASC.Common;
|
2019-12-18 12:24:22 +00:00
|
|
|
|
using ASC.Core.Common.EF.Model;
|
2019-12-05 08:51:28 +00:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2020-10-06 11:38:15 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2019-12-05 08:51:28 +00:00
|
|
|
|
|
|
|
|
|
namespace ASC.Core.Common.EF.Context
|
|
|
|
|
{
|
2020-10-06 11:38:15 +00:00
|
|
|
|
public class MySqlMessagesContext : MessagesContext { }
|
|
|
|
|
public class PostgreSqlMessagesContext : MessagesContext { }
|
2020-10-05 09:27:15 +00:00
|
|
|
|
public class MessagesContext : BaseDbContext
|
2019-12-05 08:51:28 +00:00
|
|
|
|
{
|
|
|
|
|
public DbSet<AuditEvent> AuditEvents { get; set; }
|
|
|
|
|
public DbSet<LoginEvents> LoginEvents { get; set; }
|
|
|
|
|
public DbSet<DbTenant> Tenants { get; set; }
|
|
|
|
|
public DbSet<DbWebstudioSettings> WebstudioSettings { get; set; }
|
|
|
|
|
|
2020-10-06 11:38:15 +00:00
|
|
|
|
protected override Dictionary<Provider, Func<BaseDbContext>> ProviderContext
|
2019-12-05 08:51:28 +00:00
|
|
|
|
{
|
2020-10-06 11:38:15 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return new Dictionary<Provider, Func<BaseDbContext>>()
|
|
|
|
|
{
|
|
|
|
|
{ Provider.MySql, () => new MySqlMessagesContext() } ,
|
2020-10-08 09:07:05 +00:00
|
|
|
|
{ Provider.Postgre, () => new PostgreSqlMessagesContext() } ,
|
2020-10-06 11:38:15 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-05 09:27:15 +00:00
|
|
|
|
|
2020-10-06 11:38:15 +00:00
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
2020-09-06 22:49:03 +00:00
|
|
|
|
modelBuilder.AddDbFunction();
|
2020-10-05 09:27:15 +00:00
|
|
|
|
|
2020-09-06 22:49:03 +00:00
|
|
|
|
ModelBuilderWrapper
|
|
|
|
|
.From(modelBuilder, Provider)
|
|
|
|
|
.AddDbTenant()
|
|
|
|
|
.AddWebstudioSettings()
|
|
|
|
|
.AddAuditEvent()
|
2020-10-05 10:02:28 +00:00
|
|
|
|
.AddLoginEvents();
|
2019-12-05 08:51:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class MessagesContextExtension
|
|
|
|
|
{
|
2020-02-17 08:58:14 +00:00
|
|
|
|
public static DIHelper AddMessagesContextService(this DIHelper services)
|
2019-12-05 08:51:28 +00:00
|
|
|
|
{
|
2019-12-10 15:06:51 +00:00
|
|
|
|
return services.AddDbContextManagerService<MessagesContext>();
|
2019-12-05 08:51:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|