using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35; using Ease.CoreV35.Model; using Ease.CoreV35.Caching; using System.Data.Linq.Mapping; namespace Payroll.BO { #region WeeklyHoliday [Serializable] public class WeeklyHoliday : BasicBaseObject { ObjectsTemplate _oLocs = null; HolidayCalendar _oHolidayCalendar = null; ObjectsTemplate _oHolidays = null; ObjectsTemplate _oNationalHolidays = null; ObjectsTemplate _oHolidayCalendars = null; #region Cache Store private static Cache _cache = new Cache(typeof(WeeklyHoliday)); #endregion #region Constructor public WeeklyHoliday() { _dateType = 0; _locID = null; } #endregion #region Properties #region DateType : int private int _dateType; public int DateType { get { return _dateType; } set { base.OnPropertyChange("DateType", _dateType, value); _dateType = value; } } #endregion #region LocationID : ID private ID _locID; public ID LocationID { get { return _locID; } set { base.OnPropertyChange("LocationID", _locID, value); _locID = value; } } #endregion #region Service Factory IWeeklyHolidayService : IWeeklyHolidayService internal static IWeeklyHolidayService Service { get { return Services.Factory.CreateService(typeof(IWeeklyHolidayService)); } } #endregion #endregion #region Functions public static WeeklyHoliday Get(ID nID) { WeeklyHoliday oWeeklyHoliday = null; #region Cache Header oWeeklyHoliday = (WeeklyHoliday)_cache["Get", nID]; if (oWeeklyHoliday != null) return oWeeklyHoliday; #endregion oWeeklyHoliday = WeeklyHoliday.Service.Get(nID); #region Cache Footer _cache.Add(oWeeklyHoliday, "Get", nID); #endregion return oWeeklyHoliday; } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate WeeklyHolidays = _cache["Get", status] as ObjectsTemplate; if (WeeklyHolidays != null) return WeeklyHolidays; #endregion try { WeeklyHolidays = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(WeeklyHolidays, "Get", status); #endregion return WeeklyHolidays; } public static ObjectsTemplate GetCompanyEntireHolidays() { #region Cache Header ObjectsTemplate WeeklyHolidays = _cache["GetCompanyEntireHolidays"] as ObjectsTemplate; if (WeeklyHolidays != null) return WeeklyHolidays; #endregion try { WeeklyHolidays = Service.GetCompanyEntireHolidays(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(WeeklyHolidays, "GetCompanyEntireHolidays"); #endregion return WeeklyHolidays; } public static ObjectsTemplate GetByLocation(ID nLocID) { #region Cache Header ObjectsTemplate WeeklyHolidays = _cache["GetByLocation",nLocID] as ObjectsTemplate; if (WeeklyHolidays != null) return WeeklyHolidays; #endregion try { WeeklyHolidays = Service.GetByLocation(nLocID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(WeeklyHolidays, "GetByLocation",nLocID); #endregion return WeeklyHolidays; } public static ObjectsTemplate GetByEmployee(ID nEmpID) { #region Cache Header ObjectsTemplate WeeklyHolidays = _cache["GetByEmployee", nEmpID] as ObjectsTemplate; if (WeeklyHolidays != null) return WeeklyHolidays; #endregion try { WeeklyHolidays = Service.GetByLocation(nEmpID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(WeeklyHolidays, "GetByEmployee", nEmpID); #endregion return WeeklyHolidays; } public ID Save() { base.SetAuditTrailProperties(); ID id= WeeklyHoliday.Service.Save(this); return id; } public void Delete(ID id) { WeeklyHoliday.Service.Delete(id); } #endregion } #endregion #region IWeeklyHoliday Service public interface IWeeklyHolidayService { WeeklyHoliday Get(ID id); ObjectsTemplate Get(EnumStatus status); ObjectsTemplate GetCompanyEntireHolidays(); ObjectsTemplate GetByLocation(ID nLocID); ObjectsTemplate GetByEmployee(ID nEmpID); ID Save(WeeklyHoliday item); void Delete(ID id); } #endregion }