410 lines
20 KiB
C#
410 lines
20 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Web.Mvc;
|
|
using ICSharpCode.SharpZipLib.Zip;
|
|
using Kreta.BusinessLogic.Classes;
|
|
using Kreta.BusinessLogic.Helpers;
|
|
using Kreta.Web.Areas.Nyomtatvanyok.Logic;
|
|
using Kreta.Web.Helpers;
|
|
using Kreta.Web.Security;
|
|
|
|
namespace Kreta.Web.Areas.Nyomtatvanyok.Controllers
|
|
{
|
|
public partial class NyomtatvanyokController : BaseNyomtatvanyokController
|
|
{
|
|
private static string RemoveTooLongElementOrTrunc(string text, int maxLength = 80)
|
|
{
|
|
for (int i = 0; i < text.Split('_').Length - 4; i++)
|
|
{
|
|
text = text.Wrap(0, text.LastIndexOf('_'));
|
|
|
|
if (text.Length <= maxLength)
|
|
{
|
|
return text;
|
|
}
|
|
}
|
|
|
|
return text.Wrap(0, maxLength);
|
|
}
|
|
|
|
private static string RemoveSpecialCharacters(string text)
|
|
{
|
|
return text
|
|
.ToComparableString()
|
|
.Replace("*", "_")
|
|
.Replace(" - ", "_")
|
|
.Replace('ö', 'o')
|
|
.Replace('ü', 'u')
|
|
.Replace(' ', '_')
|
|
.Replace('-', '_')
|
|
.Replace(":", "_")
|
|
.Replace(";", "_")
|
|
.Replace(",", "_")
|
|
.Replace(".", "_");
|
|
}
|
|
|
|
|
|
#region KIRStat
|
|
|
|
public ActionResult KirStatTanulok([ModelBinder(typeof(NyomtatvanyModelBinderWithPoszeidonIktatasDefiniciok))] NyomtatvanyModel model)
|
|
{
|
|
var output = new MemoryStream();
|
|
var zipOutput = new ZipOutputStream(output);
|
|
try
|
|
{
|
|
SZIRStatHelper szirSatHelper = new SZIRStatHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
|
Dictionary<int, string> feladatellatasiHelyFileNevDictionary = szirSatHelper.GetKirSzirFeladatEllatasiHelyDDl(true);
|
|
List<int> feladatellatasiHelyIdList = model.FeladatellatasiHelyIdList;
|
|
if (feladatellatasiHelyIdList == null || feladatellatasiHelyIdList.Count == 0)
|
|
{
|
|
feladatellatasiHelyIdList = new List<int>();
|
|
foreach (KeyValuePair<int, string> item in feladatellatasiHelyFileNevDictionary)
|
|
{
|
|
feladatellatasiHelyIdList.Add(item.Key);
|
|
}
|
|
}
|
|
|
|
string nyomtatvanyNeve = "KIR_OSA4TANU";
|
|
string segedletNeve = "KIR_OSA4TANU_segedlet";
|
|
|
|
foreach (int id in feladatellatasiHelyIdList)
|
|
{
|
|
string currentFileNameFeladatellatasiHelyDatummal = $"{RemoveTooLongElementOrTrunc(RemoveSpecialCharacters(feladatellatasiHelyFileNevDictionary[id]))}_{DateTime.Now:yyyy_MM_dd_HH_mm}";
|
|
|
|
var memoryStreamList = new NyomtatvanyokHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetKirStatForTanulo(Server.MapPath("~/Resources/KIRStat/XLS/" + nyomtatvanyNeve + ".xlsx"), id);
|
|
|
|
AddExcelMintZipEntry(zipOutput, memoryStreamList[0], nyomtatvanyNeve + "_" + currentFileNameFeladatellatasiHelyDatummal);
|
|
AddExcelMintZipEntry(zipOutput, memoryStreamList[1], segedletNeve + "_" + currentFileNameFeladatellatasiHelyDatummal);
|
|
}
|
|
|
|
zipOutput.Finish();
|
|
output.Position = 0;
|
|
|
|
return new FileStreamResult(output, Constants.ImportExport.ContentType)
|
|
{
|
|
FileDownloadName = $"{nyomtatvanyNeve}_{DateTime.Now:yyyy_MM_dd_HH_mm}.{Constants.ImportExport.FileFormatZip}"
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw NyomtatvanyokLogic.NyomtatvanyError(ex);
|
|
}
|
|
}
|
|
|
|
public ActionResult KirStatTanulokSegedlet()
|
|
{
|
|
FileStream fs = new FileStream(Server.MapPath("~/Resources/KIRStat/PDF/KIR_OSA4TANU_segedlet.pdf"), FileMode.Open, FileAccess.Read);
|
|
|
|
return new FileStreamResult(fs, Constants.ImportExport.FileFormatPdf)
|
|
{
|
|
FileDownloadName = $"KIR_OSA4TANU_segedlet.pdf"
|
|
};
|
|
}
|
|
|
|
public ActionResult KirStatFelhasznalok([ModelBinder(typeof(NyomtatvanyModelBinderWithPoszeidonIktatasDefiniciok))] NyomtatvanyModel model)
|
|
{
|
|
var output = new MemoryStream();
|
|
var zipOutput = new ZipOutputStream(output);
|
|
try
|
|
{
|
|
SZIRStatHelper szirSatHelper = new SZIRStatHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
|
Dictionary<int, string> feladatellatasiHelyFileNevDictionary = szirSatHelper.GetKirSzirFeladatEllatasiHelyDDl(true);
|
|
List<int> feladatellatasiHelyIdList = model.FeladatellatasiHelyIdList;
|
|
if (feladatellatasiHelyIdList == null || feladatellatasiHelyIdList.Count == 0)
|
|
{
|
|
feladatellatasiHelyIdList = new List<int>();
|
|
foreach (var item in feladatellatasiHelyFileNevDictionary)
|
|
{
|
|
feladatellatasiHelyIdList.Add(item.Key);
|
|
}
|
|
}
|
|
|
|
string nyomtatvanyNeve = "KIR_OSA2FELH";
|
|
string segedletNeve = "KIR_OSA2FELH_segedlet";
|
|
bool isKlebelsberg = ClaimData.IsKlebelsberg;
|
|
|
|
foreach (int id in feladatellatasiHelyIdList)
|
|
{
|
|
string currentFileNameFeladatellatasiHelyDatummal = $"{RemoveTooLongElementOrTrunc(RemoveSpecialCharacters(feladatellatasiHelyFileNevDictionary[id]))}_{DateTime.Now:yyyy_MM_dd_HH_mm}";
|
|
|
|
var memoryStreamList = new NyomtatvanyokHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetKirStatForFelhasznalo(Server.MapPath("~/Resources/KIRStat/XLS/" + nyomtatvanyNeve + ".xlsx"), id, isKlebelsberg);
|
|
|
|
AddExcelMintZipEntry(zipOutput, memoryStreamList[0], nyomtatvanyNeve + "_" + currentFileNameFeladatellatasiHelyDatummal);
|
|
AddExcelMintZipEntry(zipOutput, memoryStreamList[1], segedletNeve + "_" + currentFileNameFeladatellatasiHelyDatummal);
|
|
}
|
|
|
|
zipOutput.Finish();
|
|
output.Position = 0;
|
|
|
|
return new FileStreamResult(output, Constants.ImportExport.ContentType)
|
|
{
|
|
FileDownloadName = $"{nyomtatvanyNeve}_{DateTime.Now:yyyy_MM_dd_HH_mm}.{Constants.ImportExport.FileFormatZip}"
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw NyomtatvanyokLogic.NyomtatvanyError(ex);
|
|
}
|
|
}
|
|
|
|
public ActionResult KirStatFelhasznalokSegedlet()
|
|
{
|
|
FileStream fs = new FileStream(Server.MapPath("~/Resources/KIRStat/PDF/KIR_OSA2FELH_segedlet.pdf"), FileMode.Open, FileAccess.Read);
|
|
|
|
return new FileStreamResult(fs, Constants.ImportExport.FileFormatPdf)
|
|
{
|
|
FileDownloadName = $"KIR_OSA2FELH_segedlet.pdf"
|
|
};
|
|
}
|
|
|
|
#endregion KIRStat
|
|
|
|
#region SZIRStat
|
|
|
|
public ActionResult SzirStatIntezmeny([ModelBinder(typeof(NyomtatvanyModelBinderWithPoszeidonIktatasDefiniciok))] NyomtatvanyModel model)
|
|
{
|
|
try
|
|
{
|
|
SZIRStatHelper szirSatHelper = new SZIRStatHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
|
string nyomtatvanyNeve = "SZIR_OSA1INT";
|
|
|
|
var memoryStreamList = szirSatHelper.GetSzirStatIntezmeny(Server.MapPath("~/Resources/SZIRStat/XLS/" + nyomtatvanyNeve + ".xlsx"));
|
|
return new FileStreamResult(memoryStreamList[0], Constants.ImportExport.FileFormatXlsx)
|
|
{
|
|
FileDownloadName = $"{nyomtatvanyNeve}_{DateTime.Now:yyyy_MM_dd_HH_mm}.{Constants.ImportExport.FileFormatXlsx}"
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw NyomtatvanyokLogic.NyomtatvanyError(ex);
|
|
}
|
|
}
|
|
|
|
public ActionResult SzirStatTanulok([ModelBinder(typeof(NyomtatvanyModelBinderWithPoszeidonIktatasDefiniciok))] NyomtatvanyModel model)
|
|
{
|
|
var output = new MemoryStream();
|
|
var zipOutput = new ZipOutputStream(output);
|
|
try
|
|
{
|
|
SZIRStatHelper szirSatHelper = new SZIRStatHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
|
Dictionary<int, string> feladatellatasiHelyFileNevDictionary = szirSatHelper.GetKirSzirFeladatEllatasiHelyDDl(false);
|
|
List<int> feladatellatasiHelyIdList = model.FeladatellatasiHelyIdList;
|
|
if (feladatellatasiHelyIdList == null || feladatellatasiHelyIdList.Count == 0)
|
|
{
|
|
feladatellatasiHelyIdList = new List<int>();
|
|
foreach (KeyValuePair<int, string> item in feladatellatasiHelyFileNevDictionary)
|
|
{
|
|
feladatellatasiHelyIdList.Add(item.Key);
|
|
}
|
|
}
|
|
|
|
string nyomtatvanyNeve = "SZIR_OSA4TANU";
|
|
string segedletNeve = "SZIR_OSA4TANU_segedlet";
|
|
|
|
foreach (int id in feladatellatasiHelyIdList)
|
|
{
|
|
string currentFileNameFeladatellatasiHelyDatummal = $"{RemoveTooLongElementOrTrunc(RemoveSpecialCharacters(feladatellatasiHelyFileNevDictionary[id]))}_{DateTime.Now:yyyy_MM_dd_HH_mm}";
|
|
|
|
var memoryStreamList = szirSatHelper.GetSzirStatForTanulo(Server.MapPath("~/Resources/SZIRStat/XLS/" + nyomtatvanyNeve + ".xlsx"), id);
|
|
|
|
AddExcelMintZipEntry(zipOutput, memoryStreamList[0], nyomtatvanyNeve + "_" + currentFileNameFeladatellatasiHelyDatummal);
|
|
AddExcelMintZipEntry(zipOutput, memoryStreamList[1], segedletNeve + "_" + currentFileNameFeladatellatasiHelyDatummal);
|
|
}
|
|
|
|
zipOutput.Finish();
|
|
output.Position = 0;
|
|
|
|
return new FileStreamResult(output, Constants.ImportExport.ContentType)
|
|
{
|
|
FileDownloadName = $"{nyomtatvanyNeve}_{DateTime.Now:yyyy_MM_dd_HH_mm}.{Constants.ImportExport.FileFormatZip}"
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw NyomtatvanyokLogic.NyomtatvanyError(ex);
|
|
}
|
|
}
|
|
|
|
public ActionResult SzirStatTanulokSegedlet()
|
|
{
|
|
FileStream fs = new FileStream(Server.MapPath("~/Resources/SZIRStat/PDF/SZIR_OSA4TANU_segedlet.pdf"), FileMode.Open, FileAccess.Read);
|
|
|
|
return new FileStreamResult(fs, Constants.ImportExport.FileFormatPdf)
|
|
{
|
|
FileDownloadName = $"SZIR_OSA4TANU_segedlet.pdf"
|
|
};
|
|
}
|
|
|
|
public ActionResult SzirStatFelhasznalok([ModelBinder(typeof(NyomtatvanyModelBinderWithPoszeidonIktatasDefiniciok))] NyomtatvanyModel model)
|
|
{
|
|
var output = new MemoryStream();
|
|
var zipOutput = new ZipOutputStream(output);
|
|
try
|
|
{
|
|
SZIRStatHelper szirSatHelper = new SZIRStatHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
|
Dictionary<int, string> feladatellatasiHelyFileNevDictionary = szirSatHelper.GetKirSzirFeladatEllatasiHelyDDl(false);
|
|
List<int> feladatellatasiHelyIdList = model.FeladatellatasiHelyIdList;
|
|
if (feladatellatasiHelyIdList == null || feladatellatasiHelyIdList.Count == 0)
|
|
{
|
|
feladatellatasiHelyIdList = new List<int>();
|
|
foreach (var item in feladatellatasiHelyFileNevDictionary)
|
|
{
|
|
feladatellatasiHelyIdList.Add(item.Key);
|
|
}
|
|
}
|
|
|
|
string nyomtatvanyNeve = "SZIR_OSA2FELH";
|
|
string segedletNeve = "SZIR_OSA2FELH_segedlet";
|
|
bool isKlebelsberg = ClaimData.IsKlebelsberg;
|
|
|
|
foreach (int id in feladatellatasiHelyIdList)
|
|
{
|
|
string currentFileNameFeladatellatasiHelyDatummal = $"{RemoveTooLongElementOrTrunc(RemoveSpecialCharacters(feladatellatasiHelyFileNevDictionary[id]))}_{DateTime.Now:yyyy_MM_dd_HH_mm}";
|
|
|
|
var memoryStreamList = szirSatHelper.GetSzirStatForFelhasznalo(Server.MapPath("~/Resources/SZIRStat/XLS/" + nyomtatvanyNeve + ".xlsx"), id, isKlebelsberg);
|
|
|
|
AddExcelMintZipEntry(zipOutput, memoryStreamList[0], nyomtatvanyNeve + "_" + currentFileNameFeladatellatasiHelyDatummal);
|
|
AddExcelMintZipEntry(zipOutput, memoryStreamList[1], segedletNeve + "_" + currentFileNameFeladatellatasiHelyDatummal);
|
|
}
|
|
|
|
zipOutput.Finish();
|
|
output.Position = 0;
|
|
|
|
return new FileStreamResult(output, Constants.ImportExport.ContentType)
|
|
{
|
|
FileDownloadName = $"{nyomtatvanyNeve}_{DateTime.Now:yyyy_MM_dd_HH_mm}.{Constants.ImportExport.FileFormatZip}"
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw NyomtatvanyokLogic.NyomtatvanyError(ex);
|
|
}
|
|
}
|
|
|
|
public ActionResult SzirStatFelhasznalokSegedlet()
|
|
{
|
|
FileStream fs = new FileStream(Server.MapPath("~/Resources/SZIRStat/PDF/SZIR_OSA2FELH_segedlet.pdf"), FileMode.Open, FileAccess.Read);
|
|
|
|
return new FileStreamResult(fs, Constants.ImportExport.FileFormatPdf)
|
|
{
|
|
FileDownloadName = $"SZIR_OSA2FELH_segedlet.pdf"
|
|
};
|
|
}
|
|
|
|
public ActionResult SzirStatSzak([ModelBinder(typeof(NyomtatvanyModelBinderWithPoszeidonIktatasDefiniciok))] NyomtatvanyModel model)
|
|
{
|
|
var output = new MemoryStream();
|
|
var zipOutput = new ZipOutputStream(output);
|
|
try
|
|
{
|
|
SZIRStatHelper szirSatHelper = new SZIRStatHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
|
Dictionary<int, string> feladatellatasiHelyFileNevDictionary = szirSatHelper.GetKirSzirFeladatEllatasiHelyDDl(false);
|
|
List<int> feladatellatasiHelyIdList = model.FeladatellatasiHelyIdList;
|
|
if (feladatellatasiHelyIdList == null || feladatellatasiHelyIdList.Count == 0)
|
|
{
|
|
feladatellatasiHelyIdList = new List<int>();
|
|
foreach (var item in feladatellatasiHelyFileNevDictionary)
|
|
{
|
|
feladatellatasiHelyIdList.Add(item.Key);
|
|
}
|
|
}
|
|
|
|
string nyomtatvanyNeve = "SZIR_OSA5SZAK";
|
|
//string segedletNeve = "SZIR_OSA5SZAK_segedlet";
|
|
if (feladatellatasiHelyIdList.Count > 1)
|
|
{
|
|
foreach (int id in feladatellatasiHelyIdList)
|
|
{
|
|
string currentFileNameFeladatellatasiHelyDatummal = $"{RemoveTooLongElementOrTrunc(RemoveSpecialCharacters(feladatellatasiHelyFileNevDictionary[id]))}_{DateTime.Now:yyyy_MM_dd_HH_mm}";
|
|
|
|
var memoryStreamList = szirSatHelper.GetSzirStatSzak(Server.MapPath("~/Resources/SZIRStat/XLS/" + nyomtatvanyNeve + ".xlsx"), id);
|
|
|
|
AddExcelMintZipEntry(zipOutput, memoryStreamList[0], nyomtatvanyNeve + "_" + currentFileNameFeladatellatasiHelyDatummal);
|
|
//AddExcelMintZipEntry(zipOutput, memoryStreamList[1], segedletNeve + "_" + currentFileNameFeladatellatasiHelyDatummal);
|
|
}
|
|
|
|
zipOutput.Finish();
|
|
output.Position = 0;
|
|
return new FileStreamResult(output, Constants.ImportExport.ContentType)
|
|
{
|
|
FileDownloadName = $"{nyomtatvanyNeve}_{DateTime.Now:yyyy_MM_dd_HH_mm}.{Constants.ImportExport.FileFormatZip}"
|
|
};
|
|
}
|
|
else
|
|
{
|
|
string currentFileNameFeladatellatasiHelyDatummal = $"{RemoveTooLongElementOrTrunc(RemoveSpecialCharacters(feladatellatasiHelyFileNevDictionary[feladatellatasiHelyIdList[0]]))}_{DateTime.Now:yyyy_MM_dd_HH_mm}";
|
|
|
|
var memoryStreamList = szirSatHelper.GetSzirStatSzak(Server.MapPath("~/Resources/SZIRStat/XLS/" + nyomtatvanyNeve + ".xlsx"), feladatellatasiHelyIdList[0]);
|
|
return new FileStreamResult(memoryStreamList[0], Constants.ImportExport.FileFormatXlsx)
|
|
{
|
|
FileDownloadName = $"{nyomtatvanyNeve}_{currentFileNameFeladatellatasiHelyDatummal}.{Constants.ImportExport.FileFormatXlsx}"
|
|
};
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw NyomtatvanyokLogic.NyomtatvanyError(ex);
|
|
}
|
|
}
|
|
|
|
public ActionResult SzirStatMuv([ModelBinder(typeof(NyomtatvanyModelBinderWithPoszeidonIktatasDefiniciok))] NyomtatvanyModel model)
|
|
{
|
|
var output = new MemoryStream();
|
|
var zipOutput = new ZipOutputStream(output);
|
|
try
|
|
{
|
|
SZIRStatHelper szirSatHelper = new SZIRStatHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
|
Dictionary<int, string> feladatellatasiHelyFileNevDictionary = szirSatHelper.GetKirSzirFeladatEllatasiHelyDDl(false);
|
|
List<int> feladatellatasiHelyIdList = model.FeladatellatasiHelyIdList;
|
|
if (feladatellatasiHelyIdList == null || feladatellatasiHelyIdList.Count == 0)
|
|
{
|
|
feladatellatasiHelyIdList = new List<int>();
|
|
foreach (var item in feladatellatasiHelyFileNevDictionary)
|
|
{
|
|
feladatellatasiHelyIdList.Add(item.Key);
|
|
}
|
|
}
|
|
|
|
string nyomtatvanyNeve = "SZIR_OSA11MUV";
|
|
//string segedletNeve = "SZIR_OSA11MUV_segedlet";
|
|
if (feladatellatasiHelyIdList.Count > 1)
|
|
{
|
|
foreach (int id in feladatellatasiHelyIdList)
|
|
{
|
|
string currentFileNameFeladatellatasiHelyDatummal = $"{RemoveTooLongElementOrTrunc(RemoveSpecialCharacters(feladatellatasiHelyFileNevDictionary[id]))}_{DateTime.Now:yyyy_MM_dd_HH_mm}";
|
|
|
|
var memoryStreamList = szirSatHelper.GetSzirStatMuv(Server.MapPath("~/Resources/SZIRStat/XLS/" + nyomtatvanyNeve + ".xlsx"), id);
|
|
|
|
AddExcelMintZipEntry(zipOutput, memoryStreamList[0], nyomtatvanyNeve + "_" + currentFileNameFeladatellatasiHelyDatummal);
|
|
//AddExcelMintZipEntry(zipOutput, memoryStreamList[1], segedletNeve + "_" + currentFileNameFeladatellatasiHelyDatummal);
|
|
}
|
|
|
|
zipOutput.Finish();
|
|
output.Position = 0;
|
|
return new FileStreamResult(output, Constants.ImportExport.ContentType)
|
|
{
|
|
FileDownloadName = $"{nyomtatvanyNeve}_{DateTime.Now:yyyy_MM_dd_HH_mm}.{Constants.ImportExport.FileFormatZip}"
|
|
};
|
|
}
|
|
else
|
|
{
|
|
string currentFileNameFeladatellatasiHelyDatummal = $"{RemoveTooLongElementOrTrunc(RemoveSpecialCharacters(feladatellatasiHelyFileNevDictionary[feladatellatasiHelyIdList[0]]))}_{DateTime.Now:yyyy_MM_dd_HH_mm}";
|
|
|
|
var memoryStreamList = szirSatHelper.GetSzirStatMuv(Server.MapPath("~/Resources/SZIRStat/XLS/" + nyomtatvanyNeve + ".xlsx"), feladatellatasiHelyIdList[0]);
|
|
return new FileStreamResult(memoryStreamList[0], Constants.ImportExport.FileFormatXlsx)
|
|
{
|
|
FileDownloadName = $"{nyomtatvanyNeve}_{currentFileNameFeladatellatasiHelyDatummal}.{Constants.ImportExport.FileFormatXlsx}"
|
|
};
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw NyomtatvanyokLogic.NyomtatvanyError(ex);
|
|
}
|
|
}
|
|
|
|
#endregion SZIRStat
|
|
|
|
}
|
|
}
|