init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
77
KretaWeb/Controllers/Logic/CommonExportLogic.cs
Normal file
77
KretaWeb/Controllers/Logic/CommonExportLogic.cs
Normal file
|
@ -0,0 +1,77 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Web.Mvc;
|
||||
using Kreta.BusinessLogic.Helpers;
|
||||
using Kreta.Resources;
|
||||
using Kreta.Web.Areas.Hianyzas.Models;
|
||||
using Kreta.Web.Areas.OsztalyCsoport.Models;
|
||||
using Kreta.Web.Helpers;
|
||||
|
||||
namespace Kreta.Web.Controllers.Logic
|
||||
{
|
||||
/// <summary>
|
||||
/// Exportokhoz használható közös, gyűjtő logic osztály.
|
||||
/// </summary>
|
||||
public static class CommonExportLogic
|
||||
{
|
||||
public static ActionResult ExportInformaciokIgazolas(InformaciokIgazolasSearchModel model)
|
||||
{
|
||||
var stream = new IgazolasHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType()).GetInformaciokIgazolasExcelExport(model.ConvertToCo());
|
||||
return new FileStreamResult(stream, Core.Constants.ContentTypes.Xlsx) { FileDownloadName = $"{HianyzasResource.IgazolasokListajaExportFileName}_{DateTime.Now:yyyy_MM_dd}.{Constants.ImportExport.FileFormatXlsx}" };
|
||||
}
|
||||
|
||||
public static ActionResult ExportBesorolasokOsztalyok(BaseBesorolasSearchModel model, bool isKiirt)
|
||||
{
|
||||
var helper = new TanuloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
var stream = helper.GetBesorolasOsztalyokExport(model.ConvertToCo(), isKiirt);
|
||||
string fileName;
|
||||
switch (model.OktNevFelKategoriaId)
|
||||
{
|
||||
case Enums.OktNevelesiKategoriaEnum.AlapfokuMuveszetoktatas:
|
||||
fileName = isKiirt ? BesorolasResource.AMIOsztalybolKiirtakExportFileName : BesorolasResource.AMIOsztalybaBesoroltakExportFileName;
|
||||
break;
|
||||
case Enums.OktNevelesiKategoriaEnum.EGYMI:
|
||||
fileName = isKiirt ? BesorolasResource.EGYMIOsztalybolKiirtakExportFileName : BesorolasResource.EGYMIOsztalybaBesoroltakExportFileName;
|
||||
break;
|
||||
case Enums.OktNevelesiKategoriaEnum.Felnottkepzes:
|
||||
fileName = isKiirt ? BesorolasResource.FelnottkepzesOsztalybolKiirtakExportFileName : BesorolasResource.FelnottkepzesOsztalybaBesoroltakExportFileName;
|
||||
break;
|
||||
case Enums.OktNevelesiKategoriaEnum.Kollegium:
|
||||
fileName = isKiirt ? BesorolasResource.KollegiumOsztalybolKiirtakExportFileName : BesorolasResource.KollegiumOsztalybaBesoroltakExportFileName;
|
||||
break;
|
||||
default:
|
||||
fileName = isKiirt ? BesorolasResource.OsztalybolKiirtakExportFileName : BesorolasResource.OsztalybaBesoroltakExportFileName;
|
||||
break;
|
||||
}
|
||||
|
||||
return new FileStreamResult(stream, Core.Constants.ContentTypes.Xlsx) { FileDownloadName = fileName };
|
||||
}
|
||||
|
||||
public static ActionResult ExportBesorolasokCsoportok(BaseBesorolasSearchModel model, bool isKiirt)
|
||||
{
|
||||
var helper = new TanuloHelper(ConnectionTypeExtensions.GetActiveSessionConnectionType());
|
||||
var stream = helper.GetBesorolasCsoportokExport(model.ConvertToCo(), isKiirt);
|
||||
string fileName;
|
||||
switch (model.OktNevFelKategoriaId)
|
||||
{
|
||||
case Enums.OktNevelesiKategoriaEnum.AlapfokuMuveszetoktatas:
|
||||
fileName = isKiirt ? BesorolasResource.AMICsoportbolKiirtakExportFileName : BesorolasResource.AMICsoportbaBesoroltakExportFileName;
|
||||
break;
|
||||
case Enums.OktNevelesiKategoriaEnum.EGYMI:
|
||||
fileName = isKiirt ? BesorolasResource.EGYMICsoportbolKiirtakExportFileName : BesorolasResource.EGYMICsoportbaBesoroltakExportFileName;
|
||||
break;
|
||||
case Enums.OktNevelesiKategoriaEnum.Felnottkepzes:
|
||||
fileName = isKiirt ? BesorolasResource.FelnottkepzesCsoportbolKiirtakExportFileName : BesorolasResource.FelnottkepzesCsoportbaBesoroltakExportFileName;
|
||||
break;
|
||||
case Enums.OktNevelesiKategoriaEnum.Kollegium:
|
||||
fileName = isKiirt ? BesorolasResource.KollegiumCsoportbolKiirtakExportFileName : BesorolasResource.KollegiumCsoportbaBesoroltakExportFileName;
|
||||
break;
|
||||
default:
|
||||
fileName = isKiirt ? BesorolasResource.CsoportbolKiirtakExportFileName : BesorolasResource.CsoportbaBesoroltakExportFileName;
|
||||
break;
|
||||
}
|
||||
|
||||
return new FileStreamResult(stream, Core.Constants.ContentTypes.Xlsx) { FileDownloadName = fileName };
|
||||
}
|
||||
}
|
||||
}
|
38
KretaWeb/Controllers/Logic/MasterLayoutLogic.cs
Normal file
38
KretaWeb/Controllers/Logic/MasterLayoutLogic.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System.Web;
|
||||
using Kreta.Framework;
|
||||
using Kreta.Web.Classes;
|
||||
using Kreta.Web.Security;
|
||||
using Kreta.Web.Utils;
|
||||
|
||||
namespace Kreta.Web.Controllers.Logic
|
||||
{
|
||||
public static class MasterLayoutLogic
|
||||
{
|
||||
public static void LogOut()
|
||||
{
|
||||
if (HttpContext.Current == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ClaimData.IsAuthenticated)
|
||||
{
|
||||
string sessionId = ClaimData.SessionId;
|
||||
|
||||
if (SDAServer.Instance != null)
|
||||
{
|
||||
SDAServer.Instance.SessionManager.DeleteSession(sessionId);
|
||||
}
|
||||
|
||||
ProfileUtils.RemoveUserProfileImage(sessionId);
|
||||
ProfileUtils.RemoveUserProfileDocument(sessionId);
|
||||
SessionHandler.DropSession(sessionId);
|
||||
|
||||
using (var loginManager = new LoginManager())
|
||||
{
|
||||
loginManager.LogOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
75
KretaWeb/Controllers/Logic/SessionHandler.cs
Normal file
75
KretaWeb/Controllers/Logic/SessionHandler.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
using System.Runtime.Caching;
|
||||
using Kreta.Core;
|
||||
using Kreta.Framework;
|
||||
using Kreta.Web.Security;
|
||||
|
||||
namespace Kreta.Web.Controllers.Logic
|
||||
{
|
||||
public class SessionHandler
|
||||
{
|
||||
private static readonly CacheItemPolicy DefaultCacheItemPolicy = new CacheItemPolicy { SlidingExpiration = TimeSpan.FromMinutes(60) };
|
||||
|
||||
private static int sessionTimeOut = 0;
|
||||
|
||||
private static string GetCacheKey(string sessionId)
|
||||
{
|
||||
return $"{nameof(SessionHandler)}_{sessionId}";
|
||||
}
|
||||
|
||||
public static int SessionTimeOut
|
||||
{
|
||||
get
|
||||
{
|
||||
if (sessionTimeOut < 1)
|
||||
{
|
||||
sessionTimeOut = (SDAServer.Instance.Configuration.SessionTimeout - 1) * 60; // A kérés és válasz alatt a mi számlálónk elcsúszik pár másodperccel és a valódi session hamarabb járna le.
|
||||
if (sessionTimeOut < 45)
|
||||
{
|
||||
sessionTimeOut = 45;
|
||||
}
|
||||
}
|
||||
|
||||
return sessionTimeOut;
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateSessionTime()
|
||||
{
|
||||
string sessionId = ClaimData.SessionId;
|
||||
if (string.IsNullOrWhiteSpace(sessionId))
|
||||
{
|
||||
throw new Exception("Invalid Session key");
|
||||
}
|
||||
|
||||
Cache.Set(GetCacheKey(sessionId), DateTime.Now, DefaultCacheItemPolicy);
|
||||
}
|
||||
|
||||
public static int GetRemainingTime()
|
||||
{
|
||||
string sessionId = ClaimData.SessionId;
|
||||
if (string.IsNullOrWhiteSpace(sessionId))
|
||||
{
|
||||
throw new Exception("Invalid Session key");
|
||||
}
|
||||
|
||||
DateTime lastCallTime = Cache.AddOrGetExisting(GetCacheKey(sessionId), DateTime.Now, DefaultCacheItemPolicy);
|
||||
TimeSpan spendTime = DateTime.Now - lastCallTime;
|
||||
int remainingTime = SessionTimeOut - (spendTime.Minutes * 60 + spendTime.Seconds);
|
||||
|
||||
PingKretaServerSession(sessionId);
|
||||
|
||||
return remainingTime;
|
||||
}
|
||||
|
||||
public static void DropSession(string sessionId)
|
||||
{
|
||||
Cache.Remove(GetCacheKey(sessionId));
|
||||
}
|
||||
|
||||
private static void PingKretaServerSession(string sessionId)
|
||||
{
|
||||
SDAServer.Instance.SessionManager.PingSession(sessionId);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue