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; using System.IO; using System.Net.Mime; using System.Data; namespace Payroll.BO { #region AuthorizedPerson [Serializable] public class AuthorizedPerson : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(AuthorizedPerson)); #endregion #region Constructor public AuthorizedPerson() { _personID = null; _name = string.Empty; _designation = string.Empty; _position = 0; _signature = null; } #endregion #region Properties #region PersonID : ID private ID _personID; public ID PersonID { get { return _personID; } set { base.OnPropertyChange("PersonID", _personID, value); _personID = value; } } #endregion #region name : string private string _name; public string Name { get { return _name; } set { base.OnPropertyChange("name", _name, value); _name = value; } } #endregion #region designation : string private string _designation; public string Designation { get { return _designation; } set { base.OnPropertyChange("designation", _designation, value); _designation = value; } } #endregion #region position : int private int _position; public int Position { get { return _position; } set { base.OnPropertyChange("position", _position, value); _position = value; } } #endregion #region signature : byte private byte[] _signature; public byte[] Signature { get { return _signature; } set { _signature = value; } } #endregion #region Service Factory IAuthorizedPersonService : IAuthorizedPersonService internal static IAuthorizedPersonService Service { get { return Services.Factory.CreateService(typeof(IAuthorizedPersonService)); } } #endregion #endregion #region Functions public static AuthorizedPerson Get(ID nID) { AuthorizedPerson oAuthorizedPerson = null; #region Cache Header oAuthorizedPerson = (AuthorizedPerson)_cache["Get", nID]; if (oAuthorizedPerson != null) return oAuthorizedPerson; #endregion oAuthorizedPerson = AuthorizedPerson.Service.Get(nID); #region Cache Footer _cache.Add(oAuthorizedPerson, "Get", nID); #endregion return oAuthorizedPerson; } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate authorizedPersons = _cache["Get"] as ObjectsTemplate; if (authorizedPersons != null) return authorizedPersons; #endregion try { authorizedPersons = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(authorizedPersons, "Get"); #endregion return authorizedPersons; } public static ObjectsTemplate GetByReportID(ID reportID) { ObjectsTemplate oAuthorizedPerson = null; #region Cache Header oAuthorizedPerson = (ObjectsTemplate)_cache["GetByReportID", reportID]; if (oAuthorizedPerson != null) return oAuthorizedPerson; #endregion oAuthorizedPerson = AuthorizedPerson.Service.GetByReportID(reportID); #region Cache Footer _cache.Add(oAuthorizedPerson, "GetByReportID", reportID); #endregion return oAuthorizedPerson; } public bool IsExist(string Name) { return AuthorizedPerson.Service.IsExist(Name); } public ID Save() { base.SetAuditTrailProperties(); return AuthorizedPerson.Service.Save(this); } public DataTable GetImage(int PersonID) { return AuthorizedPerson.Service.GetImage(PersonID); } public ID Save(FileStream stream) { base.SetAuditTrailProperties(); return AuthorizedPerson.Service.Save(this, stream); } public void Delete() { AuthorizedPerson.Service.Delete(ID); } #endregion } #endregion #region IAuthorizedPerson Service public interface IAuthorizedPersonService { AuthorizedPerson Get(ID id); ObjectsTemplate Get(); ID Save(AuthorizedPerson item); void Delete(ID id); bool IsExist(string Name); ID Save(AuthorizedPerson oAuthorizedPerson, FileStream stream); DataTable GetImage(int PersonID); ObjectsTemplate GetByReportID(ID reportID); } #endregion }