using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Globalization; using System.IO; using System.Linq; using System.Net; using System.Web.Mvc; using FastReport; using FastReport.Table; using FastReport.Utils; using ICSharpCode.SharpZipLib.Zip; using Kreta.BusinessLogic.Classes; using Kreta.BusinessLogic.HelperClasses; using Kreta.BusinessLogic.Helpers; using Kreta.BusinessLogic.Helpers.SystemSettings; using Kreta.Core; using Kreta.Enums; using Kreta.Enums.ManualEnums; using Kreta.Resources; using Kreta.Web.Areas.Alkalmazott.Models; using Kreta.Web.Areas.Nyomtatvanyok.Controllers; using Kreta.Web.Areas.Nyomtatvanyok.Models; using Kreta.Web.Areas.Orarend.Models; using Kreta.Web.Areas.Tanulo.Models; using Kreta.Web.Controllers; using Kreta.Web.Helpers; using Kreta.Web.Helpers.Error; using Kreta.Web.Security; using Newtonsoft.Json; namespace Kreta.Web.Areas.Nyomtatvanyok.Logic { public static class NyomtatvanyokLogic { private const float LABLEC_OLDALSZAM_MAGASSAG_MILIMETERBEN = 10; private const float LABLEC_MAGASSAG_MILIMETERBEN = 22; private const float KEP_MAGASSAG_MILIMETERBEN = 20; private const float LABLEC_FUGGOLEGES_TAVOLSAG_MILIMETERBEN = 1; private const float FEJLEC_MAGASSAG = 25; public class DokumentumModel { public string SzervezetNev { get; set; } public string EloadasHelyszin { get; set; } public string EloadasNev { get; set; } public string EloadasIdopontja { get; set; } public string TanuloNev { get; set; } public string TanuloOktAzon { get; set; } } public static ActionResult GetLepGondviseloEngedelyezesZip(string data) { var modelList = JsonConvert.DeserializeObject>(data); var outPut = new MemoryStream(); var zipOutPut = new ZipOutputStream(outPut); try { var intezmenyAdatok = new IntezmenyHelper(ConnectionTypeExtensions.GetOrganizationConnectionType()).GetAktivIntezmenyNevCim(); string dokumentumNeve = "LEP_gondviselo_engedelyezes"; byte[] buffer = new byte[Constants.General.BufferSize]; foreach (var item in modelList) { var parameters = new Dictionary { {"IntezmenyNev", intezmenyAdatok.Nev}, {"IntezmenyOmAzonosito", intezmenyAdatok.OMKod}, {"SzervezetNeve", item.SzervezetNev}, {"EloadasHelyszine", item.EloadasHelyszin}, {"EloadasNeve", item.EloadasNev}, {"Idopont", item.EloadasIdopontja}, {"TanuloNev", item.TanuloNev}, {"OktatasiAzonosito", item.TanuloOktAzon} }; var filePath = System.Web.HttpContext.Current.Server.MapPath($"{ApplicationData.NyomtatasiSablonokKonyvtar}/LEP_gondviselo_engedelyezes.frx"); var stream = GetPdfMemoryStreamByPath(new DataSet(), filePath, parameters, pdfNeve: $"{item.TanuloNev}_{item.TanuloOktAzon}"); var entry = new ZipEntry($"{item.TanuloNev}_{item.TanuloOktAzon}.{Constants.ImportExport.FileFormatPdf}"); zipOutPut.PutNextEntry(entry); int sourceBytes; do { sourceBytes = stream.Read(buffer, 0, buffer.Length); zipOutPut.Write(buffer, 0, sourceBytes); } while (sourceBytes > 0); } zipOutPut.Finish(); outPut.Position = 0; return new FileStreamResult(outPut, Constants.ImportExport.ContentType) { FileDownloadName = $"{dokumentumNeve}.zip" }; } catch (Exception ex) { throw NyomtatvanyError(ex); } } public static string GetFileLetoltesUrlGondviseo(GondviseloJelszoIgenyloCo co, int tanevId) { var nevmodel = new NyomtatvanyNevGeneralasModel { TanevID = tanevId }; var fileName = CommonExtensions.NevGeneralas("BelepesiAdatok", nevmodel, forOrganization: true); var stream = OnlineUrlapGondviselonek(co, tanevId); var guid = Cache.Add(stream); var fileFullName = $"{fileName}.pdf"; var url = new UrlHelper(System.Web.HttpContext.Current.Request.RequestContext); return url.Action(nameof(CacheController.DownloadFile), nameof(CacheController).Replace("Controller", ""), new { guid, fileName = fileFullName, contentType = Kreta.Core.Constants.ContentTypes.Pdf, area = "" }); } private static MemoryStream OnlineUrlapGondviselonek(GondviseloJelszoIgenyloCo co, int tanevId) { DateTime datum = DateTime.Today; var intezmenyAdatok = new IntezmenyHelper(ConnectionTypeExtensions.GetOrganizationConnectionType()).GetAktivIntezmenyNevCim(); var parameters = new Dictionary { {"Kelt", datum.ToString(Core.Constants.ToStringPattern.HungarianDate)}, {"IntezmenyNeve", intezmenyAdatok.Nev}, {"IntezmenyTelefon", intezmenyAdatok.Telefonszam}, {"IntezmenyOMKod", intezmenyAdatok.OMKod}, {"IntezmenyEmail", intezmenyAdatok.Email}, {"OktAzon", co.OktatasiAzonosito}, {"GondviseloEmail", co.GondviseloEmail}, {"GondviseloNev", co.GondviseloNev}, {"RokonsagiFok", co.RokonsagiFok.GetDisplayName(tanevId)}, {"Orszag", co.Orszag.GetDisplayName(tanevId)}, { "Helyiseg", co.Iranyitoszam + ", " + co.HelysegNev + ", " + co.KozteruletNev + " " + co.KozteruletTipusNev }, {"Hazszam", (co.Hazszam != null && (co.Emelet != null || co.Ajto != null)) ? co.Hazszam + "," : co.Hazszam}, {"Emelet", (co.Ajto != null) ? (co.Emelet != null ? co.Emelet + ". emelet, " : string.Empty) : (co.Emelet != null ? co.Emelet + ". emelet" : string.Empty)}, {"Ajto", (co.Ajto != null) ? co.Ajto + ". ajtó" : string.Empty} }; return PDFNyomtatasGondviselo(new DataSet(), "UrlapGondviselonek", parameters, "Gondviselo_Urlap"); } public static MemoryStream PDFNyomtatasGondviselo(DataSet ds, string frxNeve, Dictionary parameterek = null, string pdfNeve = "Alap") { FastReport.Utils.Config.WebMode = true; var report = new Report(); report.Load(System.Web.Hosting.HostingEnvironment.MapPath(ApplicationData.NyomtatasiSablonokKonyvtar + "/" + frxNeve + ".frx")); foreach (DataTable dt in ds.Tables) { report.RegisterData(dt, dt.TableName); } if (parameterek != null) { foreach (var parameter in parameterek) { report.SetParameterValue(parameter.Key, parameter.Value); } } if (report.Report.Prepare()) { FastReport.Export.Pdf.PDFExport pdfExport = new FastReport.Export.Pdf.PDFExport { ShowProgress = false, Subject = "Subject", Title = pdfNeve, Compressed = true, AllowPrint = true, EmbeddingFonts = true }; var stream = new MemoryStream(); report.Report.Export(pdfExport, stream); report.Dispose(); pdfExport.Dispose(); stream.Position = 0; return stream; } return null; } public static MemoryStream GetIktSzandeknyilatkozatAdatok() { try { DataSet ds = new NyomtatvanyokHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetIktSzandeknyilatkozatAdatok(); var dokumentumNeve = "IktSzandeknyilatkozatok"; var filePath = System.Web.HttpContext.Current.Server.MapPath($"{ApplicationData.NyomtatasiSablonokKonyvtar}/{dokumentumNeve}.frx"); var result = GetPdfMemoryStreamByPath(ds, filePath, pdfNeve: dokumentumNeve, dokumentumTipus: Enums.DokumentumTipusEnum.TorzslapkivonatA4EsFelsobbEvfolyamokhozNemetGepi); return result; } catch (Exception ex) { throw NyomtatvanyError(ex); } } public static MemoryStream GetPdfMemoryStreamByPath(DataSet ds, string filePath, Dictionary parameterek = null, string pdfNeve = "Alap", bool egyediLablecKellOldalszam = true, Enums.DokumentumTipusEnum? dokumentumTipus = null) { var result = GetPdfMemoryStream(ds, parameterek, pdfNeve, filePath, egyediLablecKellOldalszam, dokumentumTipus); return result; } private static MemoryStream GetPdfMemoryStream(DataSet ds, Dictionary parameterek, string pdfNeve, string filePath, bool egyediLablecKellOldalszam, Enums.DokumentumTipusEnum? dokumentumTipus) { FastReport.Utils.Config.WebMode = true; var report = new Report(); report.Load(filePath); var temp = report.ReportResourceString; var (IsDokumentumFejlecMegjelenit, IsDokumentumLablecMegjelenit) = new NyomtatvanyokHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetActualIntezmenyAdatok(); var helper = new IntezmenyHelper(ConnectionTypeExtensions.GetSessionConnectionType()); if (!IsEgyediFejlecLablecTiltott(dokumentumTipus)) { if (IsDokumentumFejlecMegjelenit && IsDokumentumLablecMegjelenit) { Image fejlecImage = helper.GetIntezmenyFejlecDokumentum(); Image lablecImage = helper.GetIntezmenyLablecDokumentum(); EgyediFejlecLablec(report, fejlecImage, lablecImage, egyediLablecKellOldalszam); } if (IsDokumentumFejlecMegjelenit && !IsDokumentumLablecMegjelenit) { Image fejlecImage = helper.GetIntezmenyFejlecDokumentum(); EgyediFejlec(report, fejlecImage); } if (IsDokumentumLablecMegjelenit && !IsDokumentumFejlecMegjelenit) { Image lablecImage = helper.GetIntezmenyLablecDokumentum(); EgyediLablec(report, lablecImage, egyediLablecKellOldalszam); } } foreach (DataTable dt in ds.Tables) { report.RegisterData(dt, dt.TableName); } if (parameterek != null) { foreach (var parameter in parameterek) { report.SetParameterValue(parameter.Key, parameter.Value); } } if (report.Report.Prepare()) { FastReport.Export.Pdf.PDFExport pdfExport = new FastReport.Export.Pdf.PDFExport { ShowProgress = false, Subject = "Subject", Title = pdfNeve, Compressed = true, AllowPrint = true, EmbeddingFonts = true }; var stream = new MemoryStream(); report.Report.Export(pdfExport, stream); report.Dispose(); pdfExport.Dispose(); stream.Position = 0; return stream; } return null; } public static Report EgyediFejlecLablec(Report reportDetail, Image fejlec, Image lablec, bool kellOldalszam) { if (fejlec != null && lablec != null) { for (int i = 0; i < reportDetail.Pages.Count; i++) { ReportPage addHeaderAndFooterPage = reportDetail.Pages[i] as ReportPage; EgyediFejlecGeneralas(fejlec, addHeaderAndFooterPage, i); EgyediLablecGeneralas(lablec, addHeaderAndFooterPage, i, kellOldalszam); } } return reportDetail; } public static Report EgyediFejlec(Report reportDetail, Image fejlec) { if (fejlec != null) { for (int i = 0; i < reportDetail.Pages.Count; i++) { ReportPage addHeaderPage = reportDetail.Pages[i] as ReportPage; EgyediFejlecGeneralas(fejlec, addHeaderPage, i); } } return reportDetail; } public static Report EgyediLablec(Report reportDetail, Image lablec, bool kellOldalszam) { if (lablec != null) { for (int i = 0; i < reportDetail.Pages.Count; i++) { ReportPage addFooterPage = reportDetail.Pages[i] as ReportPage; EgyediLablecGeneralas(lablec, addFooterPage, i, kellOldalszam); } } return reportDetail; } private static void EgyediFejlecGeneralas(Image fejlec, ReportPage reportPage, int pageIndex) { string reportName = reportPage.Name; reportPage.CreateUniqueName(); reportPage.Name = reportName; float pageWidth = reportPage.PaperWidth - Constants.ImportExport.PageWidthCorrect; reportPage.PageHeader = new PageHeaderBand { Name = "newHeader" + pageIndex, Height = SetSizeToMilimeter(FEJLEC_MAGASSAG) }; ComponentBase pageHeader; if (reportPage.Columns.Count > 1) { pageHeader = CreateTableObject(fejlec, pageWidth, reportPage.Columns.Count); } else { pageHeader = CreatePictureObject(fejlec, pageWidth); } reportPage.PageHeader.Objects.Add(pageHeader); } private static ComponentBase CreateTableObject(Image image, float width, int columnCount) { var tableHeader = new TableObject { RowCount = 1, ColumnCount = columnCount, Width = SetSizeToMilimeter(width) }; var columnWidth = width / columnCount; for (int i = 0; i < columnCount; i++) { tableHeader.Columns[i].MaxWidth = SetSizeToMilimeter(columnWidth); tableHeader.Columns[i].Width = SetSizeToMilimeter(columnWidth); tableHeader[i, 0].AddChild(CreatePictureObject(image, columnWidth)); } return tableHeader; } private static ComponentBase CreatePictureObject(Image image, float width) { PictureObject pictureHeader = new PictureObject { Width = SetSizeToMilimeter(width), Height = SetSizeToMilimeter(KEP_MAGASSAG_MILIMETERBEN), Image = image }; pictureHeader.CreateUniqueName(); return pictureHeader; } private static void EgyediLablecGeneralas(Image lablec, ReportPage reportPage, int pageIndex, bool kellOldalszam) { string reportName = reportPage.Name; reportPage.CreateUniqueName(); reportPage.Name = reportName; float pageWidth = reportPage.PaperWidth - Constants.ImportExport.PageWidthCorrect; reportPage.PageFooter = new PageFooterBand { Name = "newFooter" + pageIndex, Height = SetSizeToMilimeter(LABLEC_MAGASSAG_MILIMETERBEN + (kellOldalszam ? LABLEC_OLDALSZAM_MAGASSAG_MILIMETERBEN : 0)) }; ComponentBase pageFooter; if (reportPage.Columns.Count > 1) { pageFooter = CreateTableObject(lablec, pageWidth, reportPage.Columns.Count); } else { pageFooter = CreatePictureObject(lablec, pageWidth); } pageFooter.Top = SetSizeToMilimeter(LABLEC_FUGGOLEGES_TAVOLSAG_MILIMETERBEN); reportPage.PageFooter.Objects.Add(pageFooter); if (kellOldalszam) { TextObject footerText = new TextObject(); footerText.CreateUniqueName(); footerText.Bounds = new RectangleF(0.0f, 0.5f * Units.Centimeters, 19.0f * Units.Centimeters, SetSizeToMilimeter(LABLEC_OLDALSZAM_MAGASSAG_MILIMETERBEN)); footerText.Top = SetSizeToMilimeter(LABLEC_FUGGOLEGES_TAVOLSAG_MILIMETERBEN + KEP_MAGASSAG_MILIMETERBEN + LABLEC_FUGGOLEGES_TAVOLSAG_MILIMETERBEN); footerText.Width = SetSizeToMilimeter(pageWidth); footerText.HorzAlign = HorzAlign.Center; footerText.VertAlign = VertAlign.Center; footerText.Text = Constants.ImportExport.FrxPageCount; reportPage.PageFooter.Objects.Add(footerText); } } public static bool IsEgyediFejlecLablecTiltott(Enums.DokumentumTipusEnum? dokumentumTipus) { if (!dokumentumTipus.HasValue) { return false; } switch (dokumentumTipus.Value) { case Enums.DokumentumTipusEnum.TorzslapAz1tol3EsFelsobbEvfolyamokSzovegesMinositesehez: case Enums.DokumentumTipusEnum.TorzslapAz1tol3EsFelsobbEvfolyamokSzovegesMinositesehezAngolGepi: case Enums.DokumentumTipusEnum.TorzslapAz1tol3EsFelsobbEvfolyamokSzovegesMinositesehezMuveszetoktatasban: case Enums.DokumentumTipusEnum.TorzslapAz1tol3EsFelsobbEvfolyamokSzovegesMinositesehezNemetGepi: case Enums.DokumentumTipusEnum.TorzslapkivonatA4EsFelsobbEvfolyamokhozAngolGepi: case Enums.DokumentumTipusEnum.TorzslapkivonatA4EsFelsobbEvfolyamokhozGepi: case Enums.DokumentumTipusEnum.TorzslapkivonatA4EsFelsobbEvfolyamokhozGepiMuveszetoktatasban: case Enums.DokumentumTipusEnum.TorzslapkivonatA4EsFelsobbEvfolyamokhozNemetGepi: return true; default: return false; } } public static float SetSizeToMilimeter(float size) { return size * Units.Millimeters; } public static string KeltSzoveg(DateTime datum, int formatumId) { if (formatumId == (int)KeltFormatumTipusEnum.Szammal) { return datum.ToString(Core.Constants.ToStringPattern.HungarianDateWithSpaces); } return datum.Date.ToString("yyyy. MMMM dd.", new CultureInfo("hu-HU")); } public static StatusError NyomtatvanyError(Exception ex, string plusMessage = null) { var message = NyomtatvanyokResource.NyomtatvanyGeneralasHiba; if (ex.Message == NyomtatvanyokResource.UresDokumentum) { message = NyomtatvanyokResource.NemTartalmazRelevansAdatokat; } else if (ex.Message == NyomtatvanyokResource.ATanulonakFelnottkepzesiJogviszonyaVan) { message = NyomtatvanyokResource.ATanulonakFelnottkepzesiJogviszonyaVan; } else if (ex.Message == NyomtatvanyokResource.MindenTanulonakFelnottkepzesiJogviszonyaVan) { message = NyomtatvanyokResource.MindenTanulonakFelnottkepzesiJogviszonyaVan; } else if (ex.Message == NyomtatvanyokResource.JelzettNaponTanulonakNemVoltJelen) { message = NyomtatvanyokResource.JelzettNaponTanulonakNemVoltJelen; } else if (ex.Message == NyomtatvanyokResource.ATanuloknakNemNappaliRendszeruOktatasVanBeallitva) { message = NyomtatvanyokResource.ATanuloknakNemNappaliRendszeruOktatasVanBeallitva; } else if (ex.Message == NyomtatvanyokResource.TanulohozNincsMentorHozzarendelve) { message = NyomtatvanyokResource.TanulohozNincsMentorHozzarendelve; } else if (ex.Message == NyomtatvanyokResource.TanulonakNincsRogzitveGondviselo) { message = NyomtatvanyokResource.TanulonakNincsRogzitveGondviselo; } else if (ex.Message == TanuloResource.ATanulonakNincsRogzitettTorvenyesKepviseloje) { message = TanuloResource.ATanulonakNincsRogzitettTorvenyesKepviseloje; } else if ( ex.InnerException.Message.Contains(NyomtatvanyokResource.TanulonalKotelezoKotelezoenValaszthatoTargyakSzamaNagyobbMintMaxSor) || ex.InnerException.Message.Contains(NyomtatvanyokResource.TanulonalValaszthatoTargyakSzamaNagyobbMintMaxSor) || ex.InnerException.Message.Contains(NyomtatvanyokResource.TanulonalKotelezoTargyakSzamaNagyobbMintMaxSor) || ex.InnerException.Message.Contains(NyomtatvanyokResource.TanulonalKotelezoenValaszthatoTargyakSzamaNagyobbMintMaxSor) || ex.InnerException.Message.Contains(NyomtatvanyokResource.TanulonalFotargyakSzamaNagyobbMintMaxSor)) { message = ex.InnerException.Message; } if (!string.IsNullOrWhiteSpace(plusMessage)) { message += plusMessage; } var result = new StatusError( HttpStatusCode.InternalServerError, message) { UnHandledException = ex }; return result; } public static StatusError NyomtatvanyError(string message, HttpStatusCode statusCode = HttpStatusCode.InternalServerError) { var result = new StatusError(statusCode, message); return result; } public static (bool HasSzovegesErtekelesHosszLimit, string WarningText) GetSzovegesErtekelesHosszValidationDeatails(int nyomtatvanyId) { var defaultResult = (false, string.Empty); if (!Core.Constants.OsszesErtesitokWithSzovegesErtekelesHosszLimit().Contains(nyomtatvanyId)) { return defaultResult; } if (Core.Constants.FeleviErtesitokWithSzovegesErtekelesHosszLimit.Contains(nyomtatvanyId)) { return (true, string.Format(NyomtatvanyokResource.SzovegesErtekelesHosszLimitText, $"a \"{NyomtatvanyokResource.FeleviErtesito}")); } if (Core.Constants.EvVegiErtesitokWithSzovegesErtekelesHosszLimit.Contains(nyomtatvanyId)) { return (true, string.Format(NyomtatvanyokResource.SzovegesErtekelesHosszLimitText, $"az \"{NyomtatvanyokResource.EvVegiErtesito}")); } if (Core.Constants.INegyedeviErtesitokWithSzovegesErtekelesHosszLimit.Contains(nyomtatvanyId)) { return (true, string.Format(NyomtatvanyokResource.SzovegesErtekelesHosszLimitText, $"az \"{NyomtatvanyokResource.INegyedeviErtesito}")); } if (Core.Constants.IINegyedeviErtesitokWithSzovegesErtekelesHosszLimit.Contains(nyomtatvanyId)) { return (true, string.Format(NyomtatvanyokResource.SzovegesErtekelesHosszLimitText, $"a \"{NyomtatvanyokResource.IINegyedeviErtesito}")); } if (Core.Constants.IIINegyedeviErtesitokWithSzovegesErtekelesHosszLimit.Contains(nyomtatvanyId)) { return (true, string.Format(NyomtatvanyokResource.SzovegesErtekelesHosszLimitText, $"a \"{NyomtatvanyokResource.IIINegyedeviErtesito}")); } if (Core.Constants.IVNegyedeviErtesitokWithSzovegesErtekelesHosszLimit.Contains(nyomtatvanyId)) { return (true, string.Format(NyomtatvanyokResource.SzovegesErtekelesHosszLimitText, $"a \"{NyomtatvanyokResource.IVNegyedeviErtesito}")); } return defaultResult; } public static void AddQrCode(Report report, Bitmap qrCode) { if (report.FindObject("PictureQr") is PictureObject pic) { pic.Image = qrCode; } } public static void ValidateFelnottkepzes(List tanulocsoportIdList, List osztalyIdList, NyomtatvanyokHelper helper) { if (tanulocsoportIdList != null) { var kivalasztottTanulokOsztalyai = helper.GetOsztalyIdListByTanulocsoportIdList(tanulocsoportIdList); var tovabbiKivalasztottOsztalyok = osztalyIdList.Except(kivalasztottTanulokOsztalyai).ToList(); if (tovabbiKivalasztottOsztalyok.Count > 0) { var tovabbiOsztalyokTanulocsoportIdList = helper.GetTanulocsoportIdByOsztalyIdList(tovabbiKivalasztottOsztalyok); tanulocsoportIdList.AddRange(tovabbiOsztalyokTanulocsoportIdList); } tanulocsoportIdList = tanulocsoportIdList.Distinct().ToList(); if (tanulocsoportIdList.Count == 0) { throw new Exception(NyomtatvanyokResource.UresDokumentum); } else if (tanulocsoportIdList.Count == 1) { if (helper.IsTanuloFelnottkepzesJogviszonyByTanulocsoportId(tanulocsoportIdList[0])) { throw new Exception(NyomtatvanyokResource.ATanulonakFelnottkepzesiJogviszonyaVan); } } else { if (helper.IsAllTanuloFelnottkepzesJogviszonyByTanulocsoportIdList(tanulocsoportIdList)) { throw new Exception(NyomtatvanyokResource.MindenTanulonakFelnottkepzesiJogviszonyaVan); } } return; } if (osztalyIdList != null) { var tanuloList = helper.GetNumberOfTanuloNemFelnottkepzesJogviszonyByOsztalyIdList(osztalyIdList); if (tanuloList == null || tanuloList == 0) { throw new Exception(NyomtatvanyokResource.UresDokumentum); } } } public static void ValidateJogviszonyLetolthetosegSzakkepzo(List tanulocsoportIdList, List osztalyIdList, NyomtatvanyokHelper helper, bool isSelectedTanev21_22orLater) { var nyomtathatoJogviszonyosTanerviJellegekIdList = new int[] { (int)TanterviJellegEnum.nappali_rendszeru_iskolai_oktatas, (int)TanterviJellegEnum.felnottoktatas_nappali_rendszeru }; if (tanulocsoportIdList != null) { var kivalasztottTanulokOsztalyai = helper.GetOsztalyIdListByTanulocsoportIdList(tanulocsoportIdList); var tovabbiKivalasztottOsztalyok = osztalyIdList.Except(kivalasztottTanulokOsztalyai).ToList(); if (tovabbiKivalasztottOsztalyok.Count > 0) { var tovabbiOsztalyokTanulocsoportIdList = helper.GetTanulocsoportIdByOsztalyIdList(tovabbiKivalasztottOsztalyok); tanulocsoportIdList.AddRange(tovabbiOsztalyokTanulocsoportIdList); } tanulocsoportIdList = tanulocsoportIdList.Distinct().ToList(); var adatok = helper.GetJogviszonyTipusTanterviJellegByTanulocsoportIdList(tanulocsoportIdList); if (adatok.Any(x => x.jogviszonyId == (int)JogviszonyTipusEnum.felnottkepzesi_jogviszony)) { if (tanulocsoportIdList.Count == 1) { throw new Exception(NyomtatvanyokResource.ATanulonakFelnottkepzesiJogviszonyaVan); } else { if (adatok.All(x => x.jogviszonyId == (int)JogviszonyTipusEnum.felnottkepzesi_jogviszony)) { throw new Exception(NyomtatvanyokResource.MindenTanulonakFelnottkepzesiJogviszonyaVan); } } } if (adatok.Any(x => !x.jogviszonyId.IsEntityId() && !nyomtathatoJogviszonyosTanerviJellegekIdList.Contains(x.tanterviJellegId))) { if (isSelectedTanev21_22orLater && (tanulocsoportIdList.Count == 1 || adatok.All(x => !x.jogviszonyId.IsEntityId() && !nyomtathatoJogviszonyosTanerviJellegekIdList.Contains(x.tanterviJellegId)))) { throw new Exception(NyomtatvanyokResource.ATanuloknakNemNappaliRendszeruOktatasVanBeallitva); } } return; } if (osztalyIdList != null) { var adatok = helper.GetJogviszonyTipusTanterviJellegByOsztalyIdList(osztalyIdList); if (!adatok.Any()) { throw new Exception(NyomtatvanyokResource.UresDokumentum); } if (adatok.All(x => x.jogviszonyId == (int)JogviszonyTipusEnum.felnottkepzesi_jogviszony)) { throw new Exception(NyomtatvanyokResource.MindenTanulonakFelnottkepzesiJogviszonyaVan); } if (adatok.All(x => !x.jogviszonyId.IsEntityId() && !nyomtathatoJogviszonyosTanerviJellegekIdList.Contains(x.tanterviJellegId)) && isSelectedTanev21_22orLater) { throw new Exception(NyomtatvanyokResource.ATanuloknakNemNappaliRendszeruOktatasVanBeallitva); } } } #region Tanulói kapcsolat keresés internal static List<(string tanuloNev, DataSet tanuloKapcsolatKeresoAdatok)> GetTanulokKapcsolatKereso(NyomtatvanyokController.NyomtatvanyModel model, TanuloiKapcsolatKeresesModel tanuloiKapcsolatKeresesAdatok) { var tanulokKapcsolatai = new List<(string, DataSet)>(); foreach (var tanuloId in model.TanuloIdList) { var tanuloNev = new TanuloHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetTanuloNev(tanuloId); var tanuloKapcsolatKeresoAdatok = GetTanuloiKapcsolatKereso(tanuloId, model.KeltDatum, tanuloiKapcsolatKeresesAdatok); tanulokKapcsolatai.Add((tanuloNev, tanuloKapcsolatKeresoAdatok)); } return tanulokKapcsolatai; } public static DataSet GetTanuloiKapcsolatKereso(int tanuloId, DateTime keresettNap, TanuloiKapcsolatKeresesModel tanuloiKapcsolatKeresesModel) { DataSet mainDataSet = new DataSet(); var foglalkozasokonJelenlevoTanuloId = new List(); var foglalkozasokonJelenlevoAlkalmazottId = new List(); var foglalkozasokonHasznaltTeremId = new List(); var foglalkozasiAdatok = tanuloiKapcsolatKeresesModel.MegtartottTanorak.FoglalkozasiAdatokFilter(tanuloId, keresettNap, foglalkozasokonJelenlevoTanuloId, foglalkozasokonJelenlevoAlkalmazottId, foglalkozasokonHasznaltTeremId); mainDataSet.Tables.Add(foglalkozasiAdatok.Tables[0].Copy()); mainDataSet.Tables[0].TableName = "Foglalkozási adatok"; var tanuloiAdatok = tanuloiKapcsolatKeresesModel.TanuloiAdatok.AdatokFilter(foglalkozasokonJelenlevoTanuloId); mainDataSet.Tables.Add(tanuloiAdatok.Tables[0].Copy()); mainDataSet.Tables[1].TableName = "Tanulói adatok"; var gondviseloiAdatok = tanuloiKapcsolatKeresesModel.GondviseloiAdatok.AdatokFilter(foglalkozasokonJelenlevoTanuloId); mainDataSet.Tables.Add(gondviseloiAdatok.Tables[0].Copy()); mainDataSet.Tables[2].TableName = "Gondviselői adatok"; var alkalmazottiAdatok = tanuloiKapcsolatKeresesModel.AlkalmazottiAdatok.AdatokFilter(foglalkozasokonJelenlevoAlkalmazottId); mainDataSet.Tables.Add(alkalmazottiAdatok.Tables[0].Copy()); mainDataSet.Tables[3].TableName = "Alkalmazotti adatok"; var tanteremAdatok = tanuloiKapcsolatKeresesModel.MegtartottTanorak.AdatokFilter(foglalkozasokonHasznaltTeremId, "TeremId"); mainDataSet.Tables.Add(tanteremAdatok.Tables[0].Copy()); mainDataSet.Tables[4].TableName = "Tanterem adatok"; NyomtatvanyokTanulokHelper.FoglalkozasiAdatokFeleslegesOszlopokTorlese(mainDataSet.Tables[0]); NyomtatvanyokTanulokHelper.TanuloiEsGondviseloiEsAlkalmazottiAdatokFeleslegesOszlopokTorlese(mainDataSet.Tables[1]); NyomtatvanyokTanulokHelper.TanuloiEsGondviseloiEsAlkalmazottiAdatokFeleslegesOszlopokTorlese(mainDataSet.Tables[2]); NyomtatvanyokTanulokHelper.TanuloiEsGondviseloiEsAlkalmazottiAdatokFeleslegesOszlopokTorlese(mainDataSet.Tables[3]); NyomtatvanyokTanulokHelper.FoglalkozasiAdatokFeleslegesOszlopokTorlese(mainDataSet.Tables[4]); return mainDataSet; } #region DataSet szűrések private static DataSet AdatokFilter(this DataSet adatok, List foglalkozasokonJelenlevoAlkalmazottId, string felhasznaloIdOszlopNev = "FelhasznaloId") { var adatokFilter = adatok.Clone(); foreach (DataRow adat in adatok.Tables[0].Rows) { var felhasznaloId = SDAConvert.ToInt32(adat[felhasznaloIdOszlopNev]); if (foglalkozasokonJelenlevoAlkalmazottId.Contains(felhasznaloId)) { adatokFilter.Tables[0].ImportRow(adat); } } return adatokFilter; } public static DataSet FoglalkozasiAdatokFilter(this DataSet megtartottTanorak, int tanuloId, DateTime keresettNap, List foglalkozasokonJelenlevoTanuloId, List foglalkozasokonJelenlevoAlkalmazottId, List foglalkozasokonHasznaltTeremId) { DataSet foglalkozasiAdatokFilter = megtartottTanorak.Clone(); var systemHelper = new SystemSettingsHelper(ConnectionTypeExtensions.GetSessionConnectionType()); var tanevHelper = new TanevHelper(ConnectionTypeExtensions.GetSessionConnectionType()); var alapertelmezettMulasztasTipus = (MulasztasTipusEnum)systemHelper.GetSystemSettingValue(RendszerBeallitasTipusEnum.alapertelmezett_statusz_naplozasok_eseteben); var tanevCo = tanevHelper.GetTanevInfo(); foreach (DataRow megtartottTanora in megtartottTanorak.Tables[0].Rows) { var foglalkozasiAdatokCo = new NyomtatvanyokFoglalkozasiAdatokCo(megtartottTanora); var megtartottTanoraTanuloi = new OsztalyCsoportHelper(ConnectionTypeExtensions.GetSessionConnectionType()) .GetMulasztasEsFelmentesOsztalyCsoportTanuloi(foglalkozasiAdatokCo.OsztalycsoportId, foglalkozasiAdatokCo.TanoraId, foglalkozasiAdatokCo.TargyId, foglalkozasiAdatokCo.TanarId, keresettNap, 1, tanevCo, alapertelmezettMulasztasTipus); var megtartottTanoraTanuloiIdLista = (from DataRow dataRow in megtartottTanoraTanuloi.Tables[0].Rows where (SDAConvert.ToInt32(dataRow["MulasztasTipus"]) == (int)MulasztasTipusEnum.jelenlet || SDAConvert.ToInt32(dataRow["MulasztasTipus"]) == (int)MulasztasTipusEnum.keses) select SDAConvert.ToInt32(dataRow["ID"])); if (megtartottTanoraTanuloiIdLista.Contains(tanuloId)) { foglalkozasiAdatokFilter.Tables[0].ImportRow(megtartottTanora); foglalkozasokonJelenlevoTanuloId.AddRange(megtartottTanoraTanuloiIdLista); foglalkozasokonJelenlevoAlkalmazottId.Add(foglalkozasiAdatokCo.TanarId); foglalkozasokonHasznaltTeremId.Add(foglalkozasiAdatokCo.TeremId); } } foglalkozasokonJelenlevoTanuloId = foglalkozasokonJelenlevoTanuloId.Distinct().ToList(); return foglalkozasiAdatokFilter; } #endregion #region DataSet feltöltés public static TanuloiKapcsolatKeresesModel TanuloiKapcsolatKeresesAdatok(DateTime keresettNap) { var tanuloiKapcsolatKeresesModel = new TanuloiKapcsolatKeresesModel(); tanuloiKapcsolatKeresesModel.MegtartottTanorak = MegtartottTanorak(keresettNap); tanuloiKapcsolatKeresesModel.TanuloiAdatok = TanuloiAdatok(); tanuloiKapcsolatKeresesModel.GondviseloiAdatok = GondviseloiAdatok(); tanuloiKapcsolatKeresesModel.AlkalmazottiAdatok = AlkalmazottiAdatok(); return tanuloiKapcsolatKeresesModel; } private static DataSet MegtartottTanorak(DateTime keresettNap) { var megtartottTanorakKeresoModel = new TanitasiOraSearchModel() { DatumTol = keresettNap, DatumIg = keresettNap, FeladatKategoriaId = Constants.MindenErteke.FeladatKategoria }; return new TanoraHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetMegtartottTanorakExport(Orarend.Models.TanitasiOraSearchModel.ConvertModelToCo(megtartottTanorakKeresoModel), isShowId: true); } private static DataSet TanuloiAdatok() { var model = new TanuloSearchModel() { FeladatKategoriaId = Constants.MindenErteke.FeladatKategoria }; return new TanuloHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetTanulokLakcimmelExport(model.ConvertModelToCo(ConnectionTypeExtensions.GetSessionConnectionType(), ClaimData.IsActivTanev), isShowId: true); } private static DataSet GondviseloiAdatok() { var model = new TanuloSearchModel() { FeladatKategoriaId = Constants.MindenErteke.FeladatKategoria }; var connectionType = ConnectionTypeExtensions.GetSessionConnectionType(); return new TanuloHelper(connectionType).GetGondviselokElerhetosegeiExport(model.ConvertModelToCo(connectionType, ClaimData.IsActivTanev), OktNevelesiKategoriaEnum.NevelesOktatas, isShowId: true); } private static DataSet AlkalmazottiAdatok() { var model = new AlkalmazottSearchModel() { }; return new AlkalmazottHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetAlkalmazottakLakcimmelExport(model.ConvertModelToCo(), isShowId: true); } #endregion #endregion } }