73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Net;
|
|
using System.Web.Mvc;
|
|
using Kreta.BusinessLogic.Security;
|
|
using Kreta.Resources;
|
|
using Kreta.Web.Classes;
|
|
using Kreta.Web.Helpers.Error;
|
|
using Kreta.Web.Security;
|
|
|
|
namespace Kreta.Web.Areas.ImportExport.Controllers
|
|
{
|
|
[MvcRoleClaimsAuthorize(true)]
|
|
[MvcRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
|
public class BaseImportExportController : Controller
|
|
{
|
|
#region Properties
|
|
|
|
public static string ImportFileName => "ImportFile";
|
|
|
|
public static string ImportForm => "ImportForm";
|
|
public static string ExportForm => "ExportForm";
|
|
|
|
public static string ImportPreviewPopupName => "ImportPreviewPopup";
|
|
public static string ImportPopupTabStripName => "ImportPopupTabStrip";
|
|
|
|
public static string OsszefoglalasGridName => "OsszefoglalasGrid";
|
|
public static string NemImportalhatoSorokGridName => "NemImportalhatoSorokGrid";
|
|
|
|
protected IUploadFileValidator UploadFileValidator { get; set; }
|
|
|
|
#endregion Properties
|
|
|
|
#region Sablon
|
|
|
|
protected FilePathResult GetExcelTemplate(string fileName)
|
|
{
|
|
string filePath = Kreta.Web.Classes.Utils.GetExcelTemplateImportExportFilePath(fileName);
|
|
|
|
if (filePath == null)
|
|
{
|
|
throw new StatusError(HttpStatusCode.BadRequest, ErrorResource.FajlNemLetezik);
|
|
}
|
|
|
|
FilePathResult result = File(filePath, Core.Constants.ContentTypes.Xlsx, fileName);
|
|
return result;
|
|
}
|
|
|
|
#endregion Sablon
|
|
|
|
#region Export
|
|
|
|
public string GetExportFileString(MemoryStream memoryStream)
|
|
{
|
|
if (memoryStream != null)
|
|
{
|
|
return Convert.ToBase64String(memoryStream.ToArray());
|
|
}
|
|
|
|
return ImportExportCommonResource.NincsElegendoAdatARendszerbenAzExportalashoz;
|
|
}
|
|
|
|
#endregion Export
|
|
|
|
public JsonResult ThrowCustomError(List<string> messageList)
|
|
{
|
|
Response.TrySkipIisCustomErrors = true;
|
|
Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
|
return Json(messageList);
|
|
}
|
|
}
|
|
}
|