EchoTex_Payroll/HRM.DA/Service/PMP/PMSObjectiveProgressAttachmentService.cs
2024-10-14 10:01:49 +06:00

203 lines
6.6 KiB
C#

using Ease.Core.DataAccess;
using Ease.Core;
using Ease.Core.Model;
using HRM.BO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ease.Core.Utility;
namespace HRM.DA
{
public class PMSObjectiveProgressAttachmentService : ServiceTemplate, IPMSObjectiveProgressAttachmentService
{
#region ObjectMapping
private void MapObject(PMSObjectiveProgressAttachment oPMSObjectiveProgressAttachment, DataReader oReader)
{
SetObjectID(oPMSObjectiveProgressAttachment, oReader.GetInt32("PMSObjectiveProgressAttachmentID", 0));
oPMSObjectiveProgressAttachment.PMSObjectiveProgressID = oReader.GetInt32("PMSObjectiveProgressID", 0);
oPMSObjectiveProgressAttachment.FileName = oReader.GetString("FileName");
oPMSObjectiveProgressAttachment.UploadTime = oReader.GetDateTime("UploadTime").Value;
oPMSObjectiveProgressAttachment.FileData = oReader.GetLob("FileData");
oPMSObjectiveProgressAttachment.FileType = oReader.GetInt32("FileType").Value;
this.SetObjectState(oPMSObjectiveProgressAttachment, ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
PMSObjectiveProgressAttachment oPMSObjectiveProgressAttachment = new PMSObjectiveProgressAttachment();
MapObject(oPMSObjectiveProgressAttachment, oReader);
return oPMSObjectiveProgressAttachment as T;
}
#endregion
#region Save
public void Save(PMSObjectiveProgressAttachment item)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
if (item.IsNew)
{
int id = tc.GenerateID("PMSObjectiveProgressAttachment", "PMSOBJECTIVEPROGRESSATTACHMENTID");
base.SetObjectID(item, (id));
PMSObjectiveProgressAttachmentDA.Insert(tc, item);
}
else
{
PMSObjectiveProgressAttachmentDA.Update(tc, item);
}
tc.End();
return;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
#endregion
#region GetAll
public List<PMSObjectiveProgressAttachment> Get()
{
List<PMSObjectiveProgressAttachment> oPMSObjectiveProgressAttachment = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMSObjectiveProgressAttachmentDA.Get(tc));
oPMSObjectiveProgressAttachment = this.CreateObjects<PMSObjectiveProgressAttachment>(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
}
return oPMSObjectiveProgressAttachment;
}
#endregion
#region Get By ID
public PMSObjectiveProgressAttachment Get(int id)
{
PMSObjectiveProgressAttachment oPMSObjectiveProgress = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMSObjectiveProgressAttachmentDA.Get(tc, id));
if (oreader.Read())
{
oPMSObjectiveProgress = this.CreateObject<PMSObjectiveProgressAttachment>(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
}
return oPMSObjectiveProgress;
}
#endregion
#region Get By PMSObjectiveProgressIDiveID
public PMSObjectiveProgressAttachment GetbyPMSObjectiveProgressID(int pmsObjectiveProgressID)
{
PMSObjectiveProgressAttachment oPMSObjectiveProgress = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMSObjectiveProgressAttachmentDA.GetByPMSObjectiveProgressID(tc, pmsObjectiveProgressID));
if (oreader.Read())
{
oPMSObjectiveProgress = this.CreateObject<PMSObjectiveProgressAttachment>(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
}
return oPMSObjectiveProgress;
}
#endregion
#region Get List By PMSObjectiveProgressIDiveID
public List<PMSObjectiveProgressAttachment> GetByObjectGetByPMSObjectiveProgressIDiveID(int pmsObjectiveProgressID)
{
List<PMSObjectiveProgressAttachment> oPMSObjectiveProgressAttachment = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PMSObjectiveProgressAttachmentDA.GetByPMSObjectiveProgressID(tc, pmsObjectiveProgressID));
oPMSObjectiveProgressAttachment = this.CreateObjects<PMSObjectiveProgressAttachment>(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
}
return oPMSObjectiveProgressAttachment;
}
#endregion
}
}