using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35.Caching; using Ease.CoreV35.Model; namespace Payroll.BO { #region HolidayCalendar [Serializable] public class HolidayCalendar : AuditTrailBase { #region Cache Store private static Cache _cache = new Cache(typeof(HolidayCalendar)); #endregion #region Constructor public HolidayCalendar() { _type = 0; _description = string.Empty; _holidayDate = DateTime.MinValue; _locationID = null; } #endregion #region Properties #region type : EnumHolidayType private EnumHolidayType _type; public EnumHolidayType Type { get { return _type; } set { base.OnPropertyChange("type", (short)_type, (short)value); _type = value; } } #endregion #region description : string private string _description; public string Description { get { return _description; } set { base.OnPropertyChange("description", _description, value); _description = value; } } #endregion #region holidayDate : DateTime private DateTime _holidayDate; public DateTime HolidayDate { get { return _holidayDate; } set { base.OnPropertyChange("holidayDate", _holidayDate, value); _holidayDate = value; } } #endregion #region LocationID : ID private ID _locationID; public ID LocationID { get { return _locationID; } set { base.OnPropertyChange("locationID", _locationID, value); _locationID = value; } } #endregion #region Service Factory IHolidayCalendarService : IHolidayCalendarService internal static IHolidayCalendarService Service { get { return Services.Factory.CreateService(typeof(IHolidayCalendarService)); } } #endregion #endregion #region Functions public static HolidayCalendar Get(ID nID) { HolidayCalendar oHolidayCalendar = null; #region Cache Header oHolidayCalendar = (HolidayCalendar)_cache["Get", nID]; if (oHolidayCalendar != null) return oHolidayCalendar; #endregion oHolidayCalendar = HolidayCalendar.Service.Get(nID); #region Cache Footer _cache.Add(oHolidayCalendar, "Get", nID); #endregion return oHolidayCalendar; } public static int GetTotalMonthlyHolidays(int loactionNumber, DateTime firstDateOfMonth, DateTime lastDateOfMonth) { int totalMonthlyHoliDays = 0; try { totalMonthlyHoliDays = Service.GetTotalMonthlyHolidays(loactionNumber, firstDateOfMonth, lastDateOfMonth); } catch (ServiceException e) { throw new Exception(e.Message, e); } return totalMonthlyHoliDays; } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate holidayCalendars = _cache["Get"] as ObjectsTemplate; if (holidayCalendars != null) return holidayCalendars; #endregion try { holidayCalendars = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(holidayCalendars, "Get"); #endregion return holidayCalendars; } public static ObjectsTemplate GetWeeklyHoliDay() { #region Cache Header ObjectsTemplate holidayCalendars = _cache["GetWeeklyHoliDay"] as ObjectsTemplate; if (holidayCalendars != null) return holidayCalendars; #endregion try { holidayCalendars = Service.GetWeeklyHoliDay(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(holidayCalendars, "GetWeeklyHoliDay"); #endregion return holidayCalendars; } public static ObjectsTemplate GetHoliDayByLocation(ID nLocID) { #region Cache Header ObjectsTemplate holidayCalendars = _cache["GetHoliDayByLocation", nLocID] as ObjectsTemplate; if (holidayCalendars != null) return holidayCalendars; #endregion try { holidayCalendars = Service.GetHoliDayByLocation(nLocID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(holidayCalendars, "GetHoliDayByLocation", nLocID); #endregion return holidayCalendars; } public static ObjectsTemplate GetWeeklyAndLocHoliday(ID nLocID) { #region Cache Header ObjectsTemplate holidayCalendars = _cache["GetWeeklyAndLocHoliday", nLocID] as ObjectsTemplate; if (holidayCalendars != null) return holidayCalendars; #endregion try { holidayCalendars = Service.GetWeeklyAndLocHoliday(nLocID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(holidayCalendars, "GetWeeklyAndLocHoliday", nLocID); #endregion return holidayCalendars; } public static ObjectsTemplate GetbyMonthRange(int nLocationID , DateTime dStartDate , DateTime dEndDate) { return HolidayCalendar.Service.GetbyMonthRange(nLocationID , dStartDate , dEndDate); } public static ObjectsTemplate GetbyDateRange(DateTime dStartDate , DateTime dEndDate) { return HolidayCalendar.Service.GetbyDateRange(dStartDate , dEndDate); } public static double GetNoofHoliday() { return HolidayCalendar.Service.GetNoofHoliday(); } public ID Save() { this.SetAuditTrailProperties(); return HolidayCalendar.Service.Save(this); } public void Delete() { HolidayCalendar.Service.Delete(ID); } public void DeleteAll() { HolidayCalendar.Service.DeleteAll(); } public void DeleteAll(int nYear) { HolidayCalendar.Service.DeleteAll(nYear); } #endregion } #endregion #region IHolidayCalendar Service public interface IHolidayCalendarService { HolidayCalendar Get(ID id); int GetTotalMonthlyHolidays(int loactionNumber, DateTime firstDateOfMonth, DateTime lastDateOfMonth); ObjectsTemplate Get(); ObjectsTemplate GetWeeklyHoliDay(); ObjectsTemplate GetHoliDayByLocation(ID nLocID); ObjectsTemplate GetWeeklyAndLocHoliday(ID nLocID); double GetNoofHoliday(); ID Save(HolidayCalendar item); void Delete(ID id); void DeleteAll(); void DeleteAll(int nYear); ObjectsTemplate GetbyMonthRange(int nLocationID , DateTime dStartDate , DateTime dEndDate); ObjectsTemplate GetbyDateRange(DateTime dStartDate , DateTime dEndDate); } #endregion }