171 lines
5.5 KiB
C#
171 lines
5.5 KiB
C#
|
using Ease.Core;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using Ease.Core.Model;
|
|||
|
using Ease.Core.Utility;
|
|||
|
using HRM.BO;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
public class PMSObjectiveProgressService : ServiceTemplate, IPMSObjectiveProgressService
|
|||
|
{
|
|||
|
#region ObjectMapping
|
|||
|
private void MapObject(PMSObjectiveProgress oPMSObjectiveProgress, DataReader oReader)
|
|||
|
{
|
|||
|
SetObjectID(oPMSObjectiveProgress, oReader.GetInt32("PMSObjectiveProgressID", 0));
|
|||
|
oPMSObjectiveProgress.ObjectiveID = oReader.GetInt32("ObjectiveID", 0);
|
|||
|
oPMSObjectiveProgress.EmployeeID = oReader.GetInt32("EmployeeID", 0);
|
|||
|
oPMSObjectiveProgress.Description = oReader.GetString("Description", null);
|
|||
|
oPMSObjectiveProgress.UpdateTime = oReader.GetDateTime("UpdateTime").Value;
|
|||
|
oPMSObjectiveProgress.AchivePercent = oReader.GetDouble("AchivePercent", 0);
|
|||
|
oPMSObjectiveProgress.IsRead = oReader.GetBoolean("IsRead").Value;
|
|||
|
oPMSObjectiveProgress.ReadTime = oReader.GetDateTime("ReadTime").HasValue ? oReader.GetDateTime("ReadTime").Value : null;
|
|||
|
oPMSObjectiveProgress.IsEmployee = oReader.GetBoolean("IsEmployee").Value;
|
|||
|
oPMSObjectiveProgress.RatingStart = oReader.GetInt32("RatingStart").HasValue ? oReader.GetInt32("RatingStart").Value : null;
|
|||
|
|
|||
|
this.SetObjectState(oPMSObjectiveProgress, ObjectState.Saved);
|
|||
|
}
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
PMSObjectiveProgress oPMSObjectiveProgress = new PMSObjectiveProgress();
|
|||
|
MapObject(oPMSObjectiveProgress, oReader);
|
|||
|
return oPMSObjectiveProgress as T;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Save
|
|||
|
public int Save(PMSObjectiveProgress item)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (item.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("PMSObjectiveProgress", "PMSObjectiveProgressID");
|
|||
|
base.SetObjectID(item, (id));
|
|||
|
PMSObjectiveProgressDA.Insert(tc, item);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
PMSObjectiveProgressDA.Update(tc, item);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
return item.ID;
|
|||
|
}
|
|||
|
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<PMSObjectiveProgress> Get()
|
|||
|
{
|
|||
|
List<PMSObjectiveProgress> oPMSObjectiveProgress = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(PMSObjectiveProgressDA.Get(tc));
|
|||
|
oPMSObjectiveProgress = this.CreateObjects<PMSObjectiveProgress>(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 ID
|
|||
|
|
|||
|
public PMSObjectiveProgress Get(int id)
|
|||
|
{
|
|||
|
PMSObjectiveProgress oPMSObjectiveProgress = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(PMSObjectiveProgressDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oPMSObjectiveProgress = this.CreateObject<PMSObjectiveProgress>(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
|
|||
|
|
|||
|
|
|||
|
public List<PMSObjectiveProgress> GetByObjectiveID(int objectiveId, int employeeid)
|
|||
|
{
|
|||
|
List<PMSObjectiveProgress> oPMSObjectiveProgress = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(PMSObjectiveProgressDA.GetByObjectiveID(tc, objectiveId, employeeid));
|
|||
|
oPMSObjectiveProgress = this.CreateObjects<PMSObjectiveProgress>(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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|