kreta/Kreta.Job.Tasks/IktatasJobBase.cs
2024-03-13 00:33:46 +01:00

61 lines
2.8 KiB
C#

using System.Collections.Generic;
using Kreta.Core;
using Kreta.Core.Iktato.Poszeidon.Factory.Interface;
using Kreta.Core.Iktato.Poszeidon.Infrastructure;
using Kreta.Core.Iktato.Poszeidon.Infrastructure.Interface;
using Kreta.DataAccessManual.Interfaces;
using Kreta.Framework.Util;
namespace Kreta.Job.Tasks
{
public class IktatasJobBase
{
public IIktatoRepositoryFactory IktatoRepositoryFactory { get; }
public IktatoServiceConfiguration IktatoServiceConfiguration { get; }
public IktatasJobBase(IIktatoRepositoryFactory iktatoRepositoryFactory, IWcfServiceContext wcfServiceContext, IktatoServiceConfiguration iktatoServiceConfiguration)
{
IktatoServiceConfiguration = iktatoServiceConfiguration;
IktatoRepositoryFactory = iktatoRepositoryFactory;
}
public IktatoRepositoryConfiguration GetIktatoRepositoryConfiguration(string intezmenyIktatoSzervezetAzonosito, string intezmenyPoszeidonBejelentkezesiNev)
{
return new IktatoRepositoryConfiguration()
{
EndpointAddress = string.Format(IktatoServiceConfiguration.EndpointAddress, "poszeidonai"),
Password = IktatoServiceConfiguration.Password,
Username = string.Format(IktatoServiceConfiguration.Username, intezmenyIktatoSzervezetAzonosito),
PoszeidonAzonosito = intezmenyPoszeidonBejelentkezesiNev
};
}
protected List<(string, string)> GetDokumentumKulcsszavak(IDalHandler dalHandler, int iktatottDokumentumId, int intezmenyId, int tanevId, string tanevNeve, string iktatoNeve)
{
var iktDokTipus = dalHandler.IktatottDokumentumDal().Get(iktatottDokumentumId).DokumentumTipus;
var kulcsszavak = new List<(string key, string value)>
{
(key: "Tanév", value: tanevNeve),
(key: "Iktató személy", value: iktatoNeve),
(key: "Dokumentum típus", value: iktDokTipus.GetItemNameFromCache(tanevId)),
};
System.Data.DataSet ds = dalHandler.NyomtatvanyokDal().GetKulcsszoertekekOnIktatottDokumentum(intezmenyId, tanevId, iktatottDokumentumId);
foreach (System.Data.DataRow row in ds.Tables[0].Rows)
{
var ertek = row["ertek"].ToString();
if (!string.IsNullOrWhiteSpace(ertek))
{
if (ertek.Length > Kreta.Core.Constants.MinMaxValues.MaxKulcsszoErtekLength)
{
ertek = ertek.Substring(0, Kreta.Core.Constants.MinMaxValues.MaxKulcsszoErtekLength - 3) + "...";
}
kulcsszavak.Add((key: row["tipus_DNAME"].ToString(), value: ertek));
}
}
return kulcsszavak;
}
}
}