init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
181
Kreta.BusinessLogic/HelperClasses/ImportCo/TanmenetImportCo.cs
Normal file
181
Kreta.BusinessLogic/HelperClasses/ImportCo/TanmenetImportCo.cs
Normal file
|
@ -0,0 +1,181 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using Kreta.BusinessLogic.Validation;
|
||||
using Kreta.Core;
|
||||
using Kreta.Core.CustomAttributes;
|
||||
using Kreta.Resources;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Kreta.BusinessLogic.HelperClasses.ImportCo
|
||||
{
|
||||
public class TanmenetImportCo : BaseImportCo
|
||||
{
|
||||
[JsonIgnore]
|
||||
public List<TanmenetImportItemCo> MainImportItemList { get; set; } = new List<TanmenetImportItemCo>();
|
||||
|
||||
[JsonIgnore]
|
||||
public List<TanmenetImportItemCo> NemImportalhatoItemList { get; set; } = new List<TanmenetImportItemCo>();
|
||||
|
||||
[JsonProperty("T_TANMENET_OSSZES")]
|
||||
public List<TanmenetImportJsonItemCo> MainImportJsonItemList { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public TantargyfelosztasItemCo Tantargyfelosztas { get; set; }
|
||||
|
||||
public Dictionary<int, List<ValidationResult>> Validate()
|
||||
{
|
||||
var validationResultDictionary = new Dictionary<int, List<ValidationResult>>();
|
||||
|
||||
foreach (TanmenetImportItemCo importItem in MainImportItemList)
|
||||
{
|
||||
var validationResultList = new List<ValidationResult>();
|
||||
//NOTE: Az import item-eket egyesével levalidáljuk!
|
||||
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>
|
||||
{
|
||||
ImportExportTanmenetResource.ImportHeaderNameOraszam
|
||||
};
|
||||
ValidateDuplicatedRows(validationResultDictionary, lineNumberCompareHashDictionary, duplicatedRowConditonTextList);
|
||||
return validationResultDictionary;
|
||||
}
|
||||
}
|
||||
|
||||
public class TanmenetImportItemCo : BaseImportItemCo, IValidatableObject
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Technikai paraméter(ek) a reflection-ös exporthoz.
|
||||
/// </summary>
|
||||
public const string NemImportalhatoSorokExportAttributeId = nameof(NemImportalhatoSorokExportAttributeId);
|
||||
|
||||
#endregion Fields
|
||||
|
||||
[SimpleExportColumn(NemImportalhatoSorokExportAttributeId, 00, nameof(ImportExportTanmenetResource.ImportHeaderNameOraszam), typeof(ImportExportTanmenetResource))]
|
||||
[Required(ErrorMessageResourceName = nameof(ErrorResource.Required), ErrorMessageResourceType = typeof(ErrorResource))]
|
||||
[MaxLength(4, ErrorMessageResourceName = nameof(CommonResource.MaxLengthValidation), ErrorMessageResourceType = typeof(CommonResource))]
|
||||
[Display(Name = nameof(ImportExportTanmenetResource.ImportHeaderNameOraszam), ResourceType = typeof(ImportExportTanmenetResource))]
|
||||
public string OraszamImportData { get; set; }
|
||||
|
||||
[SimpleExportColumn(NemImportalhatoSorokExportAttributeId, 01, nameof(ImportExportTanmenetResource.ImportHeaderNameTema), typeof(ImportExportTanmenetResource))]
|
||||
[Required(ErrorMessageResourceName = nameof(ErrorResource.Required), ErrorMessageResourceType = typeof(ErrorResource))]
|
||||
[MaxLength(1000, ErrorMessageResourceName = nameof(CommonResource.MaxLengthValidation), ErrorMessageResourceType = typeof(CommonResource))]
|
||||
[Display(Name = nameof(ImportExportTanmenetResource.ImportHeaderNameTema), ResourceType = typeof(ImportExportTanmenetResource))]
|
||||
public string TemaImportData { get; set; }
|
||||
|
||||
public int? OraSorszam => GetIntValue(OraszamImportData);
|
||||
|
||||
public string Tema => GetStringValue(TemaImportData);
|
||||
|
||||
public TanmenetItemCo Tanmenet { get; set; }
|
||||
|
||||
#region Validate
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
|
||||
//NOTE: Ha van megadva bármilyen érték az import data-ban, meg kell vizsgálni, hogy sikerült-e átkonvertálni a megfelelő típusra.
|
||||
if (!string.IsNullOrWhiteSpace(OraszamImportData))
|
||||
{
|
||||
//NOTE: Ha az érték null, akkor a bejövő adat nem megfelelő formátumú!
|
||||
if (!OraSorszam.HasValue)
|
||||
{
|
||||
yield return new ValidationResult(string.Format(ImportExportCommonResource.InvalidNumberFormat, ImportExportTanmenetResource.ImportHeaderNameOraszam, OraszamImportData));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (OraSorszam < 0 || OraSorszam > 720)
|
||||
{
|
||||
yield return new ValidationResult(ErrorResource.AzOraSzamaCsakEgy0Es720KozottiEgeszSzamLehet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Validate
|
||||
}
|
||||
|
||||
public class TanmenetImportJsonItemCo : BaseImportJsonItemCo
|
||||
{
|
||||
public TanmenetImportJsonItemCo(TanmenetImportItemCo importItemCo, TantargyfelosztasItemCo tantargyfelosztasItemCo, int tanevId, int intezmenyId, int felhasznaloId) : base(tanevId, intezmenyId, felhasznaloId)
|
||||
{
|
||||
Now = DateTime.Now;
|
||||
|
||||
if (importItemCo.Tanmenet != null)
|
||||
{
|
||||
BejegyzesIdeje = importItemCo.Tanmenet.BejegyzesIdeje;
|
||||
BejegyzesIdejeString = importItemCo.Tanmenet.BejegyzesIdejeString;
|
||||
}
|
||||
else
|
||||
{
|
||||
BejegyzesIdeje = Now;
|
||||
BejegyzesIdejeString = Now.ToString(Constants.ToStringPattern.SortableDateTimePattern);
|
||||
}
|
||||
|
||||
TantargyId = tantargyfelosztasItemCo.TantargyId;
|
||||
OsztalyCsoportId = tantargyfelosztasItemCo.OsztalyCsoportId;
|
||||
TanarId = tantargyfelosztasItemCo.TanarId;
|
||||
|
||||
Tema = importItemCo.Tema;
|
||||
//NOTE: Az OraSorszam.Value nem lehet null, mert ide már csak olyan elem jön be, aminek van óraszáma!
|
||||
OraSorszam = importItemCo.OraSorszam.Value;
|
||||
Nev = $"{OraSorszam}. {Tema}";
|
||||
|
||||
Id = importItemCo.Id;
|
||||
LineNumber = importItemCo.LineNumber;
|
||||
Operation = importItemCo.Operation;
|
||||
}
|
||||
|
||||
#region Import Json Properties
|
||||
|
||||
[JsonIgnore]
|
||||
public DateTime BejegyzesIdeje { get; set; }
|
||||
|
||||
[JsonProperty("C_BEJEGYZESIDEJE")]
|
||||
public string BejegyzesIdejeString { get; set; }
|
||||
|
||||
[JsonProperty("C_ORASZAM")]
|
||||
public int OraSorszam { get; set; }
|
||||
|
||||
[JsonProperty("C_TANTARGYID")]
|
||||
public int TantargyId { get; set; }
|
||||
|
||||
[JsonProperty("C_OSZTALYCSOPORTID")]
|
||||
public int OsztalyCsoportId { get; set; }
|
||||
|
||||
[JsonProperty("C_FELTOLTOID")]
|
||||
public int TanarId { get; set; }
|
||||
|
||||
[JsonProperty("C_TEMA")]
|
||||
public string Tema { get; set; }
|
||||
|
||||
[JsonProperty("C_NEV")]
|
||||
public string Nev { get; set; }
|
||||
|
||||
#region Default Required Import Json Properties
|
||||
|
||||
[JsonProperty("C_MEGJEGYZES")]
|
||||
public string Megjegyzes => null;
|
||||
|
||||
[JsonProperty("C_ROVIDNEV")]
|
||||
public string RovidNev => null;
|
||||
|
||||
#endregion Default Required Import Json Properties
|
||||
|
||||
#endregion Import Json Properties
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue