254 lines
8.3 KiB
C#
254 lines
8.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Ease.CoreV35;
|
|
using Ease.CoreV35.Model;
|
|
using Ease.CoreV35.DataAccess;
|
|
using Payroll.BO;
|
|
using Ease.CoreV35.Caching;
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
#region SAPDataProcess Service
|
|
|
|
[Serializable]
|
|
public class SAPDataDumpService : ServiceTemplate, ISAPDataDumpService
|
|
{
|
|
#region Private functions and declaration
|
|
Cache _cache = new Cache(typeof(SAPDataDump));
|
|
|
|
#endregion
|
|
|
|
#region ISAPDataDumpService Implementation
|
|
|
|
public SAPDataDump Get(ID id)
|
|
{
|
|
SAPDataDump oSAPDataDump = new SAPDataDump();
|
|
|
|
#region Cache Header
|
|
oSAPDataDump = _cache["Get", id] as SAPDataDump;
|
|
if (oSAPDataDump != null)
|
|
return oSAPDataDump;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(SAPDataDumpDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oSAPDataDump = this.CreateObject<SAPDataDump>(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(oSAPDataDump, "Get", id);
|
|
#endregion
|
|
|
|
return oSAPDataDump;
|
|
}
|
|
|
|
public ObjectsTemplate<SAPDataDump> Get()
|
|
{
|
|
ObjectsTemplate<SAPDataDump> oSAPDataDumps=new ObjectsTemplate<SAPDataDump>();
|
|
|
|
#region Cache Header
|
|
oSAPDataDumps = _cache["Get"] as ObjectsTemplate<SAPDataDump>;
|
|
if (oSAPDataDumps != null)
|
|
return oSAPDataDumps;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader=new DataReader(SAPDataDumpDA.Get(tc));
|
|
oSAPDataDumps = this.CreateObjects<SAPDataDump>(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(oSAPDataDumps, "Get");
|
|
#endregion
|
|
return oSAPDataDumps;
|
|
}
|
|
|
|
public void Save(ObjectsTemplate<SAPDataDump> oSAPDataDumps)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
foreach (SAPDataDump item in oSAPDataDumps)
|
|
{
|
|
Save(item, tc);
|
|
}
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public ID Save(SAPDataDump item,TransactionContext tc)
|
|
{
|
|
int numericID = 0;
|
|
ID id = null;
|
|
try
|
|
{
|
|
if(item.IsNew)
|
|
{
|
|
numericID = tc.GenerateID("SAPDataDump", "SAPDataDumpID");
|
|
id = ID.FromInteger(numericID);
|
|
base.SetObjectID(item, id);
|
|
SAPDataDumpDA.Insert(tc, item);
|
|
}
|
|
else
|
|
{
|
|
SAPDataDumpDA.Update(tc, item);
|
|
id = item.ID;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
|
|
return id;
|
|
}
|
|
|
|
public ID Save(SAPDataDump item)
|
|
{
|
|
TransactionContext tc = null;
|
|
int numericID = 0;
|
|
ID id = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (item.IsNew)
|
|
{
|
|
numericID = tc.GenerateID("SAPDataDump", "SAPDataDumpID");
|
|
id = ID.FromInteger(numericID);
|
|
base.SetObjectID(item, id);
|
|
SAPDataDumpDA.Insert(tc, item);
|
|
}
|
|
else
|
|
{
|
|
SAPDataDumpDA.Update(tc, item);
|
|
id = item.ID;
|
|
}
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
|
|
return id;
|
|
}
|
|
|
|
public void Delete(ID id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
SAPDataDumpDA.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
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ObjectMapping
|
|
|
|
protected override T CreateObject<T>(DataReader dr)
|
|
{
|
|
SAPDataDump oSAPDataDump = new SAPDataDump();
|
|
MapObject(oSAPDataDump, dr);
|
|
return oSAPDataDump as T;
|
|
}
|
|
|
|
private void MapObject(SAPDataDump oSAPDataDump, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oSAPDataDump, oReader.GetID("SAPDataDumpID"));
|
|
|
|
oSAPDataDump.EmployeeID=oReader.GetID("EmployeeID");
|
|
oSAPDataDump.FirstName =oReader.GetString("FirstName");
|
|
oSAPDataDump.LastName=oReader.GetString("LastName");
|
|
oSAPDataDump.EmailAddress=oReader.GetString("EmailAddress");
|
|
oSAPDataDump.GDDBID=oReader.GetString("GDDBID");
|
|
oSAPDataDump.BirthDate=oReader.GetDateTime("BirthDate").Value;
|
|
oSAPDataDump.JoiningDate=oReader.GetDateTime("JoiningDate").Value;
|
|
oSAPDataDump.ReHiringDate=oReader.GetDateTime("ReHiringDate").Value;
|
|
oSAPDataDump.ReligionCode=oReader.GetString("ReligionCode");
|
|
oSAPDataDump.Gender=(EnumGender)oReader.GetInt32("Gender").Value;
|
|
oSAPDataDump.MaritalStatus=(EnumMaritalStatus)oReader.GetInt32("MaritalStatus").Value;
|
|
oSAPDataDump.NationalityCode=oReader.GetString("NationalityCode");
|
|
oSAPDataDump.TIN=oReader.GetString("TIN");
|
|
oSAPDataDump.LocalJobGrade=oReader.GetString("LocalJobGrade");
|
|
oSAPDataDump.BasicSalary=oReader.GetDouble("BasicSalary").Value;
|
|
oSAPDataDump.LocationCode=oReader.GetString("LocationCode");
|
|
oSAPDataDump.DesignationCode=oReader.GetString("DesignationCode");
|
|
oSAPDataDump.CostCenterCode=oReader.GetString("CostCenterCode");
|
|
oSAPDataDump.BankCode=oReader.GetString("BankCode");
|
|
oSAPDataDump.BankAccountNo=oReader.GetString("BankAccountNo");
|
|
oSAPDataDump.ConfirmationDate=oReader.GetDateTime("ConfirmationDate").Value;
|
|
oSAPDataDump.DiscontinueEffectDate=oReader.GetDateTime("DiscontinueEffectDate").Value;
|
|
oSAPDataDump.FileName = oReader.GetString("FileName");
|
|
|
|
this.SetObjectState(oSAPDataDump, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
#endregion SAPDataProcess Service
|
|
}
|