using Ease.Core.DataAccess; using Ease.Core.Model; using Ease.Core.Utility; using System; using System.Collections.Generic; using HRM.BO; namespace HRM.DA { public class BadLoginAttemptInfoService : ServiceTemplate, IBadLoginAttemptInfoService { public BadLoginAttemptInfoService() { } private void MapObject(BadLoginAttemptInfo oBadLoginAttemptInfo, DataReader oReader) { base.SetObjectID(oBadLoginAttemptInfo, oReader.GetInt32("SlID").Value); oBadLoginAttemptInfo.UserID = oReader.GetInt32("UserID", 0); oBadLoginAttemptInfo.AttemptTime = oReader.GetDateTime("AttemptTime").Value; oBadLoginAttemptInfo.PCNumber = oReader.GetString("PCNumber"); } protected override T CreateObject(DataReader oReader) { BadLoginAttemptInfo oBadLoginAttemptInfo = new BadLoginAttemptInfo(); MapObject(oBadLoginAttemptInfo, oReader); return oBadLoginAttemptInfo as T; } protected BadLoginAttemptInfo CreateObject(DataReader oReader) { BadLoginAttemptInfo oBadLoginAttemptInfo = new BadLoginAttemptInfo(); MapObject(oBadLoginAttemptInfo, oReader); return oBadLoginAttemptInfo; } #region Service implementation public BadLoginAttemptInfo Get(int id) { BadLoginAttemptInfo oBadLoginAttemptInfo = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(BadLoginAttemptInfoDA.Get(tc, id)); if (oreader.Read()) { oBadLoginAttemptInfo = 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 } return oBadLoginAttemptInfo; } public List Get() { List BadLoginAttemptInfos = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(BadLoginAttemptInfoDA.Get(tc)); BadLoginAttemptInfos = 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 } return BadLoginAttemptInfos; } public List Get(DateTime dtFrom, DateTime dtTo) { List BadLoginAttemptInfos = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(BadLoginAttemptInfoDA.Get(tc, dtFrom, dtTo)); BadLoginAttemptInfos = 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 } return BadLoginAttemptInfos; } public int Save(BadLoginAttemptInfo oBadLoginAttemptInfo) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); int id = tc.GenerateID("BadLoginAttemptInfo", "SlID"); base.SetObjectID(oBadLoginAttemptInfo, id); BadLoginAttemptInfoDA.Insert(tc, oBadLoginAttemptInfo); tc.End(); return oBadLoginAttemptInfo.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(int id) { //Not Needed } #endregion } }