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,49 @@
using System;
using System.Data;
using System.Linq;
using Kreta.Core.MessageBroker.Contract.MobileNotification.Enum;
using Kreta.DataAccessManual;
using Kreta.Framework.Util;
using Kreta.MessageBroker.Client.MobileNotification;
using Kreta.Resources;
using Serilog;
using Serilog.Core.Enrichers;
namespace Kreta.Job.Tasks.Helpers.Notification
{
internal static class BejelentettSzamonkeresNotificationHelper
{
/// INFO @DevKornel: Mobil használja
internal static void SendBejelentettSzamonkeresNotification(string connectionString)
{
var logger = Log.ForContext(new PropertyEnricher[] { new PropertyEnricher("LoggerId", Guid.NewGuid()) });
Dal.ServiceSystemConnection.Run(connectionString, h =>
{
var szamonkeresElorejelzesDal = h.SzamonkeresElorejelzes();
try
{
var szamonkeresek = szamonkeresElorejelzesDal.GetAllSchemaBejelentettSzamonkeresNotification();
szamonkeresElorejelzesDal.SetBejelentettSzamonkeresAsKikuldott(szamonkeresek.Select(x => x.SzamonkeresId).Distinct());
var mobileNotificationMessages = szamonkeresek.Select(item => MobileNotificationMessageHelper.CreateMessage(
item.IntezmenyAzonosito,
item.TanuloId,
MobileNotificationMessageType.Exam,
item.SzamonkeresId,
string.Format(NotificationResource.BejelentettSzamonkeresNotificationMessage, item.TanuloNeve, item.TantargyNeve, item.SzamonkeresModId.GetItemNameFromCache(item.TanevId, item.IntezmenyAzonosito)),
NotificationResource.BejelentettSzamonkeresTitle)
).ToArray();
if (mobileNotificationMessages.Length > 0)
{
MobileNotificationMessageHelper.PostStudentNotification(mobileNotificationMessages);
}
}
catch (Exception ex)
{
logger.Fatal(ex, ex.GetType().FullName);
}
});
}
}
}

View file

@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Kreta.Core;
using Kreta.Core.MessageBroker.Contract.MobileNotification;
using Kreta.Core.MessageBroker.Contract.MobileNotification.Enum;
using Kreta.DataAccessManual;
using Kreta.Enums;
using Kreta.Job.Tasks.Entities;
using Kreta.MessageBroker.Client.MobileNotification;
using Kreta.Resources;
using Newtonsoft.Json;
using Serilog;
using Serilog.Core.Enrichers;
namespace Kreta.Job.Tasks.Helpers.Notification
{
internal static class ErtekelesNotificationHelper
{
internal static void SendErtekelesNotification(string connectionString)
{
var logger = Log.ForContext(new PropertyEnricher[] { new PropertyEnricher("LoggerId", Guid.NewGuid()) });
try
{
Dal.ServiceSystemConnection.Run(connectionString, h =>
{
var ertekelesDal = h.TanuloErtekelesDal();
var ertekelesek = ertekelesDal.GetAllSchemaErtekelesNotification(DateTime.Now);
List<IdWithData> ertekelesList = new List<IdWithData>();
foreach (DataRow row in ertekelesek.Tables[0].Rows)
{
if (!int.TryParse(row["ID"] == DBNull.Value ? string.Empty : row["ID"].ToString(), out int ertekelesId))
{ continue; }
ertekelesList.Add(new IdWithData(ertekelesId, row));
}
if (ertekelesList.Count > 0)
{
ertekelesDal.SetErtekelesAsKikuldott(ertekelesList.Select(x => x.Id).Distinct());
var mobileNotificationMessages = new List<MobileNotificationMessage>();
ertekelesList.ForEach(item => ProcessErtekelesNotification(item.Data, item.Id, mobileNotificationMessages));
if (mobileNotificationMessages.Count > 0)
{
MobileNotificationMessageHelper.PostStudentNotification(mobileNotificationMessages.ToArray());
}
}
});
}
catch (Exception ex)
{
logger.Fatal(ex, ex.GetType().FullName);
}
}
private static void ProcessErtekelesNotification(DataRow row, int ertekelesId, List<MobileNotificationMessage> mobileNotificationMessages)
{
if (!int.TryParse(row["TanuloId"] == DBNull.Value ? string.Empty : row["TanuloId"].ToString(), out int tanuloId))
{ return; }
Guid.TryParse(row["IdpUniqueId"] == DBNull.Value ? string.Empty : row["IdpUniqueId"].ToString(), out Guid idpUniqueId);
int.TryParse(row["ErtekelesOsztalyzatId"] == DBNull.Value ? string.Empty : row["ErtekelesOsztalyzatId"].ToString(), out int ertekelesOsztalyzatId);
var ertekelesSzazalek = row["ErtekelesSzazalek"] == DBNull.Value ? null : row["ErtekelesSzazalek"].ToString();
var osztalyzatSzoveg = row["Osztalyzat"] == DBNull.Value ? string.Empty : row["Osztalyzat"].ToString();
var ertekelesSzoveg = row["ErtekelesSzoveg"] == DBNull.Value ? string.Empty : row["ErtekelesSzoveg"].ToString();
var instituteCode = row["IntezmenyAzonosito"] == DBNull.Value ? string.Empty : row["IntezmenyAzonosito"].ToString();
var tanuloNev = row["TanuloNev"] == DBNull.Value ? string.Empty : row["TanuloNev"].ToString();
var tantargyNev = row["TantargyNev"] == DBNull.Value ? string.Empty : row["TantargyNev"].ToString();
var ertekelesTipusId = row["ErtekelesTipusId"];
var ertekelesTipus = Enum.GetName(typeof(ErtekelesTipusEnum), ertekelesTipusId);
var data = new { ErtekelesTipus = ertekelesTipus };
var message = CreateErtekelesMessage(tanuloNev, tantargyNev, ertekelesOsztalyzatId, ertekelesSzazalek, ertekelesSzoveg, osztalyzatSzoveg);
if (string.IsNullOrWhiteSpace(message))
{ return; }
mobileNotificationMessages.Add(MobileNotificationMessageHelper.CreateMessage(instituteCode, tanuloId, MobileNotificationMessageType.Evaluation, ertekelesId, message, NotificationResource.ErtekelesTitle, JsonConvert.SerializeObject(data)));
}
private static string CreateErtekelesMessage(string tanuloNev, string tantargyNev, int ertekelesOsztalyzatId, string ertekelesSzazalek, string ertekelesSzoveg, string osztalyzatSzoveg)
{
if (ertekelesOsztalyzatId.IsEntityId())
{
return string.Format(NotificationResource.ErdemjegyErtekelesNotificationMessage, tanuloNev, osztalyzatSzoveg, tantargyNev);
}
if (!string.IsNullOrWhiteSpace(ertekelesSzoveg))
{
return string.Format(NotificationResource.SzovegesErtekelesNotificationMessage, tanuloNev, tantargyNev);
}
if (!string.IsNullOrWhiteSpace(ertekelesSzazalek))
{
return string.Format(NotificationResource.SzazalekosErtekelesNotificationMessage, tanuloNev, ertekelesSzazalek, tantargyNev);
}
return string.Empty;
}
}
}

View file

@ -0,0 +1,49 @@
using System;
using System.Data;
using System.Linq;
using Kreta.Core.MessageBroker.Contract.MobileNotification;
using Kreta.Core.MessageBroker.Contract.MobileNotification.Enum;
using Kreta.DataAccessManual;
using Kreta.Framework.Util;
using Kreta.MessageBroker.Client.MobileNotification;
using Kreta.Resources;
using Serilog;
using Serilog.Core.Enrichers;
namespace Kreta.Job.Tasks.Helpers.Notification
{
internal static class FeljegyzesNotificationHelper
{
/// INFO @DevKornel: Mobil használja
internal static void SendFeljegyzesNotification(string connectionString)
{
var logger = Log.ForContext(new PropertyEnricher[] { new PropertyEnricher("LoggerId", Guid.NewGuid()) });
Dal.ServiceSystemConnection.Run(connectionString, h =>
{
var dal = h.Feljegyzes();
try
{
var entities = dal.GetAllSchemaFeljegyzesNotification();
dal.SetFeljegyzesAsKikuldott(entities.Select(x => x.FeljegyzesId).Distinct());
MobileNotificationMessage[] mobileNotificationMessages = entities.Select(entity => MobileNotificationMessageHelper.CreateMessage(
entity.IntezmenyAzonosito,
entity.TanuloId,
MobileNotificationMessageType.Note,
entity.FeljegyzesId,
string.Format(NotificationResource.FeljegyzesNotificationMessage, entity.TanuloNev, entity.TipusId.GetItemNameFromCache(entity.TanevId, entity.IntezmenyAzonosito)),
NotificationResource.FeljegyzesTitle)).ToArray();
if (mobileNotificationMessages.Length > 0)
{
MobileNotificationMessageHelper.PostStudentNotification(mobileNotificationMessages);
}
}
catch (Exception ex)
{
logger.Fatal(ex, ex.GetType().FullName);
}
});
}
}
}

View file

@ -0,0 +1,110 @@
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.DataAccessManual.Interfaces;
using Kreta.Enums.ManualEnums;
using Kreta.Job.Tasks.Entities;
using Kreta.Job.Tasks.Helpers.Utility;
using Kreta.MessageBroker.Client.MobileNotification;
using Kreta.Resources;
using Newtonsoft.Json;
using Serilog;
using Serilog.Core.Enrichers;
namespace Kreta.Job.Tasks.Helpers.Notification
{
internal static class HazifeladatNotificationHelper
{
internal static void SendHazifeladatNotification(string connectionString)
{
var logger = Log.ForContext(new PropertyEnricher[] { new PropertyEnricher("LoggerId", Guid.NewGuid()) });
try
{
logger.Information("SendHazifeladatNotification:Start");
Dal.ServiceSystemConnection.Run(connectionString, dalHandler =>
{
IDKT_FeladatDal dktFeladatDal = dalHandler.DKT_FeladatDal();
DataSet hazifeladatok = dktFeladatDal.GetAllSchemaHazifeladatNotification();
logger.Information("GetAllSchemaHazifeladatNotification");
var hazifeladatList = new List<IdWithData>();
foreach (DataRow row in hazifeladatok.Tables[0].Rows)
{
if (int.TryParse(row["ID"] == DBNull.Value ? string.Empty : row["ID"].ToString(), out int hazifeladatId))
{
hazifeladatList.Add(new IdWithData(hazifeladatId, row));
}
}
if (hazifeladatList.Count > 0)
{
dktFeladatDal.SetHazifeladatAsKikuldott(hazifeladatList.Select(x => x.Id).Distinct().ToList());
logger.Information("SetHazifeladatAsKikuldott");
var mobileNotificationMessages = new List<MobileNotificationMessage>();
hazifeladatList.ForEach(item => ProcessHazifeladatNotification(item.Data, item.Id, mobileNotificationMessages));
logger.Information($"ProcessHazifeladatNotification count: {mobileNotificationMessages.Count}");
if (mobileNotificationMessages.Count > 0)
{
MobileNotificationMessageHelper.PostStudentNotification(mobileNotificationMessages.ToArray());
logger.Information($"Hazifeladat PostStudentNotification");
}
}
});
logger.Information("SendHazifeladatNotification:End");
}
catch (Exception ex)
{
logger.Fatal(ex, ex.GetType().FullName);
}
}
private static void ProcessHazifeladatNotification(DataRow row, int hazifeladatId, List<MobileNotificationMessage> mobileNotificationMessages)
{
if (int.TryParse(row["TanuloId"] == DBNull.Value ? string.Empty : row["TanuloId"].ToString(), out int tanuloId))
{
Guid.TryParse(row["IdpUniqueId"] == DBNull.Value ? string.Empty : row["IdpUniqueId"].ToString(), out Guid idpUniqueId);
string instituteCode = row["IntezmenyAzonosito"] == DBNull.Value ? string.Empty : row["IntezmenyAzonosito"].ToString();
string tanuloNev = row["TanuloNev"] == DBNull.Value ? string.Empty : row["TanuloNev"].ToString();
string tantargyNev = row["TantargyNev"] == DBNull.Value ? string.Empty : row["TantargyNev"].ToString();
int feladatTipusId = Convert.ToInt32(row["FeladatTipusId"]);
int? xeropanBundleId = row["XeropanBundleId"] == DBNull.Value ? (int?)null : Convert.ToInt32(row["XeropanBundleId"]);
DateTime feladatDatum = Convert.ToDateTime(row["Datum"]);
string hetNapja = Extensions.GetHetnapja(feladatDatum, Convert.ToInt32(row["TanevId"]), instituteCode);
int? oraSzam = row["OraSzam"] == DBNull.Value ? (int?)null : Convert.ToInt32(row["OraSzam"]);
string idopont = oraSzam.HasValue ? $"{hetNapja} {oraSzam}. óra időpontra" : $"{hetNapja}i napra";
var dataObject = new { FeladatTipusId = feladatTipusId, FeladatDatum = feladatDatum.ToIso8601UtcString() };
// Azért szükséges ez a rész, mert ha egy napot a tanév rendjében tanítási napnak jelölök, akkor utána az órát
// beteszi a t_orarendiora táblába ugyan azokkal az adatokkal csak más id-val hetirend-el érvényesség kezdetével végével,
// ez viszont valid működés és az is, hogy lehet tenni tanítási napot mondjuk nem hétvégére, ennek kiküszöbölésére, hogy ne küldjön duplán push-t került ide ez a módosítás.
if (!mobileNotificationMessages.Any(m => m.ItemId == hazifeladatId && m.UserId == tanuloId) &&
(feladatTipusId != (int)FeladatTipusEnum.NyelviFeladat || feladatTipusId == (int)FeladatTipusEnum.NyelviFeladat && xeropanBundleId.HasValue))
{
mobileNotificationMessages.Add(MobileNotificationMessageHelper.CreateMessage(
instituteCode,
tanuloId,
MobileNotificationMessageType.Homework,
hazifeladatId,
string.Format(NotificationResource.HaziFeladatNotificationMessage, tanuloNev, tantargyNev, feladatDatum.ToString("yyyy.MM.dd."), idopont),
NotificationResource.HaziFeladatTitle,
data: JsonConvert.SerializeObject(dataObject)));
}
}
}
}
}

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);
}
}
}
}

View file

@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Hangfire.Server;
using Kreta.BusinessLogic.Helpers.Models;
using Kreta.Core.MessageBroker.Contract.MobileNotification;
using Kreta.Core.MessageBroker.Contract.MobileNotification.Enum;
using Kreta.Job.Tasks.Cache;
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 OrarendValtozasNotificationHelper
{
internal static void SendOrarendValtozasNotification(PerformContext context)
{
var logger = Log.ForContext(new PropertyEnricher[] { new PropertyEnricher("LoggerId", Guid.NewGuid()) });
try
{
var userIds = new List<int>();
foreach (var intezmenyAzonosito in KretaServer.KretaServer.Instance.GetOsszesIntezmeny())
{
OrarendValtozasCache orarendValtozasCache = KretaServer.KretaServer.Instance.CacheManager.AquireCacheMobile<OrarendValtozasCache>();
if (orarendValtozasCache != null)
{
var orarendValtozasok = orarendValtozasCache.GetOrarendValtozasok(intezmenyAzonosito);
var kikuldendoOrarendValtozasok = GetKikuldendoOrarendValtozasok(orarendValtozasok);
var mobileNotificationMessages = new List<MobileNotificationMessage>();
foreach (var orarendValtozas in kikuldendoOrarendValtozasok)
{
mobileNotificationMessages.Add(MobileNotificationMessageHelper.CreateMessage(
orarendValtozas.IntezmenyAzonosito,
orarendValtozas.UserId,
MobileNotificationMessageType.OrarendValtozas,
orarendValtozas.OrarendiOraId,
orarendValtozas.Uzenet,
NotificationResource.OrarendValtozasTitle,
orarendValtozas.Datum.ToIso8601UtcString()));
userIds.Add(orarendValtozas.UserId);
}
if (mobileNotificationMessages.Any())
{
orarendValtozasCache.RemoveOrarendValtozasok(intezmenyAzonosito);
MobileNotificationMessageHelper.PostStudentNotification(mobileNotificationMessages.ToArray());
}
}
}
context.SetJobParameter("UserIds", userIds);
}
catch (Exception ex)
{
logger.Fatal(ex, ex.GetType().FullName);
}
}
private static List<OrarendValtozasModel> GetKikuldendoOrarendValtozasok(List<OrarendValtozasModel> orarendValtozasok)
{
var kikuldendoOrarendValtozasok = new List<OrarendValtozasModel>();
var userIdGroupedOrarendValtozasok = orarendValtozasok.GroupBy(x => x.UserId).Select(x => new
{
Key = x.Key,
OrarendValtozasok = x.OrderBy(c => c.Datum)
});
foreach (var orarendValtozas in userIdGroupedOrarendValtozasok)
{
var legkorabbi = orarendValtozas.OrarendValtozasok.First();
var napok = string.Concat(string.Join("i, ", orarendValtozas.OrarendValtozasok.Select(n => n.Nap).Distinct()), "i ");
kikuldendoOrarendValtozasok.Add(new OrarendValtozasModel
{
IntezmenyAzonosito = legkorabbi.IntezmenyAzonosito,
UserId = legkorabbi.UserId,
IdpUniqueId = legkorabbi.IdpUniqueId,
UserNev = legkorabbi.UserNev,
OrarendiOraId = legkorabbi.OrarendiOraId,
Uzenet = string.Format(NotificationResource.OrarendValtozasNotificationMessage, legkorabbi.UserNev, napok),
Datum = legkorabbi.Datum
});
}
return kikuldendoOrarendValtozasok;
}
}
}

View file

@ -0,0 +1,76 @@
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.Entities;
using Kreta.MessageBroker.Client.MobileNotification;
using Kreta.Resources;
using Serilog;
using Serilog.Core.Enrichers;
namespace Kreta.Job.Tasks.Helpers.Notification
{
internal static class RendszeruzenetNotificationHelper
{
internal static void SendRendszeruzenetNotification(string connectionString)
{
var logger = Log.ForContext(new PropertyEnricher[] { new PropertyEnricher("LoggerId", Guid.NewGuid()) });
try
{
Dal.ServiceSystemConnection.Run(connectionString, h =>
{
var feljegyzesDal = h.Feljegyzes();
var feljegyzesek = feljegyzesDal.GetAllSchemaRendszeruzenetFeljegyzesNotification();
List<IdWithData> feljegyzesList = new List<IdWithData>();
foreach (DataRow row in feljegyzesek.Tables[0].Rows)
{
if (!int.TryParse(row["ID"] == DBNull.Value ? string.Empty : row["ID"].ToString(), out int feljegyzesId))
{ continue; }
feljegyzesList.Add(new IdWithData(feljegyzesId, row));
}
if (feljegyzesList.Count > 0)
{
feljegyzesDal.SetFeljegyzesAsKikuldott(feljegyzesList.Select(x => x.Id).Distinct());
var mobileNotificationMessages = new List<MobileNotificationMessage>();
feljegyzesList.ForEach(item => ProcessRendszeruzenetNotification(item.Data, item.Id, mobileNotificationMessages));
if (mobileNotificationMessages.Count > 0)
{
MobileNotificationMessageHelper.PostStudentNotification(mobileNotificationMessages.ToArray());
}
}
});
}
catch (Exception ex)
{
logger.Fatal(ex, ex.GetType().FullName);
}
}
internal static void ProcessRendszeruzenetNotification(DataRow row, int feljegyzesId, List<MobileNotificationMessage> mobileNotificationMessages)
{
if (!int.TryParse(row["TanuloId"] == DBNull.Value ? string.Empty : row["TanuloId"].ToString(), out int tanuloId)) { return; }
Guid.TryParse(row["IdpUniqueId"] == DBNull.Value ? string.Empty : row["IdpUniqueId"].ToString(), out Guid idpUniqueId);
var instituteCode = row["IntezmenyAzonosito"] == DBNull.Value ? string.Empty : row["IntezmenyAzonosito"].ToString();
var message = row["UzenetTargy"] == DBNull.Value ? string.Empty : row["UzenetTargy"].ToString();
if (string.IsNullOrWhiteSpace(message))
{ return; }
mobileNotificationMessages.Add(MobileNotificationMessageHelper.CreateMessage(
instituteCode,
tanuloId,
MobileNotificationMessageType.Note,
feljegyzesId,
message,
NotificationResource.RendszeruzenetTitle));
}
}
}