This commit is contained in:
skidoodle 2024-03-13 00:33:46 +01:00
commit e124a47765
19374 changed files with 9806149 additions and 0 deletions

View file

@ -0,0 +1,74 @@
using System.Collections.Generic;
using System.Web.Http;
using System.Web.Http.ModelBinding;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using Kreta.BusinessLogic.Helpers;
using Kreta.BusinessLogic.Security;
using Kreta.Resources;
using Kreta.Web.Areas.HRModul.Logic;
using Kreta.Web.Areas.HRModul.Models;
using Kreta.Web.Helpers;
using Kreta.Web.Helpers.Grid;
using Kreta.Web.Security;
using Newtonsoft.Json;
namespace Kreta.Web.Areas.HRModul.ApiControllers
{
[ApiRoleClaimsAuthorize(true)]
[ApiRolePackageAuthorize(KretaClaimPackages.TavolletIgenylo.ClaimValue)]
//[ApiFeatureAuthorize(Core.Constants.FeatureName.HRModul)]
public class TavolletListaApiController : ApiController
{
public DataSourceResult GetTavolletListaGrid(string data, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
{
var model = JsonConvert.DeserializeObject<TavolletListaSearchModel>(data);
var LResult = new List<TavolletListaGridModel>();
var helper = new HRModulHelper(ConnectionTypeExtensions.GetSessionConnectionType());
var alkalmazottHelper = new AlkalmazottHelper(ConnectionTypeExtensions.GetSessionConnectionType());
var (kozpontiResult, sztszAzonositok) = new TavolletListaLogic().GetTavolletBefogadottLista(model, helper, alkalmazottHelper);
if (!kozpontiResult?.IsSuccess ?? true)
{
return new DataSourceResult
{
Errors = "error"
};
}
if (kozpontiResult.Data != null)
{
var aa = alkalmazottHelper.GetAlkalmazottSztszAzonositoTavolletAlkalmazott(sztszAzonositok);
foreach (var item in kozpontiResult.Data)
{
LResult.Add(new TavolletListaGridModel
{
ID = item.Id.ToString(),
TipusId_DNAME = item.TavolletTipusNev,
SzTSzAzonosito = item.SzTSzAzonosito,
IdoszakKezdet = item.TavolletKezdete,
IdoszakVeg = item.TavolletVege,
TavolletIdotartamNap = item.TavolletIdotartamaNap,
EvesSzabadsagKeret = item.EvesKeret,
AlkalmazottNev = (aa.TryGetValue(item.SzTSzAzonosito, out var value) ? value.AlkalmazottNev : ErrorResource.NevSzinkronizalasaSikertelen)
});
}
if (LResult.Count > 0)
{
var result = new DataSourceResult
{
Data = LResult.ToDataSourceResult(request).Data,
Total = LResult.Count
};
return result;
}
}
return new DataSourceResult();
}
}
}

View file

@ -0,0 +1,396 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.ModelBinding;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using Kreta.BusinessLogic.Classes;
using Kreta.BusinessLogic.Helpers;
using Kreta.BusinessLogic.Interfaces;
using Kreta.BusinessLogic.Security;
using Kreta.Client.Tavollet;
using Kreta.Core;
using Kreta.Core.Configuratiaton;
using Kreta.Core.Iktato.Poszeidon.Factory.Interface;
using Kreta.Core.SAP.CommunicationModels;
using Kreta.Core.SAP.CommunicationModels.TavolletIgenyekKezelese;
using Kreta.Core.SAP.Enums;
using Kreta.Enums;
using Kreta.Enums.ManualEnums;
using Kreta.Resources;
using Kreta.Web.Areas.HRModul.Logic;
using Kreta.Web.Areas.HRModul.Models;
using Kreta.Web.Helpers;
using Kreta.Web.Helpers.Error;
using Kreta.Web.Helpers.Grid;
using Kreta.Web.Security;
using Newtonsoft.Json;
namespace Kreta.Web.Areas.HRModul.ApiControllers
{
[ApiRoleClaimsAuthorize(true)]
[ApiRolePackageAuthorize(KretaClaimPackages.TavolletIgenylo.ClaimValue)]
//[ApiFeatureAuthorize(Core.Constants.FeatureName.HRModul)]
public class TavolletjelentoApiController : ApiController
{
private IIktatoRepositoryFactory IktatoRepositoryFactory { get; }
private IktatoServiceConfiguration IktatoServiceConfiguration { get; }
private readonly IFileServiceHelper fileServiceHelper;
public TavolletjelentoApiController(IIktatoRepositoryFactory iktatoRepositoryFactory, IktatoServiceConfiguration iktatoServiceConfiguration, IFileServiceHelper fileServiceHelper)
{
IktatoRepositoryFactory = iktatoRepositoryFactory ?? throw new ArgumentNullException(nameof(iktatoRepositoryFactory));
IktatoServiceConfiguration = iktatoServiceConfiguration ?? throw new ArgumentNullException(nameof(iktatoServiceConfiguration));
this.fileServiceHelper = fileServiceHelper;
}
public DataSourceResult GetTavolletjelentoGrid(string data, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
{
var helper = new HRModulHelper(ConnectionTypeExtensions.GetSessionConnectionType());
List<TavolletjelentoGridModel> LResult = new List<TavolletjelentoGridModel>();
var model = JsonConvert.DeserializeObject<TavolletjelentoSearchModel>(data);
var kozpontiResult = new TavolletjelentoLogic().GetTavolletjelentoLista(model, helper);
if (!kozpontiResult?.IsSuccess ?? true)
{
return new DataSourceResult
{
Errors = "error"
};
}
if (kozpontiResult != null && kozpontiResult.IsSuccess && kozpontiResult.TavolletjelentoResultList != null)
{
bool isIntezmenyvezeto = helper.IsIntezmenyvezeto(ClaimData.FelhasznaloId);
foreach (var item in kozpontiResult.TavolletjelentoResultList)
{
LResult.Add(new TavolletjelentoGridModel()
{
ID = item.TavolletJelentoId.ToString(),
TipusId = item.TavolletTipusId,
StatuszId = item.TavolletStatuszId.ToString(),
Torolt_BOOL = item.IsTorolt,
IsTorolheto = helper.IsTorolheto(item, isIntezmenyvezeto),
AlkalmazottNev = item.AlkalmazottNev,
SzTSzAzonosito = item.AlkalmazottSzTSz,
AlkalmazottGuid = item.AlkalmazottGuid.ToString(),
RogzitoGuid = item.RogzitoGuid.ToString(),
IdoszakKezdet = item.TavolletKezdete,
IdoszakVeg = item.TavolletVege,
HasMelleklet_BOOL = item.IsMellekletTartozikHozza,
HasMelleklet_BNAME = item.IsMellekletTartozikHozza ? CommonResource.Igen : CommonResource.Nem,
RogzitesDatuma = item.RogzitesIdopontja,
MunkanapSzam = item.TavolletIdotartamaNap,
StatuszId_DNAME = item.TavolletStatuszId.GetDisplayName<TavolletStatuszEnum>(ClaimData.SelectedTanevID.Value),
TipusId_DNAME = item.TavolletTipusId.GetDisplayName<TavolletTipusEnum>(ClaimData.SelectedTanevID.Value),
HatralevoNapokSzama = item.HatralevoNapokSzama ?? default
});
}
if (LResult.Count > 0)
{
var result = new DataSourceResult
{
Data = LResult.ToDataSourceResult(request).Data,
Total = LResult.Count
};
return result;
}
}
return new DataSourceResult();
}
public DataSourceResult GetTavolletjelentoDokGrid(int tavolletId)
{
var helper = new HRModulHelper(ConnectionTypeExtensions.GetSessionConnectionType());
var result = helper.TavolletjelentoDokList(tavolletId);
return result.ToDataSourceResult();
}
public DataSourceResult GetAlkalmazottakAdatai(string data, [ModelBinder(typeof(ModelBinder.DataSourceRequestModelBinder))] DataSourceRequest request)
{
var model = JsonConvert.DeserializeObject<TavolletjelentoSearchModel>(data);
List<TavolletAlkalmazottGridModel> LResult = new List<TavolletAlkalmazottGridModel>();
var tanev = new TanevHelper(ConnectionTypeExtensions.GetSessionConnectionType());
var tanevCo = tanev.GetTanevInfo();
var kozpontiKreta = (KozpontiKretaConfiguration)ConfigurationManager.GetSection("KozpontiKretaConfig");
var client = new TavolletClient(kozpontiKreta.KgrUrl, kozpontiKreta.ApiKey);
var kozpontiResult = client.GetTavolletAlkalmazottakAdatai(model.ConvertToTavolletAdatokRequestModel(tanevCo.Sorszam));
if (!kozpontiResult?.IsSuccess ?? true)
{
return new DataSourceResult
{
Errors = "error"
};
}
if (kozpontiResult.TavolletAdatokResultList != null)
{
foreach (var item in kozpontiResult.TavolletAdatokResultList)
{
LResult.Add(new TavolletAlkalmazottGridModel()
{
ID = item.AlkalmazottId.ToString(),
AlkalmazottNev = item.AlkalmazottNev,
SzTSzAzonosito = item.SzTSzAzonosito,
IsFointezmenyeE_BNAME = item.IsTavolletFoIntezmenye ? CommonResource.Igen : CommonResource.Nem,
SzabadsagKeret = item.EvesKeret,
IgenybeVehetoTavolletek = item.FelhasznalhatoKeret,
IgenybeVettTavolletek = item.FelhasznaltKeret,
FuggobenLevoTavolletek = item.FuggoTavolletIgenyek,
});
}
if (LResult.Count > 0)
{
var result = new DataSourceResult
{
Data = LResult.ToDataSourceResult(request).Data,
Total = LResult.Count
};
return result;
}
}
return new DataSourceResult();
}
[HttpPost]
[ApiValidateAjaxAntiForgeryToken]
public int GetTavolletIdotartam(TavolletjelentoDateModel model)
{
if (model.TavolletKezdet.HasValue && model.TavolletVeg.HasValue)
{
var helper = new HRModulHelper(ConnectionTypeExtensions.GetSessionConnectionType());
return helper.GetTavolletIdotartam(model.TavolletKezdet.Value.ToLocalTime(), model.TavolletVeg.Value.ToLocalTime());
}
return 0;
}
[HttpPost]
[ApiValidateAjaxAntiForgeryToken]
public HttpResponseMessage SaveTavollet(TavolletjelentoModel model)
{
TavolletjelentoLogic tavolletJelentoLogic = new TavolletjelentoLogic();
tavolletJelentoLogic.CustomValidation(ModelState, model);
if (ModelState.IsValid)
{
var helper = new HRModulHelper(ConnectionTypeExtensions.GetSessionConnectionType());
model = tavolletJelentoLogic.UpdateModelAuthorizationData(model);
var co = tavolletJelentoLogic.ConvertModelToCo(model);
var saveModel = tavolletJelentoLogic.SaveOrUpdateTavollet(model, co);
if (model.Muvelet == WorkflowMuveletEnum.UjRogzites && saveModel.AlkalmazottList != null && saveModel.AlkalmazottList.Any(i => string.IsNullOrWhiteSpace(i.RogzitoFunkcioTerulet)))
{
ModelState.AddModelError("NincsFTError", string.Format(HRModulResource.FunkcioTeruletHianyzik,
string.Join(", ", saveModel.AlkalmazottList.Where(i => string.IsNullOrWhiteSpace(i.RogzitoFunkcioTerulet)).Select(d => d.AlkalmazottNev))));
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
}
var kozpontiKreta = (KozpontiKretaConfiguration)ConfigurationManager.GetSection("KozpontiKretaConfig");
var client = new TavolletClient(kozpontiKreta.KgrUrl, kozpontiKreta.ApiKey);
var kozpontiResult = client.SaveOrUpdateTavollet(saveModel);
if (kozpontiResult.IsSuccess)
{
if (model.FilesArray != null && model.FilesArray.Count > 0)
{
var entitys = new List<int>();
foreach (var item in kozpontiResult.AlkalmazottResultList)
{
entitys.Add(item.TavolletJelentoId);
}
helper.InsertDokumentum(IktatoRepositoryFactory, IktatoServiceConfiguration, fileServiceHelper, co, entitys);
}
tavolletJelentoLogic.SendEmail(co, model.EredetiRogzitoGuid);
return new HttpResponseMessage(HttpStatusCode.OK);
}
else
{
ModelState.AddModelStateErrorsFromString(kozpontiResult.ErrorMessage);
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
}
}
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
}
[HttpPost]
[ApiValidateAjaxAntiForgeryToken]
public HttpResponseMessage SaveTobbesTavollet(TavolletjelentoTobbesModel tobbesModel)
{
TavolletjelentoLogic tavolletJelentoLogic = new TavolletjelentoLogic();
tavolletJelentoLogic.CustomValidation(ModelState, tobbesModel);
if (ModelState.IsValid)
{
var tavolletjelentoModel = new TavolletjelentoModel()
{
Muvelet = WorkflowMuveletEnum.CsakModositas,
StatuszId = (int)TavolletStatuszEnum.Fuggo,
MegjegyzesMezo = tobbesModel.MegjegyzesMezo,
AlkalmazottList = tobbesModel.TavolletAlkalmazottIdArray,
TavolletIdotartamNap = tobbesModel.TavolletIdotartamNap,
TavolletOka = tobbesModel.TavolletOka,
TavolletKezdet = tobbesModel.TavolletKezdet,
TavolletVeg = tobbesModel.TavolletVeg
};
var co = tavolletJelentoLogic.ConvertModelToCo(tavolletjelentoModel);
var kozpontiKreta = (KozpontiKretaConfiguration)ConfigurationManager.GetSection("KozpontiKretaConfig");
var client = new TavolletClient(kozpontiKreta.KgrUrl, kozpontiKreta.ApiKey);
var felhasznaloHelper = new FelhasznaloHelper(ConnectionTypeExtensions.GetSessionConnectionType());
var saveModel = tavolletJelentoLogic.SaveOrUpdateTavollet(tavolletjelentoModel, co);
//var saveModel = new TavolletjelentoCRUDRequestModel();
//saveModel.Action = WorkflowMuveletek.Modosit;
//saveModel.TavolletTipusId = tobbesModel.TavolletOka.Value;
//saveModel.TavolletStatuszId = (int)TavolletStatuszEnum.Fuggo;
//saveModel.TavolletKezdete = tobbesModel.TavolletKezdet.Value.ToLocalTime();
//saveModel.TavolletVege = tobbesModel.TavolletVeg.Value.ToLocalTime();
//saveModel.TavolletIdotartamaNap = tobbesModel.TavolletIdotartamNap ?? default;
//saveModel.Megjegyzes = tobbesModel.Megjegyzes;
//saveModel.RogzitoNev = ClaimData.FelhasznaloNev;
//saveModel.RogzitoGuid = Guid.Parse(felhasznaloHelper.GetFelhasznaloEgyediAzonosito(ClaimData.FelhasznaloId));
//saveModel.RogzitoIntezmenyAzonosito = ClaimData.IntezmenyAzonosito;
//saveModel.TanevId
foreach (var tavollet in tobbesModel.TavolletekDictionary)
{
saveModel.AlkalmazottList.Add(new TavolletAlkalmazottData
{
TavolletJelentoId = tavollet.Key,
AlkalmazottSzTSz = tavollet.Value.AlkalmazottSzTSz,
RogzitoFunkcioTerulet = tavollet.Value.RogzitoFunkcioTerulet,
});
}
var kozpontiResult = client.SaveOrUpdateTavollet(saveModel);
if (kozpontiResult.IsSuccess)
{
co.StatuszId = (int)TavolletStatuszEnum.Fuggo;
tavolletJelentoLogic.SendEmail(co);
return new HttpResponseMessage(HttpStatusCode.OK);
}
else
{
ModelState.AddModelStateErrorsFromString(kozpontiResult.ErrorMessage);
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
}
}
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
}
[HttpPost]
[ApiValidateAjaxAntiForgeryToken]
public void SaveTavolletElfogadas([FromBody] List<TavolletjelentoElfogadasModel> ids)
{
var felhasznaloHelper = new FelhasznaloHelper(ConnectionTypeExtensions.GetSessionConnectionType());
var kozpontiKreta = (KozpontiKretaConfiguration)ConfigurationManager.GetSection("KozpontiKretaConfig");
var client = new TavolletClient(kozpontiKreta.KgrUrl, kozpontiKreta.ApiKey);
var saveModels = new List<IntezmenyiTavolletIgenyElfogadasRequestModel>();
var rogzitoGuid = Guid.Parse(felhasznaloHelper.GetFelhasznaloEgyediAzonosito(ClaimData.FelhasznaloId));
foreach (var item in ids)
{
var saveModel = new IntezmenyiTavolletIgenyElfogadasRequestModel
{
Action = WorkflowMuveletek.Jovahagy,
TavolletTipusId = (int)item.TipusId,
TavolletStatuszId = (int)HRModulHelper.GetElfogadasStatuszByTipus(item.TipusId),
RogzitoNev = ClaimData.FelhasznaloNev,
RogzitoGuid = rogzitoGuid,
TavolletJelentoId = item.ID
};
saveModels.Add(saveModel);
}
var kozpontiResult = client.JovahagyTavolletek(saveModels);
if (!kozpontiResult.IsSuccess)
{
throw new StatusError(HttpStatusCode.BadRequest, kozpontiResult.ErrorMessage);
}
foreach (var item in kozpontiResult.Data)
{
new TavolletjelentoLogic().SendEmail(item,
(int)HRModulHelper.GetElfogadasStatuszByTipus(ids.Where(x => x.ID == item.TavolletJelentoId).First().TipusId)
);
}
}
[HttpPost]
[ApiValidateAjaxAntiForgeryToken]
public void SaveTavolletElutasitas([FromBody] List<TavolletjelentoElutasitasModel> ids)
{
var felhasznaloHelper = new FelhasznaloHelper(ConnectionTypeExtensions.GetSessionConnectionType());
var saveModels = new TavolletjelentoCRUDRequestModel
{
Action = WorkflowMuveletek.Elutasit,
TavolletStatuszId = (int)TavolletStatuszEnum.Elutasitva,
RogzitoNev = ClaimData.FelhasznaloNev,
RogzitoGuid = Guid.Parse(felhasznaloHelper.GetFelhasznaloEgyediAzonosito(ClaimData.FelhasznaloId)),
};
foreach (var item in ids)
{
saveModels.AlkalmazottList.Add(new TavolletAlkalmazottData
{
TavolletJelentoId = item.ID
});
}
var kozpontiKreta = (KozpontiKretaConfiguration)ConfigurationManager.GetSection("KozpontiKretaConfig");
var client = new TavolletClient(kozpontiKreta.KgrUrl, kozpontiKreta.ApiKey);
var kozpontiResult = client.SaveOrUpdateTavollet(saveModels);
if (!kozpontiResult.IsSuccess)
{
throw new StatusError(HttpStatusCode.BadRequest, kozpontiResult.ErrorMessage);
}
foreach (var alkalmazott in kozpontiResult.AlkalmazottResultList)
{
new TavolletjelentoLogic().SendEmail(alkalmazott, (int)TavolletStatuszEnum.Elutasitva, ids.Single(x => x.ID == alkalmazott.TavolletJelentoId).RogzitoGuid);
}
}
[HttpPost]
[ApiValidateAjaxAntiForgeryToken]
public void DeleteTavollet(TavolletjelentoDeleteModel model)
{
var tavolletDeleteModel = new TavolletjelentoLogic().DeleteTavollet(model);
var kozpontiKreta = (KozpontiKretaConfiguration)ConfigurationManager.GetSection("KozpontiKretaConfig");
var client = new TavolletClient(kozpontiKreta.KgrUrl, kozpontiKreta.ApiKey);
client.DeleteTavollet(tavolletDeleteModel);
}
}
}