using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35.DataAccess; using Ease.CoreV35.Caching; using Ease.CoreV35.Model; using Payroll.BO; using System.Data; namespace Payroll.Service { [Serializable] class EmpMobileAttendanceService:ServiceTemplate,IEmpMobileAttendanceService { #region Private functions and declaration Cache _cache = new Cache(typeof(EmpMobileAttendance)); #endregion protected override T CreateObject(DataReader dr) { EmpMobileAttendance attendanceTrack = new EmpMobileAttendance(); MapObject(attendanceTrack, dr); return attendanceTrack as T; } private void MapObject(EmpMobileAttendance attendanceTrack, DataReader oReader) { base.SetObjectID(attendanceTrack, oReader.GetID("EmpMobAttendID")); attendanceTrack.EmpID = oReader.GetID("EmpID"); attendanceTrack.IMENO = oReader.GetString("IMENO"); attendanceTrack.CreatedBy = oReader.GetID("CreatedBy"); attendanceTrack.CreatedDate = oReader.GetDateTime("CreationDate").Value; attendanceTrack.ModifiedBy = oReader.GetID("ModifiedBy"); attendanceTrack.ModifiedDate = oReader.GetDateTime("ModifiedDate").HasValue ? oReader.GetDateTime("ModifiedDate").Value : DateTime.MinValue; this.SetObjectState(attendanceTrack, Ease.CoreV35.ObjectState.Saved); } #region IUserLocationService Members public ObjectsTemplate Get() { TransactionContext tc = null; ObjectsTemplate listAttendanceTrack = new ObjectsTemplate(); ; #region Cache Header listAttendanceTrack = _cache["Get"] as ObjectsTemplate; if (listAttendanceTrack != null) return listAttendanceTrack; #endregion try { tc = TransactionContext.Begin(true); DataReader oreader = new DataReader(EmpMobileAttendanceDA.Get(tc)); listAttendanceTrack = this.CreateObjects(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(listAttendanceTrack, "Get"); #endregion return listAttendanceTrack; } public EmpMobileAttendance Get(ID nID) { TransactionContext tc = null; EmpMobileAttendance attendanceTrack = new EmpMobileAttendance(); #region Cache Header attendanceTrack = _cache["Get", nID] as EmpMobileAttendance; if (attendanceTrack != null) return attendanceTrack; #endregion try { tc = TransactionContext.Begin(true); DataReader oreader = new DataReader(EmpMobileAttendanceDA.Get(tc, nID)); if (oreader.Read()) { attendanceTrack = 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(attendanceTrack, "Get", nID); #endregion return attendanceTrack; } public ID Save(EmpMobileAttendance obj) { TransactionContext tc = null; ID oId = null; try { tc = TransactionContext.Begin(true); if (obj.IsNew) { int id = tc.GenerateID("EMPMOBILEATTENDANCE", "EmpMobAttendID"); base.SetObjectID(obj, ID.FromInteger(id)); oId = EmpMobileAttendanceDA.Insert(tc, obj); } else { } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oId; } public ID Delete(EmpMobileAttendance obj) { TransactionContext tc = null; ID oId = null; try { tc = TransactionContext.Begin(true); oId = EmpMobileAttendanceDA.Delete(tc, obj); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oId; } #endregion } }