CEL_Payroll/Payroll.Service/HREmployee/Service/HREmployeeService.cs
2024-09-17 14:30:13 +06:00

2974 lines
107 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
{
public class HREmployeeService : ServiceTemplate, IHREmployeeService
{
#region Private functions and declaration
Cache _cache = new Cache(typeof(HREmployee));
public HREmployeeService()
{ }
#endregion
#region Object Mapping
#region parent object mapping
#region HREmployee Mapping
private void MapObject(HREmployee oHREmployee, DataReader oReader)
{
this.SetObjectID(oHREmployee, oReader.GetID("EmployeeID"));
oHREmployee.EmployeeNo = oReader.GetString("EmployeeNo");
oHREmployee.FirstName = oReader.GetString("FirstName");
oHREmployee.MiddleName = oReader.GetString("MiddleName");
oHREmployee.LastName = oReader.GetString("LastName");
oHREmployee.NickName = oReader.GetString("ShortName");
oHREmployee.DescriptionText = oReader.GetString("DESIGDESCRIPTION");
oHREmployee.Name= oReader.GetString("Name");
//oHREmployee. = ID.FromInteger(oReader.GetInt32("SBUID"));
oHREmployee.LocationID = oReader.GetID("LOCATIONID");
oHREmployee.DepartmentID = oReader.GetID("DEPARTMENTID");
oHREmployee.FatherName = oReader.GetString("FatherName");
oHREmployee.MotherName = oReader.GetString("MotherName");
oHREmployee.FatherOccupationID = oReader.GetID("FatherOccupationID");
oHREmployee.MotherOccupationID = oReader.GetID("MotherOccupationID");
oHREmployee.NationalityID = oReader.GetID("NationalityID");
oHREmployee.BirthDate = oReader.GetDateTime("BirthDate").Value;
//oHREmployee.BirthDate = oReader.GetDateTime("ORIGINALBIRTHDATE").HasValue ? oReader.GetDateTime("ORIGINALBIRTHDATE").Value:DateTime.Now;
oHREmployee.BirthPlace = oReader.GetString("BirthPlace");
oHREmployee.Gender = (EnumGender)oReader.GetInt32("Gender");
oHREmployee.ReligionID = oReader.GetID("ReligionID");
oHREmployee.GradeID = oReader.GetID("GradeID");
oHREmployee.DesignationID = oReader.GetID("DesignationID");
oHREmployee.CategoryID = oReader.GetID("CATEGORYID");
oHREmployee.FunctionID = oReader.GetID("FunctionID");
oHREmployee.CompanyID = oReader.GetID("CompanyID");
oHREmployee.BloodGroup = (EnumBloodGroup)oReader.GetInt32("BloodGroup");
oHREmployee.PassportNo = oReader.GetString("PassportNo");
oHREmployee.TinNo = oReader.GetString("TINNO");
oHREmployee.NationalID = oReader.GetString("NationalID");
//oHREmployee.PhotoPath = oReader.GetString("PHOTOGRAPH");
oHREmployee.PhotoPath = oReader.GetString("PhotoPath");
oHREmployee.JoiningDate = oReader.GetDateTime("JoiningDate").Value;
//oHREmployee.DiscontinueDate = oReader.GetDateTime("DATEOFEXPIRY").HasValue ? oReader.GetDateTime("DATEOFEXPIRY").Value : (DateTime?)null;
oHREmployee.Signature = oReader.GetString("EMPSIGNATURE");
oHREmployee.Status = (EnumEmployeeStatus)oReader.GetInt32("Status");
oHREmployee.IsConfirmed = oReader.GetBoolean("ISCONFIRMED").Value;
oHREmployee.MaritalStatus = (EnumMaritalStatus)oReader.GetInt32("MARITALSTATUSID");
oHREmployee.PayrollTypeID = oReader.GetID("PAYROLLTYPEID");
oHREmployee.DesktopUserPass = oReader.GetString("DESKTOPUSERPASS");
oHREmployee.EmailAddress = oReader.GetString("EMAILADDRESS");
oHREmployee.BasicSalary = oReader.GetDouble("BasicSalary").Value;
oHREmployee.GrossSalary = oReader.GetDouble("GrossSalary").Value;
oHREmployee.BirthPlace = oReader.GetString("BirthPlace");
oHREmployee.GlobalID = oReader.GetString("GlobalID");
//oHREmployee.PFMemberShiptDate = oReader.GetDateTime("PFAuditDate").Value;
//oHREmployee.EndOfContractDate = oReader.GetDateTime("DATEOFEXPIRY").HasValue ? oReader.GetDateTime("DATEOFEXPIRY").Value : (DateTime?)null;
oHREmployee.ConfirDate = oReader.GetDateTime("DATEOFCONFIRMATION").HasValue ? oReader.GetDateTime("DATEOFCONFIRMATION").Value : DateTime.Now;
//oHREmployee.AdloginID = oReader.GetID("ADLogInID");
oHREmployee.DrivingLicenceNo = oReader.GetString("DrivingLicenceNo");
oHREmployee.PassportIssuePlace = oReader.GetString("PassportIssuePlace");
oHREmployee.PassportIssueDate = oReader.GetDateTime("PassportIssueDate").GetValueOrDefault(DateTime.MinValue);
oHREmployee.PassportExpDate = oReader.GetDateTime("PassportExpDate").GetValueOrDefault(DateTime.MinValue);
oHREmployee.Role = (EnumRole)oReader.GetInt32("Role").Value;
oHREmployee.FileNo = oReader.GetString("FileNo");
this.SetObjectState(oHREmployee, ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
HREmployee oHREmployee = new HREmployee();
MapObject(oHREmployee, oReader);
return oHREmployee as T;
}
protected HREmployee CreateObject(DataReader oReader)
{
HREmployee oHREmployee = new HREmployee();
MapObject(oHREmployee, oReader);
return oHREmployee;
}
#endregion
#endregion
#region children object mappping
#region Spouse object mapping
private void MapEmpSpouseObject(EmpSpouse oEmpSpouse, DataReader oReader)
{
oEmpSpouse.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpSpouse, oReader.GetID("SpouseID"));
oEmpSpouse.Name = oReader.GetString("Name");
oEmpSpouse.MarriageDate = Convert.ToDateTime(oReader.GetString("MarriageDate"));
oEmpSpouse.OccupationID = oReader.GetID("OccupationID");
oEmpSpouse.EducationLevelID = oReader.GetID("EducationLevelID");
oEmpSpouse.PassportNo = oReader.GetString("PassportNo");
oEmpSpouse.PassportIssuePlace = oReader.GetString("PassportIssuePlace");
//oEmpSpouse.PassportIssueDate = oReader.GetDateTime("PassportIssueDate").GetValueOrDefault(DateTime.MinValue);
//oEmpSpouse.PassportExpDate = oReader.GetDateTime("PassportExpDate").GetValueOrDefault(DateTime.MinValue);
oEmpSpouse.PassportIssueDate =Convert.ToDateTime( oReader.GetDateTime("PassportIssueDate").GetValueOrDefault(DateTime.MinValue));
oEmpSpouse.PassportExpDate = Convert.ToDateTime(oReader.GetDateTime("PassportExpDate").GetValueOrDefault(DateTime.MinValue));
this.SetObjectState(oEmpSpouse, ObjectState.Saved);
}
private void MapEmpCreditCardObject(EmpCreditCard oEmpCreditCard, DataReader oReader)
{
this.SetObjectID(oEmpCreditCard, oReader.GetID("EmpCreditCardID"));
oEmpCreditCard.EmployeeID = oReader.GetID("EmployeeID");
oEmpCreditCard.UserType = (EnumCardUserType)oReader.GetInt32("UserType");
oEmpCreditCard.UserTypeID = oReader.GetID("UserTypeID");
oEmpCreditCard.CardNo = oReader.GetString("CardNo");
oEmpCreditCard.CardName = oReader.GetString("CardName");
oEmpCreditCard.BankID = oReader.GetID("BankID");
oEmpCreditCard.CardLimit = Convert.ToDouble(oReader.GetString("CardLimit"));
oEmpCreditCard.CardExpiryDate = oReader.GetDateTime("CardExpiryDate").Value;
oEmpCreditCard.TIN = oReader.GetString("TIN");
this.SetObjectState(oEmpCreditCard, ObjectState.Saved);
}
private EmpSpouse CreateEmpSpouseObject(DataReader oReader)
{
EmpSpouse spouse = new EmpSpouse();
MapEmpSpouseObject(spouse, oReader);
return spouse;
}
private EmpCreditCard CreateEmpCreditCardObject(DataReader oReader)
{
EmpCreditCard creditCard = new EmpCreditCard();
MapEmpCreditCardObject(creditCard,oReader);
return creditCard;
}
protected ObjectsTemplate<EmpSpouse> CreateEmpSpouses(DataReader oReader)
{
ObjectsTemplate<EmpSpouse> oEmpSpouses = new ObjectsTemplate<EmpSpouse>();
while (oReader.Read())
{
EmpSpouse item = CreateEmpSpouseObject(oReader);
oEmpSpouses.Add(item);
}
return oEmpSpouses;
}
protected ObjectsTemplate<EmpCreditCard> CreateEmpCreditCard(DataReader oReader)
{
ObjectsTemplate<EmpCreditCard> oEmpCreditCard = new ObjectsTemplate<EmpCreditCard>();
while (oReader.Read())
{
EmpCreditCard item = CreateEmpCreditCardObject(oReader);
oEmpCreditCard.Add(item);
}
return oEmpCreditCard;
}
#endregion
#region EmpContact object mapping
private void MapEmpContactObject(EmpContact oEmpContact, DataReader oReader)
{
oEmpContact.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpContact, oReader.GetID("ContactID"));
oEmpContact.ParmanentAddress = oReader.GetString("ParmanentAddress");
oEmpContact.ParmanentDistrictID = oReader.GetID("ParmanentDistrictID");
oEmpContact.ParmanentThanaID = oReader.GetID("ParmanentThanaID");
oEmpContact.ParmanentTelephone = oReader.GetString("ParmanentTelephone");
oEmpContact.ParmanentMobile = oReader.GetString("ParmanentMobile"); // Kalam
oEmpContact.PresentAddress = oReader.GetString("PresentAddress");
oEmpContact.PresentDistrictID = oReader.GetID("PresentDistrictID");
oEmpContact.PresentThanaID = oReader.GetID("PresentThanaID");
oEmpContact.PresentTelephone = oReader.GetString("PresentTelephone");
oEmpContact.PresentMobile = oReader.GetString("PresentMobile"); // Kalam
oEmpContact.Mobile = oReader.GetString("Mobile");
oEmpContact.PersonalTelephone = oReader.GetString("PersonalTelephone"); // Kalam
oEmpContact.PersonalEMail = oReader.GetString("PersonalEMail");
oEmpContact.OfficalEMail = oReader.GetString("OfficialEMail");
oEmpContact.Fax = oReader.GetString("Fax");
oEmpContact.EmergencyContactAddress = oReader.GetString("EmergencyContactAddress");
oEmpContact.EmergencyContactPerson = oReader.GetString("EmergencyContactPerson");
oEmpContact.EmergencyTelephone = oReader.GetString("EmergencyTelephone");
oEmpContact.EmergencyMobile = oReader.GetString("EmergencyMobile"); // Kalam
oEmpContact.ContactPersonRelationId = oReader.GetID("CPRelationID"); // Kalam
this.SetObjectState(oEmpContact, ObjectState.Saved);
}
private EmpContact CreateContactObject(DataReader oReader)
{
EmpContact contact = new EmpContact();
MapEmpContactObject(contact, oReader);
return contact;
}
protected ObjectsTemplate<EmpContact> CreateEmpContactObjects(DataReader oReader)
{
ObjectsTemplate<EmpContact> oEmpContacts = new ObjectsTemplate<EmpContact>();
while (oReader.Read())
{
EmpContact item = CreateContactObject(oReader);
oEmpContacts.Add(item);
}
return oEmpContacts;
}
#endregion
#region EmpChildren Mapping
private void MapEmpChildrenObject(EmpChildren oEmpChildren, DataReader oReader)
{
oEmpChildren.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpChildren, oReader.GetID("ChildID"));
oEmpChildren.Name = oReader.GetString("Name");
oEmpChildren.Gender = (EnumGender)oReader.GetInt16("Gender");
oEmpChildren.BirthDate = Convert.ToDateTime(oReader.GetString("BirthDate"));
oEmpChildren.MaritalStatus = (EnumMaritalStatus)oReader.GetInt32("MaritalStatus");
oEmpChildren.OccupationID = oReader.GetID("OccupationID");
oEmpChildren.PassportNo = oReader.GetString("PassportNo");
oEmpChildren.PassportIssuePlace = oReader.GetString("PassportIssuePlace");
//oEmpChildren.PassportIssueDate = oReader.GetDateTime("PassportIssueDate").GetValueOrDefault(DateTime.MinValue);
//oEmpChildren.PassportExpDate = oReader.GetDateTime("PassportExpDate").GetValueOrDefault(DateTime.MinValue);
oEmpChildren.PassportIssueDate = Convert.ToDateTime(oReader.GetDateTime("PassportIssueDate").GetValueOrDefault(DateTime.MinValue));
oEmpChildren.PassportExpDate = Convert.ToDateTime(oReader.GetDateTime("PassportExpDate").GetValueOrDefault(DateTime.MinValue));
this.SetObjectState(oEmpChildren, ObjectState.Saved);
}
private EmpChildren CreateChildrenObject(DataReader oReader)
{
EmpChildren child = new EmpChildren();
MapEmpChildrenObject(child, oReader);
return child;
}
protected ObjectsTemplate<EmpChildren> CreateEmpChildrenObjects(DataReader oReader)
{
ObjectsTemplate<EmpChildren> oEmpChildrens = new ObjectsTemplate<EmpChildren>();
while (oReader.Read())
{
EmpChildren item = CreateChildrenObject(oReader);
oEmpChildrens.Add(item);
}
return oEmpChildrens;
}
#endregion
#region EmpPublication Mapping
private void MapEmpPublicationObject(EmpPublication oEmpPublication, DataReader oReader)
{
oEmpPublication.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpPublication, oReader.GetID("PublicationID"));
oEmpPublication.Title = oReader.GetString("Title");
oEmpPublication.Description = oReader.GetString("Description");
oEmpPublication.Remarks = oReader.GetString("Remarks");
oEmpPublication.PublicationDate = Convert.ToDateTime(oReader.GetString("PublicationDate"));
oEmpPublication.PublicationType = oReader.GetString("PUBLICATIONTYPE");
oEmpPublication.PublishersName = oReader.GetString("PUBLISHERSNAME");
this.SetObjectState(oEmpPublication, ObjectState.Saved);
}
private EmpPublication CreateEmpPublicationObject(DataReader oReader)
{
EmpPublication publication = new EmpPublication();
MapEmpPublicationObject(publication, oReader);
return publication;
}
protected ObjectsTemplate<EmpPublication> CreateEmpPublicationObjects(DataReader oReader)
{
ObjectsTemplate<EmpPublication> oEmpPublications = new ObjectsTemplate<EmpPublication>();
while (oReader.Read())
{
EmpPublication item = CreateEmpPublicationObject(oReader);
oEmpPublications.Add(item);
}
return oEmpPublications;
}
#endregion
#region EmpReference Mapping
private void MapEmpReferenceObject(EmpReference oEmpReference, DataReader oReader)
{
oEmpReference.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpReference, oReader.GetID("ReferenceID"));
oEmpReference.Name = oReader.GetString("Name");
oEmpReference.OccupationID =oReader.GetID("OccupationID");
oEmpReference.Address = oReader.GetString("Address");
oEmpReference.Telephone = oReader.GetString("Telephone");
oEmpReference.ReferenceMobile = oReader.GetString("ReferenceMobile");
oEmpReference.EmailAddress = oReader.GetString("EmailAddress");
oEmpReference.RelationID = oReader.GetID("RelationID");
this.SetObjectState(oEmpReference, ObjectState.Saved);
}
private EmpReference CreateEmpReferenceObject(DataReader oReader)
{
EmpReference reference = new EmpReference();
MapEmpReferenceObject(reference, oReader);
return reference;
}
protected ObjectsTemplate<EmpReference>CreateEmpReferenceObjects(DataReader oReader)
{
ObjectsTemplate<EmpReference> oEmpReferences = new ObjectsTemplate<EmpReference>();
while (oReader.Read())
{
EmpReference item = CreateEmpReferenceObject(oReader);
oEmpReferences.Add(item);
}
return oEmpReferences;
}
#endregion
#region EmpExperience Mapping
private void MapEmpExperienceObject(EmpExperience oEmpExperience, DataReader oReader)
{
oEmpExperience.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpExperience, oReader.GetID("ExperienceID"));
oEmpExperience.Employer = oReader.GetString("Employer");
oEmpExperience.ContactPerson = oReader.GetString("ContactPerson");
oEmpExperience.Address = oReader.GetString("Address");
oEmpExperience.Telephone = oReader.GetString("Telephone");
oEmpExperience.EmployerActivity = oReader.GetString("EmployerActivity");
oEmpExperience.Designation = oReader.GetString("Designation");
oEmpExperience.JobDescription = oReader.GetString("JobDescription");
oEmpExperience.FromDate = Convert.ToDateTime(oReader.GetString("FromDate"));
oEmpExperience.ToDate = Convert.ToDateTime(oReader.GetString("ToDate"));
oEmpExperience.TillDate = Convert.ToDateTime(oReader.GetString("TODATE"));
oEmpExperience.LastJob = Convert.ToInt32(oReader.GetString("LastJob"))== 0 ? false : true;
this.SetObjectState(oEmpExperience, ObjectState.Saved);
}
private EmpExperience CreateEmpExperienceObject(DataReader oReader)
{
EmpExperience experience = new EmpExperience();
MapEmpExperienceObject(experience, oReader);
return experience;
}
protected ObjectsTemplate<EmpExperience> CreateEmpExperienceObjects(DataReader oReader)
{
ObjectsTemplate<EmpExperience> oEmpExperiences = new ObjectsTemplate<EmpExperience>();
while (oReader.Read())
{
EmpExperience item = CreateEmpExperienceObject(oReader);
oEmpExperiences.Add(item);
}
return oEmpExperiences;
}
#endregion
#region EmpTraining Mapping
private void MapEmpTrainingObject(EmpTraining oEmpTraining, DataReader oReader)
{
oEmpTraining.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpTraining, oReader.GetID("EmpTrainingID"));
oEmpTraining.Name = oReader.GetString("Name");
oEmpTraining.Description = oReader.GetString("Description");
oEmpTraining.CountryID = oReader.GetID("CountryID");
oEmpTraining.NatureOfTrainingID = oReader.GetID("NatureOfTrainingID");
oEmpTraining.TrainingTypeID = oReader.GetID("TrainingTypeID");
oEmpTraining.TrainingCompletedFrom = (EnumTrainingCompletedFrom)oReader.GetInt32("TrainingCompletedFrom");
oEmpTraining.InstitutionID = oReader.GetID("InstitutionID");
oEmpTraining.Place = oReader.GetString("TrainingPlace");
oEmpTraining.Achievement = oReader.GetString("Achievement");
oEmpTraining.Fees = Convert.ToDouble(oReader.GetString("Fees"));
oEmpTraining.OtherCost = Convert.ToDouble(oReader.GetString("OtherCost"));
oEmpTraining.FromDate = Convert.ToDateTime(oReader.GetString("FromDate"));
oEmpTraining.ToDate = Convert.ToDateTime(oReader.GetString("ToDate"));
oEmpTraining.TrainingMonth = Convert.ToInt32(oReader.GetString("TrainingMonth"));
oEmpTraining.TrainingDay = Convert.ToInt32(oReader.GetString("TrainingDay"));
oEmpTraining.TrainingHour = Convert.ToInt32(oReader.GetString("TrainingHour"));
oEmpTraining.ConfirmationDate = Convert.ToDateTime(oReader.GetString("ConfirmationDate"));
this.SetObjectState(oEmpTraining, ObjectState.Saved);
}
private EmpTraining CreateEmpTrainingObject(DataReader oReader)
{
EmpTraining training = new EmpTraining();
MapEmpTrainingObject(training, oReader);
return training;
}
protected ObjectsTemplate<EmpTraining> CreateEmpTrainingObjects(DataReader oReader)
{
ObjectsTemplate<EmpTraining> oEmpTrainings = new ObjectsTemplate<EmpTraining>();
while (oReader.Read())
{
EmpTraining item = CreateEmpTrainingObject(oReader);
oEmpTrainings.Add(item);
}
return oEmpTrainings;
}
#endregion
#region EmpTraining Mapping
private void MapEmpNomineeObject(EmpNominee oEmpNominee, DataReader oReader)
{
oEmpNominee.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpNominee, oReader.GetID("NomineeID"));
oEmpNominee.NominationPurposeID = oReader.GetID("NominationPurposeID");
oEmpNominee.NominationDate = Convert.ToDateTime(oReader.GetString("NominationDate"));
oEmpNominee.Name = oReader.GetString("Name");
oEmpNominee.RelationID = oReader.GetID("RelationID");
oEmpNominee.Percentage = Convert.ToDouble(oReader.GetString("Percentage"));
oEmpNominee.BirthDate = Convert.ToDateTime(oReader.GetString("BirthDate"));
oEmpNominee.OccupationID =oReader.GetID("OccupationID");
oEmpNominee.Address = oReader.GetString("Address");
oEmpNominee.Photograph = oReader.GetString("PHOTOPATH");
oEmpNominee.Signature = oReader.GetString("Signature");
oEmpNominee.TelePhone = oReader.GetString("TelePhone");
oEmpNominee.EmailAddress = oReader.GetString("EmailAddress");
this.SetObjectState(oEmpNominee, ObjectState.Saved);
}
private EmpNominee CreateEmpNomineeObject(DataReader oReader)
{
EmpNominee nominee = new EmpNominee();
MapEmpNomineeObject(nominee, oReader);
return nominee;
}
protected ObjectsTemplate<EmpNominee> CreateEmpNomineeObjects(DataReader oReader)
{
ObjectsTemplate<EmpNominee> oEmpNominees = new ObjectsTemplate<EmpNominee>();
while (oReader.Read())
{
EmpNominee item = CreateEmpNomineeObject(oReader);
oEmpNominees.Add(item);
}
return oEmpNominees;
}
#endregion
#region EmpAcademic Mapping
private void MapEmpAcademicObject(EmpAcademic oEmpAcademic, DataReader oReader)
{
oEmpAcademic.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpAcademic, oReader.GetID("AcademicID"));
oEmpAcademic.EducationTypeID = oReader.GetID("EducationTypeID");
oEmpAcademic.EducationLevelID = oReader.GetID("EducationLevelID");
oEmpAcademic.DisciplineID = oReader.GetID("DisciplineID");
oEmpAcademic.InstitutionID = oReader.GetID("InstitutionID");
oEmpAcademic.PassingYear = oReader.GetInt32("PassingYear").Value;
oEmpAcademic.ResultTypeID = oReader.GetID("ResultTypeID");
oEmpAcademic.GPAOrMarks = oReader.GetDouble("GPAOrMarks").Value;
oEmpAcademic.OutOf = oReader.GetDouble("OutOf").Value;
oEmpAcademic.LastLevel = oReader.GetBoolean("LastLevel").Value;
oEmpAcademic.InstituteName = oReader.GetString("InstituteName");
this.SetObjectState(oEmpAcademic, ObjectState.Saved);
}
private EmpAcademic CreateEmpAcademicObject(DataReader oReader)
{
EmpAcademic academic = new EmpAcademic();
MapEmpAcademicObject(academic, oReader);
return academic;
}
protected ObjectsTemplate<EmpAcademic> CreateEmpAcademicObjects(DataReader oReader)
{
ObjectsTemplate<EmpAcademic> oEmpAcademics = new ObjectsTemplate<EmpAcademic>();
while (oReader.Read())
{
EmpAcademic item = CreateEmpAcademicObject(oReader);
oEmpAcademics.Add(item);
}
return oEmpAcademics;
}
#endregion
#region EmpAchievement Mapping
private void MapEmpAchievementObject(EmpAchievement oEmpAchievement, DataReader oReader)
{
oEmpAchievement.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpAchievement, oReader.GetID("EmpAchivementID"));
oEmpAchievement.AchievementID = oReader.GetID("AchivementID");
this.SetObjectState(oEmpAchievement, ObjectState.Saved);
}
private EmpAchievement CreateEmpAchievementObject(DataReader oReader)
{
EmpAchievement achievement = new EmpAchievement();
MapEmpAchievementObject(achievement, oReader);
return achievement;
}
protected ObjectsTemplate<EmpAchievement> CreateEmpAchievementObjects(DataReader oReader)
{
ObjectsTemplate<EmpAchievement> oEmpAchievements = new ObjectsTemplate<EmpAchievement>();
while (oReader.Read())
{
EmpAchievement item = CreateEmpAchievementObject(oReader);
oEmpAchievements.Add(item);
}
return oEmpAchievements;
}
#endregion
#region EmpCurricularActivity Mapping
private void MapEmpCurricularActivityObject(EmpCurricularActivity oEmpCurricularActivity, DataReader oReader)
{
oEmpCurricularActivity.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpCurricularActivity, oReader.GetID("EmpExtraCurricularActivityID"));
oEmpCurricularActivity.CurricularActivityID = oReader.GetID("ExtraCurricularActivityID");
this.SetObjectState(oEmpCurricularActivity, ObjectState.Saved);
}
private EmpCurricularActivity CreateEmpCurricularActivityObject(DataReader oReader)
{
EmpCurricularActivity curricularActivity = new EmpCurricularActivity();
MapEmpCurricularActivityObject(curricularActivity, oReader);
return curricularActivity;
}
protected ObjectsTemplate<EmpCurricularActivity> CreateEmpCurricularActivityObjects(DataReader oReader)
{
ObjectsTemplate<EmpCurricularActivity> oEmpCurricularActivitys = new ObjectsTemplate<EmpCurricularActivity>();
while (oReader.Read())
{
EmpCurricularActivity item = CreateEmpCurricularActivityObject(oReader);
oEmpCurricularActivitys.Add(item);
}
return oEmpCurricularActivitys;
}
#endregion
#region EmpOtherTalent Mapping
private void MapEmpOtherTalentObject(EmpOtherTalent oEmpOtherTalent, DataReader oReader)
{
oEmpOtherTalent.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpOtherTalent, oReader.GetID("EmpOtherTalentID"));
oEmpOtherTalent.OtherTalentID = oReader.GetID("OtherTalentID");
this.SetObjectState(oEmpOtherTalent, ObjectState.Saved);
}
private EmpOtherTalent CreateEmpOtherTalentObject(DataReader oReader)
{
EmpOtherTalent otherTalents = new EmpOtherTalent();
MapEmpOtherTalentObject(otherTalents, oReader);
return otherTalents;
}
protected ObjectsTemplate<EmpOtherTalent> CreateEmpOtherTalentObjects(DataReader oReader)
{
ObjectsTemplate<EmpOtherTalent> oEmpOtherTalents = new ObjectsTemplate<EmpOtherTalent>();
while (oReader.Read())
{
EmpOtherTalent item = CreateEmpOtherTalentObject(oReader);
oEmpOtherTalents.Add(item);
}
return oEmpOtherTalents;
}
#endregion
#region EmpHobby Mapping
private void MapEmpHobby(EmpHobby oEmpHobby, DataReader oReader)
{
oEmpHobby.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpHobby, oReader.GetID("EmpHobbyID"));
oEmpHobby.HobbyID = oReader.GetID("HobbyID");
this.SetObjectState(oEmpHobby, ObjectState.Saved);
}
private EmpHobby CreateEmpHobbyObject(DataReader oReader)
{
EmpHobby hobbys = new EmpHobby();
MapEmpHobby(hobbys, oReader);
return hobbys;
}
protected ObjectsTemplate<EmpHobby> CreateEmpHobbyObjects(DataReader oReader)
{
ObjectsTemplate<EmpHobby> oEmpHobbys = new ObjectsTemplate<EmpHobby>();
while (oReader.Read())
{
EmpHobby item = CreateEmpHobbyObject(oReader);
oEmpHobbys.Add(item);
}
return oEmpHobbys;
}
#endregion
#region EmpAllergy Mapping
private void MapEmpAllergy(EmpAllergy oEmpAllergy, DataReader oReader)
{
oEmpAllergy.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpAllergy, oReader.GetID("EmpAllergyID"));
oEmpAllergy.AllergyID = oReader.GetID("AllergyID");
this.SetObjectState(oEmpAllergy, ObjectState.Saved);
}
private EmpAllergy CreateEmpAllergyObject(DataReader oReader)
{
EmpAllergy allergies = new EmpAllergy();
MapEmpAllergy(allergies, oReader);
return allergies;
}
protected ObjectsTemplate<EmpAllergy> CreateEmpAllergyObjects(DataReader oReader)
{
ObjectsTemplate<EmpAllergy> oEmpAllergys = new ObjectsTemplate<EmpAllergy>();
while (oReader.Read())
{
EmpAllergy item = CreateEmpAllergyObject(oReader);
oEmpAllergys.Add(item);
}
return oEmpAllergys;
}
#endregion
#region EmpHospitalization Mapping
private void MapEmpHospitalization(EmpHospitalization oEmpHospitalization, DataReader oReader)
{
oEmpHospitalization.EmployeeID = oReader.GetID("EmployeeID");
this.SetObjectID(oEmpHospitalization, oReader.GetID("HospitalizationID"));
oEmpHospitalization.RegistrationDate = oReader.GetDateTime("RegistrationDate").Value;
oEmpHospitalization.RegisteredPerson = oReader.GetString("RegisteredPerson");
oEmpHospitalization.RelationId = oReader.GetID("RelationId");
oEmpHospitalization.BirthDate = oReader.GetDateTime("BirthDate").Value;
oEmpHospitalization.OccupationID = oReader.GetID("OccupationID");
oEmpHospitalization.Address = oReader.GetString("Address");
oEmpHospitalization.Photograph = oReader.GetString("Photograph");
oEmpHospitalization.Telephone = oReader.GetString("TelePhone");
oEmpHospitalization.Mobile = oReader.GetString("Mobile");
oEmpHospitalization.Email = oReader.GetString("Email");
this.SetObjectState(oEmpHospitalization, ObjectState.Saved);
}
private EmpHospitalization CreateEmpHospitalizationObject(DataReader oReader)
{
EmpHospitalization hospitalization = new EmpHospitalization();
MapEmpHospitalization(hospitalization, oReader);
return hospitalization;
}
protected ObjectsTemplate<EmpHospitalization> CreateEmpHospitalizationObjects(DataReader oReader)
{
ObjectsTemplate<EmpHospitalization> oEmpHospitalizations = new ObjectsTemplate<EmpHospitalization>();
while (oReader.Read())
{
EmpHospitalization item = CreateEmpHospitalizationObject(oReader);
oEmpHospitalizations.Add(item);
}
return oEmpHospitalizations;
}
#endregion
#region MapEmpGuarantor Mapping
private void MapEmpGuarantor(EmpGuarantor oEmpGuarantor, DataReader oReader)
{
this.SetObjectID(oEmpGuarantor, oReader.GetID("GUARANTORID"));
oEmpGuarantor.EmployeeID = oReader.GetID("EMPLOYEEID");
oEmpGuarantor.Name = oReader.GetString("NAME");
oEmpGuarantor.OccupationID = oReader.GetID("OCCUPATIONID");
oEmpGuarantor.Address = oReader.GetString("ADDRESS");
oEmpGuarantor.Telephone = oReader.GetString("TELEPHONE");
oEmpGuarantor.GuarantorMobile = oReader.GetString("MOBILE");
oEmpGuarantor.EmailAddress = oReader.GetString("EMAILADDRESS");
oEmpGuarantor.CategotyDocId = oReader.GetID("CATEGORYDOCID");
oEmpGuarantor.DocumentPath = oReader.GetString("DOCUMENTPATH");
this.SetObjectState(oEmpGuarantor, ObjectState.Saved);
}
private EmpGuarantor CreateEmpGuarantorObject(DataReader oReader)
{
EmpGuarantor guarantor = new EmpGuarantor();
MapEmpGuarantor(guarantor, oReader);
return guarantor;
}
protected ObjectsTemplate<EmpGuarantor> CreateEmpGuarantorObjects(DataReader oReader)
{
ObjectsTemplate<EmpGuarantor> oEmpGuarantor = new ObjectsTemplate<EmpGuarantor>();
while (oReader.Read())
{
EmpGuarantor item = CreateEmpGuarantorObject(oReader);
oEmpGuarantor.Add(item);
}
return oEmpGuarantor;
}
#endregion
#region EmpWorkPlan Mapping
private void MapObject(EmpWorkPlanSetup oEmployeeWorkPlanSetup, DataReader oReader)
{
base.SetObjectID(oEmployeeWorkPlanSetup, oReader.GetID("EmployeeWorkPlanSetupID"));
oEmployeeWorkPlanSetup.EmployeeID = oReader.GetID("EmployeeID");
oEmployeeWorkPlanSetup.ShiftID = oReader.GetID("ShiftID");
oEmployeeWorkPlanSetup.StartDate = oReader.GetDateTime("StartDate").Value;
oEmployeeWorkPlanSetup.WorkPlanGroupID = oReader.GetID("WorkPlanGroupID");
oEmployeeWorkPlanSetup.WeekEndOn = (DayOfWeek)oReader.GetInt32("WeekEndOn").Value;
oEmployeeWorkPlanSetup.CreatedBy = oReader.GetID("CreatedBy");
oEmployeeWorkPlanSetup.CreatedDate = oReader.GetDateTime("CreatedDate").HasValue ? oReader.GetDateTime("CreatedDate").Value : DateTime.MinValue;
oEmployeeWorkPlanSetup.ModifiedBy = oReader.GetID("ModifiedBy");
oEmployeeWorkPlanSetup.ModifiedDate = oReader.GetDateTime("ModifiedDate").HasValue ? oReader.GetDateTime("ModifiedDate").Value : (DateTime?)null;
this.SetObjectState(oEmployeeWorkPlanSetup, Ease.CoreV35.ObjectState.Saved);
}
protected EmpWorkPlanSetup CreateEmpWorkObject(DataReader oReader)
{
EmpWorkPlanSetup oEmployeeWorkPlanSetup = new EmpWorkPlanSetup();
MapObject(oEmployeeWorkPlanSetup, oReader);
return oEmployeeWorkPlanSetup;
}
#endregion
#region EmpLanguage Mapping
private void MapEmpLanguage(EmpLanguage oEmpLanguage, DataReader oReader)
{
this.SetObjectID(oEmpLanguage, oReader.GetID("EmpLanguageID"));
oEmpLanguage.EmployeeID = oReader.GetID("EmployeeID");
oEmpLanguage.LanguageName = oReader.GetString("LanguageName");
oEmpLanguage.SpokenStatus = (EnumLanguageEfficiency)oReader.GetInt32("SpokenStatus");
oEmpLanguage.WrittenStatus = (EnumLanguageEfficiency)oReader.GetInt32("WrittenStatus");
this.SetObjectState(oEmpLanguage, ObjectState.Saved);
}
private EmpLanguage CreateEmpLanguageObject(DataReader oReader)
{
EmpLanguage language = new EmpLanguage();
MapEmpLanguage(language, oReader);
return language;
}
protected ObjectsTemplate<EmpLanguage> CreateEmpLanguageObjects(DataReader oReader)
{
ObjectsTemplate<EmpLanguage> oEmpLanguage = new ObjectsTemplate<EmpLanguage>();
while (oReader.Read())
{
EmpLanguage item = CreateEmpLanguageObject(oReader);
oEmpLanguage.Add(item);
}
return oEmpLanguage;
}
#endregion
#region EmpRelative Mapping
private void MapEmpRelative(EmpRelative oEmpRelative, DataReader oReader)
{
this.SetObjectID(oEmpRelative, oReader.GetID("EmpRelativeID"));
oEmpRelative.Name = oReader.GetString("Name");
oEmpRelative.EmployeeID = oReader.GetID("EmployeeID");
oEmpRelative.Designation = oReader.GetString("Designation");
oEmpRelative.RelationID = oReader.GetID("RelationID");
oEmpRelative.EmpNo = oReader.GetString("EmpNo");
oEmpRelative.JoiningDate = oReader.GetDateTime("JoiningDate").HasValue ? oReader.GetDateTime("JoiningDate").Value : DateTime.MinValue; ;//(DateTime)oReader.GetDateTime("JoiningDate");
oEmpRelative.EndDate = oReader.GetDateTime("EndDate").HasValue ? oReader.GetDateTime("EndDate").Value : DateTime.MinValue;
this.SetObjectState(oEmpRelative, ObjectState.Saved);
}
private EmpRelative CreateEmpRelativeObject(DataReader oReader)
{
EmpRelative relative = new EmpRelative();
MapEmpRelative(relative, oReader);
return relative;
}
protected ObjectsTemplate<EmpRelative> CreateEmpRelativeObjects(DataReader oReader)
{
ObjectsTemplate<EmpRelative> oEmpRelative = new ObjectsTemplate<EmpRelative>();
while (oReader.Read())
{
EmpRelative item = CreateEmpRelativeObject(oReader);
oEmpRelative.Add(item);
}
return oEmpRelative;
}
#endregion
#region EmpMembership Mapping
private void MapEmpMembership(EmpMembership oEmpMembership, DataReader oReader)
{
this.SetObjectID(oEmpMembership, oReader.GetID("EmpMembershipID"));
oEmpMembership.Organization = oReader.GetString("Organization");
oEmpMembership.EmployeeID = oReader.GetID("EmployeeID");
oEmpMembership.Activity = oReader.GetString("Activity");
oEmpMembership.FromDate = (DateTime)oReader.GetDateTime("FromDate");
oEmpMembership.EndDate = oReader.GetDateTime("EndDate").HasValue ? oReader.GetDateTime("EndDate").Value : DateTime.MinValue; ;//(DateTime)oReader.GetDateTime("EndDate");
oEmpMembership.OrganizationType = (EnumOrganizationType)oReader.GetInt32("OrganizationType");
this.SetObjectState(oEmpMembership, ObjectState.Saved);
}
private EmpMembership CreateEmpMembershipObject(DataReader oReader)
{
EmpMembership membership = new EmpMembership();
MapEmpMembership(membership, oReader);
return membership;
}
protected ObjectsTemplate<EmpMembership> CreateEmpMembershipObjects(DataReader oReader)
{
ObjectsTemplate<EmpMembership> oEmpMembership = new ObjectsTemplate<EmpMembership>();
while (oReader.Read())
{
EmpMembership item = CreateEmpMembershipObject(oReader);
oEmpMembership.Add(item);
}
return oEmpMembership;
}
#endregion
#region EmpRelation Mapping
private void MapEmpRelation(EmpRelation oEmpRelation, DataReader oReader)
{
this.SetObjectID(oEmpRelation, oReader.GetID("EmpRelationID"));
oEmpRelation.Name = oReader.GetString("Name");
oEmpRelation.EmployeeID = oReader.GetID("EmployeeID");
oEmpRelation.RelationID = oReader.GetID("Relation");
oEmpRelation.OccupationID = oReader.GetID("Occupation");
this.SetObjectState(oEmpRelation, ObjectState.Saved);
}
private EmpRelation CreateoEmpRelationObject(DataReader oReader)
{
EmpRelation relation = new EmpRelation();
MapEmpRelation(relation, oReader);
return relation;
}
protected ObjectsTemplate<EmpRelation> CreateEmpRelationObjects(DataReader oReader)
{
ObjectsTemplate<EmpRelation> oEmpRelation = new ObjectsTemplate<EmpRelation>();
while (oReader.Read())
{
EmpRelation item = CreateoEmpRelationObject(oReader);
oEmpRelation.Add(item);
}
return oEmpRelation;
}
#endregion
#region EmpHRQuestionAnswer mapping
private void MapEmpHRQuestionAnswer(EmpHRQuestionAnswer oHRQuestionAnswer, DataReader oReader)
{
this.SetObjectID(oHRQuestionAnswer, oReader.GetID("EmpHRQuestionAnswerID"));
oHRQuestionAnswer.QAnswer = oReader.GetString("QAnswer");
oHRQuestionAnswer.QuestionDes = oReader.GetString("Question");
oHRQuestionAnswer.EmployeeID = oReader.GetID("EmployeeID");
oHRQuestionAnswer.QuestionaryID = oReader.GetID("QuestionaryID");
oHRQuestionAnswer.QuestionNo = oReader.GetString("QuestionNo");
this.SetObjectState(oHRQuestionAnswer, ObjectState.Saved);
}
private EmpHRQuestionAnswer CreateoEmpHRQuestionAnswerObject(DataReader oReader)
{
EmpHRQuestionAnswer hRQuestionAnswer = new EmpHRQuestionAnswer();
MapEmpHRQuestionAnswer(hRQuestionAnswer, oReader);
return hRQuestionAnswer;
}
protected ObjectsTemplate<EmpHRQuestionAnswer> CreateEmpHRQuestionAnswerObjects(DataReader oReader)
{
ObjectsTemplate<EmpHRQuestionAnswer> oHRQuestionAnswer = new ObjectsTemplate<EmpHRQuestionAnswer>();
while (oReader.Read())
{
EmpHRQuestionAnswer item = CreateoEmpHRQuestionAnswerObject(oReader);
oHRQuestionAnswer.Add(item);
}
return oHRQuestionAnswer;
}
#endregion
#endregion
#endregion
#region Service Implimentation
#region parent service implimentation
#region Get Functions
public HREmployee Get(ID id)
{
HREmployee oHREmployee = new HREmployee();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmployees(tc, id));
if (dr.Read())
{
oHREmployee = this.CreateObject<HREmployee>(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 oHREmployee;
}
public HREmployee GetEmployee(string employeeNo)
{
HREmployee oEmployee = new HREmployee();
#region Cache Header
oEmployee = _cache["GetEmployee", employeeNo] as HREmployee;
if (oEmployee != null)
return oEmployee;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(HREmployeeDA.GetEmployee(tc, employeeNo));
if (oreader.Read())
{
oEmployee = this.CreateObject<HREmployee>(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(oEmployee, "GetEmployee", employeeNo);
#endregion
return oEmployee;
}
public EmpWorkPlanSetup GetEmpWorkPlanSetup(ID id)
{
EmpWorkPlanSetup oEmployeeWorkPlanSetup = new EmpWorkPlanSetup();
#region Cache Header
oEmployeeWorkPlanSetup = _cache["Get", id] as EmpWorkPlanSetup;
if (oEmployeeWorkPlanSetup != null)
return oEmployeeWorkPlanSetup;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(HREmployeeDA.GetEmpWorkPlanSetup(tc, id));
if (oreader.Read())
{
oEmployeeWorkPlanSetup = this.CreateEmpWorkObject(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(oEmployeeWorkPlanSetup, "Get", id);
#endregion
return oEmployeeWorkPlanSetup;
}
public HREmployee GetByEmployeeNo(string empNo)
{
HREmployee oHREmployee = new HREmployee();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetByEmployeeNo(tc, empNo));
if(dr.Read())
{
oHREmployee = this.CreateObject<HREmployee>(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 oHREmployee;
}
public ObjectsTemplate<HREmployee> GetUserGroups()
{
#region Cache Header
ObjectsTemplate<HREmployee> oHREmployees = _cache["Get"] as ObjectsTemplate<HREmployee>;
if (oHREmployees != null)
return oHREmployees;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetUserGroups(tc));
oHREmployees = this.CreateObjects<HREmployee>(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
}
#region Cache Footer
_cache.Add(oHREmployees, "Get");
#endregion
return oHREmployees;
}
public ObjectsTemplate<HREmployee> GetEmployeeByIds(string idS)
{
#region Cache Header
ObjectsTemplate<HREmployee> oHREmployees = _cache["Get"] as ObjectsTemplate<HREmployee>;
if (oHREmployees != null)
return oHREmployees;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmployeeByIds(tc, idS));
oHREmployees = this.CreateObjects<HREmployee>(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
}
#region Cache Footer
_cache.Add(oHREmployees, "Get", idS);
#endregion
return oHREmployees;
}
public string GetSubordinateIDs(ID nodeID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
string subOrdinateIDs = HREmployeeDA.GetSubordinateIDs(tc, nodeID.Integer);
tc.End();
return subOrdinateIDs;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new Exception(e.Message, e);
#endregion
}
}
public DataSet GetSubordinatesDataset(ID nodeID, string AdditionalSQL)
{
//TransactionContext tc = null;
//DataSet employees = null;
//string sql = string.Empty;
//try
//{
// tc = TransactionContext.Begin(true);
// RAHierarchyNodeService nodeService = new RAHierarchyNodeService();
// RAHierarchyNode node = nodeService.Get(tc, nodeID);
// int maxLevel = nodeService.GetMaxLevel(tc);
// if (node != null)
// {
// string subQuery = " Select NodeID From RAHierarchyNode Where ParentNodeID=" + nodeID.Integer.ToString();
// for (int i = 0; i <= maxLevel - node.Level; i++)
// {
// if (sql.Length > 0) sql += " UNION ";
// sql = sql + " " + recure(subQuery, i);
// }
// sql = "Select Employee.EmployeeId, Employee.EmployeeNo, Employee.Name, RANodeProperty.NodeId From RANodeProperty , Employee Where NodeID In " +
// "(" + sql + ")" +
// "AND RANodeProperty.EmployeeID IS NOT NULL AND RANodeProperty.EmployeeID = Employee.EmployeeID AND Employee.Status =1";
// if (AdditionalSQL != "")
// {
// sql = sql + " AND " + AdditionalSQL;
// }
// employees = EmployeeDA.GetSubordinatesEmps(tc, sql);
// }
// tc.End();
// return employees;
//}
//catch (Exception e)
//{
// #region Handle Exception
// if (tc != null)
// tc.HandleError();
// ExceptionLog.Write(e);
// throw new ServiceException(e.Message, e);
// #endregion
//}
return null;
}
public DataSet GetEmployeesDataset(string sQuery)
{
DataSet oEmployees = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
oEmployees = HREmployeeDA.GetSubordinatesEmps(tc, sQuery);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new Exception(e.Message, e);
#endregion
}
return oEmployees;
}
public ObjectsTemplate<HREmployee> GetGroupEmployees()
{
ObjectsTemplate<HREmployee> employees = new ObjectsTemplate<HREmployee>();
#region Cache Header
employees = (ObjectsTemplate<HREmployee>)_cache["GetGroupEmployees"];
if (employees != null)
return employees;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oReader = new DataReader(HREmployeeDA.GetUserGroups(tc));
employees = this.CreateObjects<HREmployee>(oReader);
oReader.Close();
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new Exception(e.Message, e);
#endregion
}
#region Cache Footer
_cache.Add(employees, "GetGroupEmployees");
#endregion
return employees;
}
public ObjectsTemplate<HREmployee> GetEmployees(string sQuery)
{
ObjectsTemplate<HREmployee> oEmployees = new ObjectsTemplate<HREmployee>();
#region Cache Header
oEmployees = (ObjectsTemplate<HREmployee>)_cache["GetEmployees", sQuery];
if (oEmployees != null)
return oEmployees;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oReader = new DataReader(HREmployeeDA.GetEmployees(tc, sQuery));
oEmployees = this.CreateObjects<HREmployee>(oReader);
oReader.Close();
tc.End();
#region Child Objects
#endregion
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new Exception(e.Message, e);
#endregion
}
#region Cache Footer
_cache.Add(oEmployees, "GetEmployees", sQuery);
#endregion
return oEmployees;
}
public ObjectsTemplate<HREmployee> Get(int payrollTypeID)
{
ObjectsTemplate<HREmployee> employees = new ObjectsTemplate<HREmployee>();
#region Cache Header
employees = (ObjectsTemplate<HREmployee>)_cache["Get"];
if (employees != null)
return employees;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oReader = new DataReader(EmployeeDA.Get(tc, payrollTypeID));
employees = this.CreateObjects<HREmployee>(oReader);
oReader.Close();
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new Exception(e.Message, e);
#endregion
}
#region Cache Footer
_cache.Add(employees, "Get");
#endregion
return employees;
}
#endregion
public bool IsEmployeeNoExist(string empNo)
{
TransactionContext tc = null;
bool result = false;
try
{
tc = TransactionContext.Begin();
result = HREmployeeDA.IsExists("Employee", "EmployeeNo", empNo, tc);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new Exception(e.Message, e);
#endregion
}
return result;
}
public bool IsNickNameExists(string nickName)
{
TransactionContext tc = null;
bool result = false;
try
{
tc = TransactionContext.Begin();
result = HREmployeeDA.IsExists("Employee", "ShortName", nickName, tc);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new Exception(e.Message, e);
#endregion
}
return result;
}
public bool IsExists(string sSearch)
{
TransactionContext tc = null;
bool bExists = false;
try
{
tc = TransactionContext.Begin();
bExists = HREmployeeDA.IsExists(tc, sSearch);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new Exception(e.Message, e);
#endregion
}
return bExists;
}
public LogInStatus IsValidateForDesktop(string empNo, string password, ref HREmployee employee)
{
TransactionContext tc = null;
LogInStatus result = LogInStatus.InvalidPassword;
//try
//{
// tc = TransactionContext.Begin();
// #region Employee
// IDataReader iReader = HR.Service.EmployeeDA.Get(tc, empNo);
// DataReader oReader = new DataReader(iReader);
// if (iReader.Read())
// {
// employee = CreateHREmployeeObject(oReader);
// }
// else
// {
// employee = new HREmployee();
// result = LogInStatus.InvalidEmployee;
// //employee.ValidationMessage = "Logged In Employee Code is not valid";
// }
// iReader.Close();
// #endregion
// tc.End();
// if (employee.PayRollStatus != EnumEmployeePayStatus.EmployeeStatusLive)
// {
// if (employee.ValidationMessage.Length == 0)
// {
// employee.ValidationMessage = "Employee status is not 'live'.";
// result = LogInStatus.DiscontinueEmployee;
// }
// }
// else
// {
// if (password.Equals(employee.DesktopPassWord))
// {
// employee.ValidationMessage = "Password is set from HRMIS. Please Change your password.";
// result = LogInStatus.PasswordIsSetFromHR;
// }
// else if (Ease.Core.Global.Encrypt(password).Equals(employee.DesktopPassWord) == false)
// {
// employee.ValidationMessage = "Invalid password. Try Again";
// result = LogInStatus.InvalidPassword;
// }
// else
// {
// result = LogInStatus.SuccessfulLogin;
// HRUser.Employee = employee;
// }
// }
//}
//catch (Exception e)
//{
// #region Handle Exception
// if (tc != null)
// tc.HandleError();
// ExceptionLog.Write(e);
// throw new ServiceException(e.Message, e);
// #endregion
//}
return result;
}
public ID Save(HREmployee employee, ID candidateId)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (employee.IsNew)
{
this.SetObjectID(employee, ID.FromInteger(HREmployeeDA.GetNewID(tc)));
HREmployeeDA.Insert(tc, employee);
}
else
{
HREmployeeDA.Update(tc, employee);
#region Delete Children
HREmployeeDA.Delete(tc, "EmpContact", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpChildren", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpSpouse", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpExperience", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpTraining", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpAcademic", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpAchivement", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpOtherTalent", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpExtraCurricularActivity", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpHobby", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpAllergy", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpReference", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpPublication", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpNominee", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpHospitalization", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpGuarantor", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmployeeWorkPlanSetup", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpLanguage", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpRelative", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpMembership", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpRelation", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpHRQuestionAnswer", "EmployeeID", employee.ID);
HREmployeeDA.Delete(tc, "EmpCreditCard", "EmployeeID", employee.ID);
//HREmployeeDA.Delete(tc,employee.ID);
//HREmployeeDA.Insert(tc, employee);
#endregion
}
#region Contact
foreach (EmpContact item in employee.Contacts)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpContact", "ContactID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region Spouse
foreach (EmpSpouse item in employee.Spouses)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpSpouse", "SpouseID")));
HREmployeeDA.Insert(tc, item);
if (item.CreditCards != null)
{
foreach (EmpCreditCard card in item.CreditCards)
{
card.EmployeeID = employee.ID;
card.UserTypeID = item.ID;
card.UserType = EnumCardUserType.Spouse;
this.SetObjectID(card, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpCreditCard", "EmpCreditCardID")));
HREmployeeDA.Insert(tc, card);
}
}
}
#endregion
#region Children
foreach (EmpChildren item in employee.Childrens)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpChildren", "ChildID")));
HREmployeeDA.Insert(tc, item);
if (item.CreditCards != null)
{
foreach (EmpCreditCard card in item.CreditCards)
{
card.EmployeeID = employee.ID;
card.UserTypeID = item.ID;
card.UserType = EnumCardUserType.Children;
this.SetObjectID(card, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpCreditCard", "EmpCreditCardID")));
HREmployeeDA.Insert(tc, card);
}
}
}
#endregion
#region Experience
foreach (EmpExperience item in employee.Experiences)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpExperience", "ExperienceID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region Training
foreach (EmpTraining item in employee.Trainings)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpTraining", "EmpTrainingID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region Academic
foreach (EmpAcademic item in employee.Academics)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpAcademic", "AcademicID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region other Qualification
#region EmployeeAchivement
foreach (EmpAchievement item in employee.Achievement)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpAchivement", "EmpAchivementID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region EmployeeHobby
foreach (EmpHobby item in employee.Hobbys)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpHobby", "EmpHobbyID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region EmployeeOtherTalent
foreach (EmpOtherTalent item in employee.OtherTalents)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpOtherTalent", "EmpOtherTalentID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region EmployeeCurricularActivity
foreach (EmpCurricularActivity item in employee.CurricularActivities)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpExtraCurricularActivity", "EmpExtraCurricularActivityID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#endregion
#region EmployeeAllergy
foreach (EmpAllergy item in employee.Allergies)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpAllergy", "EmpAllergyID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region Reference
foreach (EmpReference item in employee.References)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpReference", "ReferenceID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region Publication
foreach (EmpPublication item in employee.Publications)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpPublication", "PublicationID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region Nominee
foreach (EmpNominee item in employee.Nominees)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpNominee", "NomineeID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region Hospitalization
foreach (EmpHospitalization item in employee.Hospitalizations)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpHospitalization", "HospitalizationID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region Guarantor
foreach (EmpGuarantor item in employee.Guarantors)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpGuarantor", "GuarantorID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region EmpLanguage
foreach (EmpLanguage item in employee.EmpLanguages)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpLanguage", "EmpLanguageID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region EmpRelative
foreach (EmpRelative item in employee.EmpRelatives)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpRelative", "EmpRelativeID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region EmpMembership
foreach (EmpMembership item in employee.EmpMemberships)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpMembership", "EmpMembershipID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region EmpRelation
foreach (EmpRelation item in employee.EmpRelations)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpRelation", "EmpRelationID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region EmpHRQuestionAnswer
foreach (EmpHRQuestionAnswer item in employee.EmpHRQuestionAnswers)
{
item.EmployeeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpHRQuestionAnswer", "EmpHRQuestionAnswerID")));
HREmployeeDA.Insert(tc, item);
}
#endregion
#region EmpCreditCard
if (employee.CreditCards != null)
{
foreach (EmpCreditCard item in employee.CreditCards)
{
item.EmployeeID = employee.ID;
item.UserTypeID = employee.ID;
this.SetObjectID(item, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpCreditCard", "EmpCreditCardID")));
HREmployeeDA.Insert(tc, item);
}
}
#endregion
//if(employee.WorkPlanSetup!=null)
//{
// employee.WorkPlanSetup.EmployeeID = employee.ID;
// employee.WorkPlanSetup.CreatedBy = ID.FromInteger(1); //employee.CreatedBy;
// employee.WorkPlanSetup.CreatedDate = DateTime.Today;
// this.SetObjectID(employee.WorkPlanSetup, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmployeeWorkPlanSetup", "EmployeeWorkPlanSetupID")));
// HREmployeeDA.Insert(tc, employee.WorkPlanSetup);
//}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return employee.ID;
}
public void Save(HREmployee employee)
{
TransactionContext tc = null;
tc = TransactionContext.Begin(true);
try
{
HREmployeeDA.UpdateForSelfService(tc, employee);
if (employee.Contacts != null && employee.Contacts.Count > 0)
{
if (employee.Contacts[0].IsNew)
{
employee.Contacts[0].EmployeeID = employee.ID;
this.SetObjectID(employee.Contacts[0], ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpContact", "ContactID")));
HREmployeeDA.Insert(tc, employee.Contacts[0]);
}
else
{
HREmployeeDA.UpdateForSelfService(tc, employee.Contacts[0]);
}
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
tc.End();
}
public void SaveEmpTraining(EmpTraining empTraining)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
this.SetObjectID(empTraining, ID.FromInteger(HREmployeeDA.GetNewID(tc, "EmpTraining", "EmpTrainingID")));
HREmployeeDA.Insert(tc, empTraining);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public void UpdateStatus(ID employeeID, EnumEmployeeStatus status)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
HREmployeeDA.UpdateStatus(tc, employeeID, status);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public void UpdatePassword(string password, ID id)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
HREmployeeDA.UpdatePassword(tc, password, id.Integer);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public void UpdateContact(HREmployee employee, EmpContact contactInfo)
{
TransactionContext tc = null;
tc = TransactionContext.Begin(true);
try
{
HREmployeeDA.Delete(tc, "EMPCONTACT", "EmployeeID", employee.ID);
HREmployeeDA.Insert(tc, contactInfo);
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
tc.End();
}
public void UpdateEmpWithoutChild(HREmployee employee)
{
TransactionContext tc = null;
tc = TransactionContext.Begin(true);
try
{
HREmployeeDA.Update(tc, employee);
}
catch (Exception ex)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(ex);
throw new ServiceException(ex.Message, ex);
#endregion
}
tc.End();
}
public void UpdateUserGroup(HREmployee item)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
HREmployeeDA.UpdateUserGroup(tc, item);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public void Delete(ID id)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
HREmployeeDA.Delete(tc, id);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException("Failed to GetEmployee", e);
#endregion
}
}
#endregion
#region child service implimentation
#region spouse service implimentation
public ObjectsTemplate<EmpSpouse> GetEmpSpouses(ID id)
{
#region Cache Header
ObjectsTemplate<EmpSpouse> oEmpSpouses = _cache["Get"] as ObjectsTemplate<EmpSpouse>;
if (oEmpSpouses != null)
return oEmpSpouses;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpSpouse(tc, id));
oEmpSpouses = this.CreateEmpSpouses(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
}
#region Cache Footer
_cache.Add(oEmpSpouses, "Get", id);
#endregion
return oEmpSpouses;
}
#endregion
#region EmpCreditCard service implementation
public ObjectsTemplate<EmpCreditCard> GetEmpCreditCard(ID id)
{
#region Cache Header
ObjectsTemplate<EmpCreditCard> oEmpCreditCard = _cache["Get"] as ObjectsTemplate<EmpCreditCard>;
if (oEmpCreditCard != null)
return oEmpCreditCard;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpCreditCard(tc, id));
oEmpCreditCard = this.CreateEmpCreditCard(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
}
#region Cache Footer
_cache.Add(oEmpCreditCard, "Get", id);
#endregion
return oEmpCreditCard;
}
#endregion
#region EmpContact service implimentation
public ObjectsTemplate<EmpContact> GetEmpContacts(ID id)
{
#region Cache Header
ObjectsTemplate<EmpContact> oEmpContacts = _cache["Get"] as ObjectsTemplate<EmpContact>;
if (oEmpContacts != null)
return oEmpContacts;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpContact(tc, id));
oEmpContacts = this.CreateEmpContactObjects(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
}
#region Cache Footer
_cache.Add(oEmpContacts, "Get", id);
#endregion
return oEmpContacts;
}
public ObjectsTemplate<EmpContact> GetEmpContacts()
{
#region Cache Header
ObjectsTemplate<EmpContact> oEmpContacts = _cache["Get"] as ObjectsTemplate<EmpContact>;
if (oEmpContacts != null)
return oEmpContacts;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpContact(tc));
oEmpContacts = this.CreateEmpContactObjects(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
}
#region Cache Footer
_cache.Add(oEmpContacts,"Get");
#endregion
return oEmpContacts;
}
public void SaveMultipleEmployeeContacts(ObjectsTemplate<EmpContact> oEmpContacts)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
foreach (var oEmpContact in oEmpContacts)
{
if (oEmpContact.IsNew)
{
int id = tc.GenerateID("EMPCONTACT", "ContactID");
base.SetObjectID(oEmpContact, ID.FromInteger(id));
HREmployeeDA.Insert(tc, oEmpContact);
}
else
{
HREmployeeDA.Update(tc, oEmpContact);
}
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException("Failed to GetOpiParameterIndividual", e);
#endregion
}
}
#endregion
#region EmpChildren service implimentation
public ObjectsTemplate<EmpChildren> GetEmpChildrens(ID id)
{
#region Cache Header
ObjectsTemplate<EmpChildren> oEmpChildrens = _cache["Get"] as ObjectsTemplate<EmpChildren>;
if (oEmpChildrens != null)
return oEmpChildrens;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpChildrens(tc, id));
oEmpChildrens = this.CreateEmpChildrenObjects(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
}
#region Cache Footer
_cache.Add(oEmpChildrens, "Get", id);
#endregion
return oEmpChildrens;
}
#endregion
#region EmpPublication service implimentation
public ObjectsTemplate<EmpPublication> GetEmpPublications(ID id)
{
#region Cache Header
ObjectsTemplate<EmpPublication> oEmpPublications = _cache["Get"] as ObjectsTemplate<EmpPublication>;
if (oEmpPublications != null)
return oEmpPublications;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpPublications(tc, id));
oEmpPublications = this.CreateEmpPublicationObjects(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
}
#region Cache Footer
_cache.Add(oEmpPublications, "Get", id);
#endregion
return oEmpPublications;
}
#endregion
#region EmpReference service implimentation
public ObjectsTemplate<EmpReference> GetEmpReferences(ID id)
{
#region Cache Header
ObjectsTemplate<EmpReference> oEmpReferences = _cache["Get"] as ObjectsTemplate<EmpReference>;
if (oEmpReferences != null)
return oEmpReferences;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpReferences(tc, id));
oEmpReferences = this.CreateEmpReferenceObjects(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
}
#region Cache Footer
_cache.Add(oEmpReferences, "Get", id);
#endregion
return oEmpReferences;
}
#endregion
#region EmpExperience service implimentation
public ObjectsTemplate<EmpExperience> GetEmpExperiences(ID id)
{
#region Cache Header
ObjectsTemplate<EmpExperience> oEmpExperiences = _cache["Get"] as ObjectsTemplate<EmpExperience>;
if (oEmpExperiences != null)
return oEmpExperiences;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpExperiences(tc, id));
oEmpExperiences = this.CreateEmpExperienceObjects(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
}
#region Cache Footer
_cache.Add(oEmpExperiences, "Get", id);
#endregion
return oEmpExperiences;
}
#endregion
#region EmpTraining service implimentation
public ObjectsTemplate<EmpTraining> GetEmpTrainings(ID id)
{
#region Cache Header
ObjectsTemplate<EmpTraining> oEmpTrainings = _cache["Get"] as ObjectsTemplate<EmpTraining>;
if (oEmpTrainings != null)
return oEmpTrainings;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpTrainings(tc, id));
oEmpTrainings = this.CreateEmpTrainingObjects(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
}
#region Cache Footer
_cache.Add(oEmpTrainings, "Get", id);
#endregion
return oEmpTrainings;
}
#endregion
#region EmpNominee service implimentation
public ObjectsTemplate<EmpNominee> GetEmpNominees(ID id)
{
#region Cache Header
ObjectsTemplate<EmpNominee> oEmpNominees = _cache["Get"] as ObjectsTemplate<EmpNominee>;
if (oEmpNominees != null)
return oEmpNominees;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpNominees(tc, id));
oEmpNominees = this.CreateEmpNomineeObjects(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
}
#region Cache Footer
_cache.Add(oEmpNominees, "Get", id);
#endregion
return oEmpNominees;
}
#endregion
#region EmpAcademic service implimentation
public ObjectsTemplate<EmpAcademic> GetEmpAcademics(ID id)
{
#region Cache Header
ObjectsTemplate<EmpAcademic> oEmpAcademics = _cache["Get"] as ObjectsTemplate<EmpAcademic>;
if (oEmpAcademics != null)
return oEmpAcademics;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpAcademics(tc, id));
oEmpAcademics = this.CreateEmpAcademicObjects(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
}
#region Cache Footer
_cache.Add(oEmpAcademics, "Get", id);
#endregion
return oEmpAcademics;
}
#endregion
#region EmpAchievement service implimentation
public ObjectsTemplate<EmpAchievement> GetEmpAchievements(ID id)
{
#region Cache Header
ObjectsTemplate<EmpAchievement> oEmpAchievements = _cache["Get"] as ObjectsTemplate<EmpAchievement>;
if (oEmpAchievements != null)
return oEmpAchievements;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpAchievements(tc, id));
oEmpAchievements = this.CreateEmpAchievementObjects(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
}
#region Cache Footer
_cache.Add(oEmpAchievements, "Get", id);
#endregion
return oEmpAchievements;
}
#endregion
#region EmpCurricularActivity service implimentation
public ObjectsTemplate<EmpCurricularActivity> GetEmpCurricularActivitys(ID id)
{
#region Cache Header
ObjectsTemplate<EmpCurricularActivity> oEmpCurricularActivitys = _cache["Get"] as ObjectsTemplate<EmpCurricularActivity>;
if (oEmpCurricularActivitys != null)
return oEmpCurricularActivitys;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpCurricularActivities(tc, id));
oEmpCurricularActivitys = this.CreateEmpCurricularActivityObjects(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
}
#region Cache Footer
_cache.Add(oEmpCurricularActivitys, "Get", id);
#endregion
return oEmpCurricularActivitys;
}
#endregion
#region EmpOtherTalent service implimentation
public ObjectsTemplate<EmpOtherTalent> GetEmpOtherTalents(ID id)
{
#region Cache Header
ObjectsTemplate<EmpOtherTalent> oEmpOtherTalents = _cache["Get"] as ObjectsTemplate<EmpOtherTalent>;
if (oEmpOtherTalents != null)
return oEmpOtherTalents;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpOtherTalents(tc, id));
oEmpOtherTalents = this.CreateEmpOtherTalentObjects(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
}
#region Cache Footer
_cache.Add(oEmpOtherTalents, "Get", id);
#endregion
return oEmpOtherTalents;
}
#endregion
#region EmpHobby service implimentation
public ObjectsTemplate<EmpHobby> GetEmpHobbys(ID id)
{
#region Cache Header
ObjectsTemplate<EmpHobby> oEmpHobbys = _cache["Get"] as ObjectsTemplate<EmpHobby>;
if (oEmpHobbys != null)
return oEmpHobbys;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmployeeHobbys(tc, id));
oEmpHobbys = this.CreateEmpHobbyObjects(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
}
#region Cache Footer
_cache.Add(oEmpHobbys, "Get", id);
#endregion
return oEmpHobbys;
}
#endregion
#region EmpAllergy service implimentation
public ObjectsTemplate<EmpAllergy> GetEmpAllergys(ID id)
{
#region Cache Header
ObjectsTemplate<EmpAllergy> oEmpAllergys = _cache["Get"] as ObjectsTemplate<EmpAllergy>;
if (oEmpAllergys != null)
return oEmpAllergys;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpAllergies(tc, id));
oEmpAllergys = this.CreateEmpAllergyObjects(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
}
#region Cache Footer
_cache.Add(oEmpAllergys, "Get", id);
#endregion
return oEmpAllergys;
}
#endregion
#region EmpHospitalization service implimentation
public ObjectsTemplate<EmpHospitalization> GetEmpHospitalizations(ID id)
{
#region Cache Header
ObjectsTemplate<EmpHospitalization> oEmpHospitalizations = _cache["Get"] as ObjectsTemplate<EmpHospitalization>;
if (oEmpHospitalizations != null)
return oEmpHospitalizations;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpHospitalizations(tc, id));
oEmpHospitalizations = this.CreateEmpHospitalizationObjects(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
}
#region Cache Footer
_cache.Add(oEmpHospitalizations, "Get", id);
#endregion
return oEmpHospitalizations;
}
#endregion
#region EmpGuarantor service implimentation
public ObjectsTemplate<EmpGuarantor> GetEmpGuarantors(ID id)
{
#region Cache Header
ObjectsTemplate<EmpGuarantor> oEmpGuarantors = _cache["Get"] as ObjectsTemplate<EmpGuarantor>;
if (oEmpGuarantors != null)
return oEmpGuarantors;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpGuarantors(tc, id));
oEmpGuarantors = this.CreateEmpGuarantorObjects(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
}
#region Cache Footer
_cache.Add(oEmpGuarantors, "Get", id);
#endregion
return oEmpGuarantors;
}
#endregion
#region EmpLanguage service implementation
public ObjectsTemplate<EmpLanguage> GetEmpLanguages(ID id)
{
#region Cache Header
ObjectsTemplate<EmpLanguage> oEmpLanguages = _cache["Get"] as ObjectsTemplate<EmpLanguage>;
if (oEmpLanguages != null)
return oEmpLanguages;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpLanguages(tc, id));
oEmpLanguages = this.CreateEmpLanguageObjects(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
}
#region Cache Footer
_cache.Add(oEmpLanguages, "Get", id);
#endregion
return oEmpLanguages;
}
#endregion
#region EmpRelative service implementation
public ObjectsTemplate<EmpRelative> GetEmpRelatives(ID id)
{
#region Cache Header
ObjectsTemplate<EmpRelative> oEmpRelatives = _cache["Get"] as ObjectsTemplate<EmpRelative>;
if (oEmpRelatives != null)
return oEmpRelatives;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpRelatives(tc, id));
oEmpRelatives = this.CreateEmpRelativeObjects(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
}
#region Cache Footer
_cache.Add(oEmpRelatives, "Get", id);
#endregion
return oEmpRelatives;
}
#endregion
#region EmpMembership service implementation
public ObjectsTemplate<EmpMembership> GetEmpMemberships(ID id)
{
#region Cache Header
ObjectsTemplate<EmpMembership> oEmpMemberships = _cache["Get"] as ObjectsTemplate<EmpMembership>;
if (oEmpMemberships != null)
return oEmpMemberships;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpMemberships(tc, id));
oEmpMemberships = this.CreateEmpMembershipObjects(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
}
#region Cache Footer
_cache.Add(oEmpMemberships, "Get", id);
#endregion
return oEmpMemberships;
}
#endregion
#region EmpRelation service implementation
public ObjectsTemplate<EmpRelation> GetEmpRelations(ID id)
{
#region Cache Header
ObjectsTemplate<EmpRelation> oEmpRelations = _cache["Get"] as ObjectsTemplate<EmpRelation>;
if (oEmpRelations != null)
return oEmpRelations;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpRelations(tc, id));
oEmpRelations = this.CreateEmpRelationObjects(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
}
#region Cache Footer
_cache.Add(oEmpRelations, "Get", id);
#endregion
return oEmpRelations;
}
#endregion
#region EmpHRQuestionAnswer service implementation
public ObjectsTemplate<EmpHRQuestionAnswer> GetEmpHRQuestionAnswers(ID id)
{
#region Cache Header
ObjectsTemplate<EmpHRQuestionAnswer> oHRQuestionAnswers = _cache["Get"] as ObjectsTemplate<EmpHRQuestionAnswer>;
if (oHRQuestionAnswers != null)
return oHRQuestionAnswers;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(HREmployeeDA.GetEmpHRQuestionAnswers(tc, id));
oHRQuestionAnswers = this.CreateEmpHRQuestionAnswerObjects(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
}
#region Cache Footer
_cache.Add(oHRQuestionAnswers, "Get", id);
#endregion
return oHRQuestionAnswers;
}
#endregion
#endregion
#endregion
}
}