751 lines
26 KiB
C#
751 lines
26 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Ease.CoreV35.Caching;
|
|
using Ease.CoreV35.DataAccess;
|
|
using Ease.CoreV35.Model;
|
|
using Payroll.BO;
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
[Serializable]
|
|
public class DAMasterService :ServiceTemplate, IDAMasterService
|
|
{
|
|
#region Declaration
|
|
Cache _cache = new Cache(typeof(Complain));
|
|
#endregion
|
|
|
|
#region Map Functions
|
|
|
|
private void MapObject(DAMaster oDAMaster, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oDAMaster, oReader.GetID("DAMasterID"));
|
|
oDAMaster.DACNote = oReader.GetString("DACNote");
|
|
oDAMaster.DACOMFileName = oReader.GetString("DACOMFileName");
|
|
oDAMaster.DAMCode = oReader.GetString("DAMCode");
|
|
oDAMaster.DAMDate = (oReader.GetDateTime("DAMDate") ?? DateTime.MinValue);
|
|
oDAMaster.DAMFileName = oReader.GetString("DAMFileName");
|
|
oDAMaster.DAMNote = oReader.GetString("DAMNote");
|
|
oDAMaster.DAPRIFileName = oReader.GetString("DAPRIFileName");
|
|
oDAMaster.DCDate = (oReader.GetDateTime("DCDate") ?? DateTime.MinValue);
|
|
oDAMaster.DPRIDate = (oReader.GetDateTime("DPRIDate") ?? DateTime.MinValue);
|
|
oDAMaster.DACSheetFileName = oReader.GetString("DACSheetFileName");
|
|
oDAMaster.DACSheetNote = oReader.GetString("DACSheetNote");
|
|
oDAMaster.DCSheetDate = (oReader.GetDateTime("DCSheetDate") ?? DateTime.MinValue);
|
|
this.SetObjectState(oDAMaster, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
DAMaster oDAMaster = new DAMaster();
|
|
MapObject(oDAMaster, oReader);
|
|
return oDAMaster as T;
|
|
|
|
}
|
|
|
|
#region Child Map
|
|
|
|
#region DAEmployee Map
|
|
private ObjectsTemplate<DAEmployee> CreateDAEmployeeObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<DAEmployee> oDAEmployees = new ObjectsTemplate<DAEmployee>();
|
|
while (oReader.Read())
|
|
{
|
|
DAEmployee oDAEmployee = new DAEmployee();
|
|
MapDAEmployeeObject(oDAEmployee, oReader);
|
|
oDAEmployees.Add(oDAEmployee);
|
|
}
|
|
return oDAEmployees;
|
|
}
|
|
|
|
private void MapDAEmployeeObject(DAEmployee oDaEmployee, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oDaEmployee, oReader.GetID("DAEMPID"));
|
|
oDaEmployee.DAID = oReader.GetID("DAID");
|
|
oDaEmployee.EmployeeID = oReader.GetID("EmployeeID");
|
|
this.SetObjectState(oDaEmployee, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
#endregion
|
|
|
|
#region DAComplain Map
|
|
|
|
private ObjectsTemplate<DAComplain> CreateDAComplainObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<DAComplain> oDAComplains = new ObjectsTemplate<DAComplain>();
|
|
while (oReader.Read())
|
|
{
|
|
DAComplain oDAComplain = new DAComplain();
|
|
MapDAComplainObject(oDAComplain, oReader);
|
|
oDAComplains.Add(oDAComplain);
|
|
}
|
|
return oDAComplains;
|
|
}
|
|
|
|
private void MapDAComplainObject(DAComplain oDaComplain, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oDaComplain, oReader.GetID("DACompID"));
|
|
oDaComplain.DAID = oReader.GetID("DAID");
|
|
oDaComplain.ComplainID = oReader.GetID("ComplainID");
|
|
this.SetObjectState(oDaComplain, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
#endregion
|
|
|
|
#region DAEmpExplanation Map
|
|
|
|
private ObjectsTemplate<DAEmpExplanation> CreateDAEmpExplanationObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<DAEmpExplanation> oDAEmpExplanations = new ObjectsTemplate<DAEmpExplanation>();
|
|
while (oReader.Read())
|
|
{
|
|
DAEmpExplanation oDAEmpExplanation = new DAEmpExplanation();
|
|
MapDAEmpExplanationObject(oDAEmpExplanation, oReader);
|
|
oDAEmpExplanations.Add(oDAEmpExplanation);
|
|
}
|
|
return oDAEmpExplanations;
|
|
}
|
|
|
|
private void MapDAEmpExplanationObject(DAEmpExplanation oDAEmpExplanation, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oDAEmpExplanation, oReader.GetID("DAExpID"));
|
|
oDAEmpExplanation.DAID = oReader.GetID("DAID");
|
|
oDAEmpExplanation.DAEXNote = oReader.GetString("DAEXNote");
|
|
oDAEmpExplanation.DAEXDate = oReader.GetDateTime("DAEXDate").Value;
|
|
oDAEmpExplanation.EmployeeID = oReader.GetID("EmployeeID");
|
|
oDAEmpExplanation.FileName = oReader.GetString("FileName");
|
|
this.SetObjectState(oDAEmpExplanation, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
#endregion
|
|
|
|
#region DAPunishment Map
|
|
|
|
private ObjectsTemplate<DAPunishment> CreateDAPunishmentObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<DAPunishment> oDAPunishments = new ObjectsTemplate<DAPunishment>();
|
|
while (oReader.Read())
|
|
{
|
|
DAPunishment oDAPunishment = new DAPunishment();
|
|
MapDAPunishmentObject(oDAPunishment, oReader);
|
|
oDAPunishments.Add(oDAPunishment);
|
|
}
|
|
return oDAPunishments;
|
|
}
|
|
|
|
private void MapDAPunishmentObject(DAPunishment oDAPunishment, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oDAPunishment, oReader.GetID("DAPID"));
|
|
oDAPunishment.DAID = oReader.GetID("DAID");
|
|
oDAPunishment.DAPDate = oReader.GetDateTime("DAPDate").Value;
|
|
oDAPunishment.DAPFromDate = oReader.GetDateTime("DAPFromDate").Value;
|
|
oDAPunishment.DAPNote = oReader.GetString("DAPNote");
|
|
oDAPunishment.DAPToDate = oReader.GetDateTime("DAPToDate").Value;
|
|
oDAPunishment.EmployeeID = oReader.GetID("EmployeeID");
|
|
oDAPunishment.DAPFileName = oReader.GetString("DAPFileName");
|
|
this.SetObjectState(oDAPunishment, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
#endregion
|
|
|
|
#region DAComEmp Map
|
|
|
|
private ObjectsTemplate<DAComEmp> CreateDAComEmpObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<DAComEmp> oDAComEmps = new ObjectsTemplate<DAComEmp>();
|
|
while (oReader.Read())
|
|
{
|
|
DAComEmp oDAComEmp = new DAComEmp();
|
|
MapDAComEmpObject(oDAComEmp, oReader);
|
|
oDAComEmps.Add(oDAComEmp);
|
|
}
|
|
return oDAComEmps;
|
|
}
|
|
|
|
private void MapDAComEmpObject(DAComEmp oDAComEmp, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oDAComEmp, oReader.GetID("DACEID"));
|
|
oDAComEmp.DAID = oReader.GetID("DAID");
|
|
oDAComEmp.EmployeeID = oReader.GetID("EMPLOYEEID");
|
|
this.SetObjectState(oDAComEmp, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
#endregion
|
|
|
|
#region DAPEmployee Map
|
|
|
|
private ObjectsTemplate<DAPEmployee> CreateDAPEmployeeObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<DAPEmployee> oDAPEmployees = new ObjectsTemplate<DAPEmployee>();
|
|
while (oReader.Read())
|
|
{
|
|
DAPEmployee oDAPEmployee = new DAPEmployee();
|
|
MapDAPEmployeeObject(oDAPEmployee, oReader);
|
|
oDAPEmployees.Add(oDAPEmployee);
|
|
}
|
|
return oDAPEmployees;
|
|
}
|
|
|
|
private void MapDAPEmployeeObject(DAPEmployee oDAPEmployee, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oDAPEmployee, oReader.GetID("DAPEID"));
|
|
oDAPEmployee.DAID = oReader.GetID("DAID");
|
|
oDAPEmployee.EmpID = oReader.GetID("EmpID");
|
|
oDAPEmployee.PID = oReader.GetID("PID");
|
|
oDAPEmployee.PunishmentID = oReader.GetID("PunishmentID");
|
|
this.SetObjectState(oDAPEmployee, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
#endregion
|
|
|
|
#region DAPRIEmp Map
|
|
|
|
private ObjectsTemplate<DAPRIEmp> CreateDAPRIEmpObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<DAPRIEmp> oDAPRIEmps = new ObjectsTemplate<DAPRIEmp>();
|
|
while (oReader.Read())
|
|
{
|
|
DAPRIEmp oDAPRIEmp = new DAPRIEmp();
|
|
MapDAPRIEmpObject(oDAPRIEmp, oReader);
|
|
oDAPRIEmps.Add(oDAPRIEmp);
|
|
}
|
|
return oDAPRIEmps;
|
|
}
|
|
|
|
private void MapDAPRIEmpObject(DAPRIEmp oDAPRIEmp, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oDAPRIEmp, oReader.GetID("DAPRIID"));
|
|
oDAPRIEmp.DAID = oReader.GetID("DAID");
|
|
oDAPRIEmp.EmployeeID = oReader.GetID("EmployeeID");
|
|
this.SetObjectState(oDAPRIEmp, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region Implementation of IDAMasterService
|
|
|
|
public DAMaster Get(ID id)
|
|
{
|
|
DAMaster oDAMaster = new DAMaster();
|
|
|
|
#region Cache Header
|
|
oDAMaster = _cache["Get", id] as DAMaster;
|
|
if (oDAMaster != null)
|
|
return oDAMaster;
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(DAMasterDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oDAMaster = this.CreateObject<DAMaster>(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(oDAMaster, "Get", id);
|
|
#endregion
|
|
|
|
return oDAMaster;
|
|
}
|
|
|
|
public DAMaster Get(string code)
|
|
{
|
|
DAMaster oDAMaster = new DAMaster();
|
|
|
|
#region Cache Header
|
|
oDAMaster = _cache["Get", code] as DAMaster;
|
|
if (oDAMaster != null)
|
|
return oDAMaster;
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(DAMasterDA.Get(tc, code));
|
|
if (oreader.Read())
|
|
{
|
|
oDAMaster = this.CreateObject<DAMaster>(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(oDAMaster, "Get", code);
|
|
#endregion
|
|
|
|
return oDAMaster;
|
|
}
|
|
|
|
public ObjectsTemplate<DAMaster> GetDAs(string sql)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<DAMaster> daMasters = _cache["Get"] as ObjectsTemplate<DAMaster>;
|
|
if (daMasters != null)
|
|
return daMasters;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(DAMasterDA.GetDAs(tc,sql));
|
|
daMasters = this.CreateObjects<DAMaster>(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(daMasters, "Get");
|
|
|
|
#endregion
|
|
|
|
return daMasters;
|
|
}
|
|
|
|
public ID Save(DAMaster oDAMaster)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
if (oDAMaster.IsNew)
|
|
{
|
|
if(DAMasterDA.CheckDAMasterDuplicateCode(tc,oDAMaster.DAMCode))
|
|
{
|
|
Exception exception=new Exception("Duplicate DAMaster Code found.Try another Code");
|
|
throw exception;
|
|
}
|
|
int id = tc.GenerateID("DAMaster", "DAMasterID");
|
|
base.SetObjectID(oDAMaster, ID.FromInteger(id));
|
|
DAMasterDA.Insert(tc, oDAMaster);
|
|
}
|
|
else
|
|
{
|
|
DAMasterDA.Update(tc, oDAMaster);
|
|
|
|
#region Delete Childs
|
|
DAMasterDA.DeleteDAEmployees(tc,oDAMaster.ID);
|
|
DAMasterDA.DeleteDAComplains(tc, oDAMaster.ID);
|
|
DAMasterDA.DeleteDAEmpExplanations(tc, oDAMaster.ID);
|
|
DAMasterDA.DeleteDAPEmployees(tc, oDAMaster.ID);
|
|
DAMasterDA.DeleteDAPunishments(tc, oDAMaster.ID);
|
|
DAMasterDA.DeleteDAComEmps(tc, oDAMaster.ID);
|
|
DAMasterDA.DeleteDAPRIEmps(tc, oDAMaster.ID);
|
|
#endregion
|
|
}
|
|
|
|
#region Insert Childs
|
|
|
|
foreach (DAEmployee dAEmployee in oDAMaster.DAEmployees)
|
|
{
|
|
dAEmployee.DAID = oDAMaster.ID;
|
|
base.SetObjectID(dAEmployee, ID.FromInteger(tc.GenerateID("DAEmployee", "DAEMPID")));
|
|
DAMasterDA.InsertDAEmployee(tc,dAEmployee);
|
|
}
|
|
foreach (DAComplain dAComplain in oDAMaster.DAComplains)
|
|
{
|
|
dAComplain.DAID = oDAMaster.ID;
|
|
base.SetObjectID(dAComplain, ID.FromInteger(tc.GenerateID("DAComplain", "DACompID")));
|
|
DAMasterDA.InsertDAComplain(tc,dAComplain);
|
|
}
|
|
|
|
foreach (DAEmpExplanation dAEmpExplanation in oDAMaster.DAEmpExplanations)
|
|
{
|
|
dAEmpExplanation.DAID = oDAMaster.ID;
|
|
base.SetObjectID(dAEmpExplanation, ID.FromInteger(tc.GenerateID("DAEmpExplanation", "DAExpID")));
|
|
DAMasterDA.InsertDAEmpExplanation(tc, dAEmpExplanation);
|
|
}
|
|
foreach (DAPunishment dAPunishment in oDAMaster.DAPunishments)
|
|
{
|
|
dAPunishment.DAID = oDAMaster.ID;
|
|
base.SetObjectID(dAPunishment, ID.FromInteger(tc.GenerateID("DAPunishment", "DAPID")));
|
|
DAMasterDA.InsertDAPunishment(tc,dAPunishment);
|
|
foreach (DAPEmployee dAPEmployee in dAPunishment.DAPEmployees)
|
|
{
|
|
dAPEmployee.DAID = oDAMaster.ID;
|
|
dAPEmployee.PID = dAPunishment.ID;
|
|
base.SetObjectID(dAPEmployee, ID.FromInteger(tc.GenerateID("DAPEmployee", "DAPEID")));
|
|
DAMasterDA.InsertDAPEmployee(tc, dAPEmployee);
|
|
}
|
|
}
|
|
foreach (DAComEmp dAComEmp in oDAMaster.DAComEmps)
|
|
{
|
|
dAComEmp.DAID = oDAMaster.ID;
|
|
base.SetObjectID(dAComEmp, ID.FromInteger(tc.GenerateID("DAComEmp", "DACEID")));
|
|
DAMasterDA.InsertDAComEmp(tc,dAComEmp);
|
|
}
|
|
foreach (DAPRIEmp dAPRIEmp in oDAMaster.DAPRIEmps)
|
|
{
|
|
dAPRIEmp.DAID = oDAMaster.ID;
|
|
base.SetObjectID(dAPRIEmp, ID.FromInteger(tc.GenerateID("DAPRIEmp", "DAPRIID")));
|
|
DAMasterDA.InsertDAPRIEmp(tc,dAPRIEmp);
|
|
}
|
|
#endregion
|
|
|
|
tc.End();
|
|
return oDAMaster.ID;
|
|
}
|
|
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);
|
|
|
|
#region Delete Childs
|
|
DAMasterDA.DeleteDAEmployees(tc, id);
|
|
DAMasterDA.DeleteDAComplains(tc, id);
|
|
DAMasterDA.DeleteDAEmpExplanations(tc, id);
|
|
DAMasterDA.DeleteDAPEmployees(tc, id);
|
|
DAMasterDA.DeleteDAPunishments(tc, id);
|
|
DAMasterDA.DeleteDAComEmps(tc, id);
|
|
DAMasterDA.DeleteDAPRIEmps(tc, id);
|
|
#endregion
|
|
|
|
DAMasterDA.Delete(tc, id);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
|
|
#region Child Class Functions
|
|
|
|
public ObjectsTemplate<DAEmployee> GetDAEmployees(ID id)
|
|
{
|
|
ObjectsTemplate<DAEmployee> oDAEmployees = new ObjectsTemplate<DAEmployee>();
|
|
|
|
#region Cache Header
|
|
oDAEmployees = _cache["Get", id] as ObjectsTemplate<DAEmployee>;
|
|
if (oDAEmployees != null)
|
|
return oDAEmployees;
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(DAMasterDA.GetDAEmployees(tc, id));
|
|
|
|
oDAEmployees = this.CreateDAEmployeeObjects(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(oDAEmployees, "Get", id);
|
|
#endregion
|
|
|
|
return oDAEmployees;
|
|
}
|
|
|
|
public ObjectsTemplate<DAComplain> GetDAComplains(ID id)
|
|
{
|
|
|
|
ObjectsTemplate<DAComplain> oDAComplains = new ObjectsTemplate<DAComplain>();
|
|
|
|
#region Cache Header
|
|
oDAComplains = _cache["Get", id] as ObjectsTemplate<DAComplain>;
|
|
if (oDAComplains != null)
|
|
return oDAComplains;
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(DAMasterDA.GetDAComplains(tc, id));
|
|
//if (oreader.Read())
|
|
//{
|
|
oDAComplains = this.CreateDAComplainObjects(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(oDAComplains, "Get", id);
|
|
#endregion
|
|
|
|
return oDAComplains;
|
|
}
|
|
|
|
public ObjectsTemplate<DAEmpExplanation> GetDAEmpExplanations(ID id)
|
|
{
|
|
|
|
ObjectsTemplate<DAEmpExplanation> oDAEmpExplanations = new ObjectsTemplate<DAEmpExplanation>();
|
|
|
|
#region Cache Header
|
|
oDAEmpExplanations = _cache["Get", id] as ObjectsTemplate<DAEmpExplanation>;
|
|
if (oDAEmpExplanations != null)
|
|
return oDAEmpExplanations;
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(DAMasterDA.GetDAEmpExplanations(tc, id));
|
|
//if (oreader.Read())
|
|
//{
|
|
oDAEmpExplanations = this.CreateDAEmpExplanationObjects(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(oDAEmpExplanations, "Get", id);
|
|
#endregion
|
|
|
|
return oDAEmpExplanations;
|
|
|
|
}
|
|
|
|
public ObjectsTemplate<DAPunishment> GetDAPunishments(ID id)
|
|
{
|
|
|
|
ObjectsTemplate<DAPunishment> oDAPunishments = new ObjectsTemplate<DAPunishment>();
|
|
|
|
#region Cache Header
|
|
oDAPunishments = _cache["Get", id] as ObjectsTemplate<DAPunishment>;
|
|
if (oDAPunishments != null)
|
|
return oDAPunishments;
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(DAMasterDA.GetDAPunishments(tc, id));
|
|
//if (oreader.Read())
|
|
//{
|
|
oDAPunishments = this.CreateDAPunishmentObjects(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(oDAPunishments, "Get", id);
|
|
#endregion
|
|
|
|
return oDAPunishments;
|
|
}
|
|
|
|
public ObjectsTemplate<DAComEmp> GetDAComEmps(ID id)
|
|
{
|
|
|
|
ObjectsTemplate<DAComEmp> oDAComEmps = new ObjectsTemplate<DAComEmp>();
|
|
|
|
#region Cache Header
|
|
oDAComEmps = _cache["Get", id] as ObjectsTemplate<DAComEmp>;
|
|
if (oDAComEmps != null)
|
|
return oDAComEmps;
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(DAMasterDA.GetDAComEmps(tc, id));
|
|
//if (oreader.Read())
|
|
//{
|
|
oDAComEmps = this.CreateDAComEmpObjects(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(oDAComEmps, "Get", id);
|
|
#endregion
|
|
|
|
return oDAComEmps;
|
|
}
|
|
|
|
public ObjectsTemplate<DAPEmployee> GetDAPEmployees(ID id)
|
|
{
|
|
ObjectsTemplate<DAPEmployee> oDAPEmployees = new ObjectsTemplate<DAPEmployee>();
|
|
|
|
#region Cache Header
|
|
oDAPEmployees = _cache["Get", id] as ObjectsTemplate<DAPEmployee>;
|
|
if (oDAPEmployees != null)
|
|
return oDAPEmployees;
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(DAMasterDA.GetDAPEmployees(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oDAPEmployees = this.CreateDAPEmployeeObjects(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(oDAPEmployees, "Get", id);
|
|
#endregion
|
|
|
|
return oDAPEmployees;
|
|
}
|
|
|
|
public ObjectsTemplate<DAPRIEmp> GetDAPRIEmps(ID id)
|
|
{
|
|
ObjectsTemplate<DAPRIEmp> oDAPRIEmps = new ObjectsTemplate<DAPRIEmp>();
|
|
|
|
#region Cache Header
|
|
oDAPRIEmps = _cache["Get", id] as ObjectsTemplate<DAPRIEmp>;
|
|
if (oDAPRIEmps != null)
|
|
return oDAPRIEmps;
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(DAMasterDA.GetDAPRIEmps(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oDAPRIEmps = this.CreateDAPRIEmpObjects(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(oDAPRIEmps, "Get", id);
|
|
#endregion
|
|
|
|
return oDAPRIEmps;
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|