505 lines
19 KiB
C#
505 lines
19 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using Ease.CoreV35;
|
|
using Ease.CoreV35.Model;
|
|
using Ease.CoreV35.DataAccess;
|
|
using System.Collections.Generic;
|
|
using Payroll.BO;
|
|
using Ease.CoreV35.Caching;
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
#region InternalRecruitment Service
|
|
[Serializable]
|
|
public class InternalRecruitmentService : ServiceTemplate, IInternalRecruitmentService
|
|
{
|
|
#region InternalRecruitment
|
|
#region Private functions and declaration
|
|
Cache _cache = new Cache(typeof(InternalRecruitment));
|
|
public InternalRecruitmentService() { }
|
|
|
|
private void MapObject(InternalRecruitment oInternalRecruitment, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oInternalRecruitment, oReader.GetID("PositionId"));
|
|
oInternalRecruitment.PositionName = oReader.GetString("PositionName");
|
|
oInternalRecruitment.JobDescription = oReader.GetString("JobDescription");
|
|
oInternalRecruitment.Education = oReader.GetString("Education");
|
|
oInternalRecruitment.Experience = oReader.GetString("Experience");
|
|
oInternalRecruitment.Responsibility = oReader.GetString("Responsibility");
|
|
oInternalRecruitment.OtherResponsibility = oReader.GetString("OtherResponsibility");
|
|
oInternalRecruitment.SalaryRange = oReader.GetString("SalaryRange");
|
|
oInternalRecruitment.Benefits = oReader.GetString("Benefits");
|
|
oInternalRecruitment.ApplicationLastDate = oReader.GetString("ApplicationLastDate");
|
|
oInternalRecruitment.PublishedDate = oReader.GetDateTime("PublishedDate").GetValueOrDefault();
|
|
oInternalRecruitment.WorkflowRequired = oReader.GetBoolean("WorkflowRequired").GetValueOrDefault();
|
|
oInternalRecruitment.IsClosed = oReader.GetBoolean("IsClosed").GetValueOrDefault();
|
|
oInternalRecruitment.CreatedBy = oReader.GetID("CreatedBy");
|
|
oInternalRecruitment.CreatedDate = oReader.GetDateTime("CreationDate").GetValueOrDefault();
|
|
oInternalRecruitment.ModifiedBy = oReader.GetID("ModifiedBy");
|
|
oInternalRecruitment.ModifiedDate = oReader.GetDateTime("ModifiedDate").GetValueOrDefault();
|
|
|
|
this.SetObjectState(oInternalRecruitment, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
InternalRecruitment oInternalRecruitment = new InternalRecruitment();
|
|
MapObject(oInternalRecruitment, oReader);
|
|
return oInternalRecruitment as T;
|
|
}
|
|
|
|
private InternalRecruitment CreateObject(DataReader oReader)
|
|
{
|
|
InternalRecruitment oInternalRecruitment = new InternalRecruitment();
|
|
MapObject(oInternalRecruitment, oReader);
|
|
return oInternalRecruitment;
|
|
}
|
|
|
|
private void MapNotificationObject(IRNotification oIRNotification, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oIRNotification, oReader.GetID("IRNotificationID"));
|
|
oIRNotification.PositionID = oReader.GetID("PositionId");
|
|
oIRNotification.NotificationDate = oReader.GetDateTime("NotificationDate").GetValueOrDefault();
|
|
oIRNotification.Description = oReader.GetString("Description");
|
|
oIRNotification.NotifiedBy = oReader.GetID("NotifiedBy");
|
|
|
|
this.SetObjectState(oIRNotification, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
|
|
protected ObjectsTemplate<IRNotification> CreateDetailObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<IRNotification> oDetails = new ObjectsTemplate<IRNotification>();
|
|
while (oReader.Read())
|
|
{
|
|
IRNotification oIRNotification = new IRNotification();
|
|
MapNotificationObject(oIRNotification, oReader);
|
|
oDetails.Add(oIRNotification);
|
|
}
|
|
return oDetails;
|
|
}
|
|
|
|
private IRNotification CreateDetailObject(DataReader oReader)
|
|
{
|
|
IRNotification oIRNotification = new IRNotification();
|
|
MapNotificationObject(oIRNotification, oReader);
|
|
return oIRNotification;
|
|
}
|
|
|
|
private void MapIREmployeeObject(IREmployee oIREmployee, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oIREmployee, oReader.GetID("IREmployeeID"));
|
|
oIREmployee.PositionID = oReader.GetID("PositionId");
|
|
oIREmployee.EmployeeID = oReader.GetID("EmployeeID");
|
|
oIREmployee.WfStatus = (enumwfStatus)oReader.GetInt32("WfStatus").GetValueOrDefault();
|
|
oIREmployee.AppliedDate = oReader.GetDateTime("AppliedDate").GetValueOrDefault();
|
|
oIREmployee.Description = oReader.GetString("Description");
|
|
oIREmployee.IsSelected = oReader.GetBoolean("IsSelected").GetValueOrDefault();
|
|
|
|
this.SetObjectState(oIREmployee, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
|
|
protected ObjectsTemplate<IREmployee> CreateirEmployeeObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<IREmployee> oIREmployees = new ObjectsTemplate<IREmployee>();
|
|
while (oReader.Read())
|
|
{
|
|
IREmployee oIREmployee = new IREmployee();
|
|
MapIREmployeeObject(oIREmployee, oReader);
|
|
oIREmployees.Add(oIREmployee);
|
|
}
|
|
return oIREmployees;
|
|
}
|
|
|
|
private IREmployee CreateIREmployeeObject(DataReader oReader)
|
|
{
|
|
IREmployee oIREmployees = new IREmployee();
|
|
MapIREmployeeObject(oIREmployees, oReader);
|
|
return oIREmployees;
|
|
}
|
|
#endregion
|
|
|
|
#region Service implementation
|
|
|
|
public InternalRecruitment Get(ID id)
|
|
{
|
|
InternalRecruitment oInternalRecruitment = new InternalRecruitment();
|
|
#region Cache Header
|
|
oInternalRecruitment = (InternalRecruitment)_cache["Get", id];
|
|
if (oInternalRecruitment != null)
|
|
return oInternalRecruitment;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(InternalRecruitmentDA.Get(tc, id.Integer));
|
|
if (dr.Read())
|
|
{
|
|
oInternalRecruitment = CreateObject(dr);
|
|
}
|
|
dr.Close();
|
|
tc.End();
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to Get Leave Parameter :" + e.Message, e);
|
|
#endregion
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oInternalRecruitment, "Get", id);
|
|
#endregion
|
|
return oInternalRecruitment;
|
|
}
|
|
|
|
public ObjectsTemplate<InternalRecruitment> Get()
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<InternalRecruitment> oInternalRecruitments = _cache["Get"] as ObjectsTemplate<InternalRecruitment>;
|
|
if (oInternalRecruitments != null)
|
|
return oInternalRecruitments;
|
|
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(InternalRecruitmentDA.Get(tc));
|
|
oInternalRecruitments = this.CreateObjects<InternalRecruitment>(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
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oInternalRecruitments, "Get");
|
|
#endregion
|
|
return oInternalRecruitments;
|
|
}
|
|
|
|
public ObjectsTemplate<InternalRecruitment> Get(bool isClosed)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<InternalRecruitment> oInternalRecruitments = _cache["Get", isClosed] as ObjectsTemplate<InternalRecruitment>;
|
|
if (oInternalRecruitments != null)
|
|
return oInternalRecruitments;
|
|
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(InternalRecruitmentDA.Get(tc, isClosed));
|
|
oInternalRecruitments = this.CreateObjects<InternalRecruitment>(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
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oInternalRecruitments, "Get", isClosed);
|
|
#endregion
|
|
return oInternalRecruitments;
|
|
}
|
|
|
|
public ID Save(InternalRecruitment oInternalRecruitment)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oInternalRecruitment.IsNew)
|
|
{
|
|
int id = tc.GenerateID("InternalReqruitment", "PositionId");
|
|
base.SetObjectID(oInternalRecruitment, ID.FromInteger(id));
|
|
InternalRecruitmentDA.Insert(tc, oInternalRecruitment);
|
|
}
|
|
else
|
|
{
|
|
InternalRecruitmentDA.Update(tc, oInternalRecruitment);
|
|
}
|
|
|
|
InternalRecruitmentDA.DeleteNotifications(tc, oInternalRecruitment.ID.Integer);
|
|
InternalRecruitmentDA.DeleteIREmployees(tc, oInternalRecruitment.ID.Integer);
|
|
foreach (IRNotification oDetail in oInternalRecruitment.Notifications)
|
|
{
|
|
oDetail.PositionID = oInternalRecruitment.ID;
|
|
this.SetObjectID(oDetail, ID.FromInteger(InternalRecruitmentDA.GetNewNotificationID(tc)));
|
|
InternalRecruitmentDA.InsertNotification(tc, oDetail);
|
|
}
|
|
|
|
foreach (IREmployee oemployee in oInternalRecruitment.IREmployees)
|
|
{
|
|
oemployee.PositionID = oInternalRecruitment.ID;
|
|
this.SetObjectID(oemployee, ID.FromInteger(InternalRecruitmentDA.GetNewIREmployeeID(tc)));
|
|
InternalRecruitmentDA.InsertIREmployee(tc, oemployee);
|
|
}
|
|
|
|
tc.End();
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to Save Internal Recruitment :" + e.Message, e);
|
|
#endregion
|
|
}
|
|
return oInternalRecruitment.ID;
|
|
}
|
|
|
|
public ID SaveIrEmployee(IREmployee iREmployee)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (iREmployee.IsNew)
|
|
{
|
|
int id = tc.GenerateID("IREmployee", "IREmployeeID");
|
|
base.SetObjectID(iREmployee, ID.FromInteger(id));
|
|
InternalRecruitmentDA.InsertIREmployee(tc, iREmployee);
|
|
}
|
|
else
|
|
{
|
|
InternalRecruitmentDA.DeleteIREmployees(tc, iREmployee.PositionID.Integer,iREmployee.EmployeeID.Integer);
|
|
int id = tc.GenerateID("IREmployee", "IREmployeeID");
|
|
base.SetObjectID(iREmployee, ID.FromInteger(id));
|
|
InternalRecruitmentDA.InsertIREmployee(tc, iREmployee);
|
|
}
|
|
|
|
tc.End();
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to Save IREmployee :" + e.Message, e);
|
|
#endregion
|
|
}
|
|
return iREmployee.ID;
|
|
}
|
|
|
|
public void Delete(ID id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
InternalRecruitmentDA.DeleteNotifications(tc, id.Integer);
|
|
InternalRecruitmentDA.DeleteIREmployees(tc, id.Integer);
|
|
InternalRecruitmentDA.Delete(tc, id.Integer);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to Delete Internal Recruitment: " + e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public ObjectsTemplate<IRNotification> GetNotifications(ID PositionId)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<IRNotification> oDetails = _cache["Get", PositionId] as ObjectsTemplate<IRNotification>;
|
|
if (oDetails != null)
|
|
return oDetails;
|
|
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(InternalRecruitmentDA.GetNotifications(tc, PositionId.Integer));
|
|
oDetails = this.CreateDetailObjects(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
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oDetails, "GetDetails", PositionId);
|
|
#endregion
|
|
return oDetails;
|
|
|
|
}
|
|
|
|
public IRNotification Get(int PositionId)
|
|
{
|
|
IRNotification oIRNotification = new IRNotification();
|
|
#region Cache Header
|
|
oIRNotification = (IRNotification)_cache["Get", PositionId];
|
|
if (oIRNotification != null)
|
|
return oIRNotification;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(InternalRecruitmentDA.Get(tc, PositionId));
|
|
if (dr.Read())
|
|
{
|
|
oIRNotification = CreateDetailObject(dr);
|
|
}
|
|
dr.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to Get IRNotification: " + e.Message, e);
|
|
#endregion
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oIRNotification, "Get", PositionId);
|
|
#endregion
|
|
return oIRNotification;
|
|
}
|
|
|
|
public ObjectsTemplate<IREmployee> GetIREmployeess(ID PositioniD)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<IREmployee> oDetails = _cache["Get", PositioniD] as ObjectsTemplate<IREmployee>;
|
|
if (oDetails != null)
|
|
return oDetails;
|
|
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(InternalRecruitmentDA.GetIREmployeess(tc, PositioniD.Integer));
|
|
oDetails = this.CreateirEmployeeObjects(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
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oDetails, "GetDetails", PositioniD);
|
|
#endregion
|
|
return oDetails;
|
|
|
|
}
|
|
|
|
public IREmployee GetIrempID(ID irEmpID)
|
|
{
|
|
IREmployee oIREmployee = new IREmployee();
|
|
#region Cache Header
|
|
oIREmployee = (IREmployee)_cache["Get", irEmpID];
|
|
if (oIREmployee != null)
|
|
return oIREmployee;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(InternalRecruitmentDA.Get(tc, irEmpID));
|
|
if (dr.Read())
|
|
{
|
|
oIREmployee = CreateIREmployeeObject(dr);
|
|
}
|
|
dr.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to Get IRNotification: " + e.Message, e);
|
|
#endregion
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oIREmployee, "Get", irEmpID);
|
|
#endregion
|
|
return oIREmployee;
|
|
}
|
|
public IREmployee Get(int PositionId, int empId)
|
|
{
|
|
IREmployee oIREmployee = new IREmployee();
|
|
#region Cache Header
|
|
oIREmployee = (IREmployee)_cache["Get", PositionId, empId];
|
|
if (oIREmployee != null)
|
|
return oIREmployee;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(InternalRecruitmentDA.Get(tc, PositionId, empId));
|
|
if (dr.Read())
|
|
{
|
|
oIREmployee = CreateIREmployeeObject(dr);
|
|
}
|
|
dr.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to Get IRNotification: " + e.Message, e);
|
|
#endregion
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oIREmployee, "Get", PositionId, empId);
|
|
#endregion
|
|
return oIREmployee;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
}
|
|
#endregion
|
|
}
|