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(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 CreateRecruitementOrgObjects(DataReader oReader) { ObjectsTemplate allRecruOrgs = new ObjectsTemplate(); 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 CreateRecruitementStepObjects(DataReader oReader) { ObjectsTemplate allRecruSteps = new ObjectsTemplate(); 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 CreateBoardMemberObjects(DataReader oReader) { ObjectsTemplate allMembers = new ObjectsTemplate(); 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 CreateMemberWiseMarkObjects(DataReader oReader) { ObjectsTemplate allMemberWiseMarks = new ObjectsTemplate(); 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 CreateCandidateObjects(DataReader oReader) { ObjectsTemplate allCandidates = new ObjectsTemplate(); 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 CreateSelectedCandidateObjects(DataReader oReader) { ObjectsTemplate allSelectedCandidates = new ObjectsTemplate(); 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 CreateRecruitmentTypeObjects(DataReader oReader) { ObjectsTemplate allTypes = new ObjectsTemplate(); 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 stepItemsToDelete) public void Save(RecruitementProcess obRecrProc, ObjectsTemplate 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 obmems = CreateBoardMemberObjects(oreader); oreader.Close(); ObjectsTemplate del = new ObjectsTemplate(); ObjectsTemplate insertItems = new ObjectsTemplate(); 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 ObjectsTemplateGet() public ObjectsTemplate Get() { ObjectsTemplate allProcess = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(true); DataReader oreader = new DataReader(RecruitementProcessDA.Get(tc)); allProcess = this.CreateObjects(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 Get(ID processID) { ObjectsTemplate 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 GetByAssesmentStatus(int nAssesmentStatus,int nEmpID) { ObjectsTemplate 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 GetBoardMembers(ID processID, ID stepID) { ObjectsTemplate 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 allProcess = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(true); DataReader oreader = new DataReader(RecruitementProcessDA.GetByProcessId(tc, procID)); allProcess = this.CreateObjects(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 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 GetCanditates(ID processID) { ObjectsTemplate 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 GetCanditates(ID processID, int assessmentStatus, int logInID) { ObjectsTemplate 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 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 allCans) public void SaveCandidatesToProcess(ID processID, ObjectsTemplate allCans) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); ObjectsTemplate allCandidates = null; DataReader oreader = new DataReader(CandidateDA.GetCanditates(tc, processID)); allCandidates = CreateCandidateObjects(oreader); oreader.Close(); ObjectsTemplate finalCansForOtherDelition = new ObjectsTemplate(); 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 Get(ID stepID, ID processID) { ObjectsTemplate 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 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 GetAllSelectedCandidates(ID processID, ID stepID, bool flag) { ObjectsTemplate 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 GetSelectedCandidates(ID processID, ID stepID, bool flag) { TransactionContext tc = null; ObjectsTemplate 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 GetSelectedCandidates(ID processID, ID stepID) { TransactionContext tc = null; ObjectsTemplate 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 GetRecruitmentType() { TransactionContext tc = null; ObjectsTemplate 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 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 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 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 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 GetAllSteps(ID processID) { TransactionContext tc = null; ObjectsTemplate 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 allProcess = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(true); DataReader oreader = new DataReader(RecruitementProcessDA.CheckCode(tc, code)); allProcess = this.CreateObjects(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 allProcess = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(true); DataReader oreader = new DataReader(RecruitementProcessDA.GetProcess(tc, status)); allProcess = this.CreateObjects(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 allProcess = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(true); DataReader oreader = new DataReader(RecruitementProcessDA.GetProcess(tc, status, empID)); allProcess = this.CreateObjects(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 allProcess = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(true); DataReader oreader = new DataReader(RecruitementProcessDA.GetProcess(tc, processID, stepID, empID)); allProcess = this.CreateObjects(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 allProcess = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(true); DataReader oreader = new DataReader(RecruitementProcessDA.GetProcessID(tc, status, empID, stepID)); allProcess = this.CreateObjects(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 GetProcesses(string query) { TransactionContext tc = null; ObjectsTemplate allProcesses = null; try { tc = TransactionContext.Begin(true); DataReader oreader = new DataReader(RecruitementProcessDA.Get(query, tc)); allProcesses = this.CreateObjects(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 } }