CEL_Payroll/Payroll.Service/SAPLookUp/Service/IntigrationSetupService.cs

175 lines
6.1 KiB
C#
Raw Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Data;
using System.Linq;
using Ease.CoreV35;
using Ease.CoreV35.Model;
using Ease.CoreV35.DataAccess;
using System.Collections.Generic;
using Payroll.BO;
using Ease.CoreV35.Caching;
namespace Payroll.Service
{
#region IntigrationSetup Service
[Serializable]
public class IntigrationSetupService : ServiceTemplate, IIntigrationSetupService
{
#region Private functions and declaration
Cache _cache = new Cache(typeof(IntigrationSetup));
#endregion
public IntigrationSetupService() { }
private void MapObject(IntigrationSetup oIntigrationSetup, DataReader oReader)
{
base.SetObjectID(oIntigrationSetup, oReader.GetID("IntigrationSetupID"));
oIntigrationSetup.ReadFilePath = oReader.GetString("ReadFilePath");
oIntigrationSetup.StoreFilePath = oReader.GetString("StoreFilePath");
oIntigrationSetup.PrivateKeyFilePath = oReader.GetString("PrivateKeyFilePath");
oIntigrationSetup.ErrorLogFilePath = oReader.GetString("ErrorLogFilePath");
oIntigrationSetup.NotifyEmail = oReader.GetString("NotifyEmail");
oIntigrationSetup.PassPhrase = oReader.GetString("PassPhrase");
oIntigrationSetup.FTPFilePath = oReader.GetString("FTPFilePath");
oIntigrationSetup.FTPPassword = oReader.GetString("FTPPassword");
oIntigrationSetup.CutOffDay = oReader.GetInt16("CutOffDay").Value;
oIntigrationSetup.FTPUserName = oReader.GetString("FTPUserName");
this.SetObjectState(oIntigrationSetup, Ease.CoreV35.ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
IntigrationSetup oIntigrationSetup = new IntigrationSetup();
MapObject(oIntigrationSetup, oReader);
return oIntigrationSetup as T;
}
protected IntigrationSetup CreateObject(DataReader oReader)
{
IntigrationSetup oIntigrationSetup = new IntigrationSetup();
MapObject(oIntigrationSetup, oReader);
return oIntigrationSetup;
}
#region Service implementation
public IntigrationSetup Get(ID id)
{
IntigrationSetup oIntigrationSetup = new IntigrationSetup();
#region Cache Header
oIntigrationSetup = _cache["Get", id] as IntigrationSetup;
if (oIntigrationSetup != null)
return oIntigrationSetup;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(IntigrationSetupDA.Get(tc, id));
if (oreader.Read())
{
oIntigrationSetup = this.CreateObject<IntigrationSetup>(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(oIntigrationSetup, "Get", id);
#endregion
return oIntigrationSetup;
}
public IntigrationSetup Get()
{
IntigrationSetup oIntigrationSetup = new IntigrationSetup();
#region Cache Header
oIntigrationSetup = _cache["Get"] as IntigrationSetup;
if (oIntigrationSetup != null)
return oIntigrationSetup;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(IntigrationSetupDA.Get(tc));
if (oreader.Read())
{
oIntigrationSetup = this.CreateObject<IntigrationSetup>(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(oIntigrationSetup, "Get");
#endregion
return oIntigrationSetup;
}
public ID Save(IntigrationSetup oIntigrationSetup)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (oIntigrationSetup.IsNew)
{
int id = tc.GenerateID("IntigrationSetup", "IntigrationSetupID");
base.SetObjectID(oIntigrationSetup, ID.FromInteger(id));
IntigrationSetupDA.Insert(tc, oIntigrationSetup);
}
else
{
IntigrationSetupDA.Update(tc, oIntigrationSetup);
}
tc.End();
return oIntigrationSetup.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);
IntigrationSetupDA.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
}
#endregion
}