CEL_Payroll/Payroll.Service/Recruitement/Service/RecruitementProcessService.cs

1531 lines
53 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Ease.CoreV35;
using Ease.CoreV35.DataAccess;
using Ease.CoreV35.Model;
using Payroll.BO;
namespace Payroll.Service
{
public class RecruitementProcessService : ServiceTemplate, IRecruitementProcessService
{
#region Object Mapping
#region Map RecruitementProcess Object
private void MapRecruitementProcess(RecruitementProcess obRecProc, DataReader oReader)
{
SetObjectID(obRecProc, oReader.GetID("RecruitementProcessID"));
obRecProc.Code = oReader.GetString("Code");
obRecProc.Description = oReader.GetString("Description");
obRecProc.EndDate = oReader.GetDateTime("EndDate") == null ? DateTime.MinValue : oReader.GetDateTime("EndDate").Value;
obRecProc.ProcessStatus = (EnumRecruitementProcess)oReader.GetInt32("ProcessStatus");
obRecProc.StartDate = oReader.GetDateTime("StartDate").Value;
this.SetObjectState(obRecProc, ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
RecruitementProcess obRecProc = new RecruitementProcess();
MapRecruitementProcess(obRecProc, oReader);
return obRecProc as T;
}
#endregion
#region Map RecruitementOrg Object
private void MapRecruitementOrg(RecruitementOrg obRecOrg, DataReader oReader)
{
SetObjectID(obRecOrg, oReader.GetID("RecruitementOrgID"));
obRecOrg.ProcessId = oReader.GetID("ProcessId");
obRecOrg.OrganizationId = oReader.GetID("OrganizationId");
this.SetObjectState(obRecOrg, ObjectState.Saved);
}
private ObjectsTemplate<RecruitementOrg> CreateRecruitementOrgObjects(DataReader oReader)
{
ObjectsTemplate<RecruitementOrg> allRecruOrgs = new ObjectsTemplate<RecruitementOrg>();
while (oReader.Read())
{
RecruitementOrg obReOr = new RecruitementOrg();
MapRecruitementOrg(obReOr, oReader);
allRecruOrgs.Add(obReOr);
}
return allRecruOrgs;
}
#endregion
#region Map RecruitementStep Object
private void MapRecruitementStep(RecruitementStep obRecStep, DataReader oReader)
{
SetObjectID(obRecStep, oReader.GetID("RecruitementStepID"));
obRecStep.ProcessId = oReader.GetID("ProcessId");
obRecStep.StartDate = oReader.GetDateTime("StartDate").Value;
obRecStep.EndDate = oReader.GetDateTime("EndDate") == null ? DateTime.MinValue : oReader.GetDateTime("EndDate").Value;
obRecStep.MeetingTime = oReader.GetString("MeetingTime");
obRecStep.FullMark = oReader.GetDouble("FullMark").Value;
obRecStep.PassMark = oReader.GetDouble("PassMark").Value;
obRecStep.StepStatus = (EnumRecruitementStep)oReader.GetInt32("StepStatus");
obRecStep.Type = oReader.GetID("TypeID");
obRecStep.StepSerial = oReader.GetInt32("stepSerial") == null ? 0 : oReader.GetInt32("stepSerial").Value;
obRecStep.TopSelect = oReader.GetDouble("TopSelect").Value;
obRecStep.AssesmentStatus = (EnumAssesmentStatus)oReader.GetInt32("AssesmentStatus");
this.SetObjectState(obRecStep, ObjectState.Saved);
}
private ObjectsTemplate<RecruitementStep> CreateRecruitementStepObjects(DataReader oReader)
{
ObjectsTemplate<RecruitementStep> allRecruSteps = new ObjectsTemplate<RecruitementStep>();
while (oReader.Read())
{
RecruitementStep obReStep = new RecruitementStep();
MapRecruitementStep(obReStep, oReader);
allRecruSteps.Add(obReStep);
}
return allRecruSteps;
}
#endregion
#region Map BoardMember Object
private void MapBoardMember(BoardMember obBmember, DataReader oReader)
{
SetObjectID(obBmember, oReader.GetID("BoardMemberID"));
obBmember.EmployeeId = oReader.GetID("EmployeeId");
obBmember.StepId = oReader.GetID("StepId");
obBmember.ProcessId = oReader.GetID("ProcessId");
this.SetObjectState(obBmember, ObjectState.Saved);
}
private ObjectsTemplate<BoardMember> CreateBoardMemberObjects(DataReader oReader)
{
ObjectsTemplate<BoardMember> allMembers = new ObjectsTemplate<BoardMember>();
while (oReader.Read())
{
BoardMember obBMember = new BoardMember();
MapBoardMember(obBMember, oReader);
allMembers.Add(obBMember);
}
return allMembers;
}
#endregion
#region Map MemberWiseMark Object
private void MapMemberWiseMark(MemberWiseMark obMemWisemark, DataReader oReader)
{
SetObjectID(obMemWisemark, oReader.GetID("MemberWiseMarkID"));
obMemWisemark.ProcessId = oReader.GetID("ProcessId");
obMemWisemark.StepId = oReader.GetID("StepId");
obMemWisemark.EmployeeId = oReader.GetID("EmployeeId");
obMemWisemark.CandidateId = oReader.GetID("CandidateId");
obMemWisemark.Marks = oReader.GetDouble("Marks").Value;
//obMemWisemark.IsSelected = oReader.GetBoolean("IsSelected").Value;
obMemWisemark.IsEmployee = oReader.GetBoolean("isEmployee").Value;
this.SetObjectState(obMemWisemark, ObjectState.Saved);
}
private ObjectsTemplate<MemberWiseMark> CreateMemberWiseMarkObjects(DataReader oReader)
{
ObjectsTemplate<MemberWiseMark> allMemberWiseMarks = new ObjectsTemplate<MemberWiseMark>();
while (oReader.Read())
{
MemberWiseMark obMemMarks = new MemberWiseMark();
MapMemberWiseMark(obMemMarks, oReader);
allMemberWiseMarks.Add(obMemMarks);
}
return allMemberWiseMarks;
}
#endregion
#region Map Candidate Object
private void MapCandidate(Candidate obCandidate, DataReader oReader)
{
SetObjectID(obCandidate, oReader.GetID("CandidateID"));
obCandidate.ProcessId = oReader.GetID("ProcessId");
obCandidate.IsSelected = oReader.GetBoolean("IsSelected").Value;
obCandidate.IsEmployee = oReader.GetBoolean("IsEmployee").Value;
obCandidate.CvId = oReader.GetID("CvId") == null ? null : oReader.GetID("CvId");
obCandidate.EmployeeId = oReader.GetID("EmployeeId") == null ? null : oReader.GetID("EmployeeId");
obCandidate.StartDate = oReader.GetDateTime("StartDate") == null ? DateTime.MinValue : oReader.GetDateTime("StartDate").Value;
obCandidate.StartTime = oReader.GetString("StartTime") == null ? String.Empty : oReader.GetString("StartTime");
this.SetObjectState(obCandidate, ObjectState.Saved);
}
private ObjectsTemplate<Candidate> CreateCandidateObjects(DataReader oReader)
{
ObjectsTemplate<Candidate> allCandidates = new ObjectsTemplate<Candidate>();
while (oReader.Read())
{
Candidate obCandidate = new Candidate();
MapCandidate(obCandidate, oReader);
allCandidates.Add(obCandidate);
}
return allCandidates;
}
#endregion
#region Map SelectedCandidate Objects
private void MapSelectedCandidate(SelectedCandidate obSelectedCandidate, DataReader oReader)
{
SetObjectID(obSelectedCandidate, oReader.GetID("RecruitementSelectedCandidateID"));
obSelectedCandidate.IsEmployee = oReader.GetBoolean("isEmployee").Value;
obSelectedCandidate.ProcessId = oReader.GetID("processID");
obSelectedCandidate.StepId = oReader.GetID("stepID");
obSelectedCandidate.CandidateId = oReader.GetID("candidateID");
obSelectedCandidate.IsSelected = oReader.GetBoolean("isSelected").Value;
this.SetObjectState(obSelectedCandidate, ObjectState.Saved);
}
private ObjectsTemplate<SelectedCandidate> CreateSelectedCandidateObjects(DataReader oReader)
{
ObjectsTemplate<SelectedCandidate> allSelectedCandidates = new ObjectsTemplate<SelectedCandidate>();
while (oReader.Read())
{
SelectedCandidate obCan = new SelectedCandidate();
MapSelectedCandidate(obCan, oReader);
allSelectedCandidates.Add(obCan);
}
return allSelectedCandidates;
}
#endregion
#region Map RecruitmentType Objects
private void MapRecruitmentType(RecruitmentType obType, DataReader oReader)
{
SetObjectID(obType, oReader.GetID("ID"));
obType.Name = oReader.GetString("name");
this.SetObjectState(obType, ObjectState.Saved);
}
private ObjectsTemplate<RecruitmentType> CreateRecruitmentTypeObjects(DataReader oReader)
{
ObjectsTemplate<RecruitmentType> allTypes = new ObjectsTemplate<RecruitmentType>();
while (oReader.Read())
{
RecruitmentType oType = new RecruitmentType();
MapRecruitmentType(oType, oReader);
allTypes.Add(oType);
}
return allTypes;
}
#endregion
#endregion
#region Service Implementation
#region Save
public void Save(RecruitementProcess obRecrProc)
{
TransactionContext tc = null;
ID oID = null;
try
{
tc = TransactionContext.Begin(true);
if (obRecrProc.IsNew)
{
int id = tc.GenerateID("RecruitementProcess", "RecruitementProcessID");
oID = ID.FromInteger(id);
base.SetObjectID(obRecrProc, ID.FromInteger(id));
RecruitementProcessDA.Insert(obRecrProc, tc);
}
else
{
oID = obRecrProc.ID;
RecruitementProcessDA.Update(obRecrProc, tc);
}
#region RecruitementOrg
foreach (RecruitementOrg obRecrOrg in obRecrProc.AllRecruitementOrgs)
{
if (obRecrOrg.IsNew)
{
int id = tc.GenerateID("RecruitementOrg", "RecruitementOrgID");
obRecrOrg.ProcessId = oID;
base.SetObjectID(obRecrOrg, ID.FromInteger(id));
RecruitementOrgDA.Insert(obRecrOrg, tc);
}
else
{
RecruitementOrgDA.Update(obRecrOrg, tc);
}
}
#endregion
#region RecruitementStep
foreach (RecruitementStep obRecrStep in obRecrProc.AllRecruitementSteps)
{
if (!obRecrStep.IsNew)
{
MemberWiseMarkDA.Delete(obRecrStep.ID, oID, tc);
BoardMemberDA.Delete(obRecrStep.ID, tc);
}
}
RecruitementStepDA.Delete(tc, oID);
foreach (RecruitementStep obRecrStep in obRecrProc.AllRecruitementSteps)
{
ID recrStepId = null;
int id = tc.GenerateID("RecruitementStep", "RecruitementStepID");
recrStepId = ID.FromInteger(id);
obRecrStep.ProcessId = oID;
base.SetObjectID(obRecrStep, ID.FromInteger(id));
RecruitementStepDA.Insert(obRecrStep, tc);
#region BoardMember
foreach (BoardMember obBm in obRecrStep.MembersforSaving)
{
int Id = tc.GenerateID("RecruitementBoardMember", "BoardMemberID");
obBm.ProcessId = oID;
obBm.StepId = recrStepId;
base.SetObjectID(obBm, ID.FromInteger(Id));
BoardMemberDA.Insert(obBm, tc);
}
#endregion
}
#endregion
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
#endregion
#region Save(RecruitementProcess obRecruProc, List<int> stepItemsToDelete)
public void Save(RecruitementProcess obRecrProc, ObjectsTemplate<RecruitementStep> stepItemsToDelete)
{
TransactionContext tc = null;
ID oID = null;
try
{
tc = TransactionContext.Begin(true);
if (obRecrProc.IsNew)
{
int id = tc.GenerateID("RecruitementProcess", "RecruitementProcessID");
oID = ID.FromInteger(id);
base.SetObjectID(obRecrProc, ID.FromInteger(id));
RecruitementProcessDA.Insert(obRecrProc, tc);
}
else
{
oID = obRecrProc.ID;
RecruitementProcessDA.Update(obRecrProc, tc);
}
#region RecruitementOrg
foreach (RecruitementOrg obRecrOrg in obRecrProc.AllRecruitementOrgs)
{
if (obRecrOrg.IsNew)
{
int id = tc.GenerateID("RecruitementOrg", "RecruitementOrgID");
obRecrOrg.ProcessId = oID;
base.SetObjectID(obRecrOrg, ID.FromInteger(id));
RecruitementOrgDA.Insert(obRecrOrg, tc);
}
else
{
RecruitementOrgDA.Update(obRecrOrg, tc);
}
}
CreatedRequisitionDA.Delete(tc, obRecrProc.ID);
foreach (CreatedRequisition item in obRecrProc.SelectedRequisitions)
{
int id = tc.GenerateID("CreatedRequisition", "CreatedRequisitionID");
base.SetObjectID(item, ID.FromInteger(id));
item.RecruitementProcessID = obRecrProc.ID;
CreatedRequisitionDA.Insert(tc,item);
}
#endregion
#region RecruitementStep
foreach (RecruitementStep obRecrStep in stepItemsToDelete)
{
RecruitementSelectedCandidateDA.Delete(obRecrStep.ID, oID, tc);
MemberWiseMarkDA.Delete(obRecrStep.ID, oID, tc);
BoardMemberDA.Delete(oID, obRecrStep.ID, tc);
RecruitementStepDA.Delete(oID, obRecrStep.ID, tc);
}
foreach (RecruitementStep obRecrStep in obRecrProc.AllRecruitementSteps)
{
ID recrStepId = null;
if (obRecrStep.IsNew)
{
int id = tc.GenerateID("RecruitementStep", "RecruitementStepID");
recrStepId = ID.FromInteger(id);
obRecrStep.ProcessId = oID;
base.SetObjectID(obRecrStep, ID.FromInteger(id));
RecruitementStepDA.Insert(obRecrStep, tc);
foreach (BoardMember obBm in obRecrStep.AllMembers)
{
int Id = tc.GenerateID("RecruitementBoardMember", "BoardMemberID");
obBm.ProcessId = oID;
obBm.StepId = recrStepId;
base.SetObjectID(obBm, ID.FromInteger(Id));
BoardMemberDA.Insert(obBm, tc);
}
}
else
{
recrStepId = obRecrStep.ID;
RecruitementStepDA.Update(obRecrStep, tc);
DataReader oreader = new DataReader(BoardMemberDA.Get(tc, oID, recrStepId));
ObjectsTemplate<BoardMember> obmems = CreateBoardMemberObjects(oreader);
oreader.Close();
ObjectsTemplate<BoardMember> del = new ObjectsTemplate<BoardMember>();
ObjectsTemplate<BoardMember> insertItems = new ObjectsTemplate<BoardMember>();
foreach (var smember in obmems)
{
bool flag = true;
foreach (var tmember in obRecrStep.AllMembers)
{
if (smember.EmployeeId.Integer == tmember.EmployeeId.Integer)
{
flag = false;
break;
}
}
if (flag)
{
del.Add(smember);
}
}
foreach (var incomingmember in obRecrStep.AllMembers)
{
bool flag = true;
foreach (var smember in obmems)
{
if (smember.EmployeeId.Integer == incomingmember.EmployeeId.Integer)
{
flag = false;
break;
}
}
if (flag)
{
insertItems.Add(incomingmember);
}
}
foreach (var dmember in del)
{
MemberWiseMarkDA.Delete(obRecrProc.ID, obRecrStep.ID, dmember.EmployeeId, tc);
BoardMemberDA.Delete(oID, obRecrStep.ID, dmember.EmployeeId, tc);
}
foreach (var boardMember in insertItems)
{
int Id = tc.GenerateID("RecruitementBoardMember", "BoardMemberID");
base.SetObjectID(boardMember, ID.FromInteger(Id));
boardMember.ProcessId = oID;
boardMember.StepId = obRecrStep.ID;
BoardMemberDA.Insert(boardMember, tc);
}
}
//
}
#endregion
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
#endregion
#region void SaveRecruitementStep(RecruitementStep step, ID processID, ID stepID)
public void SaveRecruitementStep(RecruitementStep step, ID processID, ID stepID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
MemberWiseMarkDA.Delete(stepID, processID, tc);
foreach (MemberWiseMark obmem in step.AllMemberWiseMarks)
{
int id = tc.GenerateID("RecruitementMemberWiseMark", "MemberWiseMarkID");
base.SetObjectID(obmem, ID.FromInteger(id));
MemberWiseMarkDA.Insert(obmem, tc);
}
RecruitementSelectedCandidateDA.Delete(ID.FromInteger(step.StepSerial), processID, tc);
//RecruitementSelectedCandidateDA.Delete(stepID, processID, tc);
foreach (var selCan in step.SelectedCandidates)
{
int id = tc.GenerateID("RecruitementSelectedCandidate", "RecruitementSelectedCandidateID");
base.SetObjectID(selCan, ID.FromInteger(id));
selCan.ProcessId = processID;
selCan.StepId = ID.FromInteger(step.StepSerial);//stepID;
RecruitementSelectedCandidateDA.Insert(selCan, 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
#region ObjectsTemplate<RecruitementProcess>Get()
public ObjectsTemplate<RecruitementProcess> Get()
{
ObjectsTemplate<RecruitementProcess> allProcess = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementProcessDA.Get(tc));
allProcess = this.CreateObjects<RecruitementProcess>(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 allProcess;
}
#endregion
#region ObjectsTemplate< RecruitementStep > Get(ID processID)
public ObjectsTemplate<RecruitementStep> Get(ID processID)
{
ObjectsTemplate<RecruitementStep> allSteps = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementStepDA.Get(tc, processID));
allSteps = CreateRecruitementStepObjects(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 allSteps;
}
#endregion
#region ObjectsTemplate< RecruitementStep > GetByAssesmentStatus(int nAssesmentStatus)
public ObjectsTemplate<RecruitementStep> GetByAssesmentStatus(int nAssesmentStatus,int nEmpID)
{
ObjectsTemplate<RecruitementStep> allSteps = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementStepDA.GetByAssesmentStatus(tc, nAssesmentStatus, nEmpID));
allSteps = CreateRecruitementStepObjects(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 allSteps;
}
#endregion
#region ObjectsTemplate< BoardMember > GetBoardMembers(ID processID,ID stepID)
public ObjectsTemplate<BoardMember> GetBoardMembers(ID processID, ID stepID)
{
ObjectsTemplate<BoardMember> allMems = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(BoardMemberDA.Get(tc, processID, stepID));
allMems = CreateBoardMemberObjects(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 allMems;
}
#endregion
#region GetByProcessId(ID procID)
public RecruitementProcess GetByProcessId(ID procID)
{
ObjectsTemplate<RecruitementProcess> allProcess = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementProcessDA.GetByProcessId(tc, procID));
allProcess = this.CreateObjects<RecruitementProcess>(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
}
if (allProcess.Count == 1)
{
return allProcess[0];
}
return null;
}
#endregion
public RecruitementStep GetRStep(ID stepID)
{
ObjectsTemplate<RecruitementStep> allProcess = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementStepDA.GetRStep(tc, stepID));
allProcess = CreateRecruitementStepObjects(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
}
if (allProcess.Count == 1)
{
return allProcess[0];
}
return null;
}
#region ObjectsTemplate< Candidate > GetCanditates(ID processID)
public ObjectsTemplate<Candidate> GetCanditates(ID processID)
{
ObjectsTemplate<Candidate> allCans = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CandidateDA.GetCanditates(tc, processID));
allCans = CreateCandidateObjects(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 allCans;
}
#endregion
#region ObjectsTemplate< Candidate > GetCanditates(ID processID, int assessmentStatus, int logInID)
public ObjectsTemplate<Candidate> GetCanditates(ID processID, int assessmentStatus, int logInID)
{
ObjectsTemplate<Candidate> allCans = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CandidateDA.GetCanditates(tc, processID, assessmentStatus, logInID));
allCans = CreateCandidateObjects(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 allCans;
}
#endregion
public Candidate GetByCandediateID(ID nCandidateID)
{
ObjectsTemplate<Candidate> allCandidate = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementProcessDA.GetByCandediateID(tc, nCandidateID));
allCandidate = CreateCandidateObjects(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
}
if (allCandidate.Count >= 1)
{
return allCandidate[0];
}
return null;
}
#region void SaveCandidatesToProcess(ID processID, ObjectsTemplate<Candidate> allCans)
public void SaveCandidatesToProcess(ID processID, ObjectsTemplate<Candidate> allCans)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
ObjectsTemplate<Candidate> allCandidates = null;
DataReader oreader = new DataReader(CandidateDA.GetCanditates(tc, processID));
allCandidates = CreateCandidateObjects(oreader);
oreader.Close();
ObjectsTemplate<Candidate> finalCansForOtherDelition = new ObjectsTemplate<Candidate>();
foreach (var obcan in allCandidates)
{
bool flag = false;
foreach (var tarcan in allCans)
{
if (obcan.IsEmployee && tarcan.IsEmployee && obcan.ProcessId.Integer == tarcan.ProcessId.Integer && obcan.EmployeeId.Integer == tarcan.EmployeeId.Integer)
{
flag = true;
break;
}
if (!obcan.IsEmployee && !tarcan.IsEmployee && obcan.ProcessId.Integer == tarcan.ProcessId.Integer && obcan.CvId.Integer == tarcan.CvId.Integer)
{
flag = true;
break;
}
}
if (!flag)
{
finalCansForOtherDelition.Add(obcan);
}
}
foreach (var src in finalCansForOtherDelition)
{
if (src.IsEmployee)
{
MemberWiseMarkDA.Delete(processID, src.EmployeeId, src.IsEmployee, tc);
RecruitementSelectedCandidateDA.Delete(processID, src.EmployeeId, src.IsEmployee, tc);
}
else
{
MemberWiseMarkDA.Delete(processID, src.CvId, src.IsEmployee, tc);
RecruitementSelectedCandidateDA.Delete(processID, src.CvId, src.IsEmployee, tc);
}
}
CandidateDA.Delete(tc, processID);
foreach (Candidate candidate in allCans)
{
int id = tc.GenerateID("RecruitementCandidate", "CandidateID");
candidate.ProcessId = processID;
base.SetObjectID(candidate, ID.FromInteger(id));
CandidateDA.Insert(candidate, 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
#region void Delete(RecruitementProcess obRecruProc)
public void Delete(RecruitementProcess obRecruProc)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
foreach (RecruitementStep obRecrStep in obRecruProc.AllRecruitementSteps)
{
MemberWiseMarkDA.Delete(obRecrStep.ID, obRecruProc.ID, tc);
RecruitementSelectedCandidateDA.Delete(obRecrStep.ID, obRecruProc.ID, tc);
BoardMemberDA.Delete(obRecrStep.ID, tc);
RecruitementStepDA.DeleteStep(tc, obRecrStep.ID);
}
CandidateDA.Delete(tc, obRecruProc.ID);
RecruitementProcessDA.Delete(obRecruProc.ID, tc);
CreatedRequisitionDA.Delete(tc, obRecruProc.ID);
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
#endregion
#region ObjectsTemplate< MemberWiseMark > Get(ID stepID, ID processID)
public ObjectsTemplate<MemberWiseMark> Get(ID stepID, ID processID)
{
ObjectsTemplate<MemberWiseMark> allMarks = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(MemberWiseMarkDA.Get(stepID, processID, tc));
allMarks = CreateMemberWiseMarkObjects(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 allMarks;
}
#endregion
#region SaveMemberWiseMark(ObjectsTemplate< MemberWiseMark > allmemMarks, ID processID, ID stepID)
public void SaveMemberWiseMark(ObjectsTemplate<MemberWiseMark> allmemMarks, ID processID, ID stepID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
MemberWiseMarkDA.Delete(stepID, processID, tc);
foreach (MemberWiseMark obmem in allmemMarks)
{
int id = tc.GenerateID("RecruitementMemberWiseMark", "MemberWiseMarkID");
base.SetObjectID(obmem, ID.FromInteger(id));
MemberWiseMarkDA.Insert(obmem, 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
#region ObjectsTemplate < SelectedCandidate > GetAllSelectedCandidates
public ObjectsTemplate<SelectedCandidate> GetAllSelectedCandidates(ID processID, ID stepID, bool flag)
{
ObjectsTemplate<SelectedCandidate> allSelectedCans = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementSelectedCandidateDA.GetAllSelectedCandidates(processID, stepID, tc));
allSelectedCans = this.CreateSelectedCandidateObjects(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 allSelectedCans;
}
#endregion
#region Get AllSelectedCandidates
public ObjectsTemplate<SelectedCandidate> GetSelectedCandidates(ID processID, ID stepID, bool flag)
{
TransactionContext tc = null;
ObjectsTemplate<SelectedCandidate> allSeleCans = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(RecruitementSelectedCandidateDA.GetAllSelectedCandidates(processID, stepID, flag, tc));
allSeleCans = CreateSelectedCandidateObjects(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 allSeleCans;
}
#endregion
#region Get AllSelectedCandidates
public ObjectsTemplate<SelectedCandidate> GetSelectedCandidates(ID processID, ID stepID)
{
TransactionContext tc = null;
ObjectsTemplate<SelectedCandidate> allSeleCans = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(RecruitementSelectedCandidateDA.GetAllSelectedCandidates(processID, stepID, tc));
allSeleCans = CreateSelectedCandidateObjects(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 allSeleCans;
}
#endregion
#region Get Type
public ObjectsTemplate<RecruitmentType> GetRecruitmentType()
{
TransactionContext tc = null;
ObjectsTemplate<RecruitmentType> allTypes = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(RecruitmentTypeDA.Get(tc));
allTypes = CreateRecruitmentTypeObjects(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 allTypes;
}
#endregion
#region Get Type
public RecruitmentType GetType(ID id)
{
TransactionContext tc = null;
ObjectsTemplate<RecruitmentType> allTypes = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(RecruitmentTypeDA.GetType(tc, id));
allTypes = CreateRecruitmentTypeObjects(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
}
if (allTypes.Count == 1)
{
return allTypes[0];
}
else return null;
}
#endregion
#region DataSet GetShortListedCandidates(ID processID)
public DataSet GetShortListedCandidates(ID processID)
{
TransactionContext tc = null;
DataSet ds = null;
try
{
tc = TransactionContext.Begin(true);
ds = RecruitementProcessDA.GetShortListedCandidates(processID, tc);
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return ds;
}
#endregion
#region RecruitementStep GetRecruitmentStep(ID processID, int serial)
public RecruitementStep GetRecruitmentStep(ID processID, int serial)
{
TransactionContext tc = null;
ObjectsTemplate<RecruitementStep> allSteps = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementStepDA.Get(processID, serial, tc));
allSteps = CreateRecruitementStepObjects(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
}
if (allSteps.Count == 1)
{
return allSteps[0];
}
else return null;
}
#endregion
#region RecruitementStep GetRecruitmentStep(ID processID, ID stepID)
public RecruitementStep GetRecruitmentStep(ID processID, ID stepID)
{
TransactionContext tc = null;
ObjectsTemplate<RecruitementStep> allSteps = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementStepDA.Get(processID, stepID, tc));
allSteps = CreateRecruitementStepObjects(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
}
if (allSteps.Count == 1)
{
return allSteps[0];
}
else return null;
}
#endregion
#region RecruitementStep GetRecruitmentStep(ID processID, int StepStatus, int assessmentStatus)
public RecruitementStep GetRecruitmentStep(ID processID, int StepStatus, int assessmentStatus)
{
TransactionContext tc = null;
ObjectsTemplate<RecruitementStep> allSteps = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementStepDA.Get(processID, StepStatus, assessmentStatus, tc));
allSteps = CreateRecruitementStepObjects(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
}
if (allSteps.Count == 1)
{
return allSteps[0];
}
else return null;
}
#endregion
#region UpdateStep
public void UpdateStep(RecruitementStep obStep)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
RecruitementStepDA.Update(obStep, 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
#region ObjectsTemplate< RecruitementStep > GetAllSteps(ID processID)
public ObjectsTemplate<RecruitementStep> GetAllSteps(ID processID)
{
TransactionContext tc = null;
ObjectsTemplate<RecruitementStep> allSteps = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementStepDA.GetAllSteps(processID, tc));
allSteps = CreateRecruitementStepObjects(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 allSteps;
}
#endregion
#region public static void UpdateProcess(RecruitementProcess obProcess)
public void UpdateProcess(RecruitementProcess obProcess)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
RecruitementProcessDA.Update(obProcess, 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
#region RecruitementProcess CheckCode(string code)
public RecruitementProcess CheckCode(string code)
{
ObjectsTemplate<RecruitementProcess> allProcess = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementProcessDA.CheckCode(tc, code));
allProcess = this.CreateObjects<RecruitementProcess>(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
}
if (allProcess.Count >= 1)
{
return allProcess[0];
}
return null;
}
#endregion
#region GetProcess
public RecruitementProcess GetProcess(int status)
{
ObjectsTemplate<RecruitementProcess> allProcess = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementProcessDA.GetProcess(tc, status));
allProcess = this.CreateObjects<RecruitementProcess>(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
}
if (allProcess.Count >= 1)
{
return allProcess[0];
}
return null;
}
#endregion
#region GetProcess
public RecruitementProcess GetProcess(int status, int empID)
{
ObjectsTemplate<RecruitementProcess> allProcess = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementProcessDA.GetProcess(tc, status, empID));
allProcess = this.CreateObjects<RecruitementProcess>(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
}
if (allProcess.Count >= 1)
{
return allProcess[0];
}
return null;
}
#endregion
#region GetProcess
public RecruitementProcess GetProcess(ID processID, ID stepID, int empID)
{
ObjectsTemplate<RecruitementProcess> allProcess = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementProcessDA.GetProcess(tc, processID, stepID, empID));
allProcess = this.CreateObjects<RecruitementProcess>(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
}
if (allProcess.Count >= 1)
{
return allProcess[0];
}
return null;
}
#endregion
#region GetProcess
public RecruitementProcess GetProcessID(int status, int empID, ID stepID)
{
ObjectsTemplate<RecruitementProcess> allProcess = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementProcessDA.GetProcessID(tc, status, empID, stepID));
allProcess = this.CreateObjects<RecruitementProcess>(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
}
if (allProcess.Count >= 1)
{
return allProcess[0];
}
return null;
}
#endregion
#region ObjectsTemplate< RecruitementProcess > GetProcesses(string query)
public ObjectsTemplate<RecruitementProcess> GetProcesses(string query)
{
TransactionContext tc = null;
ObjectsTemplate<RecruitementProcess> allProcesses = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(RecruitementProcessDA.Get(query, tc));
allProcesses = this.CreateObjects<RecruitementProcess>(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 allProcesses;
}
#endregion
#endregion
}
}