using System; using System.Data; using System.Linq; using Ease.CoreV35; using Ease.CoreV35.Model; using Ease.CoreV35.DataAccess; using System.Collections.Generic; using Payroll.BO; using Ease.CoreV35.Caching; namespace Payroll.Service { #region FestivalBonusProjection Service [Serializable] public class FestivalBonusProjectionService : ServiceTemplate, IFestivalBonusProjectionService { #region Private functions and declaration Cache _cache = new Cache(typeof(FestivalBonusProjection)); #endregion public FestivalBonusProjectionService() { } private void MapObject(FestivalBonusProjection oFestivalBonusProjection, DataReader oReader) { base.SetObjectID(oFestivalBonusProjection, oReader.GetID("FestivalBonusProjectionID")); oFestivalBonusProjection.BasicMonth = (EnumMonths)oReader.GetInt16("basicmonth").Value; oFestivalBonusProjection.NoofBasic = oReader.GetDouble("noofbasic").Value; oFestivalBonusProjection.Sequence = oReader.GetInt32("SequenceNO").Value; oFestivalBonusProjection.Status = (EnumStatus)oReader.GetInt32("Status").Value; oFestivalBonusProjection.CreatedBy = oReader.GetID("CreatedBy"); oFestivalBonusProjection.CreatedDate = oReader.GetDateTime("CreationDate").Value; oFestivalBonusProjection.ModifiedBy = oReader.GetID("ModifiedBy"); oFestivalBonusProjection.ModifiedDate = oReader.GetDateTime("ModifiedDate"); this.SetObjectState(oFestivalBonusProjection, Ease.CoreV35.ObjectState.Saved); } protected override T CreateObject(DataReader oReader) { FestivalBonusProjection oFestivalBonusProjection = new FestivalBonusProjection(); MapObject(oFestivalBonusProjection, oReader); return oFestivalBonusProjection as T; } protected FestivalBonusProjection CreateObject(DataReader oReader) { FestivalBonusProjection oFestivalBonusProjection = new FestivalBonusProjection(); MapObject(oFestivalBonusProjection, oReader); return oFestivalBonusProjection; } #region Service implementation public FestivalBonusProjection Get(ID id) { FestivalBonusProjection oFestivalBonusProjection = new FestivalBonusProjection(); #region Cache Header oFestivalBonusProjection = _cache["Get", id] as FestivalBonusProjection; if (oFestivalBonusProjection != null) return oFestivalBonusProjection; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(FestivalBonusProjectionDA.Get(tc, id)); if (oreader.Read()) { oFestivalBonusProjection = this.CreateObject(oreader); } oreader.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } #region Cache Footer _cache.Add(oFestivalBonusProjection, "Get", id); #endregion return oFestivalBonusProjection; } public FestivalBonusProjection Get(EnumMonths dBasicMonth) { FestivalBonusProjection oFestivalBonusProjection = new FestivalBonusProjection(); #region Cache Header oFestivalBonusProjection = _cache["Get", dBasicMonth] as FestivalBonusProjection; if (oFestivalBonusProjection != null) return oFestivalBonusProjection; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(FestivalBonusProjectionDA.Get(tc, dBasicMonth)); if (oreader.Read()) { oFestivalBonusProjection = this.CreateObject(oreader); } oreader.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } #region Cache Footer _cache.Add(oFestivalBonusProjection, "Get", dBasicMonth); #endregion return oFestivalBonusProjection; } public ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate FestivalBonusProjections = _cache["Get"] as ObjectsTemplate; if (FestivalBonusProjections != null) return FestivalBonusProjections; #endregion TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(FestivalBonusProjectionDA.Get(tc, status)); FestivalBonusProjections = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } #region Cache Footer _cache.Add(FestivalBonusProjections, "Get", status); #endregion return FestivalBonusProjections; } public ID Save(FestivalBonusProjection oFestivalBonusProjection) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); if (oFestivalBonusProjection.IsNew) { int id = tc.GenerateID("FestivalBonusProjection", "FestivalBonusProjectionID"); base.SetObjectID(oFestivalBonusProjection, ID.FromInteger(id)); int seqNo = tc.GenerateID("FestivalBonusProjection", "SequenceNo"); oFestivalBonusProjection.Sequence = seqNo; FestivalBonusProjectionDA.Insert(tc, oFestivalBonusProjection); } else { FestivalBonusProjectionDA.Update(tc, oFestivalBonusProjection); } tc.End(); return oFestivalBonusProjection.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void Delete(ID id) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); FestivalBonusProjectionDA.Delete(tc, id); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } #endregion } #endregion }