init
This commit is contained in:
20
Framework/Caching/Cache.cs
Normal file
20
Framework/Caching/Cache.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace Kreta.Framework.Caching
|
||||
{
|
||||
/// <summary>
|
||||
/// A gyorsítótárak ősosztálya.
|
||||
/// </summary>
|
||||
public abstract class Cache
|
||||
{
|
||||
public CacheManager CacheManager { get; }
|
||||
|
||||
protected Cache(CacheManager cachemanager)
|
||||
{
|
||||
CacheManager = cachemanager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kiüríti a gyorsítótárat.
|
||||
/// </summary>
|
||||
public abstract void Reset();
|
||||
}
|
||||
}
|
64
Framework/Caching/CacheManager.cs
Normal file
64
Framework/Caching/CacheManager.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Kreta.Framework.Caching
|
||||
{
|
||||
public class CacheManager
|
||||
{
|
||||
private Dictionary<Type, Cache> m_Caches = new Dictionary<Type, Cache>();
|
||||
private System.Threading.ReaderWriterLockSlim m_CacheManagerLock = new System.Threading.ReaderWriterLockSlim();
|
||||
|
||||
public CacheManager()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adott cache kérése a managertől
|
||||
/// </summary>
|
||||
/// <typeparam name="CacheType">Cache típusa</typeparam>
|
||||
/// <returns>Cache példány</returns>
|
||||
public CacheType AquireCache<CacheType>() where CacheType : Cache
|
||||
{
|
||||
m_CacheManagerLock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
if (!m_Caches.ContainsKey(typeof(CacheType)))
|
||||
{
|
||||
m_Caches.Add(typeof(CacheType), (Cache)Activator.CreateInstance(typeof(CacheType), new object[] { this }));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CacheManagerLock.ExitWriteLock();
|
||||
}
|
||||
return (CacheType)m_Caches[typeof(CacheType)];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adott cache kérése a managertől, mobilból
|
||||
/// </summary>
|
||||
/// <typeparam name="CacheType">Cache típusa</typeparam>
|
||||
/// <returns>Cache példány</returns>
|
||||
public CacheType AquireCacheMobile<CacheType>() where CacheType : Cache
|
||||
{
|
||||
m_CacheManagerLock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
if (!m_Caches.ContainsKey(typeof(CacheType)))
|
||||
{
|
||||
m_Caches.Add(typeof(CacheType), (Cache)Activator.CreateInstance(typeof(CacheType), new object[] { this }));
|
||||
}
|
||||
return (CacheType)m_Caches[typeof(CacheType)];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SDAServer.Instance.Logger.ExceptionThrown(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CacheManagerLock.ExitWriteLock();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
204
Framework/Caching/DictionaryItem.cs
Normal file
204
Framework/Caching/DictionaryItem.cs
Normal file
@@ -0,0 +1,204 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Kreta.Framework.Caching
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class DictionaryItem
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public DictionaryItem(
|
||||
int id,
|
||||
int? value,
|
||||
string name,
|
||||
string name1,
|
||||
string name2,
|
||||
string name3,
|
||||
string name4,
|
||||
bool isVisible,
|
||||
string code,
|
||||
string type,
|
||||
bool isProtected,
|
||||
string color,
|
||||
int? order,
|
||||
string bgColor,
|
||||
string description,
|
||||
bool isActive,
|
||||
string shortName,
|
||||
int dictionaryTypeId)
|
||||
{
|
||||
Validate(name, type);
|
||||
|
||||
Id = id;
|
||||
Value = value;
|
||||
Name = name;
|
||||
Name1 = name1;
|
||||
Name2 = name2;
|
||||
Name3 = name3;
|
||||
Name4 = name4;
|
||||
IsVisible = isVisible;
|
||||
Code = code;
|
||||
Type = type;
|
||||
IsProtected = isProtected;
|
||||
Color = color;
|
||||
Order = order;
|
||||
BgColor = bgColor;
|
||||
Description = description;
|
||||
IsActive = isActive;
|
||||
ShortName = shortName;
|
||||
DictionaryTypeId = dictionaryTypeId;
|
||||
}
|
||||
|
||||
public DictionaryItem(DictionaryItem dictionaryItem)
|
||||
{
|
||||
Validate(dictionaryItem.Name, dictionaryItem.Type);
|
||||
|
||||
Id = dictionaryItem.Id;
|
||||
Value = dictionaryItem.Value;
|
||||
Name = dictionaryItem.Name;
|
||||
Name1 = dictionaryItem.Name1;
|
||||
Name2 = dictionaryItem.Name2;
|
||||
Name3 = dictionaryItem.Name3;
|
||||
Name4 = dictionaryItem.Name4;
|
||||
IsVisible = dictionaryItem.IsVisible;
|
||||
Code = dictionaryItem.Code;
|
||||
Type = dictionaryItem.Type;
|
||||
IsProtected = dictionaryItem.IsProtected;
|
||||
Color = dictionaryItem.Color;
|
||||
Order = dictionaryItem.Order;
|
||||
BgColor = dictionaryItem.BgColor;
|
||||
Description = dictionaryItem.Description;
|
||||
IsActive = dictionaryItem.IsActive;
|
||||
ShortName = dictionaryItem.ShortName;
|
||||
DictionaryTypeId = dictionaryItem.DictionaryTypeId;
|
||||
}
|
||||
|
||||
#endregion Constructors
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel azonosítója
|
||||
/// </summary>
|
||||
public int Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel értéke
|
||||
/// </summary>
|
||||
public int? Value { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel neve
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel neve 1
|
||||
/// </summary>
|
||||
public string Name1 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel neve 2
|
||||
/// </summary>
|
||||
public string Name2 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel neve 3
|
||||
/// </summary>
|
||||
public string Name3 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel neve 4
|
||||
/// </summary>
|
||||
public string Name4 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel látható-e
|
||||
/// </summary>
|
||||
public bool IsVisible { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel kódja
|
||||
/// </summary>
|
||||
public string Code { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel típusa
|
||||
/// </summary>
|
||||
public string Type { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel védett-e
|
||||
/// </summary>
|
||||
public bool IsProtected { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel szín kódja
|
||||
/// </summary>
|
||||
public string Color { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel sorrendje
|
||||
/// </summary>
|
||||
public int? Order { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel háttérszín kódja
|
||||
/// </summary>
|
||||
public string BgColor { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel leírása
|
||||
/// </summary>
|
||||
public string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel aktív-e
|
||||
/// </summary>
|
||||
public bool IsActive { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel rövid neve
|
||||
/// </summary>
|
||||
public string ShortName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A kódtétel típusának azonosítója
|
||||
/// </summary>
|
||||
public int DictionaryTypeId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Egyedi szótártáblák kiegészítő tulajdonságai
|
||||
/// </summary>
|
||||
public Dictionary<string, object> ExtendedProperties { get; set; }
|
||||
|
||||
#endregion Properties
|
||||
|
||||
private static void Validate(string name, string type)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
if (name.Length == 0)
|
||||
{
|
||||
throw new ArgumentException(@"The string can not be empty.", nameof(name));
|
||||
}
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
}
|
||||
|
||||
if (type.Length == 0)
|
||||
{
|
||||
throw new ArgumentException(@"The string can not be empty.", nameof(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class AgazatReszSzakmaTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public AgazatReszSzakmaTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Az ágazat rész szakma típus oktatás nevelési feladat azonosítója
|
||||
/// </summary>
|
||||
public int? OktatasiNevelesiFeladatId => (int?)ExtendedProperties[nameof(OktatasiNevelesiFeladatId)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class AgazatUjSzktTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public AgazatUjSzktTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Az ágazat új SZKT típus ágazati besorolása
|
||||
/// </summary>
|
||||
public int? AgazatiBesorolas => (int?)ExtendedProperties[nameof(AgazatiBesorolas)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class AllampolgarsagDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public AllampolgarsagDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Az állampolgárság kód 2
|
||||
/// </summary>
|
||||
public string Kod2 => (string)ExtendedProperties[nameof(Kod2)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class CsoportTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public CsoportTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Művészeti-e a csoport típus?
|
||||
/// </summary>
|
||||
public bool IsMuveszeti => (bool)ExtendedProperties[nameof(IsMuveszeti)];
|
||||
|
||||
/// <summary>
|
||||
/// Tanórai célű-e a csoport típus?
|
||||
/// </summary>
|
||||
public bool IsTanoraiCelu => (bool)ExtendedProperties[nameof(IsTanoraiCelu)];
|
||||
|
||||
/// <summary>
|
||||
/// A csoport típus óra perce?
|
||||
/// </summary>
|
||||
public int? OraPerc => (int?)ExtendedProperties[nameof(OraPerc)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class DokumentumKulcsszoTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public DokumentumKulcsszoTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// A dokumentum kulcsszó típus poszeidon kulcsszó típusa
|
||||
/// </summary>
|
||||
public string PoszeidonKulcsszoTipus => (string)ExtendedProperties[nameof(PoszeidonKulcsszoTipus)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ErtekelesModDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public ErtekelesModDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Félkövér-e az értékelés mód?
|
||||
/// </summary>
|
||||
public bool IsBold => (bool)ExtendedProperties[nameof(IsBold)];
|
||||
|
||||
/// <summary>
|
||||
/// Az értékelés mód számonkérés korlátozott-e?
|
||||
/// </summary>
|
||||
public bool IsSzamonkeresKorlatozott => (bool)ExtendedProperties[nameof(IsSzamonkeresKorlatozott)];
|
||||
|
||||
/// <summary>
|
||||
/// Az értékelés mód súlyozása
|
||||
/// </summary>
|
||||
public int Suly => (int)ExtendedProperties[nameof(Suly)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ErtekelesTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public ErtekelesTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Egyszer adható-e az értékelés típus?
|
||||
/// </summary>
|
||||
public bool IsEgyszerAdhato => (bool)ExtendedProperties[nameof(IsEgyszerAdhato)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class EsemenyTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public EsemenyTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Ellenőrzőben megjelenik-e az esemény típus?
|
||||
/// </summary>
|
||||
public bool IsEllenorzobenMegjelenik => (bool)ExtendedProperties[nameof(IsEllenorzobenMegjelenik)];
|
||||
|
||||
/// <summary>
|
||||
/// Naplóban megjelenik-e az esemény típus?
|
||||
/// </summary>
|
||||
public bool IsNaplobanMegjelenik => (bool)ExtendedProperties[nameof(IsNaplobanMegjelenik)];
|
||||
|
||||
/// <summary>
|
||||
/// Törzslapon megjelenik-e az esemény típus?
|
||||
/// </summary>
|
||||
public bool IsTorzslaponMegjelenik => (bool)ExtendedProperties[nameof(IsTorzslaponMegjelenik)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class EvfolyamTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public EvfolyamTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Az évfolyam típus alap óraszáma
|
||||
/// </summary>
|
||||
public double AlapOraszam => (double)ExtendedProperties[nameof(AlapOraszam)];
|
||||
|
||||
/// <summary>
|
||||
/// Összevont-e az évfolyam típus?
|
||||
/// </summary>
|
||||
public bool IsOsszevont => (bool)ExtendedProperties[nameof(IsOsszevont)];
|
||||
|
||||
/// <summary>
|
||||
/// A következő évfolyam típus azonosítója
|
||||
/// </summary>
|
||||
public int? KovetkezoEvfolyamTipusId => (int?)ExtendedProperties[nameof(KovetkezoEvfolyamTipusId)];
|
||||
|
||||
/// <summary>
|
||||
/// Az évfolyam típus minimum óraszáma
|
||||
/// </summary>
|
||||
public double MinimumOraszam => (double)ExtendedProperties[nameof(MinimumOraszam)];
|
||||
|
||||
/// <summary>
|
||||
/// Az évfolyam típus viszonyítási létszáma
|
||||
/// </summary>
|
||||
public double ViszonyitasiLetszam => (double)ExtendedProperties[nameof(ViszonyitasiLetszam)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class MunkakorTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public MunkakorTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Az alkalmazott munkakör típusának azonosítója
|
||||
/// </summary>
|
||||
public int? AlkalmazottMunkaKorTipusId => (int?)ExtendedProperties[nameof(AlkalmazottMunkaKorTipusId)];
|
||||
|
||||
/// <summary>
|
||||
/// SZIR oktató-e?
|
||||
/// </summary>
|
||||
public bool IsSzirStatOktato => (bool)ExtendedProperties[nameof(IsSzirStatOktato)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class NapTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public NapTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Le nem kötött munkaidő-e a nap típus?
|
||||
/// </summary>
|
||||
public bool IsLeNemKotottMunkaido => (bool)ExtendedProperties[nameof(IsLeNemKotottMunkaido)];
|
||||
|
||||
/// <summary>
|
||||
/// Sorszámozandó-e a nap típus?
|
||||
/// </summary>
|
||||
public bool IsSorszamozando => (bool)ExtendedProperties[nameof(IsSorszamozando)];
|
||||
|
||||
/// <summary>
|
||||
/// Tanítási nap-e a nap típus?
|
||||
/// </summary>
|
||||
public bool IsTanitasiNap => (bool)ExtendedProperties[nameof(IsTanitasiNap)];
|
||||
|
||||
/// <summary>
|
||||
/// Tanórai-e a nap típus?
|
||||
/// </summary>
|
||||
public bool IsTanorai => (bool)ExtendedProperties[nameof(IsTanorai)];
|
||||
|
||||
/// <summary>
|
||||
/// Tanórán kívüli-e a nap típus?
|
||||
/// </summary>
|
||||
public bool IsTanoranKivuli => (bool)ExtendedProperties[nameof(IsTanoranKivuli)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class OktNevelesiKategoriaDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public OktNevelesiKategoriaDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Az oktatás nevelési kategória feladat csoport tanuló osztály kapcsolat max száma
|
||||
/// </summary>
|
||||
public int FeladatCsoportTanuloOsztalyKapcsolatMaxSzama => (int)ExtendedProperties[nameof(FeladatCsoportTanuloOsztalyKapcsolatMaxSzama)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class OktatasiNevelesiFeladatDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public OktatasiNevelesiFeladatDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Az oktatás nevelési feladat ESL köepes átlaga
|
||||
/// </summary>
|
||||
public double EslKozepesAtlag => (double)ExtendedProperties[nameof(EslKozepesAtlag)];
|
||||
|
||||
/// <summary>
|
||||
/// Az oktatás nevelési feladat feladat kategória azonosítója
|
||||
/// </summary>
|
||||
public int FeladatKategoriaId => (int)ExtendedProperties[nameof(FeladatKategoriaId)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class OraTulajdonsagTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public OraTulajdonsagTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// BoolDefault-e az óra tulajdonság típus?
|
||||
/// </summary>
|
||||
public bool BoolDefault => (bool)ExtendedProperties[nameof(BoolDefault)];
|
||||
|
||||
/// <summary>
|
||||
/// Órarendi óra-e az óra tulajdonság típus?
|
||||
/// </summary>
|
||||
public bool IsOrarendiOra => (bool)ExtendedProperties[nameof(IsOrarendiOra)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class OrszagTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public OrszagTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Az ország típus ISO kódja
|
||||
/// </summary>
|
||||
public string IsoKod => (string)ExtendedProperties[nameof(IsoKod)];
|
||||
|
||||
/// <summary>
|
||||
/// Az ország típus kód 2
|
||||
/// </summary>
|
||||
public string Kod2 => (string)ExtendedProperties[nameof(Kod2)];
|
||||
|
||||
/// <summary>
|
||||
/// Az ország típus OECD kódja
|
||||
/// </summary>
|
||||
public int? OecdKod => (int?)ExtendedProperties[nameof(OecdKod)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class SorolasOkaTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public SorolasOkaTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Bizonyítványban megjelenik-e a sorolás oka típus?
|
||||
/// </summary>
|
||||
public bool IsBizonyitvanybanMegjelenik => (bool)ExtendedProperties[nameof(IsBizonyitvanybanMegjelenik)];
|
||||
|
||||
/// <summary>
|
||||
/// Naplóban megjelenik-e a sorolás oka típus?
|
||||
/// </summary>
|
||||
public bool IsNaplobanMegjelenik => (bool)ExtendedProperties[nameof(IsNaplobanMegjelenik)];
|
||||
|
||||
/// <summary>
|
||||
/// Törzslapon megjelenik-e a sorolás oka típus?
|
||||
/// </summary>
|
||||
public bool IsTorzslaponMegjelenik => (bool)ExtendedProperties[nameof(IsTorzslaponMegjelenik)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class SzakkepesitesTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public SzakkepesitesTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// A szakképesítés típus szintje
|
||||
/// </summary>
|
||||
public int? SzakkepesitesSzint => (int?)ExtendedProperties[nameof(SzakkepesitesSzint)];
|
||||
|
||||
/// <summary>
|
||||
/// A szakképesítés típus tanulmányi területe
|
||||
/// </summary>
|
||||
public int? TanulmanyiTerulet => (int?)ExtendedProperties[nameof(TanulmanyiTerulet)];
|
||||
|
||||
/// <summary>
|
||||
/// A szakképesítés típus terület sorszáma
|
||||
/// </summary>
|
||||
public int? TeruletSorszam => (int?)ExtendedProperties[nameof(TeruletSorszam)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class SzakmaTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public SzakmaTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// A szakma típus ágazat azonosítója
|
||||
/// </summary>
|
||||
public int? AgazatId => (int?)ExtendedProperties[nameof(AgazatId)];
|
||||
|
||||
/// <summary>
|
||||
/// A szakma típus alapfokú oktatási időtartama
|
||||
/// </summary>
|
||||
public int? AlapfokuOktatasiIdotartam => (int?)ExtendedProperties[nameof(AlapfokuOktatasiIdotartam)];
|
||||
|
||||
/// <summary>
|
||||
/// A szakma típus digitális kompetencia keretszintje
|
||||
/// </summary>
|
||||
public int? DigitalisKompetenciaKeretszint => (int?)ExtendedProperties[nameof(DigitalisKompetenciaKeretszint)];
|
||||
|
||||
/// <summary>
|
||||
/// A szakma típus érettségi oktatási időtartama
|
||||
/// </summary>
|
||||
public int? ErettsegiOktatasiIdotartam => (int?)ExtendedProperties[nameof(ErettsegiOktatasiIdotartam)];
|
||||
|
||||
/// <summary>
|
||||
/// A szakma típus szakképesítés azonosítószáma
|
||||
/// </summary>
|
||||
public string SzakkepesitesAzonositoszam => (string)ExtendedProperties[nameof(SzakkepesitesAzonositoszam)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Framework.Caching.DictionaryItemTables
|
||||
{
|
||||
/// <summary>
|
||||
/// Kódtétel osztály.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TavolletTipusDictionaryItem : DictionaryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Az osztály konstruktora.
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem">Kódtétel elem</param>
|
||||
public TavolletTipusDictionaryItem(DictionaryItem dictionaryItem) : base(dictionaryItem)
|
||||
{
|
||||
ExtendedProperties = dictionaryItem.ExtendedProperties;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// A távollét típus SAP kódja
|
||||
/// </summary>
|
||||
public string SapKod => (string)ExtendedProperties[nameof(SapKod)];
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
1255
Framework/Caching/DictionaryTableCache.cs
Normal file
1255
Framework/Caching/DictionaryTableCache.cs
Normal file
File diff suppressed because it is too large
Load Diff
140
Framework/Caching/GenericCache.cs
Normal file
140
Framework/Caching/GenericCache.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using CacheManager.Core;
|
||||
using CacheManager.Core.Internal;
|
||||
|
||||
namespace Kreta.Framework.Caching
|
||||
{
|
||||
public abstract class GenericCache<TCacheValueType> : Cache, IDisposable
|
||||
{
|
||||
private ICacheManager<TCacheValueType> cache;
|
||||
|
||||
protected GenericCache(CacheManager cacheManager, string cacheName) : base(cacheManager)
|
||||
{
|
||||
cache = CacheFactory.FromConfiguration<TCacheValueType>(cacheName);
|
||||
|
||||
cache.OnRemoveByHandle += Cache_OnRemoveByHandle;
|
||||
}
|
||||
|
||||
protected bool Exists(string key)
|
||||
{
|
||||
return cache.Exists(key);
|
||||
}
|
||||
|
||||
protected TCacheValueType Get(string key)
|
||||
{
|
||||
return cache.Get(key);
|
||||
}
|
||||
|
||||
protected TCacheValueType GetByKeyAndRegion(string key, string region)
|
||||
{
|
||||
return cache.Get(key, region);
|
||||
}
|
||||
|
||||
protected TCacheValueType GetOrAdd(string key, Func<string, TCacheValueType> valueFactory)
|
||||
{
|
||||
return cache.GetOrAdd(key, valueFactory);
|
||||
}
|
||||
|
||||
protected bool Add(string key, string region, TCacheValueType value)
|
||||
{
|
||||
return cache.Add(key, value, region);
|
||||
}
|
||||
|
||||
protected TCacheValueType GetOrAddWithRegion(string key, string region, Func<string, string, TCacheValueType> valueFactory)
|
||||
{
|
||||
return cache.GetOrAdd(key, region, valueFactory);
|
||||
}
|
||||
|
||||
protected TCacheValueType AddOrUpdate(string key, TCacheValueType addValue, Func<TCacheValueType, TCacheValueType> updateValueFactory)
|
||||
{
|
||||
return cache.AddOrUpdate(key, addValue, updateValueFactory);
|
||||
}
|
||||
|
||||
protected TCacheValueType AddOrUpdateWithRegion(string key, string region, TCacheValueType addValue, Func<TCacheValueType, TCacheValueType> updateValueFactory)
|
||||
{
|
||||
return cache.AddOrUpdate(key, region, addValue, updateValueFactory);
|
||||
}
|
||||
|
||||
protected void Put(string key, TCacheValueType value)
|
||||
{
|
||||
cache.Put(key, value);
|
||||
}
|
||||
|
||||
protected void PutWithRegion(string key, TCacheValueType value, string region)
|
||||
{
|
||||
cache.Put(key, value, region);
|
||||
}
|
||||
|
||||
protected void Update(string key, Func<TCacheValueType, TCacheValueType> valueFactory)
|
||||
{
|
||||
cache.Update(key, valueFactory);
|
||||
}
|
||||
|
||||
protected void Remove(string key)
|
||||
{
|
||||
cache.Remove(key);
|
||||
}
|
||||
|
||||
protected void RemoveFromRegion(string key, string region)
|
||||
{
|
||||
cache.Remove(key, region);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///Clear the cache region, removeing all items from the specific region only
|
||||
/// </summary>
|
||||
/// <param name="region"></param>
|
||||
protected void ClearRegion(string region)
|
||||
{
|
||||
cache.ClearRegion(region);
|
||||
}
|
||||
|
||||
protected void Expire(string key, ExpirationMode mode, TimeSpan timeout)
|
||||
{
|
||||
cache.Expire(key, mode, timeout);
|
||||
}
|
||||
|
||||
protected void AddWithAbsoluteExpiration(string key, TimeSpan timeSpan, TCacheValueType value)
|
||||
{
|
||||
cache.Add(new CacheItem<TCacheValueType>(key, value, ExpirationMode.Absolute, timeSpan));
|
||||
|
||||
}
|
||||
|
||||
protected virtual void Cache_OnRemoveByHandle(object sender, CacheItemRemovedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
cache.Clear();
|
||||
}
|
||||
|
||||
bool disposed;
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposed && disposing)
|
||||
{
|
||||
if (cache != null)
|
||||
{
|
||||
cache.Dispose();
|
||||
cache = null;
|
||||
}
|
||||
}
|
||||
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~GenericCache()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
}
|
||||
}
|
61
Framework/Caching/LoginInfoCache.cs
Normal file
61
Framework/Caching/LoginInfoCache.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using CacheManager.Core;
|
||||
using CacheManager.Core.Internal;
|
||||
using Kreta.Framework.Security;
|
||||
|
||||
namespace Kreta.Framework.Caching
|
||||
{
|
||||
public sealed class LoginInfoCache : GenericCache<LoginInfo>
|
||||
{
|
||||
private static readonly string LoginInfoCacheKeyPrefix = $"{nameof(Kreta)}_{nameof(LoginInfoCache)}_";
|
||||
|
||||
private static string GetCacheKey(string sessionId)
|
||||
{
|
||||
return $"{LoginInfoCacheKeyPrefix}{sessionId}";
|
||||
}
|
||||
|
||||
public LoginInfoCache(CacheManager cacheManager) : base(cacheManager, nameof(LoginInfoCache))
|
||||
{
|
||||
}
|
||||
|
||||
public int SessionTimeout { get; set; }
|
||||
|
||||
public void PutLoginInfo(LoginInfo loginInfo)
|
||||
{
|
||||
Put(GetCacheKey(loginInfo.SessionID), loginInfo);
|
||||
}
|
||||
|
||||
public void UpdateLoginInfo(LoginInfo loginInfo)
|
||||
{
|
||||
Update(GetCacheKey(loginInfo.SessionID), _ => loginInfo);
|
||||
}
|
||||
|
||||
public void RemoveLoginInfo(string sessionId)
|
||||
{
|
||||
Remove(GetCacheKey(sessionId));
|
||||
}
|
||||
|
||||
protected override void Cache_OnRemoveByHandle(object sender, CacheItemRemovedEventArgs e)
|
||||
{
|
||||
if (e.Key.StartsWith(LoginInfoCacheKeyPrefix, StringComparison.Ordinal) && e.Reason == CacheItemRemovedReason.Expired)
|
||||
{
|
||||
SDAServer.Instance.SessionManager.DeleteSession((LoginInfo)e.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public LoginInfo GetLoginInfo(string sessionId)
|
||||
{
|
||||
return Get(GetCacheKey(sessionId));
|
||||
}
|
||||
|
||||
public bool IsExistsLoginInfo(string sessionId)
|
||||
{
|
||||
return Exists(GetCacheKey(sessionId));
|
||||
}
|
||||
|
||||
public void Ping(string sessionId)
|
||||
{
|
||||
Expire(GetCacheKey(sessionId), ExpirationMode.Sliding, new TimeSpan(0, SessionTimeout, 0));
|
||||
}
|
||||
}
|
||||
}
|
26
Framework/Caching/ManualEnumCache.cs
Normal file
26
Framework/Caching/ManualEnumCache.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Kreta.Framework.Caching
|
||||
{
|
||||
internal sealed class ManualEnumCache : Cache
|
||||
{
|
||||
private ConcurrentDictionary<string, Dictionary<string, string>> cache;
|
||||
|
||||
public ManualEnumCache(CacheManager cacheManager) : base(cacheManager)
|
||||
{
|
||||
cache = new ConcurrentDictionary<string, Dictionary<string, string>>();
|
||||
}
|
||||
|
||||
public Dictionary<string, string> GetOrAdd(string key, Func<string, Dictionary<string, string>> valueFactory)
|
||||
{
|
||||
return cache.GetOrAdd(key, valueFactory);
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
cache.Clear();
|
||||
}
|
||||
}
|
||||
}
|
80
Framework/Caching/StringResourcesCache.cs
Normal file
80
Framework/Caching/StringResourcesCache.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Kreta.Framework.Caching
|
||||
{
|
||||
public sealed class StringResourcesCache : Cache
|
||||
{
|
||||
private const int DefaultLcid = 1038; // magyar
|
||||
private const string StringResourcesFileName = "StringResources.kres";
|
||||
|
||||
private ConcurrentDictionary<string, string> cache;
|
||||
|
||||
public StringResourcesCache(CacheManager cacheManager) : base(cacheManager)
|
||||
{
|
||||
cache = new ConcurrentDictionary<string, string>();
|
||||
LoadCache();
|
||||
}
|
||||
|
||||
private string GetStringResourcesKey(int id, int lcid)
|
||||
{
|
||||
return $"{id}¤{lcid}";
|
||||
}
|
||||
|
||||
private void LoadCache()
|
||||
{
|
||||
string[] stringResourcesFilePath = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, StringResourcesFileName, SearchOption.AllDirectories);
|
||||
if (stringResourcesFilePath.Length == 0)
|
||||
{
|
||||
throw new Exception($"Not found {StringResourcesFileName} file!");
|
||||
}
|
||||
|
||||
var root = XElement.Load(stringResourcesFilePath[0]);
|
||||
|
||||
foreach (XElement text in root.Elements())
|
||||
{
|
||||
foreach (XElement language in text.Elements())
|
||||
{
|
||||
string stringResourcesKey = GetStringResourcesKey(Convert.ToInt32(text.Attribute("ID").Value), Convert.ToInt32(language.Attribute("LCID").Value));
|
||||
string value = language.Value.Replace("\n", "<br/>");
|
||||
|
||||
cache.AddOrUpdate(stringResourcesKey, key => value, (k, v) => value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetDefaultText(int id, int lcid)
|
||||
{
|
||||
return $"Nincs fordítása -> ID:{id} - LCID:{lcid}!";
|
||||
}
|
||||
|
||||
public string Get(int id, int lcid)
|
||||
{
|
||||
return Get(id, lcid, GetDefaultText(id, lcid));
|
||||
}
|
||||
|
||||
public string Get(int id, int lcid, string defaultText)
|
||||
{
|
||||
var result = cache.GetOrAdd(GetStringResourcesKey(id, lcid), key => GetDefaultText(id, lcid));
|
||||
|
||||
if (result == null && lcid != DefaultLcid)
|
||||
{
|
||||
result = cache.GetOrAdd(GetStringResourcesKey(id, DefaultLcid), key => GetDefaultText(id, DefaultLcid));
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
result = defaultText;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
cache.Clear();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user