HRM-10/HRM.DA/Service/Basic/BadLoginAttemptInfoService.cs
Mohaimen Hasan 838b8d4480 first commit
2026-11-03 13:06:00 +06:00

163 lines
4.8 KiB
C#

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<T>(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<BadLoginAttemptInfo>(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<BadLoginAttemptInfo> Get()
{
List<BadLoginAttemptInfo> BadLoginAttemptInfos = new List<BadLoginAttemptInfo>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(BadLoginAttemptInfoDA.Get(tc));
BadLoginAttemptInfos = this.CreateObjects<BadLoginAttemptInfo>(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<BadLoginAttemptInfo> Get(DateTime dtFrom, DateTime dtTo)
{
List<BadLoginAttemptInfo> BadLoginAttemptInfos = new List<BadLoginAttemptInfo>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(BadLoginAttemptInfoDA.Get(tc, dtFrom, dtTo));
BadLoginAttemptInfos = this.CreateObjects<BadLoginAttemptInfo>(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
}
}