taken the requried service from thread

This commit is contained in:
ashutosh.nehete 2025-09-15 17:01:29 +05:30
parent a0789f7f8e
commit b17d1d30e5
2 changed files with 18 additions and 15 deletions

View File

@ -843,12 +843,13 @@ namespace Marco.Pms.Services.Controllers
response.ParentAttachmentId = versionMapping.ParentAttachmentId;
response.Version = versionMapping.Version;
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
_ = Task.Run(async () =>
{
// --- Push Notification Section ---
// This section attempts to send a test push notification to the user's device.
// It's designed to fail gracefully and handle invalid Firebase Cloud Messaging (FCM) tokens.
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
var name = $"{loggedInEmployee.FirstName} {loggedInEmployee.LastName}";
@ -966,12 +967,13 @@ namespace Marco.Pms.Services.Controllers
}
_logger.LogInfo("Document verified successfully. DocumentId: {DocumentId}, VerifiedBy: {EmployeeId}", documentAttachment.Id, loggedInEmployee.Id);
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
_ = Task.Run(async () =>
{
// --- Push Notification Section ---
// This section attempts to send a test push notification to the user's device.
// It's designed to fail gracefully and handle invalid Firebase Cloud Messaging (FCM) tokens.
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
var name = $"{loggedInEmployee.FirstName} {loggedInEmployee.LastName}";
@ -1356,12 +1358,13 @@ namespace Marco.Pms.Services.Controllers
response.Version = newVersionMapping.Version;
_logger.LogInfo("API completed successfully for AttachmentId: {AttachmentId}", newAttachment.Id);
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
_ = Task.Run(async () =>
{
// --- Push Notification Section ---
// This section attempts to send a test push notification to the user's device.
// It's designed to fail gracefully and handle invalid Firebase Cloud Messaging (FCM) tokens.
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
var name = $"{loggedInEmployee.FirstName} {loggedInEmployee.LastName}";
@ -1471,12 +1474,13 @@ namespace Marco.Pms.Services.Controllers
// Log the successful completion of the operation
_logger.LogInfo("DocumentAttachment ID: {DocumentId} has been {Message} by employee ID: {EmployeeId}", id, message, loggedInEmployee.Id);
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
_ = Task.Run(async () =>
{
// --- Push Notification Section ---
// This section attempts to send a test push notification to the user's device.
// It's designed to fail gracefully and handle invalid Firebase Cloud Messaging (FCM) tokens.
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
var entityType = documentAttachment.DocumentType?.DocumentCategory?.EntityTypeId;
var documentType = documentAttachment.DocumentType;

View File

@ -1012,13 +1012,12 @@ namespace Marco.Pms.Services.Service
contactVM.BucketIds = contactBucketMappings.Select(cb => cb.BucketId).ToList();
contactVM.ProjectIds = projectMappings.Select(cp => cp.ProjectId).ToList();
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
_ = Task.Run(async () =>
{
// --- Push Notification Section ---
// This section attempts to send a test push notification to the user's device.
// It's designed to fail gracefully and handle invalid Firebase Cloud Messaging (FCM) tokens.
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
var name = $"{loggedInEmployee.FirstName} {loggedInEmployee.LastName}";
var notification = new Notification
@ -1479,13 +1478,13 @@ namespace Marco.Pms.Services.Service
var contactVM = responseTask.Result;
_logger.LogInfo("Contact {ContactId} successfully updated by employee {EmployeeId}.", contact.Id, loggedInEmployee.Id);
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
_ = Task.Run(async () =>
{
// --- Push Notification Section ---
// This section attempts to send a test push notification to the user's device.
// It's designed to fail gracefully and handle invalid Firebase Cloud Messaging (FCM) tokens.
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
if (contactVM.BucketIds?.Any() ?? false)
{
@ -1562,13 +1561,13 @@ namespace Marco.Pms.Services.Service
_logger.LogInfo("Contact ID {ContactId} has been {(DeletedOrActivated)} by Employee ID {EmployeeId}.", id, active ? "activated" : "deleted", loggedInEmployee.Id);
using var scope = _serviceScopeFactory.CreateScope();
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
_ = Task.Run(async () =>
{
// --- Push Notification Section ---
// This section attempts to send a test push notification to the user's device.
// It's designed to fail gracefully and handle invalid Firebase Cloud Messaging (FCM) tokens.
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
if (bucketIds.Any())
{
@ -2059,13 +2058,13 @@ namespace Marco.Pms.Services.Service
loggedInEmployee.Id, note.Id, contact.Id, tenantId);
using var scope = _serviceScopeFactory.CreateScope();
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
_ = Task.Run(async () =>
{
// --- Push Notification Section ---
// This section attempts to send a test push notification to the user's device.
// It's designed to fail gracefully and handle invalid Firebase Cloud Messaging (FCM) tokens.
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
var name = $"{loggedInEmployee.FirstName} {loggedInEmployee.LastName}";
@ -2191,13 +2190,13 @@ namespace Marco.Pms.Services.Service
loggedInEmployee.Id, noteVM.Id, contact.Id, noteVM.UpdatedAt);
using var scope = _serviceScopeFactory.CreateScope();
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
_ = Task.Run(async () =>
{
// --- Push Notification Section ---
// This section attempts to send a test push notification to the user's device.
// It's designed to fail gracefully and handle invalid Firebase Cloud Messaging (FCM) tokens.
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
var name = $"{loggedInEmployee.FirstName} {loggedInEmployee.LastName}";
@ -2319,13 +2318,13 @@ namespace Marco.Pms.Services.Service
}
using var scope = _serviceScopeFactory.CreateScope();
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
_ = Task.Run(async () =>
{
// --- Push Notification Section ---
// This section attempts to send a test push notification to the user's device.
// It's designed to fail gracefully and handle invalid Firebase Cloud Messaging (FCM) tokens.
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
var name = $"{loggedInEmployee.FirstName} {loggedInEmployee.LastName}";
@ -2543,13 +2542,13 @@ namespace Marco.Pms.Services.Service
_logger.LogInfo("Employee {EmployeeId} successfully created bucket {BucketId}", loggedInEmployee.Id, newBucket.Id);
using var scope = _serviceScopeFactory.CreateScope();
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
_ = Task.Run(async () =>
{
// --- Push Notification Section ---
// This section attempts to send a test push notification to the user's device.
// It's designed to fail gracefully and handle invalid Firebase Cloud Messaging (FCM) tokens.
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
var name = $"{loggedInEmployee.FirstName} {loggedInEmployee.LastName}";
@ -2676,13 +2675,13 @@ namespace Marco.Pms.Services.Service
_logger.LogInfo("Employee ID {LoggedInEmployeeId} successfully updated bucket ID {BucketId}.", loggedInEmployee.Id, bucket.Id);
using var scope = _serviceScopeFactory.CreateScope();
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
_ = Task.Run(async () =>
{
// --- Push Notification Section ---
// This section attempts to send a test push notification to the user's device.
// It's designed to fail gracefully and handle invalid Firebase Cloud Messaging (FCM) tokens.
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
var name = $"{loggedInEmployee.FirstName} {loggedInEmployee.LastName}";
@ -2860,13 +2859,13 @@ namespace Marco.Pms.Services.Service
_logger.LogInfo("Employee {EmployeeId} removed {Count} employees from bucket {BucketId}.", loggedInEmployee.Id, removedEmployeesCount, bucketId);
}
using var scope = _serviceScopeFactory.CreateScope();
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
_ = Task.Run(async () =>
{
// --- Push Notification Section ---
// This section attempts to send a test push notification to the user's device.
// It's designed to fail gracefully and handle invalid Firebase Cloud Messaging (FCM) tokens.
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
var name = $"{loggedInEmployee.FirstName} {loggedInEmployee.LastName}";
@ -3007,13 +3006,13 @@ namespace Marco.Pms.Services.Service
}, bucketCollection);
using var scope = _serviceScopeFactory.CreateScope();
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
_ = Task.Run(async () =>
{
// --- Push Notification Section ---
// This section attempts to send a test push notification to the user's device.
// It's designed to fail gracefully and handle invalid Firebase Cloud Messaging (FCM) tokens.
var _firebase = scope.ServiceProvider.GetRequiredService<IFirebaseService>();
var name = $"{loggedInEmployee.FirstName} {loggedInEmployee.LastName}";