init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,312 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using Kreta.BusinessLogic.Classes;
|
||||
using Kreta.BusinessLogic.HelperClasses.ImportCo;
|
||||
using Kreta.BusinessLogic.Validation;
|
||||
using Kreta.Core;
|
||||
using Kreta.Core.CustomAttributes;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Framework.Util;
|
||||
using Kreta.Resources;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Kreta.BusinessLogic.HelperClasses.ImportCo
|
||||
{
|
||||
public class TanulokElerhetosegiAdataikImportCo : BaseImportCo
|
||||
{
|
||||
[JsonIgnore]
|
||||
public List<TanulokElerhetosegiAdataikImportItemCo> MainImportItemList { get; set; } = new List<TanulokElerhetosegiAdataikImportItemCo>();
|
||||
|
||||
[JsonIgnore]
|
||||
public List<TanulokElerhetosegiAdataikImportItemCo> NemImportalhatoItemList { get; set; } = new List<TanulokElerhetosegiAdataikImportItemCo>();
|
||||
|
||||
[JsonProperty("T_TELEFON_OSSZES")]
|
||||
public List<TelefonTanuloImportJsonItemCo> TelefonTanuloImportJsonItemList { get; set; }
|
||||
|
||||
[JsonProperty("T_EMAIL_OSSZES")]
|
||||
public List<EmailTanuloImportJsonItemCo> EmailTanuloImportJsonItemList { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public List<TanuloItemCo> TanuloCoList { get; set; }
|
||||
|
||||
public Dictionary<int, List<ValidationResult>> Validate()
|
||||
{
|
||||
var validationResultDictionary = new Dictionary<int, List<ValidationResult>>();
|
||||
foreach (TanulokElerhetosegiAdataikImportItemCo importItem in MainImportItemList)
|
||||
{
|
||||
var validationResultList = new List<ValidationResult>();
|
||||
var blValidator = new BlValidator(importItem);
|
||||
if (!blValidator.IsValid)
|
||||
{
|
||||
validationResultList.AddRange(blValidator.ErrorList);
|
||||
}
|
||||
if (validationResultList.Count > 0)
|
||||
{
|
||||
validationResultDictionary.Add(importItem.LineNumber, validationResultList);
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<int, string> lineNumberCompareHashDictionary = MainImportItemList.ToDictionary(x => x.LineNumber, x => x.CompareHash);
|
||||
var duplicatedRowConditonTextList = new List<string>
|
||||
{
|
||||
ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameTanuloNeve,
|
||||
ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameTanuloOktatasiAzonosito
|
||||
};
|
||||
ValidateDuplicatedRows(validationResultDictionary, lineNumberCompareHashDictionary, duplicatedRowConditonTextList);
|
||||
return validationResultDictionary;
|
||||
}
|
||||
}
|
||||
|
||||
public class TanulokElerhetosegiAdataikImportItemCo : BaseImportItemCo, IValidatableObject
|
||||
{
|
||||
private readonly int _tanevId;
|
||||
|
||||
private TanulokElerhetosegiAdataikImportItemCo() { }
|
||||
|
||||
public TanulokElerhetosegiAdataikImportItemCo(int tanevId, bool isSzakkepzoIntezmeny) : base()
|
||||
{
|
||||
_tanevId = tanevId;
|
||||
IsSzakkepzoIntezmeny = isSzakkepzoIntezmeny;
|
||||
}
|
||||
|
||||
#region Fields
|
||||
|
||||
public const string NemImportalhatoSorokExportAttributeId = nameof(NemImportalhatoSorokExportAttributeId);
|
||||
|
||||
#endregion Fields
|
||||
|
||||
[SimpleExportColumn(NemImportalhatoSorokExportAttributeId, 00, nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameTanuloNeve), typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
[Required(ErrorMessageResourceName = nameof(ErrorResource.Required), ErrorMessageResourceType = typeof(ErrorResource))]
|
||||
[MaxLength(200, ErrorMessageResourceName = nameof(CommonResource.MaxLengthValidation), ErrorMessageResourceType = typeof(CommonResource))]
|
||||
[Display(Name = nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameTanuloNeve), ResourceType = typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
public string TanuloNeveImportData { get; set; }
|
||||
|
||||
[SimpleExportColumn(NemImportalhatoSorokExportAttributeId, 01, nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameTanuloOktatasiAzonosito), typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
[Required(ErrorMessageResourceName = nameof(ErrorResource.Required), ErrorMessageResourceType = typeof(ErrorResource))]
|
||||
[MaxLength(11, ErrorMessageResourceName = nameof(CommonResource.MaxLengthValidation), ErrorMessageResourceType = typeof(CommonResource))]
|
||||
[KretaRegularExpression(Constants.RegularExpressions.OktatasiAzonositoTanulo, ErrorMessageResourceName = nameof(ErrorResource.OktatasiAzonositoFormatumaNemMegfelelo), ErrorMessageResourceType = typeof(ErrorResource))]
|
||||
[Display(Name = nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameTanuloOktatasiAzonosito), ResourceType = typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
public string TanuloOktatasiAzonositoImportData { get; set; }
|
||||
|
||||
[SimpleExportColumn(NemImportalhatoSorokExportAttributeId, 02, nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameTanuloTelefonszam), typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
[MaxLength(255, ErrorMessageResourceName = nameof(CommonResource.MaxLengthValidation), ErrorMessageResourceType = typeof(CommonResource))]
|
||||
[PhoneExtended(ErrorMessageResourceName = nameof(ErrorResource.ATelefonszamFormatumaNemMegfelelo), ErrorMessageResourceType = typeof(ErrorResource))]
|
||||
[Display(Name = nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameTanuloTelefonszam), ResourceType = typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
public string TanuloTelefonszamImportData { get; set; }
|
||||
|
||||
[SimpleExportColumn(NemImportalhatoSorokExportAttributeId, 03, nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameTelefonszamAlapertelmezett), typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
[Display(Name = nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameTelefonszamAlapertelmezett), ResourceType = typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
public string TelefonszamAlapertelmezettImportData { get; set; }
|
||||
|
||||
[SimpleExportColumn(NemImportalhatoSorokExportAttributeId, 04, nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameTelefonszamTipusa), typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
[Display(Name = nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameTelefonszamTipusa), ResourceType = typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
public string TelefonszamTipusaImportData { get; set; }
|
||||
|
||||
[SimpleExportColumn(NemImportalhatoSorokExportAttributeId, 05, nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameTanuloEmailCim), typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
[MaxLength(255, ErrorMessageResourceName = nameof(CommonResource.MaxLengthValidation), ErrorMessageResourceType = typeof(CommonResource))]
|
||||
[EmailAddressExtended(true, true, ErrorMessageResourceName = nameof(ErrorResource.NemMegfeleloFormatumuAzEmailCim), ErrorMessageResourceType = typeof(ErrorResource))]
|
||||
[Display(Name = nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameTanuloEmailCim), ResourceType = typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
public string TanuloEmailCimImportData { get; set; }
|
||||
|
||||
[SimpleExportColumn(NemImportalhatoSorokExportAttributeId, 06, nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameEmailAlapertelmezett), typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
[Display(Name = nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameEmailAlapertelmezett), ResourceType = typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
public string EmailAlapertelmezettImportData { get; set; }
|
||||
|
||||
[SimpleExportColumn(NemImportalhatoSorokExportAttributeId, 07, nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameEmailTipus), typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
[Display(Name = nameof(ImportExportTanulokElerhetosegiAdataikResource.ImportHeaderNameEmailTipus), ResourceType = typeof(ImportExportTanulokElerhetosegiAdataikResource))]
|
||||
public string EmailTipusImportData { get; set; }
|
||||
|
||||
public string FelhasznaloElotag => GetElotagFromTeljesNev(TanuloNeveImportData);
|
||||
|
||||
public string FelhasznaloVezeteknev => GetVezeteknevFromTeljesNev(TanuloNeveImportData);
|
||||
|
||||
public string FelhasznaloKeresztnev => GetKeresztnevekFromTeljesNev(TanuloNeveImportData);
|
||||
|
||||
public string FelhasznaloOktatasiAzonosito => GetStringValue(TanuloOktatasiAzonositoImportData);
|
||||
|
||||
public string CompareHashTelefon { get; set; }
|
||||
|
||||
public string CompareHashEmail { get; set; }
|
||||
|
||||
public int OperationTelefon { get; set; }
|
||||
|
||||
public int OperationEmail { get; set; }
|
||||
|
||||
public int? FelhasznaloId { get; set; }
|
||||
|
||||
public int? TelefonId { get; set; }
|
||||
|
||||
public int? EmailId { get; set; }
|
||||
|
||||
public string Nev => GetStringValue(TanuloNeveImportData);
|
||||
|
||||
public string Telefonszam => GetStringValue(TanuloTelefonszamImportData);
|
||||
|
||||
public int? TelefonTipus => string.IsNullOrWhiteSpace(TelefonszamTipusaImportData) ? (int)TelefonTipusEnum.Ismeretlen : ((int)GeneratedAdatszotarTipusEnum.TelefonTipus).GetItemIdByTypeAndName(TelefonszamTipusaImportData, _tanevId);
|
||||
|
||||
public bool? TelefonAlapertelmezett => GetBooleanValue(TelefonszamAlapertelmezettImportData);
|
||||
|
||||
public string EmailCim => GetStringValue(TanuloEmailCimImportData);
|
||||
|
||||
public int? EmailTipus => string.IsNullOrWhiteSpace(EmailTipusImportData) ? (int)EmailTipusEnum.Na : ((int)GeneratedAdatszotarTipusEnum.EmailTipus).GetItemIdByTypeAndName(EmailTipusImportData, _tanevId);
|
||||
|
||||
public bool? EmailAlapertelmezett => GetBooleanValue(EmailAlapertelmezettImportData);
|
||||
|
||||
public TanuloItemCo Tanulo { get; set; }
|
||||
|
||||
private bool IsSzakkepzoIntezmeny { get; }
|
||||
|
||||
public bool IsVanAlapertelmezettTelefonszam { get; set; }
|
||||
|
||||
public bool IsVanAlapertelmezettEmail { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(TanuloNeveImportData) &&
|
||||
!string.IsNullOrWhiteSpace(TanuloOktatasiAzonositoImportData))
|
||||
{
|
||||
if (!FelhasznaloId.IsEntityId())
|
||||
{
|
||||
yield return new ValidationResult(ImportExportTanulokElerhetosegiAdataikResource.HibaEzzelAzOktatasiAzonositovalNemLetezikTanuloEbbenATanevben);
|
||||
}
|
||||
}
|
||||
|
||||
//NOTE: Ha van megadva bármilyen érték az import data-ban, meg kell vizsgálni, hogy legyen vezetéknév és keresztnév is
|
||||
if (!string.IsNullOrWhiteSpace(TanuloNeveImportData) && (string.IsNullOrWhiteSpace(FelhasznaloVezeteknev) || string.IsNullOrWhiteSpace(FelhasznaloKeresztnev)))
|
||||
{
|
||||
yield return new ValidationResult(ImportExportTanulokElerhetosegiAdataikResource.ATanuloNeveFormatumaNemMegfelelo);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(EmailTipusImportData))
|
||||
{
|
||||
if (!EmailTipus.IsEntityId())
|
||||
{
|
||||
yield return new ValidationResult(ImportExportTanulokElerhetosegiAdataikResource.HibaNincsIlyenEmailTipus);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(TelefonszamTipusaImportData))
|
||||
{
|
||||
if (!TelefonTipus.IsEntityId())
|
||||
{
|
||||
yield return new ValidationResult(ImportExportTanulokElerhetosegiAdataikResource.HibaNincsIlyenTelefonTipus);
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(TanuloTelefonszamImportData) && string.IsNullOrWhiteSpace(TanuloEmailCimImportData))
|
||||
{
|
||||
yield return new ValidationResult(ImportExportTanulokElerhetosegiAdataikResource.HibaATelefonszamEsEmailCimKozulEgyiketLegalabbMegKellAdni);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(TanuloTelefonszamImportData) && (string.IsNullOrWhiteSpace(TelefonszamAlapertelmezettImportData) || string.IsNullOrWhiteSpace(TelefonszamTipusaImportData)))
|
||||
{
|
||||
yield return new ValidationResult(ImportExportTanulokElerhetosegiAdataikResource.HibaKitoltottTelefonszamEsetenAlapErtEsTipusKotelezo);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(TanuloEmailCimImportData) && !IsVanAlapertelmezettEmail && !(EmailAlapertelmezett.HasValue && EmailAlapertelmezett.Value))
|
||||
{
|
||||
yield return new ValidationResult(ImportExportTanulokElerhetosegiAdataikResource.ATanulonakNincsAlapertelmezettEmailCimeARendszerbenAllitsaAlapertelmezettreATanuloEmailCimet);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(TanuloTelefonszamImportData) && !IsVanAlapertelmezettTelefonszam && !(TelefonAlapertelmezett.HasValue && TelefonAlapertelmezett.Value))
|
||||
{
|
||||
yield return new ValidationResult(ImportExportTanulokElerhetosegiAdataikResource.ATanulonakNincsAlapertelmezettTelefonszamaARendszerbenAllitsaalapertelmezettreATanuloTelefonszamat);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(TanuloEmailCimImportData) && (string.IsNullOrWhiteSpace(EmailAlapertelmezettImportData) || string.IsNullOrWhiteSpace(EmailTipusImportData)))
|
||||
{
|
||||
yield return new ValidationResult(ImportExportTanulokElerhetosegiAdataikResource.HibaKitoltottEmailEsetenAlapErtEsTipusKotelezo);
|
||||
}
|
||||
|
||||
if (IsSzakkepzoIntezmeny && !string.IsNullOrWhiteSpace(TanuloOktatasiAzonositoImportData) && !Extensions.FelhasznaloExtensions.IsValidOktatasiAzonosito(TanuloOktatasiAzonositoImportData))
|
||||
{
|
||||
yield return new ValidationResult(ErrorResource.AMegadottOktatasiAzonositoHibas);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TelefonTanuloImportJsonItemCo : BaseImportJsonItemCo
|
||||
{
|
||||
public TelefonTanuloImportJsonItemCo(TanulokElerhetosegiAdataikImportItemCo importItemCo, int tanevId, int intezmenyId, int felhasznaloId) : base(tanevId, intezmenyId, felhasznaloId)
|
||||
{
|
||||
Id = importItemCo.TelefonId;
|
||||
FelhasznaloId = importItemCo.FelhasznaloId.Value;
|
||||
Nev = importItemCo.Nev;
|
||||
|
||||
Telefonszam = importItemCo.Telefonszam;
|
||||
TipusId = importItemCo.TelefonTipus;
|
||||
TipusNev = TipusId?.GetDisplayName<TelefonTipusEnum>(tanevId);
|
||||
IsAlapertelmezett = SDAConvert.ToSDABoolean(importItemCo.TelefonAlapertelmezett.HasValue && importItemCo.TelefonAlapertelmezett.Value);
|
||||
|
||||
LineNumber = importItemCo.LineNumber;
|
||||
Operation = importItemCo.OperationTelefon;
|
||||
}
|
||||
|
||||
[JsonProperty("Nev")]
|
||||
public string Nev { get; set; }
|
||||
|
||||
[JsonProperty("C_FELHASZNALOID")]
|
||||
public int FelhasznaloId { get; set; }
|
||||
|
||||
[JsonProperty("C_TELEFONSZAM")]
|
||||
public string Telefonszam { get; set; }
|
||||
|
||||
[JsonProperty("C_TELEFONTIPUSA")]
|
||||
public int? TipusId { get; set; }
|
||||
|
||||
[JsonProperty("C_ALAPERTELMEZETT")]
|
||||
public string IsAlapertelmezett { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string TipusNev { get; set; }
|
||||
|
||||
[JsonProperty("C_ISPUBLIC")]
|
||||
public string IsPublic => SDAConvert.ToSDABoolean(false);
|
||||
|
||||
[JsonProperty("C_ISHIBASANMEGADVA")]
|
||||
public string IsHibasanMegadva => SDAConvert.ToSDABoolean(false);
|
||||
}
|
||||
|
||||
public class EmailTanuloImportJsonItemCo : BaseImportJsonItemCo
|
||||
{
|
||||
public EmailTanuloImportJsonItemCo(TanulokElerhetosegiAdataikImportItemCo importItemCo, int tanevId, int intezmenyId, int felhasznaloId) : base(tanevId, intezmenyId, felhasznaloId)
|
||||
{
|
||||
Id = importItemCo.EmailId;
|
||||
FelhasznaloId = importItemCo.FelhasznaloId.Value;
|
||||
Nev = importItemCo.Nev;
|
||||
|
||||
EmailCim = importItemCo.EmailCim;
|
||||
TipusId = importItemCo.EmailTipus;
|
||||
TipusNev = TipusId?.GetDisplayName<EmailTipusEnum>(tanevId);
|
||||
IsAlapertelmezett = SDAConvert.ToSDABoolean(importItemCo.EmailAlapertelmezett.HasValue && importItemCo.EmailAlapertelmezett.Value);
|
||||
|
||||
LineNumber = importItemCo.LineNumber;
|
||||
Operation = importItemCo.OperationEmail;
|
||||
}
|
||||
|
||||
[JsonProperty("Nev")]
|
||||
public string Nev { get; set; }
|
||||
|
||||
[JsonProperty("C_FELHASZNALOID")]
|
||||
public int FelhasznaloId { get; set; }
|
||||
|
||||
[JsonProperty("C_EMAILCIM")]
|
||||
public string EmailCim { get; set; }
|
||||
|
||||
[JsonProperty("C_EMAILTIPUSA")]
|
||||
public int? TipusId { get; set; }
|
||||
|
||||
[JsonProperty("C_ALAPERTELMEZETT")]
|
||||
public string IsAlapertelmezett { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string TipusNev { get; set; }
|
||||
|
||||
[JsonProperty("C_ISPUBLIC")]
|
||||
public string IsPublic => SDAConvert.ToSDABoolean(false);
|
||||
|
||||
[JsonProperty("C_ISHIBASANMEGADVA")]
|
||||
public string IsHibasanMegadva => SDAConvert.ToSDABoolean(false);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue