563 lines
27 KiB
C#
563 lines
27 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Kreta.BusinessLogic.Classes;
|
|
using Kreta.BusinessLogic.HelperClasses;
|
|
using Kreta.BusinessLogic.Interfaces;
|
|
using Kreta.BusinessLogic.Logic;
|
|
using Kreta.Client.CoreApi;
|
|
using Kreta.Client.CoreApi.Request;
|
|
using Kreta.Client.CoreApi.Response;
|
|
using Kreta.Core;
|
|
using Kreta.Core.ConnectionType;
|
|
using Kreta.Core.Enum;
|
|
using Kreta.Core.Exceptions;
|
|
using Kreta.Core.Validation.Exceptions;
|
|
using Kreta.Core.Validation.Exceptions.Enum;
|
|
using Kreta.DataAccess.Interfaces;
|
|
using Kreta.DataAccessManual;
|
|
using Kreta.DataAccessManual.Interfaces;
|
|
using Kreta.DataAccessManual.Util;
|
|
using Kreta.Enums;
|
|
using Kreta.Enums.ManualEnums;
|
|
using Kreta.Framework.Entities;
|
|
using Kreta.Resources;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Kreta.BusinessLogic.Helpers
|
|
{
|
|
public class DktFeladatHelper : LogicBase
|
|
{
|
|
#region Constructors
|
|
|
|
public DktFeladatHelper(IConnectionType connectionType) : base(connectionType) { }
|
|
|
|
#endregion Constructors
|
|
|
|
#region CoreApi hívások
|
|
|
|
/// INFO @DevKornel: Mobil használja
|
|
public int SaveOrUpdateTanarHaziFeladat(TanarHaziFeladatCO tanarHaziFeladatCo, int? ooTanarId, IFileServiceHelper fileServiceHelper, ICoreApiClient coreApiClient)
|
|
{
|
|
return Dal.CustomConnection.Run(ConnectionType, h =>
|
|
{
|
|
var hazifeladatId = 0;
|
|
|
|
IIntezmeny intezmeny = h.IntezmenyDal().Get(tanarHaziFeladatCo.IntezmenyId);
|
|
ITanev tanev = h.TanevDal().Get(tanarHaziFeladatCo.TanevId);
|
|
|
|
var dktFileHelper = new DktFileHelper(new DalHandlerConnectionType(ConnectionType, h), fileServiceHelper);
|
|
|
|
if (!tanarHaziFeladatCo.Id.IsEntityId())
|
|
{
|
|
bool isOsztaly = h.OsztalyCsoport().GetIsOsztaly(tanarHaziFeladatCo.OsztalyCsoportId.Value);
|
|
bool isNapirend = !tanarHaziFeladatCo.Oraszam.HasValue;
|
|
var insertModel = new DKTFeladatInsertRequest
|
|
{
|
|
IntezmenyGuid = intezmeny.Guid.ToString(),
|
|
TanevSorszam = tanev.Sorszam.Value,
|
|
AlkalmazottId = ooTanarId.Value,
|
|
TantargyId = tanarHaziFeladatCo.TantargyId.Value,
|
|
OsztalyId = isOsztaly ? tanarHaziFeladatCo.OsztalyCsoportId : null,
|
|
CsoportId = !isOsztaly ? tanarHaziFeladatCo.OsztalyCsoportId : null,
|
|
OraDatum = tanarHaziFeladatCo.FeladasDatuma,
|
|
Oraszam = !isNapirend ? tanarHaziFeladatCo.Oraszam : null,
|
|
BeadasHatarido = tanarHaziFeladatCo.Hatarido,
|
|
Szoveg = tanarHaziFeladatCo.Szoveg
|
|
};
|
|
|
|
if (isNapirend && tanarHaziFeladatCo.Idopont.HasValue)
|
|
{
|
|
insertModel.OraIdopont = tanarHaziFeladatCo.FeladasDatuma.AddHours(tanarHaziFeladatCo.Idopont.Value.Hour).AddMinutes(tanarHaziFeladatCo.Idopont.Value.Minute);
|
|
}
|
|
|
|
DKTFeladatInsertResponse result = coreApiClient.DKTFeladatInsert(insertModel, tanarHaziFeladatCo.RogzitoId);
|
|
|
|
CheckResponse(result);
|
|
|
|
if (tanarHaziFeladatCo.CsatolmanyId.IsEntityId())
|
|
{
|
|
h.DKT_FileDAL().ConnectToHaziFeladat(IntezmenyId, TanevId, result.NewHazifeladatId, tanarHaziFeladatCo.CsatolmanyId.Value);
|
|
}
|
|
hazifeladatId = result.NewHazifeladatId;
|
|
}
|
|
else
|
|
{
|
|
hazifeladatId = tanarHaziFeladatCo.Id.Value;
|
|
var updateModel = new DKTFeladatUpdateRequest
|
|
{
|
|
IntezmenyGuid = intezmeny.Guid.ToString(),
|
|
TanevSorszam = tanev.Sorszam.Value,
|
|
AlkalmazottId = ooTanarId.Value,
|
|
Id = tanarHaziFeladatCo.Id.Value,
|
|
BeadasHatarido = tanarHaziFeladatCo.Hatarido,
|
|
Szoveg = tanarHaziFeladatCo.Szoveg
|
|
};
|
|
|
|
DKTFeladatResponse result = coreApiClient.DKTFeladatUpdate(updateModel, tanarHaziFeladatCo.RogzitoId);
|
|
|
|
CheckResponse(result);
|
|
|
|
if (tanarHaziFeladatCo.CsatolmanyId.IsEntityId())
|
|
{
|
|
h.DKT_FileDAL().ConnectToHaziFeladat(IntezmenyId, TanevId, tanarHaziFeladatCo.Id.Value, tanarHaziFeladatCo.CsatolmanyId.Value);
|
|
}
|
|
}
|
|
|
|
return hazifeladatId;
|
|
});
|
|
}
|
|
|
|
private void CheckResponse(DKTFeladatResponse response)
|
|
{
|
|
if (response.Status == 404)
|
|
{
|
|
throw new ValidationException(ValidationErrorType.ResourceNotFound, response.Exception?.Message ?? ErrorResource.AzElemNemTalalhato);
|
|
}
|
|
if (response.Exception != null && !string.IsNullOrWhiteSpace(response.Exception.Message))
|
|
{
|
|
throw new ValidationException(ValidationErrorType.Undefined, response.Exception.Message);
|
|
}
|
|
|
|
if (response.ValidationResult != null && response.ValidationResult.Tiltasok.Count > 0)
|
|
{
|
|
string message = string.Join(@"<\br>", response.ValidationResult.Tiltasok);
|
|
throw new ValidationException(ValidationErrorType.Undefined, message, response.ValidationResult.Tiltasok.Select((x, index) => new ValidationExceptionItem(x.Id ?? index.ToString(), x.Uzenet)));
|
|
}
|
|
|
|
if (response.Errors?.Any() ?? false)
|
|
{
|
|
throw new ValidationException(ValidationErrorType.Undefined, ErrorResource.HibaTortentAMuveletSoran, response.Errors.Select(l => new ValidationExceptionItem(l.Key, string.Join(" , ", l.Value))));
|
|
}
|
|
|
|
}
|
|
|
|
/// INFO @DevKornel: Mobil használja
|
|
public void DeleteHazi(int id, ICoreApiClient coreApiClient)
|
|
{
|
|
try
|
|
{
|
|
IDKT_Feladat dktFeladat = null;
|
|
IIntezmeny intezmeny = null;
|
|
ITanev tanev = null;
|
|
Dal.CustomConnection.Run(ConnectionType, dalHandler =>
|
|
{
|
|
dktFeladat = dalHandler.DKT_FeladatDal().Get(id);
|
|
intezmeny = dalHandler.IntezmenyDal().Get(dktFeladat.IntezmenyId);
|
|
tanev = dalHandler.TanevDal().Get(dktFeladat.TanevId);
|
|
});
|
|
|
|
var deleteModel = new DKTFeladatDeleteRequest
|
|
{
|
|
IntezmenyGuid = intezmeny.Guid.ToString(),
|
|
TanevSorszam = tanev.Sorszam.Value,
|
|
AlkalmazottId = dktFeladat.RogzitoAlkalmazottId,
|
|
Id = id
|
|
};
|
|
|
|
DKTFeladatResponse result = coreApiClient.DKTFeladatDelete(deleteModel);
|
|
|
|
CheckResponse(result);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new ValidationException(ValidationErrorType.Undefined, e.Message);
|
|
}
|
|
}
|
|
|
|
#endregion CoreApi hívások
|
|
|
|
#region CoreApi hívásnak kellene lennie! Egy elem, a hf id-ja alapján!
|
|
|
|
/// INFO: Mobil használja
|
|
public TanarHaziFeladatDetailCO GetTanarHaziFeladatDetail(int id, bool isTanariFelulet = false)
|
|
{
|
|
try
|
|
{
|
|
TanarHaziFeladatDetailCO result = Dal.CustomConnection.Run(ConnectionType, dalHandler =>
|
|
{
|
|
IDKT_Feladat tanarHaziFeladat = dalHandler.DKT_FeladatDal().Get(id);
|
|
if (tanarHaziFeladat != null && !tanarHaziFeladat.Torolt)
|
|
{
|
|
if (!IsFelhasznaloJogosultHaziFeladat(FelhasznaloId, tanarHaziFeladat, dalHandler, isTanariFelulet))
|
|
{
|
|
throw new BlException(BlExceptionType.NincsJogosultsag);
|
|
}
|
|
|
|
var csatolmanyok = new DktFileHelper(new DalHandlerConnectionType(ConnectionType, dalHandler)).GetCsatolmanyokForHaziFeladat(tanarHaziFeladat.ID);
|
|
var tanarHaziFeladatDetailCo = new TanarHaziFeladatDetailCO(tanarHaziFeladat, csatolmanyok);
|
|
|
|
return tanarHaziFeladatDetailCo;
|
|
}
|
|
|
|
throw new BlException(BlExceptionType.NemLetezoEntitas);
|
|
});
|
|
|
|
return result;
|
|
}
|
|
catch (EntityNotFoundException)
|
|
{
|
|
throw new BlException(BlExceptionType.NemLetezoEntitas);
|
|
}
|
|
}
|
|
|
|
/// INFO: Mobil használja
|
|
private bool IsFelhasznaloJogosultHaziFeladat(int felhasznaloId, IDKT_Feladat tanarHaziFeladatEntity, IDalHandler dalHandler, bool isTanariFelulet)
|
|
{
|
|
bool isTanulo = tanarHaziFeladatEntity.OsztalyCsoport.Tanulo.Select(x => x.TanuloId).Contains(felhasznaloId);
|
|
|
|
bool isOrarendiOratTartoVagyHelyettesito = false;
|
|
if (tanarHaziFeladatEntity.OrarendiOraGroupId.IsEntityId())
|
|
{
|
|
IOrarendiOra orarendiOra = dalHandler.OrarendiOra().Get(tanarHaziFeladatEntity.OrarendiOraGroupId.Value);
|
|
isOrarendiOratTartoVagyHelyettesito =
|
|
tanarHaziFeladatEntity.OrarendiOraGroupId != null &&
|
|
(orarendiOra.TanarId == felhasznaloId || orarendiOra.HelyettesTanarok.Select(x => x.HelyettesTanarokId).Contains(felhasznaloId));
|
|
}
|
|
|
|
bool isTanitasiOratTartoVagyHelyettesito = false;
|
|
if (tanarHaziFeladatEntity.TanitasiOraId.IsEntityId())
|
|
{
|
|
ITanitasiOra tanitasiOra = dalHandler.TanitasiOra().Get(tanarHaziFeladatEntity.TanitasiOraId.Value);
|
|
isTanitasiOratTartoVagyHelyettesito =
|
|
tanarHaziFeladatEntity.TanitasiOraId != null &&
|
|
(tanitasiOra.TanarId == felhasznaloId || tanitasiOra.HelyettesitoTanarId == felhasznaloId);
|
|
}
|
|
|
|
bool isHaziFeladatHelyettesito = tanarHaziFeladatEntity.HelyettesitoAlkalmazottId == felhasznaloId;
|
|
|
|
var result = isTanulo || isOrarendiOratTartoVagyHelyettesito || isTanitasiOratTartoVagyHelyettesito || isHaziFeladatHelyettesito || tanarHaziFeladatEntity.AlkalmazottId == felhasznaloId || tanarHaziFeladatEntity.RogzitoAlkalmazottId == felhasznaloId || isTanariFelulet;
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion CoreApi hívásnak kellene lennie! Egy elem, a hf id-ja alapján!
|
|
|
|
#region CoreApi hívásnak kellene lennie! Egy elem, az adott órarendi óra/tanítási órához tartozó tanár által feladott házifeladat kell!
|
|
|
|
public HaziFeladatokTabCO GetHaziFeladatTabCo(int eventId, CalendarOraTypeEnum oraType, DateTime date, bool isTanuloOrGondviselo, int feladatTipusId = (int)FeladatTipusEnum.HaziFeladat)
|
|
{
|
|
var haziFeladatokTabCo = new HaziFeladatokTabCO();
|
|
HaziFeladatokTabCO result = Dal.CustomConnection.Run(ConnectionType, dalHandler =>
|
|
{
|
|
ITanitasiOra tanora = null;
|
|
IOrarendiOra orarendiOra = null;
|
|
|
|
switch (oraType)
|
|
{
|
|
case CalendarOraTypeEnum.TanitasiOra:
|
|
tanora = dalHandler.TanitasiOra().Get(eventId);
|
|
break;
|
|
case CalendarOraTypeEnum.OrarendiOra:
|
|
orarendiOra = dalHandler.OrarendiOra().Get(eventId);
|
|
break;
|
|
}
|
|
|
|
haziFeladatokTabCo.OraType = oraType;
|
|
haziFeladatokTabCo.OraDate = date;
|
|
|
|
if (tanora != null)
|
|
{
|
|
haziFeladatokTabCo.OraId = tanora.ID;
|
|
DataSet dataSet = dalHandler.DKT_FeladatDal().GetHaziFeladatForTanitasiOra(tanora.ID, null, feladatTipusId);
|
|
haziFeladatokTabCo.TanarHaziFeladat = GetTanarHaziFeladatDetailCo(dalHandler, dataSet, isTanuloOrGondviselo);
|
|
if (haziFeladatokTabCo.TanarHaziFeladat.Id.IsEntityId())
|
|
{
|
|
if (!haziFeladatokTabCo.TanarHaziFeladat.IsTanarRogzitette)
|
|
{
|
|
haziFeladatokTabCo.TanarHaziFeladat.Szoveg = OrarendResource.EhhezAzOrahozATanarMegNemRogzitettHaziFeladatotAzOnlineFeluleten;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
haziFeladatokTabCo.TanarHaziFeladat.Rogzito = tanora.Tanar.NyomtatasiNev;
|
|
haziFeladatokTabCo.TanarHaziFeladat.FeladasDatuma = tanora.Datum;
|
|
haziFeladatokTabCo.TanarHaziFeladat.Szoveg = OrarendResource.EhhezAzOrahozATanarMegNemRogzitettHaziFeladatotAzOnlineFeluleten;
|
|
}
|
|
}
|
|
else if (orarendiOra != null)
|
|
{
|
|
haziFeladatokTabCo.OraId = orarendiOra.ID;
|
|
|
|
DataSet dataSet = dalHandler.DKT_FeladatDal().GetHaziFeladatForOrarendiOra(haziFeladatokTabCo.OraId.Value, date, null, null, feladatTipusId);
|
|
TanarHaziFeladatDetailCO tanarHazi = GetTanarHaziFeladatDetailCo(dalHandler, dataSet, isTanuloOrGondviselo);
|
|
if (tanarHazi?.Id != null && tanarHazi.Id > 0)
|
|
{
|
|
haziFeladatokTabCo.TanarHaziFeladat = tanarHazi;
|
|
|
|
if (!haziFeladatokTabCo.TanarHaziFeladat.IsTanarRogzitette)
|
|
{
|
|
haziFeladatokTabCo.TanarHaziFeladat.Szoveg = OrarendResource.EhhezAzOrahozATanarMegNemRogzitettHaziFeladatotAzOnlineFeluleten;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
haziFeladatokTabCo.TanarHaziFeladat.Rogzito = orarendiOra.Tanar.NyomtatasiNev;
|
|
haziFeladatokTabCo.TanarHaziFeladat.FeladasDatuma = date;
|
|
haziFeladatokTabCo.TanarHaziFeladat.Szoveg = OrarendResource.EhhezAzOrahozATanarMegNemRogzitettHaziFeladatotAzOnlineFeluleten;
|
|
|
|
}
|
|
}
|
|
|
|
return haziFeladatokTabCo;
|
|
});
|
|
|
|
return result;
|
|
}
|
|
|
|
public TanarHaziFeladatDetailCO GetTanitasiOraHaziFeladatDetail(int? oraId, OktNevelesiKategoriaEnum? kategoria, bool isTanuloOrGondviselo)
|
|
{
|
|
if (!oraId.IsEntityId())
|
|
{
|
|
return new TanarHaziFeladatDetailCO();
|
|
}
|
|
|
|
TanarHaziFeladatDetailCO result = Dal.CustomConnection.Run(ConnectionType, dalHandler =>
|
|
{
|
|
DataSet dataSet = dalHandler.DKT_FeladatDal().GetHaziFeladatForTanitasiOra(oraId.Value, kategoria);
|
|
TanarHaziFeladatDetailCO tanarHaziFeladatDetailCo = GetTanarHaziFeladatDetailCo(dalHandler, dataSet, isTanuloOrGondviselo);
|
|
return tanarHaziFeladatDetailCo;
|
|
});
|
|
|
|
return result;
|
|
}
|
|
|
|
public TanarHaziFeladatDetailCO GetOrarendiOraHaziFeladatDetail(int? orarendiOraId, DateTime? date, bool isTanuloOrGondviselo, int? oraszam = null, OktNevelesiKategoriaEnum? kategoria = null)
|
|
{
|
|
if (!orarendiOraId.IsEntityId())
|
|
{
|
|
return new TanarHaziFeladatDetailCO();
|
|
}
|
|
|
|
TanarHaziFeladatDetailCO result = Dal.CustomConnection.Run(ConnectionType, dalHandler =>
|
|
{
|
|
DataSet dataSet = dalHandler.DKT_FeladatDal().GetHaziFeladatForOrarendiOra(orarendiOraId.Value, date, oraszam, kategoria);
|
|
TanarHaziFeladatDetailCO tanarHaziFeladatDetailCo = GetTanarHaziFeladatDetailCo(dalHandler, dataSet, isTanuloOrGondviselo);
|
|
return tanarHaziFeladatDetailCo;
|
|
});
|
|
|
|
return result;
|
|
}
|
|
|
|
private TanarHaziFeladatDetailCO GetTanarHaziFeladatDetailCo(IDalHandler dalHandler, DataSet dataSet, bool isTanuloOrGondviselo)
|
|
{
|
|
var tanarHaziFeladatDetailCo = new TanarHaziFeladatDetailCO();
|
|
if (dataSet?.Tables[0]?.Rows.Count > 0)
|
|
{
|
|
DataRow dataRow = dataSet.Tables[0].Rows[0];
|
|
|
|
DateTime? lathatosagIdopont = SDAConvert.ToDateTime(dataRow["LathatosagIdopont"]);
|
|
if (IsDktFeladatLathato(isTanuloOrGondviselo, lathatosagIdopont))
|
|
{
|
|
tanarHaziFeladatDetailCo.Id = SDAConvert.ToInt32(dataRow["ID"]);
|
|
tanarHaziFeladatDetailCo.FeladasDatuma = SDAConvert.ToDateTime(dataRow["FeladasDatuma"]).Value;
|
|
tanarHaziFeladatDetailCo.Hatarido = SDAConvert.ToDateTime(dataRow["Hatarido"]);
|
|
tanarHaziFeladatDetailCo.IsTanarRogzitette = SDAConvert.ToBoolean(dataRow["IsTanarRogzitette_BOOL"]);
|
|
tanarHaziFeladatDetailCo.Oraszam = SDAConvert.ToNullableInt32(dataRow["Oraszam"]);
|
|
tanarHaziFeladatDetailCo.OsztalyCsoport = SDAConvert.ToString(dataRow["OsztCsop"]);
|
|
tanarHaziFeladatDetailCo.OsztalyCsoportId = SDAConvert.ToInt32(dataRow["OsztalyCsoportId"]);
|
|
tanarHaziFeladatDetailCo.Rogzito = SDAConvert.ToString(dataRow["HelyettesitoTanarNev"], SDAConvert.ToString(dataRow["Rogzito"]));
|
|
tanarHaziFeladatDetailCo.RogzitoId = SDAConvert.ToInt32(dataRow["RogzitoId"]);
|
|
tanarHaziFeladatDetailCo.Szoveg = SDAConvert.ToString(dataRow["Szoveg"]);
|
|
tanarHaziFeladatDetailCo.TanitasiOraId = SDAConvert.ToNullableInt32(dataRow["TanoraId"]);
|
|
tanarHaziFeladatDetailCo.Tantargy = SDAConvert.ToString(dataRow["Tantargy"]);
|
|
tanarHaziFeladatDetailCo.RogzitesIdopontja = SDAConvert.ToDateTime(dataRow["HaziFeladatTenylegesRogzitesDatuma"]).Value;
|
|
tanarHaziFeladatDetailCo.FeladatTipusId = SDAConvert.ToInt32(dataRow["FeladatTipusId"]);
|
|
tanarHaziFeladatDetailCo.IsLathato = SDAConvert.ToBoolean(dataRow["IsLathato_BOOL"]);
|
|
}
|
|
}
|
|
|
|
if (tanarHaziFeladatDetailCo.Id.IsEntityId())
|
|
{
|
|
var csatolmanyok = new DktFileHelper(new DalHandlerConnectionType(ConnectionType, dalHandler)).GetCsatolmanyokForHaziFeladat(tanarHaziFeladatDetailCo.Id.Value);
|
|
foreach ((int csatolmanyId, string fajlNev) in csatolmanyok)
|
|
{
|
|
tanarHaziFeladatDetailCo.Csatolmanyok.Add(csatolmanyId, fajlNev);
|
|
}
|
|
}
|
|
|
|
return tanarHaziFeladatDetailCo;
|
|
}
|
|
|
|
#endregion CoreApi hívásnak kellene lennie! Egy elem, az adott órarendi óra/tanítási órához tartozó tanár által feladott házifeladat kell!
|
|
|
|
#region CoreApi hívásnak kellene lennie! Lista, szűrési paraméterekkel!
|
|
|
|
/// INFO: Mobil használja
|
|
public DataSet GetTanuloHaziFeladat(TanuloHaziFeladatSearchCO haziFeladatKereso, OktNevelesiKategoriaEnum? feladatKategoria, bool isFromMobil, bool isTanuloOrGondviselo)
|
|
{
|
|
DataSet dataSet = Dal.CustomConnection.Run(ConnectionType, dalHandler =>
|
|
dalHandler.DKT_FeladatDal(GridParameters).GetTanuloHaziFeladat(IntezmenyId, TanevId, FelhasznaloId, feladatKategoria, haziFeladatKereso.ConvertCoToPco()));
|
|
|
|
//NOTE: Azért haladunk visszafelé, hogy tudjuk az esetleges nem szükséges sorokat törölni!
|
|
for (int index = dataSet.Tables[0].Rows.Count - 1; index >= 0; index--)
|
|
{
|
|
DataRow dataRow = dataSet.Tables[0].Rows[index];
|
|
DateTime? lathatosagIdopont = SDAConvert.ToDateTime(dataRow["LathatosagIdopont"]);
|
|
if (IsDktFeladatLathato(isTanuloOrGondviselo, lathatosagIdopont))
|
|
{
|
|
string haziFeladatSzovege = isFromMobil ? SDAConvert.ToString(dataRow["HaziFeladatSzoveg"]) : RichTextLogic.CutHtmlTagsAndDecode(SDAConvert.ToString(dataRow["HaziFeladatSzoveg"]));
|
|
|
|
if (!isFromMobil)
|
|
{
|
|
string helyettesitoTanarNev = SDAConvert.ToString(dataRow["HelyettesitoNev"]);
|
|
if (!string.IsNullOrWhiteSpace(helyettesitoTanarNev))
|
|
{
|
|
dataRow["TanarNeve"] = helyettesitoTanarNev;
|
|
}
|
|
|
|
string[] splittedSzoveg = haziFeladatSzovege.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
|
var stringBuilder = new StringBuilder();
|
|
foreach (string szovegResz in splittedSzoveg)
|
|
{
|
|
if (stringBuilder.Length + szovegResz.Length + 1 > 100)
|
|
{
|
|
stringBuilder.Append("...");
|
|
break;
|
|
}
|
|
|
|
if (stringBuilder.Length > 0)
|
|
{
|
|
stringBuilder.Append(" ");
|
|
}
|
|
|
|
stringBuilder.Append(szovegResz);
|
|
}
|
|
|
|
string rovidHazifeladatSzoveg = stringBuilder.ToString();
|
|
dataRow["HaziFeladatSzoveg"] = rovidHazifeladatSzoveg;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
dataSet.Tables[0].Rows.Remove(dataRow);
|
|
}
|
|
}
|
|
|
|
return dataSet;
|
|
}
|
|
|
|
/// INFO @DevKornel: Mobil használja
|
|
public List<IDKT_Feladat> GetFeladatokByDateRange(DateTime start, DateTime end, bool isTanuloOrGondviselo, FeladatTipusEnum? feladatTipus = null)
|
|
{
|
|
List<IDKT_Feladat> result = Dal.CustomConnection.Run(ConnectionType, dalHandler =>
|
|
{
|
|
IDKT_FeladatDal dal = dalHandler.DKT_FeladatDal(GridParameters);
|
|
|
|
DataSet dataSet = dal.GetFeladatokByDateRange(IntezmenyId, TanevId, start, end, (int?)feladatTipus);
|
|
|
|
var feladatList = new List<IDKT_Feladat>();
|
|
if (dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0)
|
|
{
|
|
foreach (DataRow dataRow in dataSet.Tables[0].Rows)
|
|
{
|
|
DateTime? lathatosagIdopont = SDAConvert.ToDateTime(dataRow["LathatosagIdopont"]);
|
|
if (IsDktFeladatLathato(isTanuloOrGondviselo, lathatosagIdopont))
|
|
{
|
|
IDKT_Feladat feladat = dal.Get();
|
|
feladat.ID = SDAConvert.ToInt32(dataRow["ID"]);
|
|
feladat.Datum = SDAConvert.ToDateTime(dataRow["Datum"], DateTime.MinValue).Value;
|
|
feladat.OrarendiOraGroupId = SDAConvert.ToInt32(dataRow["OrarendiOraGroupId"]);
|
|
feladat.TanitasiOraId = SDAConvert.ToInt32(dataRow["TanitasiOraId"]);
|
|
feladat.BeadasHatarido = SDAConvert.ToDateTime(dataRow["BeadasHatarido"], DateTime.MinValue).Value;
|
|
feladat.AlkalmazottId = SDAConvert.ToInt32(dataRow["Tanar"]);
|
|
feladat.TantargyId = SDAConvert.ToInt32(dataRow["Tantargy"]);
|
|
feladat.OsztalyCsoportId = SDAConvert.ToInt32(dataRow["OsztalyCsoport"]);
|
|
feladat.Oraszam = SDAConvert.ToNullableInt32(dataRow["Oraszam"]);
|
|
feladat.FeladatTipusId = SDAConvert.ToInt32(dataRow["FeladatTipusId"]);
|
|
feladat.GroupId = SDAConvert.ToNullableGuid(dataRow["GroupId"]);
|
|
if (!feladat.Oraszam.HasValue)
|
|
feladat.Idopont = SDAConvert.ToDateTime(dataRow["Idopont"]);
|
|
feladatList.Add(feladat);
|
|
}
|
|
}
|
|
}
|
|
|
|
return feladatList;
|
|
});
|
|
|
|
return result;
|
|
}
|
|
|
|
public bool HasOrarendiOraKapcsolodoHazifeladatot(int? orarendiOraGroupId, DateTime oraErvenyessegKezdete, DateTime oraErvenyessegVege, bool idoszakonKivul = true)
|
|
{
|
|
if (!orarendiOraGroupId.IsEntityId())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool result = Dal.CustomConnection.Run(ConnectionType, dalHandler =>
|
|
dalHandler.DKT_FeladatDal().HasOrarendiOraKapcsolodoHazifeladatot(TanevId, orarendiOraGroupId.Value, oraErvenyessegKezdete, oraErvenyessegVege, idoszakonKivul));
|
|
return result;
|
|
}
|
|
|
|
#endregion CoreApi hívásnak kellene lennie! Lista, szűrési paraméterekkel!
|
|
|
|
private static bool IsDktFeladatLathato(bool isTanuloOrGondviselo, DateTime? lathatosagIdopont)
|
|
{
|
|
bool result = false;
|
|
|
|
//NOTE: Ha a felhasználó felhasználó tanuló vagy gondviselő, csak abban az esetben jelenhet meg a Dkt feladat, ha
|
|
// - van beállítva láthatóság időpont és
|
|
// - a láthatóság időpontnak dátuma kisebb vagy egyenlő, mint a mai nap dátuma.
|
|
if (isTanuloOrGondviselo)
|
|
{
|
|
if (lathatosagIdopont.HasValue && lathatosagIdopont.Value.Date <= DateTime.Today)
|
|
{
|
|
result = true;
|
|
}
|
|
}
|
|
//NOTE: Ha a felhasználó nem tanuló és nem gondviselő, minden esetben jelenjen meg a Dkt feladat.
|
|
else
|
|
{
|
|
result = true;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public void UpdateDktFeladatTanitasiOra(int tanitasiOraId)
|
|
{
|
|
Dal.CustomConnection.Run(ConnectionType, h =>
|
|
{
|
|
var tanarHaziFeladatDetailCO = GetTanitasiOraHaziFeladatDetail(tanitasiOraId, null, false);
|
|
|
|
if (tanarHaziFeladatDetailCO.Id.IsEntityId())
|
|
{
|
|
var dktFeladatDal = h.DKT_FeladatDal();
|
|
|
|
var hazifeladat = dktFeladatDal.Get(tanarHaziFeladatDetailCO.Id.Value);
|
|
|
|
if (!hazifeladat.TanitasiOraId.IsEntityId())
|
|
{
|
|
hazifeladat.TanitasiOraId = tanitasiOraId;
|
|
|
|
dktFeladatDal.Update(hazifeladat);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
public void DeleteDktFeladatTanitasiOra(int tanitasiOraId)
|
|
{
|
|
Dal.CustomConnection.Run(ConnectionType, h =>
|
|
{
|
|
var tanarHaziFeladatDetailCO = GetTanitasiOraHaziFeladatDetail(tanitasiOraId, null, false);
|
|
|
|
if (tanarHaziFeladatDetailCO.Id.IsEntityId())
|
|
{
|
|
var dktFeladatDal = h.DKT_FeladatDal();
|
|
|
|
var hazifeladat = dktFeladatDal.Get(tanarHaziFeladatDetailCO.Id.Value);
|
|
|
|
hazifeladat.TanitasiOraId = null;
|
|
|
|
dktFeladatDal.Update(hazifeladat);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|