EchoTex_Payroll/HRM.DA/Service/Recruitement/CVService.cs

1950 lines
70 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
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 HRM.BO.Basic;
using NPOI.SS.Formula.Functions;
namespace HRM.DA
{
public class CVService : ServiceTemplate, ICVService
{
#region CV Object Mapping
private void MapCVObject(CV obCv, DataReader oReader)
{
this.SetObjectID(obCv, oReader.GetInt32("CVID").Value);
obCv.Name = oReader.GetString("Name") != null ? oReader.GetString("Name") : string.Empty;
obCv.FirstName = oReader.GetString("FirstName") != null ? oReader.GetString("FirstName") : string.Empty;
obCv.LastName = oReader.GetString("LastName") != null ? oReader.GetString("LastName") : string.Empty;
obCv.Email = oReader.GetString("Email") != null ? oReader.GetString("Email") : string.Empty;
obCv.Mobile = oReader.GetString("Mobile") != null ? oReader.GetString("Mobile") : string.Empty;
obCv.DesignationID = oReader.GetString("DesignationID") != null ? oReader.GetInt32("DesignationID").Value : 0;
obCv.PresentAddress = oReader.GetString("PresentAddress") != null ? oReader.GetString("PresentAddress") : string.Empty;
obCv.PermanentAddress = oReader.GetString("PermanentAddress") != null ? oReader.GetString("PermanentAddress") : string.Empty;
obCv.Gender = oReader.GetString("Gender") != null ? (EnumGender)oReader.GetInt32("Gender").Value : EnumGender.None;
obCv.MaritalStatus = oReader.GetString("MaritalStatus") != null ? (EnumMaritalStatus)oReader.GetInt32("MaritalStatus").Value : EnumMaritalStatus.None;
obCv.ReligionID = oReader.GetString("ReligionID") != null ? oReader.GetInt32("ReligionID").Value : 0;
obCv.PositionID = oReader.GetInt32("PositionID", true, 0);
obCv.CandidateID = oReader.GetInt32("CandidateID", true, 0);
obCv.SortStatus = oReader.GetString("SortStatus", true, null);
obCv.ErCvID = oReader.GetInt32("ErCvID", true, 0);
obCv.Reference = oReader.GetString("Reference") != null ? oReader.GetString("Reference") : string.Empty;
obCv.Experience = oReader.GetString("Experience") != null ? oReader.GetString("Experience") : string.Empty;
obCv.Education = oReader.GetString("Education") != null ? oReader.GetString("Education") : string.Empty;
obCv.Skill = oReader.GetString("Skill") != null ? oReader.GetString("Skill") : string.Empty;
obCv.PrimarySelected= oReader.GetBoolean("PrimarySelected", true, false);
obCv.Institute = oReader.GetString("InstituteName", true, null);
// obCv.PositionStatus = (EnumOnBoradStatus)oReader.GetInt32("ONBOARDSTATUS", true, 1);
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(CVExperience obExperience, DataReader oReader)
{
SetObjectID(obExperience, (oReader.GetInt32("CVExperienceID").Value));
obExperience.Employeer = oReader.GetString("Employeer") != null ? oReader.GetString("Employeer") : string.Empty;
obExperience.ContactPerson = oReader.GetString("ContactPerson") != null ? oReader.GetString("ContactPerson") : string.Empty;
obExperience.Address = oReader.GetString("Address") != null ? oReader.GetString("Address") : string.Empty;
obExperience.Industry = oReader.GetString("Industry") != null ? oReader.GetString("Industry") : string.Empty;
obExperience.Designation = oReader.GetString("Designation") != null ? oReader.GetString("Designation") : string.Empty;
obExperience.FromDate = oReader.GetString("FromDate") != null ? oReader.GetDateTime("FromDate").Value : DateTime.MinValue;
obExperience.ToDate = oReader.GetString("ToDate") != null ? oReader.GetDateTime("ToDate").Value : DateTime.MinValue;
obExperience.Telephone = oReader.GetString("Telephone") != null ? oReader.GetString("Telephone") : string.Empty;
obExperience.RoleDefination = oReader.GetString("RoleDefination") != null ? oReader.GetString("RoleDefination") : string.Empty;
obExperience.CVID = oReader.GetString("CVID") != null ? oReader.GetInt32("CVID").Value : 0;
this.SetObjectState(obExperience, ObjectState.Saved);
}
private List<CVExperience> CreateExperienceObjects(DataReader oReader)
{
List<CVExperience> allExperiences = new List<CVExperience>();
while (oReader.Read())
{
CVExperience obExp = new CVExperience();
MapExperience(obExp, oReader);
allExperiences.Add(obExp);
}
return allExperiences;
}
#endregion
#region CVReference Object Mapping
private void MapReference(CVReference obExperience, DataReader oReader)
{
SetObjectID(obExperience, (oReader.GetInt32("CVReferenceID").Value));
obExperience.Name = oReader.GetString("Name") != null ? oReader.GetString("Name") : string.Empty;
obExperience.Occupation = oReader.GetString("Occupation") != null ? oReader.GetString("Occupation") : string.Empty;
obExperience.Relation = oReader.GetString("Relation") != null ? oReader.GetString("Relation") : string.Empty;
obExperience.Address = oReader.GetString("Address") != null ? oReader.GetString("Address") : string.Empty;
obExperience.Email = oReader.GetString("Email") != null ? oReader.GetString("Email") : string.Empty;
obExperience.Telephone = oReader.GetString("Telephone") != null ? oReader.GetString("Telephone") : string.Empty;
obExperience.Mobile = oReader.GetString("Mobile") != null ? oReader.GetString("Mobile") : string.Empty;
obExperience.CVID = oReader.GetString("CVID") != null ? oReader.GetInt32("CVID").Value : 0;
this.SetObjectState(obExperience, ObjectState.Saved);
}
private List<CVReference> CreateReferenceObjects(DataReader oReader)
{
List<CVReference> allExperiences = new List<CVReference>();
while (oReader.Read())
{
CVReference obExp = new CVReference();
MapReference(obExp, oReader);
allExperiences.Add(obExp);
}
return allExperiences;
}
#endregion
#region Map ReferredBy Object
private void MapReferredBy(ReferredBy obReferredBy, DataReader oReader)
{
SetObjectID(obReferredBy, (oReader.GetInt32("ReferredByID").Value));
obReferredBy.CvId = (oReader.GetInt32("CvId").Value);
obReferredBy.Name = oReader.GetString("Name");
obReferredBy.OtherDetail = oReader.GetString("OtherDetail");
obReferredBy.ReferredBY = (EnumReferredBy)oReader.GetInt32("ReferredBy");
this.SetObjectState(obReferredBy, ObjectState.Saved);
}
private List<ReferredBy> CreateReferredByObjects(DataReader oReader)
{
List<ReferredBy> allobRefs = new List<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.GetInt32("CVOrgID").Value));
obCVOrg.CvID = oReader.GetInt32("CVID", 0);
obCVOrg.DesignationID = oReader.GetInt32("DesignationID", 0);
obCVOrg.OrganizationId = oReader.GetInt32("OrganizationID", 0);
obCVOrg.CVOrgType = (EnumCVOrgType)oReader.GetInt32("CVOrgType");
this.SetObjectState(obCVOrg, ObjectState.Saved);
}
private List<CVOrg> CreateCVOrgObjects(DataReader oReader)
{
List<CVOrg> allobCVOrgs = new List<CVOrg>();
while (oReader.Read())
{
CVOrg obCVOrg = new CVOrg();
MapCVOrg(obCVOrg, oReader);
allobCVOrgs.Add(obCVOrg);
}
return allobCVOrgs;
}
#endregion
#region Map EductionalQualification
private void MapEductionalQualification(CVEducation obEductionalQualification, DataReader oReader)
{
SetObjectID(obEductionalQualification, (oReader.GetInt32("CVEducationID").Value));
obEductionalQualification.DegreeTitleID = oReader.GetInt32("DegreeTitleID", 0);
obEductionalQualification.DisciplineID = oReader.GetInt32("DisciplineIID", 0);
obEductionalQualification.BoardID = oReader.GetInt32("BoardID", 0);
obEductionalQualification.PassingYear = oReader.GetString("PassingYear") != null ? oReader.GetString("PassingYear") : string.Empty;
obEductionalQualification.ResultID = oReader.GetInt32("ResultID", 0);
obEductionalQualification.CGPA = oReader.GetString("CGPA") != null ? oReader.GetString("CGPA") : string.Empty;
obEductionalQualification.OutOF = oReader.GetString("OutOF", null);
obEductionalQualification.IsHighest = oReader.GetBoolean("IsHighest").Value;
obEductionalQualification.InstituteName = oReader.GetString("InstituteName") != null ? oReader.GetString("InstituteName") : string.Empty;
obEductionalQualification.CVID = oReader.GetInt32("CVID", 0);
this.SetObjectState(obEductionalQualification, ObjectState.Saved);
}
private List<CVEducation> CreateEductionalQualificationObjects(DataReader oReader)
{
List<CVEducation> allQualfs = new List<CVEducation>();
while (oReader.Read())
{
CVEducation obQuef = new CVEducation();
MapEductionalQualification(obQuef, oReader);
allQualfs.Add(obQuef);
}
return allQualfs;
}
#endregion
#region CVAttachment
protected List<FileAttachment> CreateirFileAttachmentObjects(DataReader oReader)
{
List<FileAttachment> oIRFileAttachments = new List<FileAttachment>();
while (oReader.Read())
{
FileAttachment oIRFileAtachment = new FileAttachment();
MapIRFileAttachmentObject(oIRFileAtachment, oReader);
oIRFileAttachments.Add(oIRFileAtachment);
}
return oIRFileAttachments;
}
private void MapIRFileAttachmentObject(FileAttachment oIRFileAttachment, DataReader oReader)
{
base.SetObjectID(oIRFileAttachment, (oReader.GetInt32("FILEATTACHMENTID").Value));
oIRFileAttachment.ReferenceID = oReader.GetInt32("ReferenceID", 0);
oIRFileAttachment.FileAsByteArray = oReader.GetLob("FileData");
oIRFileAttachment.OriginalFileName = oReader.GetString("OriginalFileName");
oIRFileAttachment.FileType = (EnumFileType)oReader.GetInt32("FileType").GetValueOrDefault();
this.SetObjectState(oIRFileAttachment, Ease.Core.ObjectState.Saved);
}
//private List<FileAttachment> MapIRFileAttachmentObjects(DataReader oReader)
//{
// List<FileAttachment> FileAttachment = new List<FileAttachment>();
// base.SetObjectID(oIRFileAttachment, (oReader.GetInt32("FILEATTACHMENTID").Value));
// oIRFileAttachment.ReferenceID = oReader.GetInt32("ReferenceID", 0);
// oIRFileAttachment.FileAsByteArray = oReader.GetLob("FileData");
// oIRFileAttachment.OriginalFileName = oReader.GetString("OriginalFileName");
// oIRFileAttachment.FileType = (EnumFileType)oReader.GetInt32("FileType").GetValueOrDefault();
// this.SetObjectState(oIRFileAttachment, Ease.Core.ObjectState.Saved);
//}
#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);
#region Delete Experience
ExperienceDA.Delete(obCv.ID, tc);
#endregion
#region Delete Reference
CVReferenceDA.Delete(obCv.ID, tc);
#endregion
#region Delete Education
CVEducationDA.Delete(obCv.ID, tc);
#endregion
#region Delete Attachment
FileAttachmentDA.Delete(tc, obCv.ID, EnumFileType.CV);
#endregion
#region Delete CV
CVDA.Delete(obCv.ID, 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
}
}
public void DeleteCVRecuirtmemt(CV obCv)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
#region Delete Experience
ExperienceDA.Delete(obCv.ID, tc);
#endregion
#region Delete Reference
CVReferenceDA.Delete(obCv.ID, tc);
#endregion
#region Delete Education
CVEducationDA.Delete(obCv.ID, tc);
#endregion
#region Delete Attachment
FileAttachmentDA.Delete(tc, obCv.ID, EnumFileType.CV);
#endregion
#region Delete CV
CVDA.Delete(obCv.ID, tc);
#endregion
//#region Delete Candidate
//CandidateDA.DeleteCVCandidate(tc, obCv.ID);
//#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
public List<CV> SaveCVs(List<CV> cvs, string connectionString)
{
List<CV> newItemList = new List<CV>();
List<Candidate> candidates = new List<Candidate>();
List<int> idList = new List<int>();
TransactionContext tc = null;
int positionID = 0;
try
{
tc = TransactionContext.Begin(true);
foreach (var obCv in cvs)
{
obCv.DesignationID = null;
obCv.ReligionID = null;
positionID = obCv.PositionID;
int oID = 0;
if (obCv.IsNew)
{
int id = tc.GenerateID("CV", "CvID");
oID = (id);
base.SetObjectID(obCv, (id));
CVDA.InsertCVBase(obCv, tc);
}
else
{
oID = obCv.ID;
CVDA.UpdateCVBase(obCv, tc);
}
if (obCv.AllExperiences != null && obCv.AllExperiences.Count > 0)
{
ExperienceDA.DeleteByCvId(oID, tc);
foreach (CVExperience exprItem in obCv.AllExperiences)
{
int id = tc.GenerateID("CVExperience", "CVExperienceID");
exprItem.CVID = oID;
base.SetObjectID(exprItem, (id));
ExperienceDA.InsertExperience(exprItem, tc);
}
}
if (obCv.AllEduQualifications != null && obCv.AllEduQualifications.Count > 0)
{
CVEducationDA.DeleteByCvId(oID, tc);
foreach (CVEducation eduItem in obCv.AllEduQualifications)
{
int id = tc.GenerateID("CVEducation", "CVEducationID");
eduItem.CVID = oID;
base.SetObjectID(eduItem, (id));
CVEducationDA.InsertEductionalQualification(eduItem, tc);
}
}
if (obCv.CVReferences != null && obCv.CVReferences.Count > 0)
{
CVReferenceDA.DeleteByCvId(oID, tc);
foreach (CVReference oItem in obCv.CVReferences)
{
int id = tc.GenerateID("CVReference", "CVReferenceID");
oItem.CVID = oID;
base.SetObjectID(oItem, (id));
CVReferenceDA.Insert(oItem, tc);
}
}
CVDA.DeleteAttachment(tc, obCv.ID, EnumFileType.CV);
// CandidateDA.DeleteCVCandidate(tc, obCv.ID);
var candidate = new Candidate();
candidate.CvID = oID;
candidate.ProcessId = obCv.PositionID;
candidate.IsSelected = false;
candidate.IsEmployee = false;
candidate.PrimarySelected = true;
candidate.StartDate = new DateTime();
candidates.Add(candidate);
idList.Add(obCv.ID);
}
if (candidates != null && candidates.Count > 0)
{
new CandidateService().SaveMultipleCandidates(tc, candidates);
}
var recJobTracking = new RecJobTrackingService().GetByRecruitmentId(tc, positionID);
if(recJobTracking != null)
{
if(recJobTracking.ActualCvCollectionDate == null)
{
RecJobTrackingDA.UpdateactualCvCollectionDate(tc, positionID);
}
}
if (positionID > 0)
{
CVDA.UpdateRequisitionStatus(positionID, EnumOnBoradStatus.CVCollection, tc);
}
tc.End();
foreach (var item in cvs)
{
if (item.IRFileAttacments != null && item.IRFileAttacments.Count > 0)
{
foreach (var uploadfile in item.IRFileAttacments)
{
if (uploadfile.FileType == EnumFileType.CVProfilePhoto && uploadfile.FileTobase64 != null)
{
byte[] newBytes = Convert.FromBase64String(uploadfile.FileTobase64);
uploadfile.FileAsByteArray = newBytes;
uploadfile.ReferenceID = item.ID;
uploadfile.FileType = EnumFileType.CVProfilePhoto;
FileAttachmentDA.Insert(uploadfile, connectionString);
}
else if (uploadfile.ID > 0 && uploadfile.FileTobase64 != null)
{
byte[] newBytes = Convert.FromBase64String(uploadfile.FileTobase64);
uploadfile.FileAsByteArray = newBytes;
uploadfile.ReferenceID = item.ID;
uploadfile.FileType = EnumFileType.CV;
FileAttachmentDA.Insert(uploadfile, connectionString);
}
else if (uploadfile.isCvExtractorModule && uploadfile.FileTobase64 != null)
{
byte[] newBytes = Convert.FromBase64String(uploadfile.FileTobase64);
uploadfile.FileAsByteArray = newBytes;
uploadfile.ReferenceID = item.ID;
uploadfile.FileType = EnumFileType.CV;
FileAttachmentDA.Insert(uploadfile, connectionString);
}
else
{
FileStream stream = new FileStream(uploadfile.FilePath, FileMode.Open, FileAccess.Read);
BinaryReader reader = new BinaryReader(stream);
byte[] buff = reader.ReadBytes((int)stream.Length);
reader.Close();
stream.Close();
uploadfile.FileAsByteArray = buff;
uploadfile.ReferenceID = item.ID;
uploadfile.FileType = EnumFileType.CV;
FileAttachmentDA.Insert(uploadfile, connectionString);
}
}
}
}
candidates = new CandidateService().GetCanditatebyCvID(String.Join(",", idList));
if(candidates != null && candidates.Count > 0)
{
foreach(Candidate c in candidates)
{
var exist = cvs?.Where(x => x.ID == c.CvID).FirstOrDefault();
if(exist != null)
{
exist.CandidateID = c.ID;
}
}
}
newItemList = cvs;
}
catch (Exception ex)
{
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
}
return newItemList;
}
#region Insert(CV obCv)
public void Save(CV obCv, string connectionString)
{
TransactionContext tc = null;
int oID = 0;
try
{
tc = TransactionContext.Begin(true);
if (obCv.ErCvID == 0)
{
obCv.ErCvID = null;
}
if (obCv.IsNew)
{
int id = tc.GenerateID("CV", "CvID");
oID = (id);
base.SetObjectID(obCv, (id));
CVDA.InsertCVBase(obCv, tc);
}
else
{
oID = obCv.ID;
CVDA.UpdateCVBase(obCv, tc);
}
if (obCv.AllExperiences != null && obCv.AllExperiences.Count > 0)
{
ExperienceDA.DeleteByCvId(oID, tc);
foreach (CVExperience exprItem in obCv.AllExperiences)
{
int id = tc.GenerateID("CVExperience", "CVExperienceID");
exprItem.CVID = oID;
base.SetObjectID(exprItem, (id));
ExperienceDA.InsertExperience(exprItem, tc);
}
}
if (obCv.AllEduQualifications != null && obCv.AllEduQualifications.Count > 0)
{
CVEducationDA.DeleteByCvId(oID, tc);
foreach (CVEducation eduItem in obCv.AllEduQualifications)
{
int id = tc.GenerateID("CVEducation", "CVEducationID");
eduItem.CVID = oID;
base.SetObjectID(eduItem, (id));
CVEducationDA.InsertEductionalQualification(eduItem, tc);
}
}
if (obCv.CVReferences != null && obCv.CVReferences.Count > 0)
{
CVReferenceDA.DeleteByCvId(oID, tc);
foreach (CVReference oItem in obCv.CVReferences)
{
int id = tc.GenerateID("CVReference", "CVReferenceID");
oItem.CVID = oID;
base.SetObjectID(oItem, (id));
CVReferenceDA.Insert(oItem, tc);
}
}
//CVDA.DeleteAttachment(tc, obCv.ID, EnumFileType.CV);
tc.End();
if(obCv.CVProfilePhoto != null)
{
//if (obCv.ErCVProfilePhoto.ID > 0 && item.claimRequisitionFileAttacment.PreviousFileTobase64 != null)
//{
// byte[] newBytes = Convert.FromBase64String(item.claimRequisitionFileAttacment.PreviousFileTobase64);
// item.claimRequisitionFileAttacment.FileAsByteArray = newBytes;
// item.claimRequisitionFileAttacment.ReferenceID = oClaimRequisition.ID;
// item.claimRequisitionFileAttacment.RefchildID = itemid;
// item.claimRequisitionFileAttacment.FileType = EnumFileType.ClaimRequisition;
// FileAttachmentDA.Insert(item.claimRequisitionFileAttacment, oClaimRequisition.ConnectionString);
//}
//else
//{
obCv.CVProfilePhoto.ReferenceID = oID;
obCv.CVProfilePhoto.FileType = EnumFileType.CVProfilePhoto;
obCv.CVProfilePhoto.RefchildID = null;
FileAttachmentDA.Insert(obCv.CVProfilePhoto, connectionString);
// }
}
if (obCv.IRFileAttacments != null && obCv.IRFileAttacments.Count > 0)
{
foreach (var uploadfile in obCv.IRFileAttacments)
{
if (uploadfile.ID > 0 && uploadfile.FileTobase64 != null)
{
byte[] newBytes = Convert.FromBase64String(uploadfile.FileTobase64);
uploadfile.FileAsByteArray = newBytes;
uploadfile.ReferenceID = obCv.ID;
uploadfile.FileType = EnumFileType.CV;
FileAttachmentDA.Insert(uploadfile, connectionString);
}
else
{
FileStream stream = new FileStream(uploadfile.FilePath, FileMode.Open, FileAccess.Read);
BinaryReader reader = new BinaryReader(stream);
byte[] buff = reader.ReadBytes((int)stream.Length);
reader.Close();
stream.Close();
uploadfile.FileAsByteArray = buff;
uploadfile.ReferenceID = obCv.ID;
uploadfile.FileType = EnumFileType.CV;
FileAttachmentDA.Insert(uploadfile, connectionString);
}
}
}
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
#endregion
/// <summary>
/// //For cv collection module
/// </summary>
/// <param name="Items"></param>
public void SaveCVSort(List<CVSort> Items)
{
TransactionContext tc = null;
try
{
int RequisitionID = 0;
tc = TransactionContext.Begin(true);
foreach (var obCvSort in Items)
{
RequisitionID = obCvSort.RequisitionID;
int oID = 0;
if (obCvSort.IsNew)
{
int id = tc.GenerateID("CVSort", "CVSORTID");
oID = (id);
base.SetObjectID(obCvSort, (id));
CVDA.InsertCVSort(obCvSort, tc);
}
else
{
oID = obCvSort.ID;
CVDA.UpdateCVSort(obCvSort, tc);
}
}
if (RequisitionID > 0)
{
CVDA.UpdateRequisitionStatus(RequisitionID, EnumOnBoradStatus.CVCollection, tc);
}
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
#region Insert(CV obCv)
public void SaveUserCVSort(UserCvSort obCv)
{
TransactionContext tc = null;
int oID = 0;
try
{
var recruitment = new InternalRecruitmentService().Get(obCv.PositionID);
tc = TransactionContext.Begin(true);
if (obCv.IsNew)
{
int id = tc.GenerateID("UserCvSort", "USERCVSORTID");
oID = (id);
base.SetObjectID(obCv, (id));
CVDA.InsertUserCvSort(obCv, tc);
}
//CVDA.UpdateCVCandidate(obCv, tc);
CVDA.UpdateCandidate(obCv, tc);
var status = "Not selected for interview by Department Position: " + recruitment.PositionName + " Date: " + recruitment.PositionDate.ToString("dd-MM-yyyy");
CVDA.UpdateCandidateLastStatus(status, obCv.CandidateID, tc);
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
}
#region GetReferredBy(int cVID)
public List<ReferredBy> GetReferredBy(int cVID)
{
List<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(int cVID)
public List<CVOrg> GetCVOrgByID(int cVID)
{
List<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(int cVID)
public List<CVEducation> GetEducationQualifications(int cVID)
{
List<CVEducation> 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(int cVID)
public List<CVExperience> GetExperiences(int cVID)
{
List<CVExperience> 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 List<CV> Get()
{
List<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();
foreach (CV cv in allCVs)
{
if (cv != null)
{
cv.AllExperiences = GetAllExp(tc, cv.ID);
cv.AllEduQualifications = GetAllEducations(tc, cv.ID);
if (cv.AllEduQualifications != null && cv.AllEduQualifications.Count > 0)
{
foreach (CVEducation item in cv.AllEduQualifications)
{
item.EducationLevels = new EducationLevelService().GetByID(tc, item.DegreeTitleID);
item.Disciplines = new DisciplineService().GetByID(tc, item.DisciplineID);
}
}
cv.CVReferences = GetAllReferences(tc, cv.ID);
cv.IRFileAttacments = GetAllAttachments(tc, cv.ID, EnumFileType.CV);
}
}
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;
}
public List<CV> getAllOnlyCV()
{
List<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;
}
public List<CV> GetAllSearchedCV(string name, string email, string mobile, DateTime? fromDate, DateTime? toDate)
{
List<CV> allCVs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.GetAllSearchedCV(tc, name, email, mobile, fromDate, toDate));
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;
}
public List<CV> GetByCvSearch(string name, string email, string mobile)
{
List<CV> allCVs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.GetByCvSearch(tc, name, email, mobile));
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(int cVID)
public CV Get(int cVID)
{
CV cv = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.Get(cVID, tc));
if (oreader.Read())
{
cv = this.CreateObject<CV>(oreader);
}
oreader.Close();
if (cv != null)
{
cv.AllExperiences = GetAllExp(tc, cv.ID);
cv.AllEduQualifications = GetAllEducations(tc, cv.ID);
if (cv.AllEduQualifications != null && cv.AllEduQualifications.Count > 0)
{
foreach (CVEducation item in cv.AllEduQualifications)
{
item.EducationLevels = new EducationLevelService().GetByID(tc, item.DegreeTitleID);
item.Disciplines = new DisciplineService().GetByID(tc, item.DisciplineID);
}
}
cv.CVReferences = GetAllReferences(tc, cv.ID);
cv.IRFileAttacments = GetAllAttachments(tc, cv.ID, EnumFileType.CV);
}
tc.End();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return cv;
}
public CV GetByErcvId(int ercvId)
{
CV cv = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.GetByErcvId(ercvId, tc));
if (oreader.Read())
{
cv = this.CreateObject<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 cv;
}
private List<FileAttachment> GetAllAttachments(TransactionContext tc, int cvID, EnumFileType type)
{
List<FileAttachment> allExps = null;
try
{
DataReader oreader = new DataReader(FileAttachmentDA.GetByReferenceId(tc, cvID, type));
allExps = this.CreateirFileAttachmentObjects(oreader);
oreader.Close();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return allExps;
}
public List<FileAttachment> GetCv(TransactionContext tc, int cvID)
{
List<FileAttachment> allExps = null;
try
{
DataReader oreader = new DataReader(FileAttachmentDA.GetCv(tc, cvID));
allExps = this.CreateirFileAttachmentObjects(oreader);
oreader.Close();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return allExps;
}
private List<CVReference> GetAllReferences(TransactionContext tc, int cVID)
{
List<CVReference> allExps = null;
try
{
DataReader oreader = new DataReader(CVReferenceDA.Get(cVID, tc));
allExps = this.CreateReferenceObjects(oreader);
oreader.Close();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return allExps;
}
private List<CVEducation> GetAllEducations(TransactionContext tc, int cVID)
{
List<CVEducation> allExps = null;
try
{
DataReader oreader = new DataReader(CVDA.GetEducationQualifications(cVID, tc));
allExps = this.CreateEductionalQualificationObjects(oreader);
oreader.Close();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return allExps;
}
public void UpdateCvNameMobileEmail(int cvId, string name, string mobile, string email,string reference, string education, string experience, string skill)
{
TransactionContext tc = null;
try
{
if (name != null)
{
string[] separated = name.Split(' ');
string secondName = "";
string secondFirstLetter = "";
string secondOtherLetters = "";
if (name.Length > 2)
{
secondName = separated[1];
secondFirstLetter = secondName.Substring(0, 1).ToUpper();
secondOtherLetters = secondName.Substring(0).ToLower();
}
}
tc = TransactionContext.Begin(true);
CVDA.UpdateCvNameMobileEmail(cvId, name, mobile, email, reference, education, experience, skill, 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<CV> EmailAndPhoneDuplicateCheck(string mobile, string email)
{
TransactionContext tc = null;
List<CV> cvlist = new List<CV>();
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.EmailAndPhoneDuplicateCheck(tc, email, mobile));
cvlist = 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 cvlist;
}
public List<CV> GetPreviousCVbyRequisitionID(int requisitionID)
{
List<CV> allCVs = null;
InternalRecruitment Requisition = null;
List<Candidate> prevCandidates = null;
List<UserCvSort> usercvs = new List<UserCvSort>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.GetPreviousCvOfRequisition(tc, requisitionID));
allCVs = this.CreateObjects<CV>(oreader);
oreader.Close();
foreach (CV cv in allCVs)
{
if (cv != null)
{
cv.AllExperiences = GetAllExp(tc, cv.ID);
cv.AllEduQualifications = GetAllEducations(tc, cv.ID);
if (cv.AllEduQualifications != null && cv.AllEduQualifications.Count > 0)
{
foreach (CVEducation item in cv.AllEduQualifications)
{
item.EducationLevels = new EducationLevelService().GetByID(tc, item.DegreeTitleID);
item.Disciplines = new DisciplineService().GetByID(tc, item.DisciplineID);
}
}
cv.CVReferences = GetAllReferences(tc, cv.ID);
cv.IRFileAttacments = GetCv(tc, (int)cv.ID);
prevCandidates = new CandidateService().GetCanditatebyCvId(tc, (int)cv.ID,cv.PositionID);
foreach(var item in prevCandidates)
{
cv.PrevCandidateStatus += item.CandidateLastStatus + ",";
}
// not sure logic
//if (cv.ErCvID != null && cv.ErCvID > 0)
// cv.IRFileAttacments = GetCv(tc, (int)cv.ErCvID);
}
}
if (allCVs != null && allCVs.Count > 0)
{
Requisition = new InternalRecruitmentService().Get(allCVs[0].PositionID);
if (Requisition != null)
{
DataReader oreader1 = new DataReader(CVDA.GetUserCVSortByRequisitionID(requisitionID, tc));
while (oreader1.Read())
{
UserCvSort item = new UserCvSort();
item.ID = oreader1.GetInt32("UserCvSortId").Value;
item.PositionID = oreader1.GetInt32("RequisitionID", 0);
item.CandidateID = oreader1.GetInt32("CandidateID", 0);
item.SelectStatus = oreader1.GetBoolean("Discardstatus", false);
usercvs.Add(item);
}
oreader1.Close();
}
}
tc.End();
if (Requisition != null && Requisition.OnBoradStatus == EnumOnBoradStatus.CVCollection)
{
foreach (CV cv in allCVs)
{
var userCvExit = usercvs?.Where(x => (x.PositionID == cv.PositionID) && (x.CandidateID == cv.CandidateID) && x.SelectStatus == true)?.Any();
if (userCvExit != null && userCvExit == true)
{
cv.SortStatus = "Selected";
}
else
{
cv.SortStatus = "Rejected";
}
}
}
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return allCVs;
}
public bool IsRequisitionComplete(int requisitionID)
{
List<CVSort> usercvs = new List<CVSort>();
TransactionContext tc = null;
bool isRequisitionComplete = true;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.GetCVSortByRequisitionID(requisitionID, tc));
while (oreader.Read())
{
CVSort item = new CVSort();
item.ID = oreader.GetInt32("CVSortID").Value;
item.EmployeeID = oreader.GetInt32("EmployeeID", 0);
item.RequisitionID = oreader.GetInt32("RequisitionID", 0);
item.WfStatus = oreader.GetString("WfStatus") != null ? (EnumWFCvSortStatus)oreader.GetInt32("WfStatus").Value : EnumWFCvSortStatus.Not_Yet_Completed;
usercvs.Add(item);
}
oreader.Close();
tc.End();
if (usercvs != null && usercvs.Count > 0)
{
foreach (var item in usercvs)
{
if(item.WfStatus == EnumWFCvSortStatus.Not_Yet_Completed)
{
isRequisitionComplete = false;
break;
}
}
}
else
{
isRequisitionComplete = false;
}
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return isRequisitionComplete;
}
public List<CVSort> GetCVSortByrequisitionID(int requisitionID)
{
List<CVSort> usercvs = new List<CVSort>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.GetCVSortByRequisitionID(requisitionID, tc));
while (oreader.Read())
{
CVSort item = new CVSort();
item.ID = oreader.GetInt32("CVSortID").Value;
item.EmployeeID = oreader.GetInt32("EmployeeID", 0);
item.RequisitionID = oreader.GetInt32("RequisitionID", 0);
item.WfStatus = oreader.GetString("WfStatus") != null ? (EnumWFCvSortStatus)oreader.GetInt32("WfStatus").Value : EnumWFCvSortStatus.Not_Yet_Completed;
usercvs.Add(item);
}
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 usercvs;
}
private List<CVExperience> GetAllExp(TransactionContext tc, int cVID)
{
List<CVExperience> allExps = null;
try
{
DataReader oreader = new DataReader(CVDA.GetExperiences(cVID, tc));
allExps = this.CreateExperienceObjects(oreader);
oreader.Close();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
return allExps;
}
public List<FileAttachment> GetCVAttachmentbyID(int cvId)
{
List<FileAttachment> oFileAttachments = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(FileAttachmentDA.GetByReferenceId(tc, cvId, EnumFileType.CV));
oFileAttachments = this.CreateirFileAttachmentObjects(oreader);
oreader.Close();
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException("Failed to Get IRNotifications: " + ex.Message, ex);
#endregion
}
return oFileAttachments;
}
#endregion
#region List< CV > GetByQuery(string query)
public List<CV> GetByQuery(string query)
{
List<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;
}
public DataTable dtGetCVByID(int cvID)
{
DataSet ds = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
ds = CVDA.dtGetCVByID(tc, 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 ds.Tables[0];
}
//public DataTable dtGetRecruitmentbyCVSort(int employeeID)
//{
// DataSet ds = new DataSet();
// TransactionContext tc = null;
// try
// {
// tc = TransactionContext.Begin(true);
// ds = CVDA.dtGetRecruitmentbyCVSort(tc, employeeID);
// 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.Tables[0];
//}
public List<RecruitmentByCVSort> dtGetRecruitmentbyCVSort(int employeeID)
{
List<RecruitmentByCVSort> sortItems = new List<RecruitmentByCVSort>();
RecruitmentByCVSort sortItem = null;
DataSet ds = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
ds = CVDA.dtGetRecruitmentbyCVSort(tc, employeeID);
tc.End();
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow Dr in ds.Tables[0].Rows)
{
sortItem = new RecruitmentByCVSort();
sortItem.AssignedDatetime = Convert.ToDateTime(Dr["AssignedDatetime"]).ToString("dd MMM yyyy");
sortItem.PositionID = Convert.ToInt32(Dr["PositionID"].ToString());
sortItem.PositionName = Dr["PositionName"] is DBNull ? null : Dr["PositionName"].ToString();
sortItem.OnBoardStatus = (EnumOnBoradStatus)Convert.ToInt16(Dr["OnBoardStatus"].ToString());
sortItem.OnBoardStatusString = EnumDescription.GetEnumDescription(sortItem.OnBoardStatus);
sortItem.TotalCV = Dr["TotalCV"] is DBNull ? 0 : Convert.ToInt32(Dr["TotalCV"].ToString());
sortItem.CompleteStatus = (EnumWFCvSortStatus)Convert.ToInt16(Dr["WFSTATUS"].ToString());
sortItems.Add(sortItem);
}
}
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return sortItems;
}
public List<CVSortDetails> dtCVSortDetails(int positionID)
{
List<CVSortDetails> deatilItems = new List<CVSortDetails>();
CVSortDetails detailItem = null;
DataSet ds = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
ds = CVDA.dtCVSortDetails(tc, positionID);
tc.End();
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow Dr in ds.Tables[0].Rows)
{
detailItem = new CVSortDetails();
detailItem.PositionID = Convert.ToInt32(Dr["PositionID"].ToString());
detailItem.PositionName = Dr["PositionName"] is DBNull ? null : Dr["PositionName"].ToString();
detailItem.CandidateName = Dr["Name"] is DBNull ? null : Dr["Name"].ToString();
detailItem.Mobile = Dr["Mobile"] is DBNull ? null : Dr["Mobile"].ToString();
detailItem.Email = Dr["Email"] is DBNull ? null : Dr["Email"].ToString();
detailItem.CandidateID = Convert.ToInt32(Dr["CandidateID"].ToString());
detailItem.CvID = Convert.ToInt32(Dr["CvID"].ToString());
detailItem.PrimarySelection = Convert.ToBoolean(Dr["PrimarySelected"].ToString());
detailItem.IsCVSelect = detailItem.PrimarySelection == true ? false : true;
// detailItem.UserCvSortID = Dr["UserCvSortID"] is DBNull ? 0 : Convert.ToInt32(Dr["UserCvSortID"] is DBNull ? 0.ToString() : Dr["UserCvSortID"].ToString());
// detailItem.IsCVSelect = Convert.ToBoolean(Dr["PrimarySelected"] is DBNull ? false.ToString() : Dr["SELECTSTATUS"].ToString());
// detailItem.Remarks = Dr["Remarks"] is DBNull ? null : Dr["Remarks"].ToString(); ;
deatilItems.Add(detailItem);
}
}
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return deatilItems;
}
public List<FileAttachment> GetAllAttachments(int refID, EnumFileType type)
{
List<FileAttachment> allExps = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(FileAttachmentDA.GetByReferenceId(tc, refID, type));
allExps = this.CreateirFileAttachmentObjects(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;
}
public List<CV> GetCVs()
{
List<CV> allCVs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.GetCVs(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;
}
public List<CV> GetCVs(string name,string email, string mobile, string institute, int degreeTitleId)
{
List<CV> allCVs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.Getcvs(tc, name, email, mobile, institute, degreeTitleId));
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;
}
public List<CV> GetOnlinePortalCVs(int requisitionID)
{
List<CV> allCVs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.GetOnlinePortalCvs(tc, requisitionID));
allCVs = this.CreateObjects<CV>(oreader);
oreader.Close();
if (allCVs != null && allCVs.Count > 0)
{
foreach (var cv in allCVs)
{
cv.AllExperiences = GetAllExp(tc, cv.ID);
cv.AllEduQualifications = GetAllEducations(tc, cv.ID);
if (cv.AllEduQualifications != null && cv.AllEduQualifications.Count > 0)
{
foreach (CVEducation item in cv.AllEduQualifications)
{
item.EducationLevels = new EducationLevelService().GetByID(tc, item.DegreeTitleID);
item.Disciplines = new DisciplineService().GetByID(tc, item.DisciplineID);
}
}
cv.CVReferences = GetAllReferences(tc, cv.ID);
//if(cv.ErCvID != null && cv.ErCvID > 0)
// cv.IRFileAttacments = GetCv(tc, (int)cv.ErCvID);
cv.IRFileAttacments = GetCv(tc, (int)cv.ID);
}
}
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;
}
public List<CV> GetCVByIDs(string cVIDs)
{
List<CV> allCVs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.Get(cVIDs, 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;
}
public List<CV> GetCVByCandidateIDs(string candidateIDs)
{
List<CV> allCVs = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
DataReader oreader = new DataReader(CVDA.GetByCandiadteId(candidateIDs, 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;
}
public void DeleteUserCvsort(UserCvSort obCv)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
#region Delete UserCvSort
CVDA.DeleteUserCvSort(obCv.ID, 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
}
}
public void DeleteCvsort(CVSort obCv)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
#region Delete UserCvSort
CVDA.DeleteCvSort(obCv.RequisitionID, obCv.EmployeeID, 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
}
}
public void UpdateCompleteStatus(int positionID, int employeeID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
CVDA.UpdateEmployeeWFStatus(positionID, employeeID, 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
#endregion
#endregion
}
}