-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
1,308 additions
and
0 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
MaxiSolution/MaxiSolution/src/com.maxi.checks.Repository/ApplicationDbContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using Maxi.Services.SouthSide.Data.Entities; | ||
using Microsoft.EntityFrameworkCore; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Maxi.Services.SouthSide.Data | ||
{ | ||
public class ApplicationDbContext : DbContext | ||
{ | ||
private DbSet<ServiceConfiguration> _servicesConfiguration; | ||
private DbSet<ServiceAttribute> _attributes; | ||
private DbSet<GlobalAttributes> _globalAttributes; | ||
|
||
public DbSet<ServiceConfiguration> ServicesConfiguration | ||
{ | ||
get | ||
{ | ||
if (_servicesConfiguration == null) | ||
_servicesConfiguration = Set<ServiceConfiguration>(); | ||
return _servicesConfiguration; | ||
} | ||
} | ||
|
||
public DbSet<ServiceAttribute> Attributes | ||
{ | ||
get | ||
{ | ||
if (_attributes == null) | ||
_attributes = Set<ServiceAttribute>(); | ||
return _attributes; | ||
} | ||
|
||
} | ||
|
||
public DbSet<GlobalAttributes> GlobalAttributes | ||
{ | ||
get | ||
{ | ||
if (_globalAttributes == null) | ||
_globalAttributes = Set<GlobalAttributes>(); | ||
return _globalAttributes; | ||
} | ||
} | ||
|
||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) | ||
: base(options) | ||
{ | ||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
if (modelBuilder != null) | ||
{ | ||
// base.OnModelCreating(modelBuilder); | ||
//modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>(); | ||
|
||
|
||
foreach (var entityType in modelBuilder.Model.GetEntityTypes()) | ||
{ | ||
// equivalent of modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>(); | ||
entityType.GetForeignKeys() | ||
.Where(fk => !fk.IsOwnership && fk.DeleteBehavior == DeleteBehavior.Cascade) | ||
.ToList() | ||
.ForEach(fk => fk.DeleteBehavior = DeleteBehavior.Restrict); | ||
} | ||
|
||
// TODO | ||
//modelBuilder.Conventions.Remove<IncludeMetadataConvention>(); | ||
|
||
|
||
//modelBuilder.Configurations.Add(new ServiceConfiguationScheduleTypeConfiguration()); | ||
//modelBuilder.Configurations.Add(new ServiceConfigurationTickTypeConfiguration()); | ||
//modelBuilder.Configurations.Add(new ServiceConfigurationTypeConfiguration()); | ||
//modelBuilder.Configurations.Add(new ServiceAttributeTypeConfiguration()); | ||
//modelBuilder.Configurations.Add(new GlobalAttributesTypeConfiguration()); | ||
//modelBuilder.Configurations.Add(new ServiceScheduleTypeConfiguration()); | ||
|
||
modelBuilder.Entity<ServiceConfiguration>().ToTable("ServiceConfiguration", "Services"); | ||
modelBuilder.Entity<ServiceConfiguration>().HasKey(c => c.Code); | ||
modelBuilder.Entity<ServiceAttribute>().ToTable("ServiceAttributes", "Services"); | ||
modelBuilder.Entity<ServiceAttribute>().HasKey(c => new { c.Code, c.Key}); | ||
modelBuilder.Entity<GlobalAttributes>().ToTable("GlobalAttributes"); | ||
modelBuilder.Entity<GlobalAttributes>().HasKey(c => c.Name); | ||
|
||
|
||
} | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
MaxiSolution/MaxiSolution/src/com.maxi.checks.Repository/Configurations/AppSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Placeholder for "MaxiSolution\src\"com.maxi.checks.Repository"\Configurations\AppSettings.json" |
1 change: 1 addition & 0 deletions
1
MaxiSolution/MaxiSolution/src/com.maxi.checks.Repository/Interfaces/IRepositoryService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Placeholder for "MaxiSolution\src\"com.maxi.checks.Repository"\Interfaces\I"com.maxi.checks.Repository"Service.cs" |
64 changes: 64 additions & 0 deletions
64
MaxiSolution/MaxiSolution/src/com.maxi.checks.Repository/Messaging/RabbitMQMessaging.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using RabbitMQ.Client; | ||
using RabbitMQ.Client.Events; | ||
using System; | ||
using System.Text; | ||
|
||
namespace com.maxi.checks.Repository.Messaging | ||
{ | ||
public class RabbitMQMessaging | ||
{ | ||
private readonly IConnection _connection; | ||
private readonly IModel _channel; | ||
|
||
public RabbitMQMessaging() | ||
{ | ||
var factory = new ConnectionFactory() { HostName = "localhost" }; | ||
_connection = factory.CreateConnection(); | ||
_channel = _connection.CreateModel(); | ||
} | ||
|
||
public void SendMessage(string queueName, string message) | ||
{ | ||
_channel.QueueDeclare(queue: queueName, | ||
durable: false, | ||
exclusive: false, | ||
autoDelete: false, | ||
arguments: null); | ||
|
||
var body = Encoding.UTF8.GetBytes(message); | ||
|
||
_channel.BasicPublish(exchange: "", | ||
routingKey: queueName, | ||
basicProperties: null, | ||
body: body); | ||
Console.WriteLine(" [x] Sent {0}", message); | ||
} | ||
|
||
public void ReceiveMessage(string queueName) | ||
{ | ||
_channel.QueueDeclare(queue: queueName, | ||
durable: false, | ||
exclusive: false, | ||
autoDelete: false, | ||
arguments: null); | ||
|
||
var consumer = new EventingBasicConsumer(_channel); | ||
consumer.Received += (model, ea) => | ||
{ | ||
var body = ea.Body.ToArray(); | ||
var message = Encoding.UTF8.GetString(body); | ||
Console.WriteLine(" [x] Received {0}", message); | ||
}; | ||
_channel.BasicConsume(queue: queueName, | ||
autoAck: true, | ||
consumer: consumer); | ||
} | ||
|
||
public void Close() | ||
{ | ||
_channel.Close(); | ||
_connection.Close(); | ||
} | ||
} | ||
} | ||
|
1 change: 1 addition & 0 deletions
1
MaxiSolution/MaxiSolution/src/com.maxi.checks.Repository/Models/RepositoryModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Placeholder for "MaxiSolution\src\"com.maxi.checks.Repository"\Models\"com.maxi.checks.Repository"Model.cs" |
1 change: 1 addition & 0 deletions
1
MaxiSolution/MaxiSolution/src/com.maxi.checks.Repository/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Placeholder for "MaxiSolution\src\"com.maxi.checks.Repository"\Program.cs" |
Oops, something went wrong.