init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
370
KretaWeb/Areas/Beiratkozas/Controllers/NebuloController.cs
Normal file
370
KretaWeb/Areas/Beiratkozas/Controllers/NebuloController.cs
Normal file
|
@ -0,0 +1,370 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Kreta.BusinessLogic.Classes;
|
||||
using Kreta.BusinessLogic.HelperClasses;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Helpers.ImportExport;
|
||||
using Kreta.BusinessLogic.Logic;
|
||||
using Kreta.BusinessLogic.Security;
|
||||
using Kreta.Client.Eugyintezes.Configuration;
|
||||
using Kreta.Client.KozpontiKreta;
|
||||
using Kreta.Client.KozpontiKreta.Model;
|
||||
using Kreta.Core;
|
||||
using Kreta.Core.Configuratiaton.Interface;
|
||||
using Kreta.Core.FeatureToggle;
|
||||
using Kreta.Enums;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.Beiratkozas.Models;
|
||||
using Kreta.Web.Classes;
|
||||
using Kreta.Web.Controllers;
|
||||
using Kreta.Web.Helpers;
|
||||
using Kreta.Web.Models.EditorTemplates;
|
||||
using Kreta.Web.Security;
|
||||
using OfficeOpenXml;
|
||||
using ModelStateDictionary = System.Web.Http.ModelBinding.ModelStateDictionary;
|
||||
|
||||
namespace Kreta.Web.Areas.Beiratkozas.Controllers
|
||||
{
|
||||
[MvcRoleClaimsAuthorize(true)]
|
||||
[MvcRolePackageDenyAuthorize(KretaClaimPackages.IsOnlyAlkalmozott.ClaimValue)]
|
||||
[MvcRolePackageAuthorize(KretaClaimPackages.Adminisztrator.ClaimValue)]
|
||||
public class NebuloController : Controller
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public static string NewModifyNebuloPopupName => "New_Modify_Popup";
|
||||
public static string NemFelvettNebuloPopupName => "Nem_Felvett_Popup";
|
||||
public static string NewModifyNebuloFormName => "NewModifyNebuloForm";
|
||||
public static string NebuloMultiEditPopupName => "MultiEdit_Popup";
|
||||
public static string NebuloMultiEditFormName => "NebuloMultiEditForm";
|
||||
public static string ImportNebuloFormName => "ImportNebuloForm";
|
||||
public static string KirLoginFormName => "KirLoginForm";
|
||||
public static string KirLoginPopupName => "KirLogin_Popup";
|
||||
public static string NebuloTelephelyPopupName => "NebuloTelephely_Popup";
|
||||
public static string KirFeladatellatasiHelySorszamPopupName => "KirFeladatellatasiHelySorszam_PopUp";
|
||||
public static string KirFeladatellatasiHelySorszamGridName => "KirFeladatellatasiHelySorszamGrid";
|
||||
public static string NebuloTelephelyGrid => "NebuloTelephelyGrid";
|
||||
|
||||
private IUploadFileValidator UploadFileValidator { get; }
|
||||
private IFeatureContext FeatureContext { get; }
|
||||
private readonly IEugyintezesClientConfiguration EugyintezesClientConfiguration;
|
||||
private readonly IKozpontiKretaConfiguration KozpontiKretaConfiguration;
|
||||
|
||||
#endregion Properties
|
||||
|
||||
public NebuloController(IUploadFileValidator uploadFileValidator, IFeatureContext featureContext, IEugyintezesClientConfiguration eugyintezesClientConfiguration, IKozpontiKretaConfiguration kozpontiKretaConfiguration)
|
||||
{
|
||||
UploadFileValidator = uploadFileValidator ?? throw new ArgumentNullException(nameof(uploadFileValidator));
|
||||
FeatureContext = featureContext ?? throw new ArgumentNullException(nameof(featureContext));
|
||||
EugyintezesClientConfiguration = eugyintezesClientConfiguration ?? throw new ArgumentNullException(nameof(eugyintezesClientConfiguration));
|
||||
KozpontiKretaConfiguration = kozpontiKretaConfiguration ?? throw new ArgumentNullException(nameof(kozpontiKretaConfiguration));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult Index()
|
||||
{
|
||||
var helper = new NebuloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
var intezmenyHelper = new IntezmenyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
|
||||
var model = new NebuloSearchModel
|
||||
{
|
||||
MaxAllowedFileSizeInBytes = UploadFileValidator.Configuration.ImportMaxAllowedFileSizeInBytes,
|
||||
AllowedFileExtensions = UploadFileValidator.Configuration.ImportAllowedFileExtensions,
|
||||
EnableKirSzinkron = FeatureContext.IsEnabled(Core.Constants.FeatureName.KirSzinkron, ApplicationData.SystemType.ToString(), ClaimData.IntezmenyAzonosito),
|
||||
EnableEugyHatarozat = FeatureContext.IsEnabled(Core.Constants.FeatureName.BeiratkozasEugyHatarozat, ApplicationData.SystemType.ToString(), ClaimData.IntezmenyAzonosito) && helper.GetIsEnableEugyHatarozat(),
|
||||
EnableStatuszVeglegesites = intezmenyHelper.GetIntezmenyiAdatok().EnableBAIStatuszVeglegesites,
|
||||
FeladatellatasiHelyIdSearch = ClaimData.FelhelySzuro
|
||||
};
|
||||
|
||||
/*Létszám adatok*/
|
||||
var client = new KozpontiClient(KozpontiKretaConfiguration.KtrUrl, KozpontiKretaConfiguration.ApiKey);
|
||||
var tanevSorszam = new TanevHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).GetTanevInfo().Sorszam;
|
||||
var kozpontiResult = client.GetBeiratkozasLetszamList(new KozpontiNebuloEngedelyezettRequestModel()
|
||||
{
|
||||
IntezmenyAzonosito = ClaimData.IntezmenyAzonosito,
|
||||
TanevId = tanevSorszam
|
||||
});
|
||||
|
||||
if (kozpontiResult != null)
|
||||
{
|
||||
model.EOLNemOsszevontOsztaly = kozpontiResult.EngedelyezettOsztaly;
|
||||
model.EOsszLNemOsszevontOsztaly = kozpontiResult.EngedelyezettOsztalyLetszam;
|
||||
model.EOLOsszevontOsztaly = kozpontiResult.EngedelyezettOsszevontOsztaly;
|
||||
model.EOsszLOsszevontOsztaly = kozpontiResult.EngedelyezettOsszevontOsztalyLetszam;
|
||||
}
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
#region Popup actions
|
||||
|
||||
[HttpPost]
|
||||
[MvcValidateAjaxAntiForgeryToken]
|
||||
public ActionResult OpenNewModifyNebuloPopup(int? id)
|
||||
{
|
||||
bool isModify = id.IsEntityId();
|
||||
NebuloModel nebuloModel;
|
||||
|
||||
if (isModify)
|
||||
{
|
||||
NebuloCo co = new NebuloHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetNebuloById(id.Value);
|
||||
nebuloModel = new NebuloModel(co);
|
||||
}
|
||||
else
|
||||
{
|
||||
nebuloModel = new NebuloModel
|
||||
{
|
||||
SzuletesiOrszag = (int)OrszagTipusEnum.Magyarorszag,
|
||||
Anyanyelv = (int)AnyanyelvEnum.magyar,
|
||||
Allampolgarsag = (int)AllampolgarsagEnum.magyar,
|
||||
TKCimeAzonos = true,
|
||||
TK2CimeAzonos = true,
|
||||
THCimeAzonos = true,
|
||||
Tagozat = (int)TagozatTipusEnum.Normal_egesz_napos_iskola,
|
||||
EletvitelszeruOttLakasKorzetes = false,
|
||||
FelvetelStatusza = (int)FelvetelStatuszaTipusEnum.Fuggoben,
|
||||
SNILetszamSuly = 1,
|
||||
BTMLetszamSuly = 1,
|
||||
KirSzolgaltatasTipusId = (int)KirSzolgaltatasTipusEnum.AltalanosFeltetelekSzerintiNevelesOktatas
|
||||
};
|
||||
}
|
||||
|
||||
nebuloModel.FeladatellatasiHelyList = GetFeladatellatasiHelyList();
|
||||
var popupModel = new PopUpModel(nebuloModel, NewModifyNebuloPopupName);
|
||||
popupModel = popupModel.AddCancelBtn(popupModel, "NebuloHelper.newModifyNebuloPopupCancel");
|
||||
|
||||
if (!ClaimData.IsBeiratkozasVeglegesitve)
|
||||
{
|
||||
popupModel = popupModel.AddOkBtn(popupModel, "NebuloHelper.newModifyNebuloPopupSave");
|
||||
if (isModify)
|
||||
{
|
||||
popupModel.AddDeleteBtn(popupModel, "NebuloHelper.newModifyNebuloPopupDelete");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nebuloModel.FelvetelStatusza == (int)FelvetelStatuszaTipusEnum.NemFelveve)
|
||||
{
|
||||
popupModel = popupModel.AddBtn(popupModel, "masodfok", BeiratkozasResource.MasodfokonFelveteltNyert, "NebuloHelper.masodfokConfirmWindow");
|
||||
}
|
||||
}
|
||||
return PartialView(Constants.General.PopupView, popupModel);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[MvcValidateAjaxAntiForgeryToken]
|
||||
public ActionResult OpenNebuloNemFelvettPopup(int id)
|
||||
{
|
||||
NebuloCo co = new NebuloHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetNebuloById(id);
|
||||
NebuloModel model = new NebuloModel(co);
|
||||
model.FelvetelStatusza = (int)FelvetelStatuszaTipusEnum.NemFelveve;
|
||||
|
||||
var popupModel = new PopUpModel(model, NemFelvettNebuloPopupName);
|
||||
popupModel = popupModel.AddCancelBtn(popupModel, "NebuloHelper.nebuloNemFelvettPopupCancel");
|
||||
popupModel = popupModel.AddOkBtn(popupModel, "NebuloHelper.nebuloNemFelvettPopupSave");
|
||||
|
||||
return PartialView(Constants.General.PopupView, popupModel);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[MvcValidateAjaxAntiForgeryToken]
|
||||
public ActionResult OpenMultiEditNebuloPopup(List<int> idList)
|
||||
{
|
||||
NebuloMultiEditModel nebuloModel = new NebuloMultiEditModel(idList)
|
||||
{
|
||||
FeladatellatasiHelyList = GetFeladatellatasiHelyList()
|
||||
};
|
||||
|
||||
var popupModel = new PopUpModel(nebuloModel, NebuloMultiEditPopupName);
|
||||
popupModel = popupModel.AddCancelBtn(popupModel, "NebuloHelper.multiEditPopupCancel");
|
||||
|
||||
if (!ClaimData.IsBeiratkozasVeglegesitve)
|
||||
{
|
||||
popupModel = popupModel.AddOkBtn(popupModel, "NebuloHelper.multiEditNebuloPopupSave");
|
||||
}
|
||||
return PartialView(Constants.General.PopupView, popupModel);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[MvcValidateAjaxAntiForgeryToken]
|
||||
public ActionResult OpenKirLoginPopup()
|
||||
{
|
||||
if (FeatureContext.IsEnabled(Core.Constants.FeatureName.KirSzinkron, ApplicationData.SystemType.ToString(), ClaimData.IntezmenyAzonosito))
|
||||
{
|
||||
string token = Cache.Get($"{ClaimData.FelhasznaloNev}_{ClaimData.FelhasznaloId}_{ClaimData.IntezmenyAzonosito}_Token")?.ToString();
|
||||
var kirFeladatellatasiHelyList = Cache.Get($"{ClaimData.FelhasznaloNev}_{ClaimData.FelhasznaloId}_{ClaimData.IntezmenyAzonosito}_KirFeladatellatasiHelyList") as List<SelectListItem>;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(token) ||
|
||||
kirFeladatellatasiHelyList == null)
|
||||
{
|
||||
var nebuloKirSzinkronModel = new NebuloKirSzinkronModel
|
||||
{
|
||||
KirLoginModel = new KirLoginModel()
|
||||
};
|
||||
|
||||
var popupModel = new PopUpModel(nebuloKirSzinkronModel, KirLoginPopupName);
|
||||
popupModel = popupModel.AddCancelBtn(popupModel, "KirHelper.kirLoginPopupCancel");
|
||||
popupModel = popupModel.AddBtn(popupModel, "Bejelentkezes", CommonResource.Bejelentkezes, "KirHelper.getKirFeladatellatasiHelyList");
|
||||
|
||||
return PartialView(Constants.General.PopupView, popupModel);
|
||||
}
|
||||
|
||||
var responseMessage = new NebuloApiController(EugyintezesClientConfiguration).KirSzinkron(null);
|
||||
|
||||
return new JsonResult
|
||||
{
|
||||
Data = new
|
||||
{
|
||||
statusCode = responseMessage.StatusCode,
|
||||
content = responseMessage.Content
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return new EmptyResult();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[MvcValidateAjaxAntiForgeryToken]
|
||||
public ActionResult OpenNebuloTelephelyPopup()
|
||||
{
|
||||
if (FeatureContext.IsEnabled(Core.Constants.FeatureName.KirSzinkron, ApplicationData.SystemType.ToString(), ClaimData.IntezmenyAzonosito))
|
||||
{
|
||||
var kirFeladatellatasiHelyList = Cache.Get($"{ClaimData.FelhasznaloNev}_{ClaimData.FelhasznaloId}_{ClaimData.IntezmenyAzonosito}_KirFeladatellatasiHelyList") as List<SelectListItem>;
|
||||
DataSet nemSzinkronizaltNebulok = new NebuloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType())
|
||||
.GetNemSzinkronizaltNebulok();
|
||||
|
||||
if (kirFeladatellatasiHelyList != null && nemSzinkronizaltNebulok.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
var nebuloKirSzinkronModel = new NebuloKirSzinkronModel
|
||||
{
|
||||
TelephelyList = kirFeladatellatasiHelyList
|
||||
};
|
||||
|
||||
var popupModel = new PopUpModel(nebuloKirSzinkronModel, NebuloTelephelyPopupName);
|
||||
popupModel = popupModel.AddCancelBtn(popupModel, "KirHelper.nebuloTelephelyPopupCancel");
|
||||
popupModel = popupModel.AddBtn(popupModel, "kirSzinkron_Mentes", "Mentés", "KirHelper.nebuloKirSzinkron");
|
||||
|
||||
return PartialView(Constants.General.PopupView, popupModel);
|
||||
}
|
||||
|
||||
var responseMessage = new NebuloApiController(EugyintezesClientConfiguration).KirSzinkron(null);
|
||||
|
||||
return new JsonResult
|
||||
{
|
||||
Data = new
|
||||
{
|
||||
statusCode = responseMessage.StatusCode,
|
||||
content = responseMessage.Content
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return new EmptyResult();
|
||||
}
|
||||
|
||||
#endregion Popup actions
|
||||
|
||||
[HttpPost]
|
||||
[MvcValidateAjaxAntiForgeryToken]
|
||||
public string GetFilteredExcel(NebuloSearchModel model)
|
||||
{
|
||||
MemoryStream memoryStream = new NebuloImportExportHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetExport(model.ToCo());
|
||||
var guid = Cache.Add(memoryStream);
|
||||
|
||||
return Url.Action(nameof(CacheController.DownloadFile), nameof(CacheController).Replace("Controller", ""), new { guid, fileName = BeiratkozasResource.NebuloExportFilename, contentType = Core.Constants.ContentTypes.Xlsx, area = "" });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[MvcValidateAjaxAntiForgeryToken]
|
||||
private List<SelectListItem> GetFeladatellatasiHelyList()
|
||||
{
|
||||
FeladatEllatasiHelyHelper helper = new FeladatEllatasiHelyHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
var dictionary = helper.GetFeladatEllatasiHelyDDl("");
|
||||
List<SelectListItem> list = new List<SelectListItem>();
|
||||
|
||||
foreach (var item in dictionary)
|
||||
{
|
||||
SelectListItem sli = new SelectListItem { Text = item.Value, Value = item.Key };
|
||||
list.Add(sli);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ActionResult GetHibasNebuloExcel()
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
var helper = new NebuloHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
|
||||
List<NebuloCo> nebuloCoList = helper.GetNebuloList();
|
||||
var nebuloModelList = nebuloCoList.Select(x => new NebuloModel(x)).ToList();
|
||||
|
||||
var invalidNebuloNevList = new Dictionary<string, string>();
|
||||
var cnt = 0;
|
||||
foreach (var nebuloModel in nebuloModelList)
|
||||
{
|
||||
cnt++;
|
||||
ModelStateDictionary modelStateDictionary = nebuloModel.Validate(ClaimData.SelectedTanevID.Value);
|
||||
var gvCnt = helper.GetOvodasGvCntByNebuloOktAzon(nebuloModel.OktatasiAzonositoSzama);
|
||||
|
||||
if (!modelStateDictionary.IsValid)
|
||||
{
|
||||
var msg = string.Empty;
|
||||
foreach (var item in modelStateDictionary)
|
||||
{
|
||||
if (msg.Length > 0)
|
||||
{ msg += " "; }
|
||||
msg += item.Value.Errors[0].ErrorMessage;
|
||||
}
|
||||
|
||||
invalidNebuloNevList.Add($"{cnt}. {nebuloModel.NebuloNeve}", msg);
|
||||
}
|
||||
|
||||
if (gvCnt == 0)
|
||||
{
|
||||
invalidNebuloNevList.Add(nebuloModel.NebuloNeve, BeiratkozasResource.OvisGyereknekNincsGondviseloje);
|
||||
}
|
||||
}
|
||||
|
||||
var dataSet = new DataSet();
|
||||
dataSet.Tables.Add();
|
||||
dataSet.Tables[0].Columns.Add("Nebulo");
|
||||
dataSet.Tables[0].Columns.Add("HibasAdatok");
|
||||
|
||||
foreach (var item in invalidNebuloNevList)
|
||||
{
|
||||
dataSet.Tables[0].Rows.Add(item.Key, item.Value);
|
||||
}
|
||||
|
||||
DataTable dataTable = dataSet.Tables[0];
|
||||
ExportLogic.TryCreateHeaderIfNotExist(dataTable);
|
||||
|
||||
using (var excel = new ExcelPackage(stream))
|
||||
{
|
||||
ExcelWorksheet workSheet = excel.Workbook.Worksheets.Add(FelhasznalokResource.Export);
|
||||
|
||||
(string nameFrom, string nameTo, Type type)[] map = new[]
|
||||
{
|
||||
("Nebulo", BeiratkozasResource.Nebulo, typeof(string)),
|
||||
("HibasAdatok", BeiratkozasResource.HibasAdatok, typeof(string)),
|
||||
};
|
||||
var table = ExportLogic.MapDataTable(dataTable, map);
|
||||
workSheet.Cells[1, 1].LoadFromDataTable(table, true);
|
||||
|
||||
ExportLogic.SetHeaderStyles(workSheet.Cells[1, 1, 1, table.Columns.Count]);
|
||||
|
||||
workSheet.Cells.AutoFitColumns();
|
||||
excel.Save();
|
||||
}
|
||||
|
||||
stream.Position = 0;
|
||||
|
||||
var result = new FileStreamResult(stream, Core.Constants.ContentTypes.Xlsx) { FileDownloadName = "NebuloHibasAdatok" + "_" + DateTime.Now.ToString("yyyy_MM_dd") + ".xlsx" };
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue