using System; using System.Collections.Generic; using System.IO; using System.Web; using System.Web.Mvc; using Kreta.BusinessLogic.Exceptions; using Kreta.BusinessLogic.Helpers; using Kreta.BusinessLogic.Security; using Kreta.Enums.ManualEnums; using Kreta.Framework.Util; using Kreta.Web.Areas.Adatszolgaltatasok.ApiControllers; using Kreta.Web.Areas.Adatszolgaltatasok.Models; using Kreta.Web.Helpers; using Kreta.Web.Security; using Newtonsoft.Json; namespace Kreta.Web.Areas.Adatszolgaltatasok.Controllers { //Note: kikapcsolva, mert jelenleg nincs használatban [MvcRoleClaimsAuthorize(true)] [MvcRolePackageDenyAuthorize(KretaClaimPackages.IsOnlyAlkalmozott.ClaimValue)] //[MvcRolePackageAuthorize(KretaClaimPackages.Fenntarto.ClaimValue, KretaClaimPackages.Adminisztrator.ClaimValue)] public class EnaploAdatszolgaltatasController : Controller { [MvcRolePackageDenyAuthorize(KretaClaimPackages.IsOnlyAlkalmozott.ClaimValue)] public ActionResult Index() { EnaploAdatszolgaltatasApiController api = new EnaploAdatszolgaltatasApiController(); EnaploAdatszolgaltatasModel model = api.GetEnaploAdatszolgaltatas(); model.IgenNemList = GetIgenNemList(); return View("Index", model); } /// /// Uploads the agreement. /// /// The szerzodes file. /// The model. /// [HttpPost] public ActionResult UploadSzerzodes(HttpPostedFileBase szerzodesFile, EnaploAdatszolgaltatasModel model) { try { var input_file = szerzodesFile.InputStream; MemoryStream memoryStream = new MemoryStream(); var fileName = szerzodesFile.FileName; byte[] buffer = new byte[16 * 1024]; int read; while ((read = input_file.Read(buffer, 0, buffer.Length)) > 0) { memoryStream.Write(buffer, 0, read); } var helper = new AdatszolgaltatasokHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()); helper.SaveorUpdateSzerzodesForEnaploAdatszolgaltatas(memoryStream, fileName, model.ID); } catch (InvalidDataException ex) { return Content(ex.Message); } catch (KretaInvalidFileFormatException e) { return Content(e.Message); } catch (Exception e) { return Content(JsonConvert.SerializeObject(e)); } return Content(string.Empty); } [MvcValidateAjaxAntiForgeryToken] [HttpPost] public ActionResult RemoveSzerzodes(HttpPostedFileBase szerzodesFile) { try { //Fájl törlés hack } catch (InvalidDataException ex) { return Content(ex.Message); } catch (KretaInvalidFileFormatException e) { return Content(e.Message); } catch (Exception e) { return Content(JsonConvert.SerializeObject(e)); } return Content(string.Empty); } public List GetIgenNemList() { IDictionary dictionary = FrameworkEnumExtensions.EnumToListManual(); return dictionary.ToSelectListItemList(); } } }