init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
474
KretaWeb/Areas/Tanar/Controllers/TanarDashboardController.cs
Normal file
474
KretaWeb/Areas/Tanar/Controllers/TanarDashboardController.cs
Normal file
|
@ -0,0 +1,474 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Kreta.BusinessLogic.Classes;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.BusinessLogic.Security;
|
||||
using Kreta.Client.Eugyintezes;
|
||||
using Kreta.Client.Eugyintezes.Configuration;
|
||||
using Kreta.Core;
|
||||
using Kreta.Core.FeatureToggle;
|
||||
using Kreta.Enums.ManualEnums;
|
||||
using Kreta.Framework;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.Tanar.Models;
|
||||
using Kreta.Web.Configuration;
|
||||
using Kreta.Web.Helpers;
|
||||
using Kreta.Web.Security;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Kreta.Web.Areas.Tanar.Controllers
|
||||
{
|
||||
[MvcRoleClaimsAuthorize(true)]
|
||||
[MvcRolePackageDenyAuthorize(KretaClaimPackages.IsOnlyAlkalmozott.ClaimValue)]
|
||||
[MvcRolePackageAuthorize(KretaClaimPackages.Naplo.ClaimValue)]
|
||||
public class TanarDashboardController : Controller
|
||||
{
|
||||
private IEugyintezesClientConfiguration EugyintezesClientConfiguration { get; }
|
||||
|
||||
private IIdpConfiguration IdpConfiguration { get; }
|
||||
|
||||
private IFeatureContext FeatureContext { get; }
|
||||
|
||||
private const int ElemekAListaban = 8;
|
||||
|
||||
public TanarDashboardController(IEugyintezesClientConfiguration eugyintezesClientConfiguration, IIdpConfiguration idpConfiguration, IFeatureContext featureContext)
|
||||
{
|
||||
EugyintezesClientConfiguration = eugyintezesClientConfiguration ?? throw new ArgumentNullException(nameof(eugyintezesClientConfiguration));
|
||||
IdpConfiguration = idpConfiguration ?? throw new ArgumentNullException(nameof(idpConfiguration));
|
||||
FeatureContext = featureContext ?? throw new ArgumentNullException(nameof(idpConfiguration));
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
string shortMainVersion = KretaVersion.Instance.ShortMainVersion;
|
||||
string nextUpdateDateTimeText = new AdminHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetKovTelepitesDatum().ToString("yyyy.MM.dd. HH:mm");
|
||||
|
||||
ViewBag.ShortMainVersion = shortMainVersion;
|
||||
ViewBag.NextUpdateDateTimeText = nextUpdateDateTimeText;
|
||||
|
||||
var model = GetTanarDashboard();
|
||||
|
||||
return View("Index", model);
|
||||
}
|
||||
|
||||
public ActionResult DownloadCovidFertozott()
|
||||
{
|
||||
MemoryStream stream = new AdminHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetCovidFertozottekExcel(ClaimData.FelhasznaloId);
|
||||
var result = new FileStreamResult(stream, Core.Constants.ContentTypes.Xlsx) { FileDownloadName = string.Format(RendszerErtesitesResource.CovidFertozottekExcelName, DateTime.Now.ToString("yyyyMMddHHmm")) };
|
||||
return result;
|
||||
}
|
||||
|
||||
private TanarDashboardModel GetTanarDashboard()
|
||||
{
|
||||
var model = new TanarDashboardModel();
|
||||
|
||||
DataSet beNemIrtOrakDS = null;
|
||||
DataSet kiirtHelyettesitesekDS = null;
|
||||
DataSet mulasztasokDS = null;
|
||||
DataSet bukasraAlloTanulokDS = null;
|
||||
DataSet dashBoardUzenetekDS = null;
|
||||
|
||||
string uzenetek = null;
|
||||
string ugyek = null;
|
||||
|
||||
bool vanCovidFertozott = false;
|
||||
|
||||
var isSzuperOsztalyFonok = AuthorizeHelper.CheckPackageAccess(new string[] { KretaClaimPackages.SzuperOsztalyfonok.ClaimValue });
|
||||
|
||||
var isTanarTTFfelVagySzuperOsztalyFonok = isSzuperOsztalyFonok || AuthorizeHelper.CheckPackageAccess(new string[] { KretaClaimPackages.Tanar.ClaimValue });
|
||||
ViewData["IsTanarTTFfelVagySzuperOsztalyFonok"] = isTanarTTFfelVagySzuperOsztalyFonok;
|
||||
|
||||
var osztalyFonokVagyCsoportVezeto = new[]
|
||||
{
|
||||
KretaClaimPackages.SzuperOsztalyfonok.ClaimValue,
|
||||
KretaClaimPackages.Osztalyfonok.ClaimValue,
|
||||
KretaClaimPackages.CsoportVezeto.ClaimValue,
|
||||
KretaClaimPackages.Evfolyamfelelos.ClaimValue,
|
||||
};
|
||||
|
||||
var isOsztalyFonokVagyCsoportVezeto = AuthorizeHelper.CheckPackageAccess(osztalyFonokVagyCsoportVezeto);
|
||||
ViewData["IsOsztalyFonokVagyCsoportVezeto"] = isOsztalyFonokVagyCsoportVezeto;
|
||||
|
||||
if (isTanarTTFfelVagySzuperOsztalyFonok)
|
||||
{
|
||||
var helper = new TanarHelper(ConnectionTypeExtensions.GetSessionConnectionType());
|
||||
beNemIrtOrakDS = helper.GetUtolsoBeNemIrtOrak(ClaimData.IntezmenyId, ClaimData.FelhasznaloId, ElemekAListaban);
|
||||
kiirtHelyettesitesekDS = helper.GetKiirtHelyettesitesek(ClaimData.IntezmenyId, ClaimData.FelhasznaloId, ElemekAListaban);
|
||||
dashBoardUzenetekDS = helper.GetTanarDashboardUzenet(ClaimData.FelhasznaloId);
|
||||
vanCovidFertozott = helper.GetCovidFertozottek(ClaimData.FelhasznaloId).Tables[0].Rows.Count > 0;
|
||||
|
||||
if (isOsztalyFonokVagyCsoportVezeto)
|
||||
{
|
||||
mulasztasokDS = helper.GetMulasztasokSzama(ClaimData.FelhasznaloId, isSzuperOsztalyFonok, ElemekAListaban);
|
||||
bukasraAlloTanulokDS = helper.GetBukasokSzama(ClaimData.FelhasznaloId, ElemekAListaban);
|
||||
}
|
||||
|
||||
EugyintezesClient eUgyClient = new EugyintezesClient(EugyintezesClientConfiguration);
|
||||
|
||||
var icHelper = new IntezmenyConfigHelper(ConnectionTypeExtensions.GetSystemConnectionType());
|
||||
|
||||
var uzenetModulFeatureEnabled = icHelper.GetIntezmenyConfig<bool>(IntezmenyConfigModulEnum.UzenetModul, IntezmenyConfigTipusEnum.IsEnabled);
|
||||
|
||||
var uzenetekEnabled = uzenetModulFeatureEnabled; //&& ClaimData.IsAktivUzenetekMenu;
|
||||
|
||||
ViewData["UzenetekEnabled"] = uzenetekEnabled;
|
||||
|
||||
if (uzenetekEnabled)
|
||||
{
|
||||
uzenetek = ExceptionLogger(() => eUgyClient.GetUzenetek(ClaimData.IntezmenyAzonosito, ClaimData.FelhasznaloIdpEgyediAzonosito, ElemekAListaban));
|
||||
}
|
||||
|
||||
var eugyintezesFeatureEnabled = icHelper.GetIntezmenyConfig<bool>(IntezmenyConfigModulEnum.Eugyintezes, IntezmenyConfigTipusEnum.IsEnabled);
|
||||
|
||||
var ugyekEnabled = eugyintezesFeatureEnabled && isOsztalyFonokVagyCsoportVezeto;
|
||||
|
||||
ViewData["UgyekEnabled"] = ugyekEnabled;
|
||||
|
||||
if (ugyekEnabled)
|
||||
{
|
||||
ugyek = ExceptionLogger(() => eUgyClient.GetUgyek(ClaimData.IntezmenyAzonosito, ClaimData.FelhasznaloIdpEgyediAzonosito, ElemekAListaban));
|
||||
}
|
||||
}
|
||||
|
||||
model.BeNemIrtOrak = ConvertBeNemIrtOrak(beNemIrtOrakDS);
|
||||
model.KiirtHelyettesitesek = ConvertKiirtHelyettesitesek(kiirtHelyettesitesekDS);
|
||||
model.Uzenetek = ConvertUzenetek(uzenetek);
|
||||
model.Ugyek = ConvertUgyek(ugyek);
|
||||
model.Mulasztasok = ConvertMulasztasok(mulasztasokDS);
|
||||
model.BukasraAlloTanulok = ConvertBukasraAlloTanulok(bukasraAlloTanulokDS);
|
||||
model.DashBoardUzenetek = ConvertDashBoardUzenetek(dashBoardUzenetekDS);
|
||||
model.VanCovidFertozott = vanCovidFertozott;
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
private TanarDashboardTableModel ConvertUzenetek(string uzenetek)
|
||||
{
|
||||
var helper = new IntezmenyConfigHelper(ConnectionTypeExtensions.GetSystemConnectionType());
|
||||
var result = new TanarDashboardTableModel
|
||||
{
|
||||
Url = GetEugyUrl(helper.GetIntezmenyConfig<string>(IntezmenyConfigModulEnum.UzenetModul, IntezmenyConfigTipusEnum.Url)),
|
||||
OpenInNewWindow = true,
|
||||
Name = TanarDashBoardResource.Uzenetek,
|
||||
Headers = new List<string>
|
||||
{
|
||||
TanarDashBoardResource.Datum,
|
||||
TanarDashBoardResource.Felado,
|
||||
TanarDashBoardResource.Targy,
|
||||
},
|
||||
Rows = new List<TanarDashboardTableRowModel>()
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(uzenetek))
|
||||
{
|
||||
var uzenetList = TryDeserialize<List<Uzenet>>(uzenetek) ?? new List<Uzenet>();
|
||||
|
||||
var rows = new List<TanarDashboardTableRowModel>();
|
||||
|
||||
foreach (var uzenet in uzenetList)
|
||||
{
|
||||
var row = new TanarDashboardTableRowModel
|
||||
{
|
||||
Columns = new List<string>
|
||||
{
|
||||
SDAFormat.GetShortDateFormat(uzenet.BeerkezesIdopontja),
|
||||
uzenet.FeladoNev,
|
||||
uzenet.Targy,
|
||||
}
|
||||
};
|
||||
|
||||
rows.Add(row);
|
||||
}
|
||||
|
||||
result.Rows = rows;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private TanarDashboardTableModel ConvertUgyek(string ugyek)
|
||||
{
|
||||
var helper = new IntezmenyConfigHelper(ConnectionTypeExtensions.GetSystemConnectionType());
|
||||
var result = new TanarDashboardTableModel
|
||||
{
|
||||
Url = GetEugyUrl(helper.GetIntezmenyConfig<string>(IntezmenyConfigModulEnum.Eugyintezes, IntezmenyConfigTipusEnum.Url)),
|
||||
OpenInNewWindow = true,
|
||||
Name = TanarDashBoardResource.EUgyintezes,
|
||||
Headers = new List<string>
|
||||
{
|
||||
TanarDashBoardResource.Nev,
|
||||
TanarDashBoardResource.Osztaly,
|
||||
TanarDashBoardResource.Ugytipus,
|
||||
TanarDashBoardResource.BekuldesIdopontja,
|
||||
},
|
||||
Rows = new List<TanarDashboardTableRowModel>()
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(ugyek))
|
||||
{
|
||||
var ugyList = TryDeserialize<List<Ugy>>(ugyek) ?? new List<Ugy>();
|
||||
|
||||
var rows = new List<TanarDashboardTableRowModel>();
|
||||
|
||||
foreach (var ugy in ugyList)
|
||||
{
|
||||
var row = new TanarDashboardTableRowModel
|
||||
{
|
||||
Columns = new List<string>
|
||||
{
|
||||
ugy.TanuloNev,
|
||||
ugy.TanuloOsztaly,
|
||||
ugy.UgyTipusKod,
|
||||
SDAFormat.GetShortDateFormat(ugy.BekuldesIdopontja),
|
||||
}
|
||||
};
|
||||
|
||||
rows.Add(row);
|
||||
}
|
||||
|
||||
result.Rows = rows;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private TanarDashboardTableModel ConvertBeNemIrtOrak(DataSet ds)
|
||||
{
|
||||
var result = new TanarDashboardTableModel
|
||||
{
|
||||
Url = GetUrl(Constants.Areas.Tanar, Constants.Controllers.NemNaplozottTanorak, "Index"),
|
||||
Name = TanarDashBoardResource.BeNemIrtOrak,
|
||||
Headers = new List<string>
|
||||
{
|
||||
TanarDashBoardResource.Datum,
|
||||
TanarDashBoardResource.Oraszam,
|
||||
TanarDashBoardResource.Osztalycsoport,
|
||||
TanarDashBoardResource.Tantargy,
|
||||
},
|
||||
Rows = new List<TanarDashboardTableRowModel>()
|
||||
};
|
||||
|
||||
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
var rows = new List<TanarDashboardTableRowModel>();
|
||||
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var row = new TanarDashboardTableRowModel
|
||||
{
|
||||
Columns = new List<string>
|
||||
{
|
||||
SDAFormat.GetShortDateFormat(dr["Datum"]),
|
||||
SDAConvert.ToString(dr["Oraszam"]),
|
||||
SDAConvert.ToString(dr["OsztalyCsoport"]),
|
||||
SDAConvert.ToString(dr["Tantargy"])
|
||||
}
|
||||
};
|
||||
|
||||
rows.Add(row);
|
||||
}
|
||||
|
||||
result.Rows = rows;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private TanarDashboardTableModel ConvertKiirtHelyettesitesek(DataSet ds)
|
||||
{
|
||||
var result = new TanarDashboardTableModel
|
||||
{
|
||||
Url = GetUrl(Constants.Areas.Tanar, Constants.Controllers.NemNaplozottTanorak, "Index", new Dictionary<string, object>
|
||||
{
|
||||
{ "csakAHelyettesiteseim", true },
|
||||
{ "helyettesitettOraimIs", false },
|
||||
{ "jovobeniOrakMegjelenitese", true },
|
||||
}),
|
||||
Name = TanarDashBoardResource.KiirtHelyettesitesek,
|
||||
Headers = new List<string>
|
||||
{
|
||||
TanarDashBoardResource.Datum,
|
||||
TanarDashBoardResource.Oraszam,
|
||||
TanarDashBoardResource.Osztalycsoport,
|
||||
TanarDashBoardResource.Tantargy,
|
||||
},
|
||||
Rows = new List<TanarDashboardTableRowModel>()
|
||||
};
|
||||
|
||||
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
var rows = new List<TanarDashboardTableRowModel>();
|
||||
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var row = new TanarDashboardTableRowModel
|
||||
{
|
||||
Columns = new List<string>
|
||||
{
|
||||
SDAFormat.GetShortDateFormat(dr["Datum"]),
|
||||
SDAConvert.ToString(dr["Oraszam"]),
|
||||
SDAConvert.ToString(dr["OsztalyCsoport"]),
|
||||
SDAConvert.ToString(dr["Tantargy"])
|
||||
}
|
||||
};
|
||||
|
||||
rows.Add(row);
|
||||
}
|
||||
|
||||
result.Rows = rows;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private TanarDashboardTableModel ConvertMulasztasok(DataSet ds)
|
||||
{
|
||||
var result = new TanarDashboardTableModel
|
||||
{
|
||||
Url = GetUrl(Constants.Areas.Hianyzas, Constants.Controllers.Mulasztasok, "Index"),
|
||||
Name = TanarDashBoardResource.Mulasztasok,
|
||||
Headers = new List<string>
|
||||
{
|
||||
TanarDashBoardResource.MulasztasDatuma,
|
||||
TanarDashBoardResource.MulasztasNapja,
|
||||
TanarDashBoardResource.MulasztasokSzama,
|
||||
},
|
||||
Rows = new List<TanarDashboardTableRowModel>()
|
||||
};
|
||||
|
||||
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
var rows = new List<TanarDashboardTableRowModel>();
|
||||
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var row = new TanarDashboardTableRowModel
|
||||
{
|
||||
Columns = new List<string>
|
||||
{
|
||||
SDAFormat.GetShortDateFormat(dr["MulasztasDatuma"]),
|
||||
SDAConvert.ToString(dr["MulasztasNapja"]),
|
||||
SDAConvert.ToString(dr["MulasztasokSzama"])
|
||||
}
|
||||
};
|
||||
|
||||
rows.Add(row);
|
||||
}
|
||||
|
||||
result.Rows = rows;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private TanarDashboardTableModel ConvertBukasraAlloTanulok(DataSet ds)
|
||||
{
|
||||
var result = new TanarDashboardTableModel
|
||||
{
|
||||
Url = GetUrl(Constants.Areas.Tanulo, Constants.Controllers.TanarTanitottTanulok, "Index", new Dictionary<string, object>
|
||||
{
|
||||
{ "csakBukasraAllok", true },
|
||||
}),
|
||||
Name = TanarDashBoardResource.BukasraAlloTanulok,
|
||||
Headers = new List<string>
|
||||
{
|
||||
TanarDashBoardResource.Nev,
|
||||
TanarDashBoardResource.Osztaly,
|
||||
TanarDashBoardResource.TantargyakSzama,
|
||||
},
|
||||
Rows = new List<TanarDashboardTableRowModel>()
|
||||
};
|
||||
|
||||
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
var rows = new List<TanarDashboardTableRowModel>();
|
||||
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var row = new TanarDashboardTableRowModel
|
||||
{
|
||||
Columns = new List<string>
|
||||
{
|
||||
SDAConvert.ToString(dr["Nev"]),
|
||||
SDAConvert.ToString(dr["Osztaly"]),
|
||||
SDAConvert.ToString(dr["TantargyakSzama"])
|
||||
}
|
||||
};
|
||||
|
||||
rows.Add(row);
|
||||
}
|
||||
|
||||
result.Rows = rows;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<TanarDashboardItemModel> ConvertDashBoardUzenetek(DataSet ds)
|
||||
{
|
||||
var result = new List<TanarDashboardItemModel>();
|
||||
|
||||
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow row in ds.Tables[0].Rows)
|
||||
{
|
||||
var item = new TanarDashboardItemModel
|
||||
{
|
||||
Name = SDAConvert.ToString(row["C_CIM"]),
|
||||
Content = SDAConvert.ToString(row["C_TARTALOM"]),
|
||||
Type = (AdminDashboardTipusEnum)SDAConvert.ToInt32(row["C_DASHBOARDUZENETKATEGORIAID"]),
|
||||
Sorrend = SDAConvert.ToInt32(row["SORREND"]),
|
||||
EgyediAzonosito = SDAConvert.ToString(row["C_EGYEDIAZONOSITO"])
|
||||
};
|
||||
|
||||
result.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
return result.OrderBy(o => o.Sorrend).ToList();
|
||||
}
|
||||
|
||||
private string GetUrl(string area, string controller, string action, Dictionary<string, object> parameters = null)
|
||||
{
|
||||
var dictionary = new Dictionary<string, object> { { "Area", area } };
|
||||
|
||||
if (parameters != null)
|
||||
{
|
||||
dictionary = dictionary.Concat(parameters).ToDictionary(x => x.Key, x => x.Value);
|
||||
}
|
||||
|
||||
var routeValues = new RouteValueDictionary(dictionary);
|
||||
|
||||
return UrlHelper.GenerateUrl(null, action, controller, routeValues, RouteTable.Routes, HttpContext.Request.RequestContext, false);
|
||||
}
|
||||
|
||||
private string GetEugyUrl(string url)
|
||||
{
|
||||
return Kreta.Web.Classes.Utils.GetAuthenticationTokenRedirectUrl(url, IdpConfiguration.AuthenticationTokenKey);
|
||||
}
|
||||
|
||||
private T ExceptionLogger<T>(Func<T> action)
|
||||
{
|
||||
try
|
||||
{
|
||||
return action();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SDAServer.Instance.Logger.ExceptionThrown(ex);
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
private T TryDeserialize<T>(string json)
|
||||
{
|
||||
return ExceptionLogger(() => JsonConvert.DeserializeObject<T>(json));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue