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

486 lines
16 KiB
C#

using System;
using System.Data;
using Ease.Core.Model;
using Ease.Core.DataAccess;
using Ease.Core;
using System.Collections.Generic;
using Ease.Core.Utility;
using HRM.BO;
using System.IO;
using System.Linq;
using System.Reflection;
namespace HRM.DA
{
public class InterviewAssessmentKPIService : ServiceTemplate, IInterviewAssessmentKPIService
{
#region MapAssesmentKpiObject
private void MapAssesmentKpiObject(InterviewAssessmentKPI obKpi, DataReader oReader)
{
this.SetObjectID(obKpi, oReader.GetInt32("InterviewAssessmentKPIID").Value);
obKpi.Description = oReader.GetString("Description") != null ? oReader.GetString("Description") : string.Empty;
obKpi.MinMark = oReader.GetInt32("MinMark", true, 0);
obKpi.MaxMark = oReader.GetInt32("MaxMark", true, 0);
obKpi.IsDefault = oReader.GetBoolean("IsDefault", true, false);
obKpi.CreatedBy = oReader.GetInt32("CreatedBy", true, 0);
obKpi.CreatedDate = oReader.GetDateTime("CreationDate") == null
? DateTime.MinValue
: oReader.GetDateTime("CreationDate").Value;
obKpi.ModifiedBy = oReader.GetInt32("ModifiedBy");
obKpi.ModifiedDate = oReader.GetDateTime("ModificationDate");
this.SetObjectState(obKpi, ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
InterviewAssessmentKPI obKpi = new InterviewAssessmentKPI();
MapAssesmentKpiObject(obKpi, oReader);
return obKpi as T;
}
protected InterviewAssessmentKPI CreateObject(DataReader oReader)
{
InterviewAssessmentKPI obKpi = new InterviewAssessmentKPI();
MapAssesmentKpiObject(obKpi, oReader);
return obKpi;
}
#endregion
#region InterviewBoardAssessmentKPI Object Mapping
private void MapReference(InterviewBoardAssessmentKPI onBoardKpi, DataReader oReader)
{
SetObjectID(onBoardKpi, (oReader.GetInt32("InterviewBoardAssessmentKPIID").Value));
onBoardKpi.InterviewAssessmentKPIID = oReader.GetString("InterviewAssessmentKPIID") != null ? oReader.GetInt32("InterviewAssessmentKPIID").Value : 0;
onBoardKpi.Marks = oReader.GetString("Marks") != null ? oReader.GetInt32("Marks").Value : 0;
this.SetObjectState(onBoardKpi, ObjectState.Saved);
}
private List<InterviewBoardAssessmentKPI> CreateBoardKpiObjects(DataReader oReader)
{
List<InterviewBoardAssessmentKPI> allboardKpis = new List<InterviewBoardAssessmentKPI>();
while (oReader.Read())
{
InterviewBoardAssessmentKPI boardKpi = new InterviewBoardAssessmentKPI();
MapReference(boardKpi, oReader);
allboardKpis.Add(boardKpi);
}
return allboardKpis;
}
#endregion
#region InterviewAssessmentKPI Service Implementation
public void Save(InterviewAssessmentKPI obKpi)
{
TransactionContext tc = null;
int oID = 0;
try
{
tc = TransactionContext.Begin(true);
if (obKpi.IsNew)
{
int id = tc.GenerateID("InterviewAssessmentKPI", "InterviewAssessmentKPIID");
oID = (id);
base.SetObjectID(obKpi, (id));
InterviewAssessmentKPIDA.Insert(obKpi, tc);
}
else
{
oID = obKpi.ID;
InterviewAssessmentKPIDA.Update(obKpi, tc);
}
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
public List<InterviewAssessmentKPI> Get()
{
List<InterviewAssessmentKPI> allRefs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(InterviewAssessmentKPIDA.Get(tc));
allRefs = this.CreateObjects<InterviewAssessmentKPI>(oreader);
oreader.Close();
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return allRefs;
}
public List<InterviewAssessmentKPI> GetBySessionIDStepID(int sessionID, int stepID)
{
List<InterviewAssessmentKPI> allRefs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(InterviewAssessmentKPIDA.GetBySessionIDStepID(tc, sessionID, stepID));
allRefs = this.CreateObjects<InterviewAssessmentKPI>(oreader);
oreader.Close();
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return allRefs;
}
public InterviewAssessmentKPI GetById(int id)
{
InterviewAssessmentKPI obKpi = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(InterviewAssessmentKPIDA.GeById(tc, id));
if (oreader.Read())
{
obKpi = this.CreateObject<InterviewAssessmentKPI>(oreader);
}
oreader.Close();
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return obKpi;
}
public void Delete(InterviewAssessmentKPI interviewAssessmentKpi)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
InterviewAssessmentKPIDA.Delete(interviewAssessmentKpi, tc);
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
public void SaveInterviewAssessmentBySessionAndKPI(List<int> kpiIds, int sessionID, int stepID, int recruitementID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
int id = tc.GenerateID("InterviewAssessmentBySessionAndKPI", "InterviewAssessmentBySessionAndKpiID");
foreach (int kpi in kpiIds)
{
InterviewAssessmentBySessionAndKPI kpiSession = new InterviewAssessmentBySessionAndKPI();
kpiSession.ID = (id);
kpiSession.KpiID = kpi;
kpiSession.SessionID = sessionID;
kpiSession.StepID = stepID;
kpiSession.RecruitementID = recruitementID;
InterviewAssessmentKPIDA.InsertInterviewAssessmentBySessionAndKPI(kpiSession, tc);
id++;
}
//else
//{
// oID = obKpi.ID;
// InterviewAssessmentKPIDA.Update(obKpi, tc);
//}
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
public void SaveInterviewAssessmentBySessionAndKPI(TransactionContext tc, List<int> kpiIds, int sessionID, int stepID, int recruitementID)
{
try
{
int id = tc.GenerateID("InterviewAssessmentBySessionAndKPI", "InterviewAssessmentBySessionAndKpiID");
foreach (int kpi in kpiIds)
{
InterviewAssessmentBySessionAndKPI kpiSession = new InterviewAssessmentBySessionAndKPI();
kpiSession.ID = (id);
kpiSession.KpiID = kpi;
kpiSession.SessionID = sessionID;
kpiSession.StepID = stepID;
kpiSession.RecruitementID = recruitementID;
InterviewAssessmentKPIDA.InsertInterviewAssessmentBySessionAndKPI(kpiSession, tc);
id++;
}
//else
//{
// oID = obKpi.ID;
// InterviewAssessmentKPIDA.Update(obKpi, tc);
//}
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
#endregion
#region InterviewBoardAssessmentKPI Service Implementation
public void SaveBoardKpi(InterviewBoardAssessmentKPI obKpi)
{
TransactionContext tc = null;
int oID = 0;
try
{
tc = TransactionContext.Begin(true);
if (obKpi.IsNew)
{
int id = tc.GenerateID("InterviewBoardAssessmentKPI", "InterviewBoardAssessmentKPIID");
oID = (id);
base.SetObjectID(obKpi, (id));
InterviewAssessmentKPIDA.InsertBoardKpi(obKpi, tc);
}
else
{
oID = obKpi.ID;
InterviewAssessmentKPIDA.UpdateBoardKpi(obKpi, tc);
}
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
public void SaveBoardKpis(List<InterviewBoardAssessmentKPI> Items)
{
TransactionContext tc = null;
try
{
int RequisitionID = 0;
tc = TransactionContext.Begin(true);
foreach (var obKpi in Items)
{
int oID = 0;
if (obKpi.IsNew)
{
int id = tc.GenerateID("InterviewBoardAssessmentKPI", "InterviewBoardAssessmentKPIID");
oID = (id);
base.SetObjectID(obKpi, (id));
InterviewAssessmentKPIDA.InsertBoardKpi(obKpi, tc);
}
else
{
oID = obKpi.ID;
InterviewAssessmentKPIDA.UpdateBoardKpi(obKpi, tc);
}
}
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
public List<InterviewBoardAssessmentKPI> GetBoardKpi()
{
List<InterviewBoardAssessmentKPI> allRefs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(InterviewAssessmentKPIDA.GetBoardKpi(tc));
allRefs = this.CreateObjects<InterviewBoardAssessmentKPI>(oreader);
oreader.Close();
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return allRefs;
}
public InterviewBoardAssessmentKPI GetBoardKpiById(int id)
{
InterviewBoardAssessmentKPI obKpi = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(InterviewAssessmentKPIDA.GetBoardbyId(tc, id));
if (oreader.Read())
{
obKpi = this.CreateObject<InterviewBoardAssessmentKPI>(oreader);
}
oreader.Close();
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return obKpi;
}
public List<InterviewBoardAssessmentKPI> GetBoardbyBoardMemberIdCandidateIdSessionId(int candidateID, int interviewBoardMemberID, int sessionID)
{
List<InterviewBoardAssessmentKPI> allRefs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(InterviewAssessmentKPIDA.GetBoardbyBoardMemberIdCandidateIdSessionId(tc, candidateID, interviewBoardMemberID, sessionID));
allRefs = this.CreateBoardKpiObjects(oreader);
oreader.Close();
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return allRefs;
}
public void DeleteBoardKpi(InterviewBoardAssessmentKPI interviewAssessmentBoardKpi)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
InterviewAssessmentKPIDA.DeleteBoardKpi(interviewAssessmentBoardKpi, tc);
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
#endregion
}
}