Saving the mail logs in mongodb rather than my sql
This commit is contained in:
parent
9b8bb5d0cb
commit
a0a65fc08c
@ -55,7 +55,7 @@ namespace Marco.Pms.DataAccess.Data
|
|||||||
public DbSet<Document> Documents { get; set; }
|
public DbSet<Document> Documents { get; set; }
|
||||||
public DbSet<MailingList> MailingList { get; set; }
|
public DbSet<MailingList> MailingList { get; set; }
|
||||||
public DbSet<MailDetails> MailDetails { get; set; }
|
public DbSet<MailDetails> MailDetails { get; set; }
|
||||||
public DbSet<MailLog> MailLogs { get; set; }
|
//public DbSet<MailLog> MailLogs { get; set; }
|
||||||
public DbSet<OTPDetails> OTPDetails { get; set; }
|
public DbSet<OTPDetails> OTPDetails { get; set; }
|
||||||
public DbSet<MPINDetails> MPINDetails { get; set; }
|
public DbSet<MPINDetails> MPINDetails { get; set; }
|
||||||
public DbSet<FCMTokenMapping> FCMTokenMappings { get; set; }
|
public DbSet<FCMTokenMapping> FCMTokenMappings { get; set; }
|
||||||
|
|||||||
9453
Marco.Pms.DataAccess/Migrations/20251206102239_Removed_MaiLogs_Table.Designer.cs
generated
Normal file
9453
Marco.Pms.DataAccess/Migrations/20251206102239_Removed_MaiLogs_Table.Designer.cs
generated
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,42 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Marco.Pms.DataAccess.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Removed_MaiLogs_Table : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "MailLogs");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "MailLogs",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
Body = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
EmailId = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
EmployeeId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
ProjectId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
TimeStamp = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_MailLogs", x => x.Id);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3171,37 +3171,6 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
b.ToTable("MailDetails");
|
b.ToTable("MailDetails");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Marco.Pms.Model.Mail.MailLog", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("char(36)");
|
|
||||||
|
|
||||||
b.Property<string>("Body")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<string>("EmailId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<Guid?>("EmployeeId")
|
|
||||||
.HasColumnType("char(36)");
|
|
||||||
|
|
||||||
b.Property<Guid>("ProjectId")
|
|
||||||
.HasColumnType("char(36)");
|
|
||||||
|
|
||||||
b.Property<Guid>("TenantId")
|
|
||||||
.HasColumnType("char(36)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("TimeStamp")
|
|
||||||
.HasColumnType("datetime(6)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("MailLogs");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Marco.Pms.Model.Mail.MailingList", b =>
|
modelBuilder.Entity("Marco.Pms.Model.Mail.MailingList", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
|
|||||||
34
Marco.Pms.Helpers/Utility/MailLogHelper.cs
Normal file
34
Marco.Pms.Helpers/Utility/MailLogHelper.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using Marco.Pms.Model.Mail;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Helpers.Utility
|
||||||
|
{
|
||||||
|
public class MailLogHelper
|
||||||
|
{
|
||||||
|
private readonly IMongoCollection<MailLog> _collection;
|
||||||
|
private readonly ILogger<MailLogHelper> _logger;
|
||||||
|
public MailLogHelper(IConfiguration configuration, ILogger<MailLogHelper> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
var connectionString = configuration["MongoDB:MailConnectionString"];
|
||||||
|
var mongoUrl = new MongoUrl(connectionString);
|
||||||
|
var client = new MongoClient(mongoUrl); // Your MongoDB connection string
|
||||||
|
var mongoDB = client.GetDatabase(mongoUrl.DatabaseName); // Your MongoDB Database name
|
||||||
|
_collection = mongoDB.GetCollection<MailLog>("MailLogs");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AddWebMenuItemAsync(List<MailLog> mailLogs)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _collection.InsertManyAsync(mailLogs);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error occurred while adding Mail Logs.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using Marco.Pms.DataAccess.Data;
|
using Marco.Pms.DataAccess.Data;
|
||||||
|
using Marco.Pms.Helpers.Utility;
|
||||||
using Marco.Pms.Model.Dtos.Attendance;
|
using Marco.Pms.Model.Dtos.Attendance;
|
||||||
using Marco.Pms.Model.Employees;
|
using Marco.Pms.Model.Employees;
|
||||||
using Marco.Pms.Model.Mail;
|
using Marco.Pms.Model.Mail;
|
||||||
@ -17,12 +18,14 @@ namespace Marco.Pms.Services.Helpers
|
|||||||
private readonly IEmailSender _emailSender;
|
private readonly IEmailSender _emailSender;
|
||||||
private readonly ILoggingService _logger;
|
private readonly ILoggingService _logger;
|
||||||
private readonly CacheUpdateHelper _cache;
|
private readonly CacheUpdateHelper _cache;
|
||||||
public ReportHelper(ApplicationDbContext context, IEmailSender emailSender, ILoggingService logger, CacheUpdateHelper cache)
|
private readonly MailLogHelper _mailLogger;
|
||||||
|
public ReportHelper(ApplicationDbContext context, IEmailSender emailSender, ILoggingService logger, CacheUpdateHelper cache, MailLogHelper mailLogger)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_emailSender = emailSender;
|
_emailSender = emailSender;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_cache = cache;
|
_cache = cache;
|
||||||
|
_mailLogger = mailLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ProjectStatisticReport?> GetDailyProjectReportWithOutTenant(Guid projectId, DateTime reportDate)
|
public async Task<ProjectStatisticReport?> GetDailyProjectReportWithOutTenant(Guid projectId, DateTime reportDate)
|
||||||
@ -599,7 +602,8 @@ namespace Marco.Pms.Services.Helpers
|
|||||||
TenantId = tenantId
|
TenantId = tenantId
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
_context.MailLogs.AddRange(mailLogs);
|
//_context.MailLogs.AddRange(mailLogs);
|
||||||
|
await _mailLogger.AddWebMenuItemAsync(mailLogs);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@ -212,6 +212,7 @@ builder.Services.AddScoped<EmployeeCache>();
|
|||||||
builder.Services.AddScoped<ReportCache>();
|
builder.Services.AddScoped<ReportCache>();
|
||||||
builder.Services.AddScoped<ExpenseCache>();
|
builder.Services.AddScoped<ExpenseCache>();
|
||||||
builder.Services.AddScoped<SidebarMenuHelper>();
|
builder.Services.AddScoped<SidebarMenuHelper>();
|
||||||
|
builder.Services.AddScoped<MailLogHelper>();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// Singleton services (one instance for the app's lifetime)
|
// Singleton services (one instance for the app's lifetime)
|
||||||
|
|||||||
@ -42,7 +42,8 @@
|
|||||||
"MongoDB": {
|
"MongoDB": {
|
||||||
"SerilogDatabaseUrl": "mongodb://devuser:DevPass123@147.93.98.152:27017/DotNetLogsLocalDev?authSource=admin&eplicaSet=rs01&directConnection=true",
|
"SerilogDatabaseUrl": "mongodb://devuser:DevPass123@147.93.98.152:27017/DotNetLogsLocalDev?authSource=admin&eplicaSet=rs01&directConnection=true",
|
||||||
"ConnectionString": "mongodb://devuser:DevPass123@147.93.98.152:27017/MarcoBMSLocalCache?authSource=admin&eplicaSet=rs01&directConnection=true&socketTimeoutMS=500&serverSelectionTimeoutMS=500&connectTimeoutMS=500",
|
"ConnectionString": "mongodb://devuser:DevPass123@147.93.98.152:27017/MarcoBMSLocalCache?authSource=admin&eplicaSet=rs01&directConnection=true&socketTimeoutMS=500&serverSelectionTimeoutMS=500&connectTimeoutMS=500",
|
||||||
"ModificationConnectionString": "mongodb://devuser:DevPass123@147.93.98.152:27017/MarcoBMSLocalDev?authSource=admin&eplicaSet=rs01&directConnection=true"
|
"ModificationConnectionString": "mongodb://devuser:DevPass123@147.93.98.152:27017/MarcoBMSLocalDev?authSource=admin&eplicaSet=rs01&directConnection=true",
|
||||||
|
"MailConnectionString": "mongodb://devuser:DevPass123@147.93.98.152:27017/MailLogsLocalDev?authSource=admin&eplicaSet=rs01&directConnection=true"
|
||||||
},
|
},
|
||||||
"Razorpay": {
|
"Razorpay": {
|
||||||
"Key": "rzp_test_RXCzgEcXucbuAi",
|
"Key": "rzp_test_RXCzgEcXucbuAi",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user