init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,746 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using Kreta.BusinessLogic.Classes;
|
||||
using Kreta.BusinessLogic.Classes.AsposeHelpers;
|
||||
using Kreta.BusinessLogic.HelperClasses;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Helpers.Nyomtatvanyok.Excel;
|
||||
using Kreta.Core;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Enums.ManualEnums;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Helpers;
|
||||
using Kreta.Web.Security;
|
||||
|
||||
namespace Kreta.Web.Areas.Nyomtatvanyok.Controllers
|
||||
{
|
||||
public partial class NyomtatvanyokController : BaseNyomtatvanyokController
|
||||
{
|
||||
public ActionResult AltalanosTanuloiGeneralas(NyomtatvanyModel model, string frxNyomtatvanyNeve, DokumentumKategoriaEnum dokumentumKategoria, Enums.DokumentumTipusEnum? dokumentumTipus, System.Reflection.MethodInfo metodus, int osztalyIdParameterOrder, IDictionary<string, object> dataSetParameterek, Dictionary<string, object> frxParameterek, string nyomtatvanyNeve = null, string excludedTables = null, string distinctTables = null, bool isCsoport = false, string tablakFilterByTanuloId = "", string tanuloIdColumnName = "", BaseNyomtatvanyExcelWithDataSet formazottExcelGenerator = null, string emptyDocumentTable = null, bool egyediLablecKellOldalszam = true, bool IsAspose = false, System.Reflection.MethodInfo asposeMetodus = null, AsposeHelperOptions asposeHelperOptions = null, bool egyTanuloTobbNyomtatvanyaEgyben = false)
|
||||
{
|
||||
if ((model.FormatumId == NyomtatvanyFormatumEnum.Excel.AsInt()) && (formazottExcelGenerator == null))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(formazottExcelGenerator));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(nyomtatvanyNeve))
|
||||
{
|
||||
nyomtatvanyNeve = frxNyomtatvanyNeve;
|
||||
}
|
||||
|
||||
var OutPut = new MemoryStream();
|
||||
var ZipOutPut = new ZipOutputStream(OutPut);
|
||||
|
||||
var buffer = new byte[Constants.General.BufferSize];
|
||||
var nevmodel = new NyomtatvanyNevGeneralasModel() { TanevID = ClaimData.SelectedTanevID.Value };
|
||||
|
||||
DataSet mergedDs = new DataSet();
|
||||
var needMergedData = false;
|
||||
var atLeastOneData = false;
|
||||
|
||||
var isOsztalySzintuGeneralas =
|
||||
// ha nincs kijelölve tanuló
|
||||
(model.TanuloIdList == null)
|
||||
// és (egy osztálycsoport egyben
|
||||
&& (((isCsoport ? model.CsoportIdList : model.OsztalyIdList).Count == 1 && !model.AlapszintuNyomtatvanyokKulonDokumentumba)
|
||||
// vagy egynél több osztály külön)
|
||||
|| (((isCsoport ? model.CsoportIdList : model.OsztalyIdList).Count > 1 && model.AlapszintuNyomtatvanyokKulonDokumentumba)));
|
||||
|
||||
var foszamKulcsSzavak = (kulcsSzavak: (NameValueCollection)null, foszamDefinicio: (BusinessLogic.Helpers.Nyomtatvanyok.Iktatas.FoszamDefinicioValueModel)null);
|
||||
|
||||
var osztalyCsoportLista = (isCsoport) ? GetCsoportIdList(model.CsoportIdList, null) : GetOsztalyIdList(model.OsztalyIdList, null);
|
||||
|
||||
for (int db = 0; db < osztalyCsoportLista.Count; db++)
|
||||
{
|
||||
var osztalyId = osztalyCsoportLista[db];
|
||||
if (isOsztalySzintuGeneralas)
|
||||
{
|
||||
if (isCsoport)
|
||||
{
|
||||
nevmodel.CsoportId = osztalyId;
|
||||
}
|
||||
else
|
||||
{
|
||||
nevmodel.OsztalyID = osztalyId;
|
||||
}
|
||||
}
|
||||
|
||||
DataSet osztalyDS;
|
||||
|
||||
var pis = metodus.GetParameters();
|
||||
var parObjs = new object[pis.Length];
|
||||
for (int i = 0; i < pis.Length; i++)
|
||||
{
|
||||
if (i == osztalyIdParameterOrder)
|
||||
{
|
||||
parObjs[i] = osztalyId;
|
||||
}
|
||||
else
|
||||
{
|
||||
parObjs[i] = (dataSetParameterek.Keys.Contains(pis[i].Name)) ? dataSetParameterek[pis[i].Name] : Type.Missing;
|
||||
}
|
||||
}
|
||||
|
||||
osztalyDS = metodus.Invoke(new NyomtatvanyokHelper(ConnectionTypeExtensions.GetSessionConnectionType()), parObjs) as DataSet;
|
||||
|
||||
var tanuloIdList = (isOsztalySzintuGeneralas || (osztalyCsoportLista.Count > 1 && !model.AlapszintuNyomtatvanyokKulonDokumentumba && model.TanuloIdList == null)) ? new int[] { -1 }.ToList() : GetTanulokIdList(model.TanuloIdList, osztalyId);
|
||||
|
||||
if (dokumentumTipus == Enums.DokumentumTipusEnum.TanuloiJogviszonyIgazoloLap_ && model.TanuloIdList != null)
|
||||
{
|
||||
tanuloIdList = model.TanuloIdList.Distinct().ToList();
|
||||
}
|
||||
|
||||
if (model.MustGondviselo.HasValue && model.MustGondviselo.Value && osztalyCsoportLista.Count == 1 && model.TanuloIdList != null)
|
||||
{
|
||||
var tanuloIdListTemp = tanuloIdList.ToList();
|
||||
|
||||
if (tanuloIdListTemp.Count == 1 && tanuloIdList.First() == -1)
|
||||
{
|
||||
tanuloIdListTemp = GetTanulokIdList(new List<int>(), osztalyId);
|
||||
}
|
||||
|
||||
tanuloIdListTemp = CheckTanuloHasGondviselo(tanuloIdListTemp);
|
||||
|
||||
if (tanuloIdListTemp.Count == 0)
|
||||
{
|
||||
throw new Exception(NyomtatvanyokResource.TanulonakNincsRogzitveGondviselo);
|
||||
}
|
||||
}
|
||||
|
||||
if (model.MustGondviseloIsTorvenyes.HasValue && model.MustGondviseloIsTorvenyes.Value && osztalyCsoportLista.Count == 1 && model.TanuloIdList != null)
|
||||
{
|
||||
var tanuloIdListTemp = tanuloIdList.ToList();
|
||||
|
||||
if (tanuloIdListTemp.Count == 1 && tanuloIdListTemp.First() == -1)
|
||||
{
|
||||
tanuloIdListTemp = GetTanulokIdList(new List<int>(), osztalyId);
|
||||
}
|
||||
|
||||
tanuloIdListTemp = CheckTanuloGondviseloIsTorvenyes(tanuloIdListTemp);
|
||||
|
||||
if (tanuloIdListTemp.Count == 0)
|
||||
{
|
||||
throw new ApplicationException(TanuloResource.ATanulonakNincsRogzitettTorvenyesKepviseloje);
|
||||
}
|
||||
}
|
||||
|
||||
if (osztalyDS.Tables.Contains("Orarend"))
|
||||
{
|
||||
if (osztalyDS.Tables["Orarend"].Columns.Contains("Szombat"))
|
||||
{
|
||||
var szombatColIdx = osztalyDS.Tables["Orarend"].Columns.IndexOf("Szombat");
|
||||
var columnHasData = osztalyDS.Tables["Orarend"].AsEnumerable().FirstOrDefault(row => !(row[szombatColIdx] is DBNull));
|
||||
|
||||
if (!frxParameterek.Keys.Contains("SzombatiNap"))
|
||||
{
|
||||
if (columnHasData == null)
|
||||
{
|
||||
frxParameterek.Add("SzombatiNap", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
frxParameterek.Add("SzombatiNap", true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var val = (bool)frxParameterek["SzombatiNap"];
|
||||
val |= (columnHasData != null);
|
||||
frxParameterek["SzombatiNap"] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var tanuloId in tanuloIdList)
|
||||
{
|
||||
DataSet ds;
|
||||
if (tanuloId.IsEntityId())
|
||||
{
|
||||
nevmodel.TanuloID = tanuloId;
|
||||
|
||||
if (model.MustGondviseloIsTorvenyes.HasValue && model.MustGondviseloIsTorvenyes.Value && !CheckTanuloGondviseloIsTorvenyes(tanuloId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Tanuló bizonyítványainak és értesítőinek lekérése egyszerre miatt kell, mert a zip-be annyi egyforma nevű fájl kerül, ahány osztályba/csoportba jár. Ráadásul magában a csoport dokumentumban sem szerepel a csoport megnevezése. (KRETA2-6697)
|
||||
if (egyTanuloTobbNyomtatvanyaEgyben)
|
||||
{
|
||||
if (!isCsoport)
|
||||
{
|
||||
nevmodel.OsztalyID = osztalyId;
|
||||
}
|
||||
else
|
||||
{
|
||||
nevmodel.CsoportId = osztalyId;
|
||||
}
|
||||
}
|
||||
ds = new DataSet();
|
||||
|
||||
if (model.MustGondviselo.HasValue && model.MustGondviselo.Value && osztalyDS.Tables.Contains("GondviseloAdatok"))
|
||||
{
|
||||
var tabla = osztalyDS.Tables["GondviseloAdatok"];
|
||||
|
||||
DataView dv = tabla.DefaultView;
|
||||
dv.RowFilter = tanuloIdColumnName + "=" + tanuloId;
|
||||
|
||||
if (dv.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (DataTable tabla in osztalyDS.Tables)
|
||||
{
|
||||
if (tablakFilterByTanuloId.Split(",".ToCharArray()).Contains(tabla.TableName))
|
||||
{
|
||||
DataView dv = tabla.DefaultView;
|
||||
dv.RowFilter = tanuloIdColumnName + "=" + tanuloId;
|
||||
ds.Tables.Add(dv.ToTable(tabla.TableName));
|
||||
}
|
||||
else
|
||||
{
|
||||
ds.Tables.Add(tabla.Copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ds = osztalyDS;
|
||||
}
|
||||
|
||||
if (!
|
||||
// nem kell merge
|
||||
(
|
||||
// külön dokumentumba kerüljön minden
|
||||
(model.AlapszintuNyomtatvanyokKulonDokumentumba)
|
||||
// egy osztálycsoport kell egyben (osztály szintű)
|
||||
|| (osztalyCsoportLista.Count == 1 && model.TanuloIdList == null)
|
||||
// egy tanuló egyben (tanuló szintű)
|
||||
|| (osztalyCsoportLista.Count == 1 && model.TanuloIdList.Count == 1)
|
||||
))
|
||||
{
|
||||
if (model.FormatumId == NyomtatvanyFormatumEnum.Excel.AsInt())
|
||||
{
|
||||
formazottExcelGenerator.CreateSheet(ds, osztalyId, db + 1);
|
||||
}
|
||||
|
||||
TobbNyomtatvanyEgyDataSetbe(ref mergedDs, ds, excludedTables, distinctTables);
|
||||
needMergedData = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((tanuloIdList.Count > 1) || (osztalyCsoportLista.Count > 1))
|
||||
{
|
||||
if ((!string.IsNullOrWhiteSpace(emptyDocumentTable)) && (ds.Tables[emptyDocumentTable].Rows.Count == 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
atLeastOneData = true;
|
||||
if (model.Iktatas)
|
||||
{
|
||||
foszamKulcsSzavak = KulcsszavakEsFoszamGeneralas(model, dokumentumTipus.Value, ds, (!tanuloId.IsEntityId()) ? ((isCsoport) ? DokumentumElemiSzintEnum.Csoport : DokumentumElemiSzintEnum.Osztaly) : DokumentumElemiSzintEnum.Tanulo);
|
||||
if (model.FormatumId != NyomtatvanyFormatumEnum.Excel.AsInt())
|
||||
{
|
||||
Nyomtatas(ds, frxNyomtatvanyNeve, frxParameterek, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel), model.Iktatas, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel, true), formatumId: model.FormatumId, osztalyId: osztalyId, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus.Value, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio, egyediLablecKellOldalszam: egyediLablecKellOldalszam, IsAspose: IsAspose, asposeMetodus: asposeMetodus, asposeHelperOptions: asposeHelperOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
var stream = formazottExcelGenerator.ExcelNyomtatas(ds, osztalyId);
|
||||
ExcelNyomtatas(stream, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel), model.Iktatas, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel, true), osztalyId: osztalyId, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus.Value, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (model.FormatumId != NyomtatvanyFormatumEnum.Excel.AsInt())
|
||||
{
|
||||
AddNyomtatvanyMintZipEntry(ZipOutPut, ds, frxNyomtatvanyNeve, frxParameterek, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel), formatumId: model.FormatumId, egyediLablecKellOldalszam: egyediLablecKellOldalszam, dokumentumTipus: dokumentumTipus, IsAspose: IsAspose, asposeMetodus: asposeMetodus, asposeHelperOptions: asposeHelperOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
var stream = formazottExcelGenerator.ExcelNyomtatas(ds, osztalyId);
|
||||
AddExcelMintZipEntry(ZipOutPut, stream, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((!string.IsNullOrWhiteSpace(emptyDocumentTable)) && (ds.Tables[emptyDocumentTable].Rows.Count == 0))
|
||||
{
|
||||
throw new ApplicationException(NyomtatvanyokResource.UresDokumentum);
|
||||
}
|
||||
|
||||
if (model.Iktatas)
|
||||
{
|
||||
foszamKulcsSzavak = KulcsszavakEsFoszamGeneralas(model, dokumentumTipus.Value, ds, !tanuloId.IsEntityId() ? ((isCsoport) ? DokumentumElemiSzintEnum.Csoport : DokumentumElemiSzintEnum.Osztaly) : DokumentumElemiSzintEnum.Tanulo);
|
||||
atLeastOneData = true;
|
||||
}
|
||||
|
||||
ActionResult nyomtatvany;
|
||||
if (model.FormatumId != NyomtatvanyFormatumEnum.Excel.AsInt())
|
||||
{
|
||||
nyomtatvany = Nyomtatas(ds, frxNyomtatvanyNeve, frxParameterek, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel), model.Iktatas, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel, true), formatumId: model.FormatumId, osztalyId: osztalyId, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio, egyediLablecKellOldalszam: egyediLablecKellOldalszam, IsAspose: IsAspose, asposeMetodus: asposeMetodus, asposeHelperOptions: asposeHelperOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
var stream = formazottExcelGenerator.ExcelNyomtatas(ds, osztalyId);
|
||||
nyomtatvany = ExcelNyomtatas(stream, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel), model.Iktatas, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel, true), osztalyId: osztalyId, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio);
|
||||
}
|
||||
|
||||
if (!model.Iktatas)
|
||||
{
|
||||
return nyomtatvany;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ZipOutPut.Finish();
|
||||
|
||||
OutPut.Position = 0;
|
||||
|
||||
if (!model.Iktatas)
|
||||
{
|
||||
if (!model.AlapszintuNyomtatvanyokKulonDokumentumba)
|
||||
{
|
||||
if ((!string.IsNullOrWhiteSpace(emptyDocumentTable)) && !mergedDs.IsEmpty() && (mergedDs.Tables[emptyDocumentTable].Rows.Count == 0))
|
||||
{
|
||||
throw new ApplicationException(NyomtatvanyokResource.UresDokumentum);
|
||||
}
|
||||
|
||||
var postFix = "";
|
||||
if (model.TanuloIdList == null)
|
||||
{
|
||||
nevmodel.TanuloID = null;
|
||||
if (osztalyCsoportLista.Count > 1)
|
||||
{
|
||||
if (isCsoport)
|
||||
{
|
||||
nevmodel.CsoportId = null;
|
||||
postFix = "_Csoportok";
|
||||
}
|
||||
else
|
||||
{
|
||||
nevmodel.OsztalyID = null;
|
||||
postFix = "_Osztalyok";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nevmodel.TanuloID = null;
|
||||
nevmodel.CsoportId = null;
|
||||
nevmodel.OsztalyID = null;
|
||||
postFix = "_Tanulok";
|
||||
}
|
||||
|
||||
if (model.FormatumId != NyomtatvanyFormatumEnum.Excel.AsInt())
|
||||
{
|
||||
return Nyomtatas(mergedDs, frxNyomtatvanyNeve, frxParameterek, CommonExtensions.NevGeneralas(nyomtatvanyNeve + postFix, nevmodel), model.Iktatas, CommonExtensions.NevGeneralas(nyomtatvanyNeve + postFix, nevmodel, true), formatumId: model.FormatumId, osztalyId: 0, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio, egyediLablecKellOldalszam: egyediLablecKellOldalszam, IsAspose: IsAspose, asposeMetodus: asposeMetodus, asposeHelperOptions: asposeHelperOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
var stream = formazottExcelGenerator.ExcelNyomtatas();
|
||||
return ExcelNyomtatas(stream, CommonExtensions.NevGeneralas(nyomtatvanyNeve + postFix, nevmodel), model.Iktatas, CommonExtensions.NevGeneralas(nyomtatvanyNeve + postFix, nevmodel, true), osztalyId: 0, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!atLeastOneData)
|
||||
{
|
||||
throw new ApplicationException(NyomtatvanyokResource.UresDokumentum);
|
||||
}
|
||||
|
||||
var postFix = "";
|
||||
|
||||
var zipnevmodel = new NyomtatvanyNevGeneralasModel() { TanevID = ClaimData.SelectedTanevID.Value };
|
||||
if (osztalyCsoportLista.Count > 1)
|
||||
{
|
||||
postFix = (isOsztalySzintuGeneralas) ? ((isCsoport) ? "_Csoportok" : "_Osztalyok") : "_Tanulok";
|
||||
}
|
||||
else
|
||||
{
|
||||
zipnevmodel.OsztalyCsoportId = osztalyCsoportLista[0];
|
||||
}
|
||||
|
||||
return new FileStreamResult(OutPut, Constants.ImportExport.ContentType)
|
||||
{
|
||||
FileDownloadName = $"{CommonExtensions.NevGeneralas(nyomtatvanyNeve + postFix, zipnevmodel)}.{Constants.ImportExport.FileFormatZip}"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if ((needMergedData && (mergedDs.Tables.Count == 0))
|
||||
|| (!needMergedData && !atLeastOneData))
|
||||
{
|
||||
throw new ApplicationException(NyomtatvanyokResource.UresDokumentum);
|
||||
}
|
||||
|
||||
if (mergedDs.Tables.Count > 0)
|
||||
{
|
||||
if ((!string.IsNullOrWhiteSpace(emptyDocumentTable)) && (mergedDs.Tables[emptyDocumentTable].Rows.Count == 0))
|
||||
{
|
||||
throw new ApplicationException(NyomtatvanyokResource.UresDokumentum);
|
||||
}
|
||||
|
||||
var postFix = "";
|
||||
if (model.TanuloIdList == null)
|
||||
{
|
||||
nevmodel.TanuloID = null;
|
||||
if (isCsoport)
|
||||
{
|
||||
nevmodel.CsoportId = null;
|
||||
postFix = "_Csoportok";
|
||||
}
|
||||
else
|
||||
{
|
||||
nevmodel.OsztalyID = null;
|
||||
postFix = "_Osztalyok";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nevmodel.TanuloID = null;
|
||||
nevmodel.CsoportId = null;
|
||||
nevmodel.OsztalyID = null;
|
||||
postFix = "_Tanulok";
|
||||
}
|
||||
|
||||
foszamKulcsSzavak = KulcsszavakEsFoszamGeneralas(model, dokumentumTipus.Value, mergedDs, DokumentumElemiSzintEnum.Intezmeny);
|
||||
if (model.FormatumId != NyomtatvanyFormatumEnum.Excel.AsInt())
|
||||
{
|
||||
Nyomtatas(mergedDs, frxNyomtatvanyNeve, frxParameterek, CommonExtensions.NevGeneralas(nyomtatvanyNeve + postFix, nevmodel), model.Iktatas, CommonExtensions.NevGeneralas(nyomtatvanyNeve + postFix, nevmodel, true), formatumId: model.FormatumId, osztalyId: 0, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio, egyediLablecKellOldalszam: egyediLablecKellOldalszam, IsAspose: IsAspose, asposeMetodus: asposeMetodus, asposeHelperOptions: asposeHelperOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
var stream = formazottExcelGenerator.ExcelNyomtatas();
|
||||
return ExcelNyomtatas(stream, CommonExtensions.NevGeneralas(nyomtatvanyNeve + postFix, nevmodel), model.Iktatas, CommonExtensions.NevGeneralas(nyomtatvanyNeve + postFix, nevmodel, true), osztalyId: 0, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus.Value, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio);
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToAction("Index", Constants.Controllers.IktatottDokumentumok, new { area = Constants.Areas.Nyomtatvanyok });
|
||||
}
|
||||
|
||||
private ActionResult AltalanosPedagogusGeneralas(NyomtatvanyModel model, string frxNyomtatvanyNeve, DokumentumKategoriaEnum dokumentumKategoria, Enums.DokumentumTipusEnum? dokumentumTipus, System.Reflection.MethodInfo metodus, int pedagogusIdParameterOrder, IDictionary<string, object> dataSetParameterek, Dictionary<string, object> frxParameterek, string nyomtatvanyNeve = null, string excludedTables = null, string distinctTables = null, string emptyDocumentTable = null, bool egyediLablecKellOldalszam = true, Bitmap qrCode = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(nyomtatvanyNeve))
|
||||
{
|
||||
nyomtatvanyNeve = frxNyomtatvanyNeve;
|
||||
}
|
||||
|
||||
var OutPut = new MemoryStream();
|
||||
var ZipOutPut = new ZipOutputStream(OutPut);
|
||||
var buffer = new byte[Constants.General.BufferSize];
|
||||
|
||||
ActionResult egyediPedagogusResult = new FileStreamResult(OutPut, Constants.ImportExport.ContentType);
|
||||
|
||||
DataSet mergedDs = new DataSet();
|
||||
var pedagogusIdList = GetPedagogusIdListByFelhasznaloId(model.PedagogusIdList);
|
||||
var foszamKulcsSzavak = (kulcsSzavak: (NameValueCollection)null, foszamDefinicio: (BusinessLogic.Helpers.Nyomtatvanyok.Iktatas.FoszamDefinicioValueModel)null);
|
||||
|
||||
foreach (var pedagogusId in pedagogusIdList)
|
||||
{
|
||||
var pis = metodus.GetParameters();
|
||||
var parObjs = new object[pis.Length];
|
||||
for (int i = 0; i < pis.Length; i++)
|
||||
{
|
||||
if (i == pedagogusIdParameterOrder)
|
||||
{
|
||||
parObjs[i] = pedagogusId;
|
||||
}
|
||||
else
|
||||
{
|
||||
parObjs[i] = (dataSetParameterek.Keys.Contains(pis[i].Name)) ? dataSetParameterek[pis[i].Name] : Type.Missing;
|
||||
}
|
||||
}
|
||||
|
||||
var ds = metodus.Invoke(new NyomtatvanyokHelper(ConnectionTypeExtensions.GetSessionConnectionType()), parObjs) as DataSet;
|
||||
|
||||
if (ds.Tables.Count == 0 && pedagogusIdList.Count == 1)
|
||||
{
|
||||
throw new ApplicationException(NyomtatvanyokResource.UresDokumentum);
|
||||
}
|
||||
|
||||
if (ds.Tables.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var par in metodus.GetParameters().Where(p => p.IsOut).ToList())
|
||||
{
|
||||
frxParameterek[par.Name] = parObjs[par.Position];
|
||||
}
|
||||
|
||||
var nevmodel = new NyomtatvanyNevGeneralasModel() { TanarID = pedagogusId, TanevID = ClaimData.SelectedTanevID.Value };
|
||||
if (pedagogusIdList.Count > 1)
|
||||
{
|
||||
if (!model.AlapszintuNyomtatvanyokKulonDokumentumba)
|
||||
{
|
||||
TobbNyomtatvanyEgyDataSetbe(ref mergedDs, ds, excludedTables, distinctTables);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((!string.IsNullOrWhiteSpace(emptyDocumentTable)) && (ds.Tables[emptyDocumentTable].Rows.Count == 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (model.Iktatas)
|
||||
{
|
||||
foszamKulcsSzavak = KulcsszavakEsFoszamGeneralas(model, dokumentumTipus.Value, ds, DokumentumElemiSzintEnum.Tanulo);
|
||||
|
||||
egyediPedagogusResult = Nyomtatas(ds, frxNyomtatvanyNeve, frxParameterek, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel), model.Iktatas, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel, true), formatumId: model.FormatumId, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus.Value, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio, egyediLablecKellOldalszam: egyediLablecKellOldalszam);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddNyomtatvanyMintZipEntry(ZipOutPut, ds, frxNyomtatvanyNeve, frxParameterek, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel), formatumId: model.FormatumId, egyediLablecKellOldalszam: egyediLablecKellOldalszam, dokumentumTipus: dokumentumTipus);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((!string.IsNullOrWhiteSpace(emptyDocumentTable)) && (ds.Tables[emptyDocumentTable].Rows.Count == 0))
|
||||
{
|
||||
throw new ApplicationException(NyomtatvanyokResource.UresDokumentum);
|
||||
}
|
||||
|
||||
if (model.Iktatas)
|
||||
{
|
||||
foszamKulcsSzavak = KulcsszavakEsFoszamGeneralas(model, dokumentumTipus.Value, ds, DokumentumElemiSzintEnum.Tanulo);
|
||||
}
|
||||
|
||||
return Nyomtatas(ds, frxNyomtatvanyNeve, frxParameterek, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel), model.Iktatas, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel, true), formatumId: model.FormatumId, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio, egyediLablecKellOldalszam: egyediLablecKellOldalszam, qrCode: qrCode);
|
||||
}
|
||||
}
|
||||
|
||||
ZipOutPut.Finish();
|
||||
|
||||
OutPut.Position = 0;
|
||||
|
||||
if (!model.AlapszintuNyomtatvanyokKulonDokumentumba)
|
||||
{
|
||||
if ((!string.IsNullOrWhiteSpace(emptyDocumentTable)) && (mergedDs.Tables[emptyDocumentTable].Rows.Count == 0))
|
||||
{
|
||||
throw new ApplicationException(NyomtatvanyokResource.UresDokumentum);
|
||||
}
|
||||
|
||||
if (model.Iktatas)
|
||||
{
|
||||
foszamKulcsSzavak = KulcsszavakEsFoszamGeneralas(model, dokumentumTipus.Value, mergedDs, DokumentumElemiSzintEnum.Intezmeny);
|
||||
}
|
||||
|
||||
var nevmodel = new NyomtatvanyNevGeneralasModel() { TanevID = ClaimData.SelectedTanevID.Value };
|
||||
return Nyomtatas(mergedDs, frxNyomtatvanyNeve, frxParameterek, CommonExtensions.NevGeneralas(nyomtatvanyNeve + "_Tanarok", nevmodel), model.Iktatas, CommonExtensions.NevGeneralas(nyomtatvanyNeve + "_Tanarok", nevmodel, true), formatumId: model.FormatumId, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio, egyediLablecKellOldalszam: egyediLablecKellOldalszam);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (model.Iktatas)
|
||||
{
|
||||
return egyediPedagogusResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
var zipnevmodel = new NyomtatvanyNevGeneralasModel() { TanevID = ClaimData.SelectedTanevID.Value };
|
||||
return new FileStreamResult(OutPut, Constants.ImportExport.ContentType)
|
||||
{
|
||||
FileDownloadName = $"{CommonExtensions.NevGeneralas(nyomtatvanyNeve, zipnevmodel)}.{Constants.ImportExport.FileFormatZip}"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ActionResult AltalanosOsztalyFormazottXlsGeneralas(NyomtatvanyModel model, BaseNyomtatvanyExcel formazottExcelGenerator, DokumentumKategoriaEnum dokumentumKategoria, Enums.DokumentumTipusEnum? dokumentumTipus, IDictionary<string, object> dataSetParameterek, string osztalyIdParameterName, string nyomtatvanyNeve, string excludedTables = null, string distinctTables = null)
|
||||
{
|
||||
var OutPut = new MemoryStream();
|
||||
var ZipOutPut = new ZipOutputStream(OutPut);
|
||||
|
||||
OktNevelesiKategoriaEnum? oktNevKategoria = (model.OktNevelesiKategoriaId.IsEntityId()) ? (OktNevelesiKategoriaEnum?)model.OktNevelesiKategoriaId : (OktNevelesiKategoriaEnum?)null;
|
||||
var osztalyIdList = GetOsztalyIdList(model.OsztalyIdList, oktNevKategoria);
|
||||
|
||||
var foszamKulcsSzavak = (kulcsSzavak: (NameValueCollection)null, foszamDefinicio: (BusinessLogic.Helpers.Nyomtatvanyok.Iktatas.FoszamDefinicioValueModel)null);
|
||||
|
||||
var nevmodel = new NyomtatvanyNevGeneralasModel() { TanevID = ClaimData.SelectedTanevID.Value };
|
||||
|
||||
MemoryStream excelContent;
|
||||
DataSet mergedDs = new DataSet();
|
||||
for (int i = 0; i < osztalyIdList.Count; i++)
|
||||
{
|
||||
var osztalyId = osztalyIdList[i];
|
||||
var parameters = dataSetParameterek.ToDictionary(k => k.Key, k => (k.Value ?? "").ToString());
|
||||
parameters.Add(osztalyIdParameterName, osztalyId.ToString());
|
||||
|
||||
if (osztalyIdList.Count > 1)
|
||||
{
|
||||
if (!model.AlapszintuNyomtatvanyokKulonDokumentumba)
|
||||
{
|
||||
formazottExcelGenerator.CreateSheet(parameters, i + 1);
|
||||
if (model.Iktatas)
|
||||
{
|
||||
var ds = formazottExcelGenerator.GetSheetDataSet();
|
||||
TobbNyomtatvanyEgyDataSetbe(ref mergedDs, ds, excludedTables, distinctTables);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nevmodel.OsztalyID = osztalyId;
|
||||
excelContent = formazottExcelGenerator.ExcelNyomtatas(parameters);
|
||||
if (!model.Iktatas)
|
||||
{
|
||||
AddExcelMintZipEntry(ZipOutPut, excelContent, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel));
|
||||
}
|
||||
else
|
||||
{
|
||||
var ds = formazottExcelGenerator.GetSheetDataSet();
|
||||
foszamKulcsSzavak = KulcsszavakEsFoszamGeneralas(model, dokumentumTipus.Value, ds, Enums.DokumentumElemiSzintEnum.Osztaly);
|
||||
ExcelNyomtatas(excelContent, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel), model.Iktatas, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel, true), osztalyId, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nevmodel.OsztalyID = osztalyId;
|
||||
excelContent = formazottExcelGenerator.ExcelNyomtatas(parameters);
|
||||
|
||||
var ds = formazottExcelGenerator.GetSheetDataSet();
|
||||
|
||||
if (model.Iktatas)
|
||||
{
|
||||
foszamKulcsSzavak = KulcsszavakEsFoszamGeneralas(model, dokumentumTipus.Value, ds, Enums.DokumentumElemiSzintEnum.Osztaly);
|
||||
}
|
||||
|
||||
var ret = ExcelNyomtatas(excelContent, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel), model.Iktatas, CommonExtensions.NevGeneralas(nyomtatvanyNeve, nevmodel, true), osztalyId, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio);
|
||||
|
||||
formazottExcelGenerator.Dispose();
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (model.Iktatas)
|
||||
{
|
||||
if (!model.AlapszintuNyomtatvanyokKulonDokumentumba)
|
||||
{
|
||||
excelContent = formazottExcelGenerator.ExcelNyomtatas();
|
||||
formazottExcelGenerator.Dispose();
|
||||
foszamKulcsSzavak = KulcsszavakEsFoszamGeneralas(model, dokumentumTipus.Value, mergedDs, Enums.DokumentumElemiSzintEnum.Intezmeny);
|
||||
ExcelNyomtatas(excelContent, CommonExtensions.NevGeneralas("Tobb" + nyomtatvanyNeve, nevmodel), model.Iktatas, CommonExtensions.NevGeneralas("Tobb" + nyomtatvanyNeve, nevmodel, true), 0, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio);
|
||||
}
|
||||
|
||||
return RedirectToAction("Index", Constants.Controllers.IktatottDokumentumok, new { area = Constants.Areas.Nyomtatvanyok });
|
||||
}
|
||||
|
||||
if (!model.AlapszintuNyomtatvanyokKulonDokumentumba)
|
||||
{
|
||||
excelContent = formazottExcelGenerator.ExcelNyomtatas();
|
||||
formazottExcelGenerator.Dispose();
|
||||
return ExcelNyomtatas(excelContent, CommonExtensions.NevGeneralas("Tobb" + nyomtatvanyNeve, nevmodel), false, CommonExtensions.NevGeneralas("Tobb" + nyomtatvanyNeve, nevmodel, true), 0, dokumentumKategoria: dokumentumKategoria, dokumentumTipus: dokumentumTipus, kulcsSzavak: foszamKulcsSzavak.kulcsSzavak, foszamDefinicio: foszamKulcsSzavak.foszamDefinicio);
|
||||
}
|
||||
else
|
||||
{
|
||||
ZipOutPut.Finish();
|
||||
OutPut.Position = 0;
|
||||
var zipnevmodel = new NyomtatvanyNevGeneralasModel() { TanevID = ClaimData.SelectedTanevID.Value };
|
||||
return new FileStreamResult(OutPut, Constants.ImportExport.ContentType)
|
||||
{
|
||||
FileDownloadName = $"{CommonExtensions.NevGeneralas(nyomtatvanyNeve, zipnevmodel)}.{Constants.ImportExport.FileFormatZip}"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private List<int> CheckTanuloHasGondviselo(List<int> tanuloIds)
|
||||
{
|
||||
if (tanuloIds == null || tanuloIds.Count == 0)
|
||||
{
|
||||
return tanuloIds;
|
||||
}
|
||||
|
||||
var validTanuloIdList = new List<int>();
|
||||
var invalidTanuloIdList = new List<int>();
|
||||
var tanulohelper = new TanuloHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
foreach (var tanuloId in tanuloIds)
|
||||
{
|
||||
if (!tanulohelper.ExistsGondviselo(tanuloId))
|
||||
{
|
||||
invalidTanuloIdList.Add(tanuloId);
|
||||
}
|
||||
else
|
||||
{
|
||||
validTanuloIdList.Add(tanuloId);
|
||||
}
|
||||
}
|
||||
|
||||
//NOTE: Ha többet generálnak és van köztük olyan akinek van gondviselője, akkor invalidok kihagyása
|
||||
if (validTanuloIdList.Any())
|
||||
{
|
||||
tanuloIds = validTanuloIdList;
|
||||
}
|
||||
|
||||
return tanuloIds;
|
||||
}
|
||||
|
||||
private List<int> CheckTanuloGondviseloIsTorvenyes(List<int> tanuloIds)
|
||||
{
|
||||
if (tanuloIds == null)
|
||||
{
|
||||
return tanuloIds;
|
||||
}
|
||||
|
||||
var resultTanuloIds = tanuloIds.ToList();
|
||||
|
||||
if (tanuloIds.Count == 1
|
||||
&& !CheckTanuloGondviseloIsTorvenyes(tanuloIds.First()))
|
||||
{
|
||||
resultTanuloIds.Remove(tanuloIds.First());
|
||||
return resultTanuloIds;
|
||||
}
|
||||
|
||||
foreach (var tanuloId in tanuloIds)
|
||||
{
|
||||
if (!CheckTanuloGondviseloIsTorvenyes(tanuloId))
|
||||
{
|
||||
resultTanuloIds.Remove(tanuloId);
|
||||
}
|
||||
}
|
||||
|
||||
return resultTanuloIds;
|
||||
}
|
||||
|
||||
private bool CheckTanuloGondviseloIsTorvenyes(int tanuloId)
|
||||
{
|
||||
var gondviseloHelper = new GondviseloHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
return gondviseloHelper.HasTanuloTorvenyesGondviselo(tanuloId);
|
||||
}
|
||||
|
||||
private List<int> CheckTanuloIsTankotelezettAllapot(List<int> tanuloIds, bool tankotelezettseg)
|
||||
{
|
||||
if (tanuloIds == null)
|
||||
{
|
||||
return tanuloIds;
|
||||
}
|
||||
|
||||
var resultTanuloIds = tanuloIds.ToList();
|
||||
|
||||
var tanulohelper = new TanuloHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
foreach (var tanuloId in tanuloIds)
|
||||
{
|
||||
if (tanulohelper.IsTankotelezettsegetTeljesito(tanuloId) != tankotelezettseg)
|
||||
{
|
||||
resultTanuloIds.Remove(tanuloId);
|
||||
}
|
||||
}
|
||||
|
||||
return resultTanuloIds;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue