This commit is contained in:
skidoodle 2024-03-13 00:33:46 +01:00
commit e124a47765
19374 changed files with 9806149 additions and 0 deletions

View file

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Kreta.Core.MessageBroker.Contract.MobileNotification;
using Kreta.Core.MessageBroker.Contract.MobileNotification.Enum;
using Kreta.DataAccessManual;
using Kreta.Job.Tasks.Helpers.Utility;
using Kreta.MessageBroker.Client.MobileNotification;
using Kreta.Resources;
using Serilog;
using Serilog.Core.Enrichers;
namespace Kreta.Job.Tasks.Helpers.Notification
{
internal static class MulasztasNotificationHelper
{
/// INFO @DevKornel: Mobil használja
internal static void SendMulasztasNotification(string connectionString)
{
var logger = Log.ForContext(new PropertyEnricher[] { new PropertyEnricher("LoggerId", Guid.NewGuid()) });
try
{
logger.Information($"SendMulasztasNotification:Start");
Dal.ServiceSystemConnection.Run(connectionString, h =>
{
var dal = h.MulasztasDal();
var entities = dal.GetAllSchemaMulasztasNotification();
logger.Information($"GetAllSchemaMulasztasNotification");
dal.SetMulasztasAsKikuldott(entities.Select(x => x.MulasztasId).Distinct());
List<MobileNotificationMessage> mobileNotificationMessagesList = new List<MobileNotificationMessage>();
MobileNotificationMessage[] mobileNotificationMessages = entities.Select(entity => MobileNotificationMessageHelper.CreateMessage(
entity.IntezmenyAzonosito,
entity.TanuloId,
MobileNotificationMessageType.Absence,
entity.MulasztasId,
string.Format(NotificationResource.MulasztasNotificationMessage, entity.TanuloNev, entity.TantargyNev, entity.MulasztasDatuma.ToString("yyyy.MM.dd."), Extensions.GetHetnapja(entity.MulasztasDatuma, entity.TanevId, entity.IntezmenyAzonosito), entity.OraSorszama.HasValue ? " " + entity.OraSorszama.Value + ". óra időpontra" : "i napra"),
NotificationResource.MulasztasTitle)
).ToArray();
logger.Information($"Mulasztas CreateMessage count: {mobileNotificationMessages.Length}");
if (mobileNotificationMessages.Length > 0)
{
MobileNotificationMessageHelper.PostStudentNotification(mobileNotificationMessages);
logger.Information($"Mulasztas PostStudentNotification");
}
});
logger.Information("SendMulasztasNotification:End");
}
catch (Exception ex)
{
logger.Fatal(ex, ex.GetType().FullName);
}
}
}
}