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 ReportAuthorization [Serializable] public class ReportAuthorization:AuditTrailBase { #region Cache Store private static Cache _cache = new Cache(typeof(ReportAuthorization)); #endregion #region Constructor public ReportAuthorization() { _reportID = null; _authorizePersionId = null; _position = 0; } #endregion #region Properties #region ReportID : ID private ID _reportID; public ID ReportID { get { return _reportID; } set { base.OnPropertyChange("ReportID", _reportID, value); _reportID = value; } } #endregion #region AuthorizePersionId : ID private ID _authorizePersionId; public ID AuthorizePersionId { get { return _authorizePersionId; } set { base.OnPropertyChange("AuthorizePersionId", _authorizePersionId, value); _authorizePersionId = value; } } #endregion #region position : int private int _position; public int Position { get { return _position; } set { base.OnPropertyChange("position", _position, value); _position = value; } } #endregion #region Service Factory IReportAuthorizationService : IReportAuthorizationService internal static IReportAuthorizationService Service { get { return Services.Factory.CreateService(typeof(IReportAuthorizationService)); } } #endregion #endregion #region Functions public static ReportAuthorization Get(ID nID) { ReportAuthorization oReportAuthorization = null; #region Cache Header oReportAuthorization = (ReportAuthorization)_cache["Get", nID]; if (oReportAuthorization != null) return oReportAuthorization; #endregion oReportAuthorization = ReportAuthorization.Service.Get(nID); #region Cache Footer _cache.Add(oReportAuthorization, "Get", nID); #endregion return oReportAuthorization; } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate reportAuthorizations = _cache["Get"] as ObjectsTemplate; if (reportAuthorizations != null) return reportAuthorizations; #endregion try { reportAuthorizations = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(reportAuthorizations, "Get"); #endregion return reportAuthorizations; } public static ObjectsTemplate GetByReportID(ID reportID) { #region Cache Header ObjectsTemplate reportAuthorizations = _cache["GetByReportID"] as ObjectsTemplate; if (reportAuthorizations != null) return reportAuthorizations; #endregion try { reportAuthorizations = Service.GetByReportID(reportID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(reportAuthorizations, "GetByReportID"); #endregion return reportAuthorizations; } public static ReportAuthorization Get(ID reportID,int position) { #region Cache Header ReportAuthorization reportAuthorization = _cache["GetByReportID"] as ReportAuthorization; if (reportAuthorization != null) return reportAuthorization; #endregion try { reportAuthorization = Service.Get(reportID,position); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(reportAuthorization, "GetByReportID"); #endregion return reportAuthorization; } public ID Save() { return ReportAuthorization.Service.Save(this); } public void Delete() { ReportAuthorization.Service.Delete(ID); } public void Delete(ID iD) { ReportAuthorization.Service.Delete(iD); } #endregion } #endregion #region IReportAuthorization Service public interface IReportAuthorizationService { ReportAuthorization Get(ID id); ObjectsTemplate Get(); ObjectsTemplate GetByReportID(ID reportID); ReportAuthorization Get(ID reportID, int position); ID Save(ReportAuthorization item); void Delete(ID id); } #endregion }