3ca8b29e04
Regression: PrintLocation added the compare methods back Breaking: Kot.Code is now integers Breaking: Kot Update is now via Stored Procedure to get DB Values Breaking: Reprints Insert is now via Stored Procedure to get DV Values Breaking: Voucher.BillID and KotID are now integers Breaking: Voucher Insert/Update is now via Stored Procedures to get DV Values also Dirty Checking for Voucher has been overwritten to set dirty for LastEditDate update Fix: Login forms simplified Feature: PrintLocation and Products are cached application wide.
67 lines
2.3 KiB
C#
67 lines
2.3 KiB
C#
using NHibernate;
|
|
using Tanshu.Accounts.Entities;
|
|
using System.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq.Expressions;
|
|
using System.Configuration;
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
{
|
|
public class Cache
|
|
{
|
|
private static IList<ProductGroup> cache = null;
|
|
private static Dictionary<int, PrintLocation> locations = new Dictionary<int, PrintLocation>();
|
|
private static string location = ConfigurationManager.AppSettings["Location"].ToLowerInvariant();
|
|
|
|
public static IList<ProductGroup> ProductGroups()
|
|
{
|
|
if (cache == null)
|
|
{
|
|
using (var bi = new ProductGroupBI())
|
|
{
|
|
var list = bi.SaleList();
|
|
foreach (var item in list)
|
|
{
|
|
NHibernateUtil.Initialize(item.Products);
|
|
}
|
|
cache = list;
|
|
}
|
|
}
|
|
return cache;
|
|
}
|
|
public static PrintLocation BasePrinter
|
|
{
|
|
get
|
|
{
|
|
if (!locations.ContainsKey(location.GetHashCode()))
|
|
{
|
|
using (var bi = new PrintLocationBI())
|
|
{
|
|
var loc = bi.Get(x => x.Location == location && x.ProductGroup == null);
|
|
locations.Add(location.GetHashCode(), loc);
|
|
}
|
|
}
|
|
return locations[location.GetHashCode()];
|
|
}
|
|
}
|
|
public static PrintLocation KotPrinter(Guid productGroupID)
|
|
{
|
|
if (!locations.ContainsKey(location.GetHashCode() ^ productGroupID.GetHashCode()))
|
|
{
|
|
using (var bi = new PrintLocationBI())
|
|
{
|
|
var loc = bi.Get(x => x.Location == location && x.ProductGroup.ProductGroupID == productGroupID) ??
|
|
bi.Get(x => x.Location == location && x.ProductGroup == null);
|
|
locations.Add(location.GetHashCode() ^ productGroupID.GetHashCode(), loc);
|
|
}
|
|
}
|
|
return locations[location.GetHashCode() ^ productGroupID.GetHashCode()];
|
|
}
|
|
public static void Invalidate()
|
|
{
|
|
cache = null;
|
|
locations = new Dictionary<int, PrintLocation>();
|
|
}
|
|
}
|
|
} |