init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
10
Kreta.Job.Tasks/Helpers/Constants.cs
Normal file
10
Kreta.Job.Tasks/Helpers/Constants.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
namespace Kreta.Job.Tasks.Helpers
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public static class Iktatas
|
||||
{
|
||||
public const string IrattargyfajtaNev = "KRÉTA iratfajták";
|
||||
}
|
||||
}
|
||||
}
|
103
Kreta.Job.Tasks/Helpers/Email/KozelgoFogadooraMailHelper.cs
Normal file
103
Kreta.Job.Tasks/Helpers/Email/KozelgoFogadooraMailHelper.cs
Normal file
|
@ -0,0 +1,103 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using Hangfire;
|
||||
using Kreta.Core;
|
||||
using Kreta.DataAccessManual;
|
||||
using Kreta.DataAccessManual.Interfaces;
|
||||
using Kreta.Framework;
|
||||
using Kreta.Job.Tasks.Core;
|
||||
using Kreta.Job.Tasks.Core.Models;
|
||||
using Kreta.Resources;
|
||||
|
||||
namespace Kreta.Job.Tasks.Helpers.Email
|
||||
{
|
||||
internal static class KozelgoFogadooraMailHelper
|
||||
{
|
||||
internal static void SendKozelgoFogadooraMail(string connectionString)
|
||||
{
|
||||
Dal.ServiceSystemConnection.Run(connectionString, h =>
|
||||
{
|
||||
var fogadooraDal = h.Fogadoora();
|
||||
try
|
||||
{
|
||||
var kozelgoFogadoorak = fogadooraDal.GetKozelgoFogadoorak().Tables[0].AsEnumerable().Select(f => new
|
||||
{
|
||||
FogadooraKezdete = f.Field<DateTime>("FogadooraKezdete"),
|
||||
FogadooraVege = f.Field<DateTime>("FogadooraVege"),
|
||||
NyomtatasiNev = f.Field<string>("NyomtatasiNev"),
|
||||
EmailCim = f.Field<string>("EmailCim"),
|
||||
EmailGuid = f.Field<Guid?>("EmailGuid"),
|
||||
TeremNev = f.Field<string>("TeremNev"),
|
||||
IntezmenyNev = f.Field<string>("IntezmenyNev"),
|
||||
IntezmenyCim = f.Field<string>("IntezmenyCim"),
|
||||
IntezmenyFenntartoEmail = f.Field<string>("IntezmenyFenntartoEmail"),
|
||||
IntezmenyUrl = string.Format(CommonResource.IntezmenyUrl, f.Field<string>("IntezmenyAzon")),
|
||||
IntezmenyAzon = f.Field<string>("IntezmenyAzon"),
|
||||
UserId = f.Field<int>("UserId"),
|
||||
OsztalyCsoportNev = f.Field<string>("OsztalyCsoportNev")
|
||||
});
|
||||
|
||||
foreach (var kozelgoFogadoora in kozelgoFogadoorak.Where(f => f.EmailCim.IsValidEmail()))
|
||||
{
|
||||
if (GetProfileData(h, kozelgoFogadoora.UserId, "FogadooraEmlekeztetoEmailJelentkezes"))
|
||||
{
|
||||
var datum = kozelgoFogadoora.FogadooraKezdete.ToString(Kreta.Core.Constants.ToStringPattern.HungarianDate);
|
||||
var idopont = string.Format("{0} - {1}",
|
||||
kozelgoFogadoora.FogadooraKezdete.ToString(Kreta.Core.Constants.ToStringPattern.HungarianDateTimeWithoutSeconds),
|
||||
kozelgoFogadoora.FogadooraVege.ToString(Kreta.Core.Constants.ToStringPattern.HungarianDateTimeWithoutSeconds));
|
||||
|
||||
var subject = string.Format(EmailResource.KozelgoFogadooraTargy, datum, kozelgoFogadoora.OsztalyCsoportNev, kozelgoFogadoora.NyomtatasiNev);
|
||||
var message = string.Format(EmailResource.KozelgoFogadooraTartalom,
|
||||
kozelgoFogadoora.NyomtatasiNev,
|
||||
idopont,
|
||||
kozelgoFogadoora.TeremNev,
|
||||
kozelgoFogadoora.NyomtatasiNev,
|
||||
kozelgoFogadoora.IntezmenyUrl,
|
||||
kozelgoFogadoora.IntezmenyNev,
|
||||
kozelgoFogadoora.IntezmenyCim,
|
||||
kozelgoFogadoora.OsztalyCsoportNev
|
||||
);
|
||||
|
||||
var emailModel = new EmailModel(kozelgoFogadoora.IntezmenyAzon, kozelgoFogadoora.EmailGuid)
|
||||
{
|
||||
TargetEmail = kozelgoFogadoora.EmailCim,
|
||||
Subject = subject,
|
||||
Message = message
|
||||
+ string.Format(CommonResource.TevesCimzett, kozelgoFogadoora.IntezmenyFenntartoEmail)
|
||||
+ Environment.NewLine
|
||||
+ string.Format(CommonResource.IntezmenyNevEsUrlLink, kozelgoFogadoora.IntezmenyNev, kozelgoFogadoora.IntezmenyUrl)
|
||||
};
|
||||
|
||||
BackgroundJob.Enqueue<IEmailJob>((email) => email.SendMailAsync(emailModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SDAServer.Instance.Logger.ExceptionThrown(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static bool GetProfileData(IDalHandler h, int felhasznaloId, string profileTipus)
|
||||
{
|
||||
var dal = h.Fogadoora(null);
|
||||
var profileXml = dal.GetProfileData(felhasznaloId);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(profileXml))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
XmlDocument xDoc = new XmlDocument();
|
||||
xDoc.LoadXml(profileXml);
|
||||
XmlNode node = xDoc.SelectSingleNode("UserProfile/" + profileTipus);
|
||||
if (node == null)
|
||||
return true;
|
||||
|
||||
return (bool.TryParse(node.InnerText, out bool result)) && result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using Hangfire;
|
||||
using Kreta.Core;
|
||||
using Kreta.DataAccessManual;
|
||||
using Kreta.Job.Tasks.Core;
|
||||
using Kreta.Job.Tasks.Core.Models;
|
||||
using Kreta.Resources;
|
||||
|
||||
namespace Kreta.Job.Tasks.Helpers.Email
|
||||
{
|
||||
internal static class NemNaplozottTanorakEmailHelper
|
||||
{
|
||||
internal static void SendNemNaplozottTanorakMail(string connectionString)
|
||||
{
|
||||
Dal.ServiceSystemConnection.Run(connectionString, (h) =>
|
||||
{
|
||||
var tanarokNemNaplozottOrarendiOrakDataRows = h.OrarendiOra().GetTanarokNemNaplozottOrarendiOrakHetiEmailErtesito().Tables[0].Rows;
|
||||
|
||||
string kuldesNapja = DateTime.Now.Date.ToString("yyyy.MM.dd");
|
||||
|
||||
foreach (DataRow dr in tanarokNemNaplozottOrarendiOrakDataRows)
|
||||
{
|
||||
string tanarNev = dr["NyomtatasiNev"].ToString();
|
||||
string tanarEmailCim = dr["Email"].ToString();
|
||||
Guid tanarEmailGuid = (Guid)dr["EmailGuid"];
|
||||
string intezmenyAzonosito = dr["IntezmenyAzonosito"].ToString();
|
||||
string intezmenyNev = dr["IntezmenyNev"].ToString();
|
||||
string intezmenyEmailCim = dr["IntezmenyEmailCim"].ToString();
|
||||
int osszesNemNaplozottOra = int.Parse(dr["OsszesNemNaplozottTanorak"].ToString());
|
||||
int multHetenNemNaplozottHelyettesitesek = int.Parse(dr["MultHetenNemNaplozottHelyettesitesek"].ToString());
|
||||
int multHetenNemNaplozottTanorak = int.Parse(dr["MultHetenNemNaplozottTanorak"].ToString());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(tanarEmailCim) && tanarEmailCim.IsValidEmail())
|
||||
{
|
||||
var emailModel = new EmailModel(intezmenyAzonosito, tanarEmailGuid)
|
||||
{
|
||||
Message = string.Format(EmailResource.NemNaplozottTanorakEmailTartalom, tanarNev, intezmenyNev, string.Format(CommonResource.IntezmenyUrl, intezmenyAzonosito), multHetenNemNaplozottTanorak, multHetenNemNaplozottHelyettesitesek, osszesNemNaplozottOra)
|
||||
+ string.Format(CommonResource.TevesCimzett, intezmenyEmailCim)
|
||||
+ Environment.NewLine
|
||||
+ string.Format(CommonResource.IntezmenyNevEsUrlLink, intezmenyNev, intezmenyAzonosito),
|
||||
|
||||
Subject = $"{EmailResource.NemNaplozottTanorakEmailTargy} {kuldesNapja}",
|
||||
TargetEmail = tanarEmailCim
|
||||
};
|
||||
|
||||
BackgroundJob.Enqueue<IEmailJob>((email) => email.SendMailAsync(emailModel));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
7
Kreta.Job.Tasks/Helpers/Iktatas/AlszamosIktatasData.cs
Normal file
7
Kreta.Job.Tasks/Helpers/Iktatas/AlszamosIktatasData.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace Kreta.Job.Tasks.Helpers.Iktatas
|
||||
{
|
||||
public class AlszamosIktatasData : FoszamosIktatasData
|
||||
{
|
||||
public int Foszam { get; set; }
|
||||
}
|
||||
}
|
11
Kreta.Job.Tasks/Helpers/Iktatas/FeltoltesUjVerzioData.cs
Normal file
11
Kreta.Job.Tasks/Helpers/Iktatas/FeltoltesUjVerzioData.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
namespace Kreta.Job.Tasks.Helpers.Iktatas
|
||||
{
|
||||
public class FeltoltesUjVerzioData
|
||||
{
|
||||
public string PoszeidonAzonosito { get; set; }
|
||||
public string DokumentumNev { get; set; }
|
||||
public string DokumentumTipus { get; set; }
|
||||
public byte[] Tartalom { get; set; }
|
||||
public string ElektronikusPeldanyId { get; set; }
|
||||
}
|
||||
}
|
19
Kreta.Job.Tasks/Helpers/Iktatas/FoszamosIktatasData.cs
Normal file
19
Kreta.Job.Tasks/Helpers/Iktatas/FoszamosIktatasData.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Kreta.Job.Tasks.Helpers.Iktatas
|
||||
{
|
||||
[Serializable]
|
||||
public class FoszamosIktatasData
|
||||
{
|
||||
public string PoszeidonAzonosito { get; set; }
|
||||
public string Targy { get; set; }
|
||||
public Dictionary<string, string> Kulcsszavak { get; set; }
|
||||
public string DokumentumNev { get; set; }
|
||||
public string DokumentumTipus { get; set; }
|
||||
public byte[] Tartalom { get; set; }
|
||||
public int IktatoId { get; set; }
|
||||
public int PartnerId { get; set; }
|
||||
public string ParentJobId { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Kreta.Job.Tasks.Helpers.Iktatas
|
||||
{
|
||||
public class WordIktatoszamVonalkodTextReplacer : Aspose.Words.Replacing.IReplacingCallback
|
||||
{
|
||||
public List<Aspose.Words.Run> nodes = new List<Aspose.Words.Run>();
|
||||
|
||||
Aspose.Words.Replacing.ReplaceAction Aspose.Words.Replacing.IReplacingCallback.Replacing(Aspose.Words.Replacing.ReplacingArgs e)
|
||||
{
|
||||
// This is a Run node that contains either the beginning or the complete match.
|
||||
Aspose.Words.Node currentNode = e.MatchNode;
|
||||
|
||||
// The first (and may be the only) run can contain text before the match,
|
||||
// in this case it is necessary to split the run.
|
||||
if (e.MatchOffset > 0)
|
||||
currentNode = SplitRun((Aspose.Words.Run)currentNode, e.MatchOffset);
|
||||
|
||||
System.Collections.ArrayList runs = new System.Collections.ArrayList();
|
||||
|
||||
// Find all runs that contain parts of the match string.
|
||||
int remainingLength = e.Match.Value.Length;
|
||||
while (
|
||||
|
||||
(remainingLength > 0) &&
|
||||
|
||||
(currentNode != null) &&
|
||||
|
||||
(currentNode.GetText().Length <= remainingLength))
|
||||
{
|
||||
|
||||
runs.Add(currentNode);
|
||||
|
||||
remainingLength -= currentNode.GetText().Length;
|
||||
|
||||
// Select the next Run node.
|
||||
// Have to loop because there could be other nodes such as BookmarkStart etc.
|
||||
do
|
||||
{
|
||||
currentNode = currentNode.NextSibling;
|
||||
}
|
||||
while ((currentNode != null) && (currentNode.NodeType != Aspose.Words.NodeType.Run));
|
||||
}
|
||||
|
||||
// Split the last run that contains the match if there is any text left.
|
||||
if ((currentNode != null) && (remainingLength > 0))
|
||||
{
|
||||
SplitRun((Aspose.Words.Run)currentNode, remainingLength);
|
||||
runs.Add(currentNode);
|
||||
}
|
||||
|
||||
String runText = "";
|
||||
foreach (Aspose.Words.Run run in runs)
|
||||
runText += run.Text;
|
||||
|
||||
((Aspose.Words.Run)runs[0]).Text = runText;
|
||||
|
||||
for (int i = 1; i < runs.Count; i++)
|
||||
{
|
||||
((Aspose.Words.Run)runs[i]).Remove();
|
||||
}
|
||||
|
||||
((Aspose.Words.Run)runs[0]).Font.Color = System.Drawing.Color.Black;
|
||||
if (e.Match.Value == "{vonalkod}")
|
||||
{
|
||||
((Aspose.Words.Run)runs[0]).Font.Name = "Code 128";
|
||||
}
|
||||
|
||||
nodes.Add((Aspose.Words.Run)runs[0]);
|
||||
|
||||
return Aspose.Words.Replacing.ReplaceAction.Replace;
|
||||
}
|
||||
|
||||
private static Aspose.Words.Run SplitRun(Aspose.Words.Run run, int position)
|
||||
{
|
||||
Aspose.Words.Run afterRun = (Aspose.Words.Run)run.Clone(true);
|
||||
afterRun.Text = run.Text.Substring(position);
|
||||
run.Text = run.Text.Substring(0, position);
|
||||
run.ParentNode.InsertAfter(afterRun, run);
|
||||
return afterRun;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
55
Kreta.Job.Tasks/Helpers/Utility/Extensions.cs
Normal file
55
Kreta.Job.Tasks/Helpers/Utility/Extensions.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Framework.Util;
|
||||
|
||||
namespace Kreta.Job.Tasks.Helpers.Utility
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
/// UTC: 2016-10-30T20:00:00Z
|
||||
/// Local: 2016-10-30T23:00:00+01:00
|
||||
/// Unspecified: 2016-10-30T22:00:00
|
||||
public static DateTime ToIso8601Utc(this DateTime dt)
|
||||
=> new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, dt.Kind).ToUniversalTime();
|
||||
|
||||
/// UTC: 2016-10-30T20:00:00Z
|
||||
/// Local: 2016-10-30T23:00:00+01:00
|
||||
/// Unspecified: 2016-10-30T22:00:00
|
||||
public static string ToIso8601UtcString(this DateTime dt)
|
||||
=> dt.ToIso8601Utc().ToString("yyyy-MM-dd'T'HH:mm:ssK", CultureInfo.InvariantCulture);
|
||||
|
||||
public static string GetHetnapja(DateTime date, int tanevId, string intezmenyAzonosito)
|
||||
=> GetHetNapja(date).GetItemNameFromCache(tanevId, intezmenyAzonosito).ToLower();
|
||||
|
||||
private static int GetHetNapja(DateTime date)
|
||||
{
|
||||
HetNapjaTipusEnum hetNapja = HetNapjaTipusEnum.na;
|
||||
switch (date.DayOfWeek)
|
||||
{
|
||||
case DayOfWeek.Monday:
|
||||
hetNapja = HetNapjaTipusEnum.Hetfo;
|
||||
break;
|
||||
case DayOfWeek.Tuesday:
|
||||
hetNapja = HetNapjaTipusEnum.Kedd;
|
||||
break;
|
||||
case DayOfWeek.Wednesday:
|
||||
hetNapja = HetNapjaTipusEnum.Szerda;
|
||||
break;
|
||||
case DayOfWeek.Thursday:
|
||||
hetNapja = HetNapjaTipusEnum.Csutortok;
|
||||
break;
|
||||
case DayOfWeek.Friday:
|
||||
hetNapja = HetNapjaTipusEnum.Pentek;
|
||||
break;
|
||||
case DayOfWeek.Saturday:
|
||||
hetNapja = HetNapjaTipusEnum.Szombat;
|
||||
break;
|
||||
case DayOfWeek.Sunday:
|
||||
hetNapja = HetNapjaTipusEnum.Vasarnap;
|
||||
break;
|
||||
}
|
||||
return (int)hetNapja;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue