emailjobs #21
+1
-1
@@ -41,7 +41,7 @@ steps:
|
||||
\"tag_name\": \"$VERSION\",
|
||||
\"target_commitish\": \"${DRONE_COMMIT_SHA}\",
|
||||
\"name\": \"Library Suite $VERSION\",
|
||||
\"body\": \"### Published NuGet Packages\nAll packages versioned as **$VERSION**:\n* LiteCharms.Abstractions\n* LiteCharms.Features\n\n[View in Nexus](https://nexus.khongisa.co.za/repository/nuget-group/)\",
|
||||
\"body\": \"### Published NuGet Packages\nAll packages versioned as **$VERSION**:\n* LiteCharms.Features\n\n[View in Nexus](https://nexus.khongisa.co.za/repository/nuget-group/)\",
|
||||
\"draft\": false,
|
||||
\"prerelease\": false
|
||||
}"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using LiteCharms.Features.Abstractions;
|
||||
using LiteCharms.Features.Quartz.Abstractions;
|
||||
using static LiteCharms.Features.Extensions.Timezones;
|
||||
|
||||
namespace LiteCharms.Features.Quartz;
|
||||
|
||||
@@ -47,12 +46,12 @@ public class JobOrchestrator(ISchedulerFactory schedulerFactory) : IJobOrchestra
|
||||
.StoreDurably()
|
||||
.Build();
|
||||
|
||||
var now = SouthAfricanTimeZone.UtcNow();
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
var trigger = global::Quartz.TriggerBuilder.Create()
|
||||
.WithIdentity(triggerKey)
|
||||
.WithDescription($"Scheduled via Main Job at {now:g}")
|
||||
.WithCronSchedule(cronExpression, cron => cron.InTimeZone(SouthAfricanTimeZone)
|
||||
.WithDescription($"Scheduled via Main Job at {now:g} UTC")
|
||||
.WithCronSchedule(cronExpression, cron => cron
|
||||
.WithMisfireHandlingInstructionFireAndProceed())
|
||||
.StartAt(now)
|
||||
.Build();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using LiteCharms.Features.Abstractions;
|
||||
using LiteCharms.Features.Mediator;
|
||||
|
||||
namespace LiteCharms.Features.Quartz;
|
||||
|
||||
@@ -13,9 +14,12 @@ public class MediatorJob<TNotification>(IMediator mediator) : IJob where TNotifi
|
||||
|
||||
var notification = JsonSerializer.Deserialize<TNotification>(data);
|
||||
|
||||
if(notification is null) return;
|
||||
if (notification is null) return;
|
||||
|
||||
using var activity = MediatorTelemetry.Source.StartActivity($"Quartz: {typeof(TNotification).Name}");
|
||||
|
||||
activity?.SetTag("event.correlation_id", notification.CorrelationId);
|
||||
|
||||
if(notification is TNotification)
|
||||
await mediator.Publish(notification, context.CancellationToken);
|
||||
await mediator.Publish(notification, context.CancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ public class PackageService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||
|
||||
var newPackage = context.Packages.Add(new Entities.Package
|
||||
{
|
||||
UpdatedAt = null,
|
||||
Name = name,
|
||||
Summary = summary,
|
||||
Description = description,
|
||||
@@ -206,7 +205,7 @@ public class PackageService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||
package.Summary = summary;
|
||||
package.Description = description;
|
||||
package.ImageUrl = ImageUrl;
|
||||
package.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
||||
package.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||
? Result.Ok()
|
||||
|
||||
@@ -103,6 +103,7 @@ public class LeadService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||
return Result.Fail(new Error($"Lead with ID {leadId} not found."));
|
||||
|
||||
lead.Status = status;
|
||||
lead.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||
? Result.Ok()
|
||||
|
||||
+4
-5
@@ -1,7 +1,6 @@
|
||||
using LiteCharms.Features.Email;
|
||||
using LiteCharms.Features.Shop.Notifications.Entities;
|
||||
using LiteCharms.Features.Shop.Notifications.Models;
|
||||
using LiteCharms.Features.Shop.Postgres;
|
||||
using static LiteCharms.Features.Extensions.Timezones;
|
||||
|
||||
namespace LiteCharms.Features.Shop.Notifications.Events.Handlers;
|
||||
|
||||
@@ -17,8 +16,8 @@ public class ProcessEmailNotificationsEventHandler(IDbContextFactory<ShopDbConte
|
||||
using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||
|
||||
var notifications = await context.Notifications
|
||||
.OrderByDescending(o => o.Priority)
|
||||
.ThenBy(o => o.CreatedAt)
|
||||
.OrderByDescending(o => o.CreatedAt)
|
||||
.ThenBy(o => o.Priority)
|
||||
.Where(n => n.CorrelationIdType == CorrelationIdTypes.Email)
|
||||
.Where(n => n.Direction == NotificationDirection.Outgoing)
|
||||
.Take(message.MaxRecords)
|
||||
@@ -44,7 +43,7 @@ public class ProcessEmailNotificationsEventHandler(IDbContextFactory<ShopDbConte
|
||||
}
|
||||
|
||||
notification.Processed = true;
|
||||
notification.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
||||
notification.UpdatedAt = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
await context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using LiteCharms.Features.Models;
|
||||
using LiteCharms.Features.Shop.Orders.Models;
|
||||
using LiteCharms.Features.Shop.Postgres;
|
||||
using static LiteCharms.Features.Extensions.Timezones;
|
||||
|
||||
namespace LiteCharms.Features.Shop.Orders;
|
||||
|
||||
@@ -241,7 +240,7 @@ public class OrderService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||
return Result.Fail(new Error($"Order {request.OrderId} not found"));
|
||||
|
||||
order.Status = request.Status;
|
||||
order.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
||||
order.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(request.InvoiceUrl)) order.InvoiceUrl = request.InvoiceUrl;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using LiteCharms.Features.Extensions;
|
||||
using LiteCharms.Features.Shop.Postgres;
|
||||
using LiteCharms.Features.Shop.Products.Models;
|
||||
using static LiteCharms.Features.Extensions.Timezones;
|
||||
|
||||
namespace LiteCharms.Features.Shop.Products;
|
||||
|
||||
@@ -19,7 +18,7 @@ public class ProductService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||
return Result.Fail($"Could not find product price with ID {productPriceId}");
|
||||
|
||||
price.Active = active;
|
||||
price.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
||||
price.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||
? Result.Ok()
|
||||
@@ -200,7 +199,7 @@ public class ProductService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||
return Result.Fail($"Could not find product price with ID {productPriceId}");
|
||||
|
||||
existingPrice.Active = false;
|
||||
existingPrice.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
||||
existingPrice.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
if (!(await context.SaveChangesAsync(cancellationToken) > 0))
|
||||
return Result.Fail<Guid>($"Failed to deactivate existing price of ID {productPriceId}, try again later");
|
||||
@@ -212,7 +211,7 @@ public class ProductService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||
var deactivatedPrice = await context.ProductPrices.FirstOrDefaultAsync(p => p.Id == productPriceId, cancellationToken);
|
||||
|
||||
existingPrice.Active = true;
|
||||
existingPrice.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
||||
existingPrice.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||
? Result.Fail<Guid>("Reverted to old price, creation of new price failed")
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using LiteCharms.Features.Models;
|
||||
using LiteCharms.Features.Shop.Postgres;
|
||||
using LiteCharms.Features.Shop.Quotes.Models;
|
||||
using static LiteCharms.Features.Extensions.Timezones;
|
||||
|
||||
namespace LiteCharms.Features.Shop.Quotes;
|
||||
|
||||
@@ -26,6 +25,7 @@ public class QuoteService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||
return Result.Fail(new Error($"Quote with id {quoteId} is already assigned to order with id {orderId}"));
|
||||
|
||||
quote.OrderId = orderId;
|
||||
quote.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||
? Result.Ok()
|
||||
@@ -52,6 +52,7 @@ public class QuoteService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||
return Result.Fail(new Error($"Shopping Cart with id {shoppingCartId} not found"));
|
||||
|
||||
quote.ShoppingCartId = shoppingCartId;
|
||||
quote.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||
? Result.Ok()
|
||||
@@ -140,7 +141,7 @@ public class QuoteService(IDbContextFactory<ShopDbContext> contextFactory)
|
||||
return Result.Fail(new Error("Quote not found."));
|
||||
|
||||
quote.Status = status;
|
||||
quote.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
||||
quote.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||
? Result.Ok()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using LiteCharms.Features.Extensions;
|
||||
using LiteCharms.Features.Shop.Postgres;
|
||||
using LiteCharms.Features.Shop.ShoppingCarts.Models;
|
||||
using static LiteCharms.Features.Extensions.Timezones;
|
||||
|
||||
namespace LiteCharms.Features.Shop.ShoppingCarts;
|
||||
|
||||
@@ -284,7 +283,7 @@ public class ShoppingCartService(IDbContextFactory<ShopDbContext> contextFactory
|
||||
return Result.Fail($"Shopping cart item could not be found with id {shoppingCartItemId}");
|
||||
|
||||
item.Quantity = quantity;
|
||||
item.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
||||
item.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||
? Result.Ok()
|
||||
|
||||
Reference in New Issue
Block a user