106 lines
4 KiB
C#
106 lines
4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Web.Mvc;
|
|
using ICSharpCode.SharpZipLib.Zip;
|
|
using Kreta.BusinessLogic.Classes;
|
|
using Kreta.BusinessLogic.Helpers;
|
|
using Kreta.Enums;
|
|
using Kreta.Enums.ManualEnums;
|
|
using Kreta.Web.Areas.Nyomtatvanyok.Logic;
|
|
using Kreta.Web.Helpers;
|
|
|
|
namespace Kreta.Web.Areas.Nyomtatvanyok.Controllers
|
|
{
|
|
public partial class NyomtatvanyokController : BaseNyomtatvanyokController
|
|
{
|
|
public MemoryStream NebuloEgyedi(int nebuloId, int statusz)
|
|
{
|
|
try
|
|
{
|
|
DataSet ds = new NyomtatvanyokHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetNebuloErtesito(nebuloId);
|
|
|
|
DataRow dr = ds.Tables[0].Rows[0];
|
|
|
|
string frxNeve = statusz == FelvetelStatuszaTipusEnum.Felveve.AsInt() ? nameof(NyomtatvanyEnum.NebuloErtesitoFelveve) : nameof(NyomtatvanyEnum.NebuloErtesitoNemFelveve);
|
|
|
|
string dokumentumNeve = $"{dr["NebuloNeve"].ToString().Trim().Replace(" ", "_")}_{dr["SzulIdo"].ToString().Trim().Replace(".", "")}";
|
|
|
|
var filePath = System.Web.HttpContext.Current.Server.MapPath($"{ApplicationData.NyomtatasiSablonokKonyvtar}/{frxNeve}.frx");
|
|
|
|
var result = GetPdfMemoryStreamByPath(ds, filePath, pdfNeve: dokumentumNeve);
|
|
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw NyomtatvanyokLogic.NyomtatvanyError(ex);
|
|
}
|
|
}
|
|
|
|
public ActionResult NebuloFelvettZip(NyomtatvanyModel model)
|
|
{
|
|
return GetNebuloInZip(model, FelvetelStatuszaTipusEnum.Felveve.AsInt());
|
|
}
|
|
|
|
public ActionResult NebuloElutasitottZip(NyomtatvanyModel model)
|
|
{
|
|
return GetNebuloInZip(model, FelvetelStatuszaTipusEnum.NemFelveve.AsInt());
|
|
}
|
|
|
|
public MemoryStream NebuloSablon(NyomtatvanyModel model)
|
|
{
|
|
try
|
|
{
|
|
DataSet ds = new NyomtatvanyokHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetDokumentumFejlecLablecSablon();
|
|
|
|
return GetMemoryStreamByName(ds, nameof(NyomtatvanyEnum.NebuloSablon), nyomtatvanyNeve: nameof(NyomtatvanyEnum.NebuloSablon));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw NyomtatvanyokLogic.NyomtatvanyError(ex);
|
|
}
|
|
}
|
|
|
|
public FileStreamResult GetNebuloInZip(NyomtatvanyModel model, int statusz)
|
|
{
|
|
var OutPut = new MemoryStream();
|
|
ZipOutputStream ZipOutPut = new ZipOutputStream(OutPut);
|
|
|
|
try
|
|
{
|
|
List<DataSet> dsList = new NyomtatvanyokHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetNebuloErtesitoZip(statusz);
|
|
|
|
byte[] buffer = new byte[Constants.General.BufferSize];
|
|
|
|
string ertesitoTipus = statusz == FelvetelStatuszaTipusEnum.Felveve.AsInt() ? nameof(NyomtatvanyEnum.NebuloErtesitoFelveve) : nameof(NyomtatvanyEnum.NebuloErtesitoNemFelveve);
|
|
|
|
foreach (DataSet item in dsList)
|
|
{
|
|
DataRow dr = item.Tables[0].Rows[0];
|
|
|
|
string dokumentumNeve = $"{dr["NebuloNeve"].ToString().Trim().Replace(" ", "_")}_{dr["SzulIdo"].ToString().Trim().Replace(".", "")}";
|
|
|
|
var stream = GetMemoryStreamByName(item, ertesitoTipus, nyomtatvanyNeve: dokumentumNeve);
|
|
|
|
var fajlneve = $"{dokumentumNeve}.{Constants.ImportExport.FileFormatPdf}";
|
|
AddZipEntry(ZipOutPut, stream, fajlneve);
|
|
}
|
|
|
|
ZipOutPut.Finish();
|
|
|
|
OutPut.Position = 0;
|
|
|
|
return new FileStreamResult(OutPut, Constants.ImportExport.ContentType)
|
|
{
|
|
FileDownloadName = ertesitoTipus + ".zip"
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw NyomtatvanyokLogic.NyomtatvanyError(ex);
|
|
}
|
|
}
|
|
}
|
|
}
|