CEL_Payroll/Payroll.Service/Recruitement/Service/CVService.cs

553 lines
19 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Collections.Generic;
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 CVService : ServiceTemplate, ICVService
{
#region CV Object Mapping
private void MapCVObject(CV obCv,DataReader oReader)
{
SetObjectID(obCv,oReader.GetID("CvID"));
obCv.TrackNo = oReader.GetString("TrackNo");
obCv.TotalYearOfExperience = oReader.GetDouble("TotalYearOfExperience").Value;
obCv.SpecialSkill = oReader.GetString("SpecialSkill") == null ? String.Empty : oReader.GetString("SpecialSkill");
obCv.OrganPositionId = oReader.GetID("OrganPositionId") == null ? null : oReader.GetID("OrganPositionId");
obCv.NationalId = oReader.GetString("NationalId") == null ? String.Empty : oReader.GetString("NationalId");
obCv.Name = oReader.GetString("Name");
obCv.MotherName = oReader.GetString("MotherName") == null ? String.Empty : oReader.GetString("MotherName");
obCv.MobileNo = oReader.GetString("MobileNo") == null ? String.Empty : oReader.GetString("MobileNo");
obCv.LandPhoneNo = oReader.GetString("LandPhoneNo") == null ? String.Empty : oReader.GetString("LandPhoneNo");
obCv.FileAddress = oReader.GetString("FileAddress") == null ? String.Empty : oReader.GetString("FileAddress");
obCv.FatherName = oReader.GetString("FatherName") == null ? String.Empty : oReader.GetString("FatherName");
obCv.ExpectedMinimumSalary = oReader.GetDouble("ExpectedMinimumSalary").Value;
obCv.EmailAddress = oReader.GetString("EmailAddress") == null ? String.Empty : oReader.GetString("EmailAddress");
obCv.IsFresher = oReader.GetBoolean("IsFresher").Value;
obCv.ContactAddress = oReader.GetString("ContactAddress") == null ? String.Empty : oReader.GetString("ContactAddress");
obCv.ApplicationDate = oReader.GetDateTime("ApplicationDate").Value;
obCv.CreatedBy = oReader.GetInt32("CreatedBy") == null ? null : oReader.GetID("CreatedBy");
obCv.ModifiedBy = oReader.GetInt32("ModifiedBy") == null ? null : oReader.GetID("ModifiedBy");
obCv.Designation = oReader.GetInt32("DesignationID") == null ? null : oReader.GetID("DesignationID");
if(oReader.GetDateTime("CreationDate") == null)
{
obCv.CreatedDate = DateTime.MinValue;
}
else
{
obCv.CreatedDate = oReader.GetDateTime("CreationDate").Value;
}
if (oReader.GetDateTime("ModificationDate") == null)
{
obCv.ModifiedDate = DateTime.MinValue;
}
else
{
obCv.ModifiedDate = oReader.GetDateTime("ModificationDate").Value;
}
this.SetObjectState(obCv, ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
CV obCv = new CV();
MapCVObject(obCv, oReader);
return obCv as T;
}
#endregion
#region Experience Object Mapping
private void MapExperience(Experience obExperience,DataReader oReader)
{
SetObjectID(obExperience, oReader.GetID("ExperienceID"));
obExperience.ContactNo = oReader.GetString("ContactNo");
obExperience.ContactPerson = oReader.GetString("ContactPerson");
obExperience.CvId = oReader.GetID("CvId");
obExperience.Employer = oReader.GetString("Employer");
obExperience.FromDate = oReader.GetDateTime("FromDate").Value;
obExperience.ToDate = oReader.GetDateTime("ToDate") == null ? DateTime.MinValue : oReader.GetDateTime("ToDate").Value;
obExperience.RoleDefination = oReader.GetString("RoleDefination");
this.SetObjectState(obExperience, ObjectState.Saved);
}
private ObjectsTemplate< Experience > CreateExperienceObjects(DataReader oReader)
{
ObjectsTemplate< Experience > allExperiences = new ObjectsTemplate< Experience >();
while (oReader.Read())
{
Experience obExp = new Experience();
MapExperience(obExp, oReader);
allExperiences.Add(obExp);
}
return allExperiences;
}
#endregion
#region Map ReferredBy Object
private void MapReferredBy(ReferredBy obReferredBy,DataReader oReader)
{
SetObjectID(obReferredBy, oReader.GetID("ReferredByID"));
obReferredBy.CvId = oReader.GetID("CvId");
obReferredBy.Name = oReader.GetString("Name");
obReferredBy.OtherDetail = oReader.GetString("OtherDetail");
obReferredBy.ReferredBY = (EnumReferredBy)oReader.GetInt32("ReferredBy");
this.SetObjectState(obReferredBy, ObjectState.Saved);
}
private ObjectsTemplate<ReferredBy> CreateReferredByObjects(DataReader oReader)
{
ObjectsTemplate<ReferredBy> allobRefs = new ObjectsTemplate<ReferredBy>();
while (oReader.Read())
{
ReferredBy obRef = new ReferredBy();
MapReferredBy(obRef, oReader);
allobRefs.Add(obRef);
}
return allobRefs;
}
#endregion
#region Map CVOrg Object
private void MapCVOrg(CVOrg obCVOrg, DataReader oReader)
{
SetObjectID(obCVOrg, oReader.GetID("CVOrgID"));
obCVOrg.CvID = oReader.GetID("CVID");
obCVOrg.DesignationID = oReader.GetID("DesignationID");
obCVOrg.OrganizationId = oReader.GetID("OrganizationID");
obCVOrg.CVOrgType = (EnumCVOrgType)oReader.GetInt32("CVOrgType");
this.SetObjectState(obCVOrg, ObjectState.Saved);
}
private ObjectsTemplate<CVOrg> CreateCVOrgObjects(DataReader oReader)
{
ObjectsTemplate<CVOrg> allobCVOrgs = new ObjectsTemplate<CVOrg>();
while (oReader.Read())
{
CVOrg obCVOrg = new CVOrg();
MapCVOrg(obCVOrg, oReader);
allobCVOrgs.Add(obCVOrg);
}
return allobCVOrgs;
}
#endregion
#region Map EductionalQualification
private void MapEductionalQualification(EductionalQualification obEductionalQualification,DataReader oReader)
{
SetObjectID(obEductionalQualification, oReader.GetID("EductionalQualificationID"));
obEductionalQualification.BoardId = oReader.GetID("BoardId");
obEductionalQualification.CgpaOrMarks = oReader.GetDouble("CgpaOrMarks").Value;
obEductionalQualification.CgpaOrMarksOutOf = oReader.GetDouble("CgpaOrMarksOutOf").Value;
obEductionalQualification.CvId = oReader.GetID("CvId");
obEductionalQualification.DegreeTitleId = oReader.GetID("DegreeTitleId");
obEductionalQualification.DisciplineId = oReader.GetID("DisciplineId");
obEductionalQualification.IsHighestEducation = oReader.GetBoolean("IsHighestEducation").Value;
obEductionalQualification.Name = oReader.GetString("Name");
//obEductionalQualification.PassingYear = oReader.GetInt32("PassingYear").Value;
obEductionalQualification.ResultID = oReader.GetID("Result");
obEductionalQualification.InstituteName = oReader.GetString("InstituteName");
this.SetObjectState(obEductionalQualification, ObjectState.Saved);
}
private ObjectsTemplate<EductionalQualification> CreateEductionalQualificationObjects(DataReader oReader)
{
ObjectsTemplate<EductionalQualification> allQualfs = new ObjectsTemplate<EductionalQualification>();
while (oReader.Read())
{
EductionalQualification obQuef = new EductionalQualification();
MapEductionalQualification(obQuef, oReader);
allQualfs.Add(obQuef);
}
return allQualfs;
}
#endregion
#region Service Implementation
#region GenerateTrackNo()
public int GenerateTrackNo()
{
TransactionContext tc = null;
int id;
try
{
tc = TransactionContext.Begin(true);
//id = tc.GenerateID("CVMain", "TrackNo");
id = tc.GenerateID("CVMain", "CvID");
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return id;
}
#endregion
#region Delete(CV obCv)
public void Delete(CV obCv)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
foreach (Experience exprItem in obCv.AllExperiences)
{
ExperienceDA.Delete(exprItem.ID,tc);
}
foreach (ReferredBy refItem in obCv.AllReferences)
{
ReferredByDA.Delete(refItem.ID, tc);
}
foreach (EductionalQualification eduItem in obCv.AllEduQualifications)
{
EductionalQualificationDA.Delete(eduItem.ID, tc);
}
CVDA.Delete(obCv.ID, 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 Save(CV obCv)
public void Save(CV obCv)
{
TransactionContext tc = null;
ID oID = null;
try
{
tc = TransactionContext.Begin(true);
if(obCv.IsNew)
{
int id = tc.GenerateID("CVMain", "CvID");
oID = ID.FromInteger(id);
base.SetObjectID(obCv, ID.FromInteger(id));
CVDA.InsertCVBase(obCv,tc);
}
else
{
oID = obCv.ID;
CVDA.UpdateCVBase(obCv,tc);
}
ExperienceDA.DeleteByCvId(oID,tc);
foreach(Experience exprItem in obCv.AllExperiences)
{
int id = tc.GenerateID("CVExperience", "ExperienceID");
exprItem.CvId = oID;
base.SetObjectID(exprItem, ID.FromInteger(id));
ExperienceDA.InsertExperience(exprItem,tc);
}
ReferredByDA.DeleteByCvId(oID, tc);
foreach (ReferredBy refItem in obCv.AllReferences)
{
int id = tc.GenerateID("CVReferredBy", "ReferredByID");
refItem.CvId = oID;
base.SetObjectID(refItem, ID.FromInteger(id));
ReferredByDA.InsertReferredBy(refItem,tc);
}
EductionalQualificationDA.DeleteByCvId(oID, tc);
foreach (EductionalQualification eduItem in obCv.AllEduQualifications)
{
int id = tc.GenerateID("CVEductionalQualification", "EductionalQualificationID");
eduItem.CvId = oID;
base.SetObjectID(eduItem, ID.FromInteger(id));
EductionalQualificationDA.InsertEductionalQualification(eduItem,tc);
}
CVOrgDA.DeleteByCvId(oID, tc);
foreach (CVOrg oItem in obCv.CVOrgs)
{
int id = tc.GenerateID("CVOrg", "CVOrgID");
oItem.CvID = oID;
base.SetObjectID(oItem, ID.FromInteger(id));
CVOrgDA.InsertCVOrgDA(oItem, 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 GetReferredBy(ID cVID)
public ObjectsTemplate< ReferredBy > GetReferredBy(ID cVID)
{
ObjectsTemplate<ReferredBy> allRefs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.GetReferredBy(cVID,tc));
allRefs = this.CreateReferredByObjects(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;
}
#endregion
#region GetCVOrgByID(ID cVID)
public ObjectsTemplate<CVOrg> GetCVOrgByID(ID cVID)
{
ObjectsTemplate<CVOrg> allCVOrgs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.GetCVOrgByID(cVID, tc));
allCVOrgs = this.CreateCVOrgObjects(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 allCVOrgs;
}
#endregion
#region GetEducationQualifications(ID cVID)
public ObjectsTemplate< EductionalQualification > GetEducationQualifications(ID cVID)
{
ObjectsTemplate<EductionalQualification> allEduQuals = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.GetEducationQualifications(cVID,tc));
allEduQuals = this.CreateEductionalQualificationObjects(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 allEduQuals;
}
#endregion
#region GetExperiences(ID cVID)
public ObjectsTemplate< Experience > GetExperiences(ID cVID)
{
ObjectsTemplate<Experience> allExps = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.GetExperiences(cVID,tc));
allExps = this.CreateExperienceObjects(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 allExps;
}
#endregion
#region Get()
public ObjectsTemplate< CV > Get()
{
ObjectsTemplate< CV > allCVs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.Get(tc));
allCVs = this.CreateObjects < CV >(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 allCVs;
}
#endregion
#region Get(ID cVID)
public CV Get(ID cVID)
{
ObjectsTemplate<CV> allCVs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.Get(cVID,tc));
allCVs = this.CreateObjects<CV>(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 (allCVs.Count != 0) return allCVs[0];
return null;
}
#endregion
#region ObjectsTemplate< CV > GetByQuery(string query)
public ObjectsTemplate<CV> GetByQuery(string query)
{
ObjectsTemplate<CV> allCVs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.GetByQuery(query, tc));
allCVs = this.CreateObjects<CV>(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 allCVs;
}
#endregion
#endregion
}
}