406 lines
15 KiB
C#
406 lines
15 KiB
C#
using System;
|
|
using System.Data;
|
|
using Ease.Core.Model;
|
|
using Ease.Core.DataAccess;
|
|
using Ease.Core;
|
|
using System.Collections.Generic;
|
|
using Ease.Core.Utility;
|
|
using HRM.BO;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
#region RecruitmentLetters Service
|
|
|
|
public class RecruitmentLettersService : ServiceTemplate, IRecruitmentLettersService
|
|
{
|
|
public RecruitmentLettersService()
|
|
{
|
|
}
|
|
|
|
#region MapObject For RecruitmentLetters
|
|
|
|
private void MapObject(RecruitmentLetters oRecruitmentLetter, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oRecruitmentLetter, (oReader.GetInt32("RecruitmentLetterID").Value));
|
|
oRecruitmentLetter.CandidateID = oReader.GetInt32("CandidateID", 0);
|
|
oRecruitmentLetter.RequisitionID = oReader.GetInt32("RequisitionID").Value;
|
|
oRecruitmentLetter.ProcessID = oReader.GetInt32("ProcessID", 0);
|
|
oRecruitmentLetter.AcceptOfferBefore =
|
|
oReader.GetDateTime("AcceptOfferBefore");
|
|
oRecruitmentLetter.IssueOfferDate =
|
|
oReader.GetDateTime("IssueOfferDate");
|
|
oRecruitmentLetter.AcceptOfferDate =
|
|
oReader.GetDateTime("AcceptOfferDate");
|
|
oRecruitmentLetter.RejectOfferDate =
|
|
oReader.GetDateTime("RejectOfferDate");
|
|
oRecruitmentLetter.RejectOfferReason = oReader.GetString("RejectOfferReason");
|
|
oRecruitmentLetter.OfferLetterCount = oReader.GetInt32("OfferLetterCount", 0);
|
|
oRecruitmentLetter.OfferCreatedBy = (oReader.GetInt32("OfferCreatedBy", 0));
|
|
oRecruitmentLetter.OfferCreatedDate =
|
|
oReader.GetDateTime("OfferCreatedDate");
|
|
oRecruitmentLetter.GradeID = oReader.GetInt32("GradeID", 0);
|
|
oRecruitmentLetter.BasicSalary = oReader.GetDouble("BasicSalary").GetValueOrDefault(0);
|
|
oRecruitmentLetter.DepartmentID = (oReader.GetInt32("DepartmentID", 0));
|
|
oRecruitmentLetter.LocationID = (oReader.GetInt32("LocationID", 0));
|
|
//oRecruitmentLetter.EmployeeID = oReader.GetID("EmployeeID").IsUnassigned ? (0) : oReader.GetID("EmployeeID");
|
|
oRecruitmentLetter.NoticePeriod = oReader.GetInt32("NoticePeriod").GetValueOrDefault(0);
|
|
oRecruitmentLetter.AppAcceptBefore =
|
|
oReader.GetDateTime("AppAcceptBefore");
|
|
oRecruitmentLetter.IssueAppLetterDate =
|
|
oReader.GetDateTime("IssueAppLetterDate");
|
|
oRecruitmentLetter.RejectAppLetterDate =
|
|
oReader.GetDateTime("RejectAppLetterDate");
|
|
|
|
oRecruitmentLetter.RejectAppLetterReason = oReader.GetString("RejectAppLetterReason");
|
|
oRecruitmentLetter.CarEligible = oReader.GetBoolean("CarEligible").GetValueOrDefault(false);
|
|
oRecruitmentLetter.AppCreatedBy = (oReader.GetInt32("AppCreatedBy", 0));
|
|
oRecruitmentLetter.AppCreatedDate =
|
|
oReader.GetDateTime("AppCreatedDate").GetValueOrDefault(DateTime.MinValue);
|
|
oRecruitmentLetter.AppLetterCount = oReader.GetInt32("AppLetterCount").GetValueOrDefault(0);
|
|
oRecruitmentLetter.JoiningLetter = oReader.GetBoolean("JoiningLetter").GetValueOrDefault(false);
|
|
oRecruitmentLetter.VendorMail = oReader.GetBoolean("VendorMail").GetValueOrDefault(false);
|
|
oRecruitmentLetter.WelcomeMail = oReader.GetBoolean("WelcomeMail").GetValueOrDefault(false);
|
|
oRecruitmentLetter.InductionRequest = oReader.GetBoolean("InductionRequest").GetValueOrDefault();
|
|
oRecruitmentLetter.Announcement = oReader.GetBoolean("Announcement").GetValueOrDefault(false);
|
|
oRecruitmentLetter.OtherLetters = oReader.GetBoolean("OtherLetters").GetValueOrDefault(false);
|
|
oRecruitmentLetter.OthersCount = oReader.GetInt32("OthersCount").GetValueOrDefault(0);
|
|
oRecruitmentLetter.OtherCreatedBy = (oReader.GetInt32("OtherCreatedBy", 0));
|
|
oRecruitmentLetter.OtherCreateddate =
|
|
oReader.GetDateTime("OtherCreateddate");
|
|
oRecruitmentLetter.JoiningBeforeDate =
|
|
oReader.GetDateTime("JoiningBeforeDate");
|
|
oRecruitmentLetter.ConfirmJoiningDate =
|
|
oReader.GetDateTime("ConfirmJoiningDate");
|
|
|
|
oRecruitmentLetter.CreatedBy = oReader.GetInt32("CreatedBy").Value;
|
|
oRecruitmentLetter.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|
oRecruitmentLetter.ModifiedBy = oReader.GetInt32("ModifiedBy");
|
|
oRecruitmentLetter.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|
|
|
this.SetObjectState(oRecruitmentLetter, Ease.Core.ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
RecruitmentLetters oRecruitmentLetter = new RecruitmentLetters();
|
|
MapObject(oRecruitmentLetter, oReader);
|
|
return oRecruitmentLetter as T;
|
|
}
|
|
|
|
protected RecruitmentLetters CreateObject(DataReader oReader)
|
|
{
|
|
RecruitmentLetters oRecruitmentLetter = new RecruitmentLetters();
|
|
MapObject(oRecruitmentLetter, oReader);
|
|
return oRecruitmentLetter;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Service Implementation
|
|
|
|
public RecruitmentLetters Get(int id)
|
|
{
|
|
RecruitmentLetters oRecruitmentLetter = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(RecruitmentLettersDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oRecruitmentLetter = this.CreateObject<RecruitmentLetters>(oreader);
|
|
}
|
|
|
|
oreader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oRecruitmentLetter;
|
|
}
|
|
|
|
public RecruitmentLetters GetByCandidateID(int nCandidateID)
|
|
{
|
|
RecruitmentLetters oRecruitmentLetter = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(RecruitmentLettersDA.GetByCandidateID(tc, nCandidateID));
|
|
if (oreader.Read())
|
|
{
|
|
oRecruitmentLetter = this.CreateObject<RecruitmentLetters>(oreader);
|
|
}
|
|
|
|
oreader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return oRecruitmentLetter;
|
|
}
|
|
|
|
public List<RecruitmentLetters> Get()
|
|
{
|
|
List<RecruitmentLetters> recruitmentLetters = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(RecruitmentLettersDA.Get(tc));
|
|
recruitmentLetters = this.CreateObjects<RecruitmentLetters>(dr);
|
|
dr.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
return recruitmentLetters;
|
|
}
|
|
|
|
|
|
public List<RecruitmentLetters> GetbyRequisitionID(int nProcessID)
|
|
{
|
|
List<RecruitmentLetters> recruitmentLetters = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(RecruitmentLettersDA.GetbyRequisitionID(tc, nProcessID));
|
|
recruitmentLetters = this.CreateObjects<RecruitmentLetters>(dr);
|
|
dr.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return recruitmentLetters;
|
|
}
|
|
public List<RecruitmentLetters> GetByProcessID(int nProcessID)
|
|
{
|
|
List<RecruitmentLetters> recruitmentLetters = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(RecruitmentLettersDA.GetByProcessID(tc, nProcessID));
|
|
recruitmentLetters = this.CreateObjects<RecruitmentLetters>(dr);
|
|
dr.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
|
|
return recruitmentLetters;
|
|
}
|
|
|
|
public int Save(RecruitmentLetters oRecruitmentLetters, int CheckValue)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oRecruitmentLetters.IsNew)
|
|
{
|
|
int id = tc.GenerateID("RecruitmentLetters", "RecruitmentLetterID");
|
|
base.SetObjectID(oRecruitmentLetters, (id));
|
|
oRecruitmentLetters.OfferCreatedBy = oRecruitmentLetters.CreatedBy;
|
|
oRecruitmentLetters.OfferCreatedDate = oRecruitmentLetters.CreatedDate;
|
|
RecruitmentLettersDA.Insert(tc, oRecruitmentLetters);
|
|
}
|
|
else
|
|
{
|
|
if (CheckValue == 1)
|
|
{
|
|
oRecruitmentLetters.OfferCreatedBy = oRecruitmentLetters.CreatedBy;
|
|
oRecruitmentLetters.OfferCreatedDate = oRecruitmentLetters.CreatedDate;
|
|
}
|
|
else if (CheckValue == 2)
|
|
{
|
|
oRecruitmentLetters.AppCreatedBy = oRecruitmentLetters.CreatedBy;
|
|
oRecruitmentLetters.AppCreatedDate = oRecruitmentLetters.CreatedDate;
|
|
}
|
|
else
|
|
{
|
|
oRecruitmentLetters.OtherCreatedBy = oRecruitmentLetters.CreatedBy;
|
|
oRecruitmentLetters.OtherCreateddate = oRecruitmentLetters.CreatedDate;
|
|
}
|
|
|
|
RecruitmentLettersDA.Update(tc, oRecruitmentLetters);
|
|
}
|
|
|
|
return oRecruitmentLetters.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
finally
|
|
{
|
|
tc.End();
|
|
}
|
|
}
|
|
|
|
public void Delete(int id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
RecruitmentLettersDA.Delete(tc, id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
finally
|
|
{
|
|
tc.End();
|
|
}
|
|
}
|
|
|
|
public void Save(List<RecruitmentLetters> recruitmentLetters)
|
|
{
|
|
List<RecruitmentLetters> saveditems = this.GetbyRequisitionID(recruitmentLetters[0].RequisitionID);
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (recruitmentLetters.Count > 0)
|
|
{
|
|
foreach (RecruitmentLetters letterItem in recruitmentLetters)
|
|
{
|
|
var saveItem = saveditems.Find(x => x.RequisitionID ==
|
|
letterItem.RequisitionID && x.CandidateID == letterItem.CandidateID);
|
|
|
|
InternalRecruitment position = new InternalRecruitmentService().Get(recruitmentLetters[0].RequisitionID);
|
|
DateTime? acceptDate = recruitmentLetters[0].AcceptOfferDate;
|
|
DateTime? rejectDate = recruitmentLetters[0].RejectOfferDate;
|
|
if(acceptDate != null)
|
|
{
|
|
var status = "Offer Letter Accepted." + "Position: " + position.PositionName + " Date: " + position.PositionDate.ToString("dd-MM-yyyy");
|
|
CVDA.UpdateCandidateLastStatus(status, letterItem.CandidateID, tc);
|
|
}
|
|
else if(rejectDate != null && saveItem.RejectOfferDate != null)
|
|
{
|
|
var status = "Offer Letter Rejected." + "Position: " + position.PositionName + " Date: " + position.PositionDate.ToString("dd-MM-yyyy");
|
|
CVDA.UpdateCandidateLastStatus(status, letterItem.CandidateID, tc);
|
|
}
|
|
|
|
if (saveItem!= null)
|
|
{
|
|
letterItem.ID = saveItem.ID;
|
|
}
|
|
|
|
if (letterItem.IsNew)
|
|
{
|
|
int id = tc.GenerateID("RecruitmentLetters", "RecruitmentLetterID");
|
|
base.SetObjectID(letterItem, (id));
|
|
RecruitmentLettersDA.Insert(tc, letterItem);
|
|
}
|
|
else
|
|
{
|
|
RecruitmentLettersDA.Update(tc, letterItem);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
finally
|
|
{
|
|
tc.End();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
} |