289 lines
9.3 KiB
C#
289 lines
9.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Ease.Core.DataAccess;
|
|
using Ease.Core.Model;
|
|
using Ease.Core.Utility;
|
|
using HRM.BO;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
public class BadliProcessService : ServiceTemplate
|
|
{
|
|
public BadliProcessService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(BadliProcess oBadliProcess, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oBadliProcess, (oReader.GetInt32("BadliProcessID").Value));
|
|
oBadliProcess.FromDate = oReader.GetDateTime("FromDate").Value;
|
|
oBadliProcess.ToDate = oReader.GetDateTime("ToDate").Value;
|
|
oBadliProcess.WorkPlanGroupID = oReader.GetInt32("WorkPlanGroupID", 0);
|
|
oBadliProcess.ProcessDate = oReader.GetDateTime("ProcessDate").Value;
|
|
oBadliProcess.Description = oReader.GetString("Description");
|
|
oBadliProcess.ProcessCode = oReader.GetString("ProcessCode");
|
|
oBadliProcess.CreatedBy = oReader.GetInt32("CreatedBy", 0);
|
|
oBadliProcess.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|
oBadliProcess.ModifiedBy = oReader.GetInt32("ModifiedBy", 0);
|
|
oBadliProcess.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|
this.SetObjectState(oBadliProcess, Ease.Core.ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
BadliProcess oBadliProcess = new BadliProcess();
|
|
MapObject(oBadliProcess, oReader);
|
|
return oBadliProcess as T;
|
|
}
|
|
|
|
#region ServiceImplementation
|
|
|
|
public List<BadliProcess> Get()
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(BadliProcessDA.Get(tc));
|
|
var oBadliProcesss = this.CreateObjects<BadliProcess>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return oBadliProcesss;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<BadliProcess> Get(DateTime processDate)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(BadliProcessDA.Get(tc, processDate));
|
|
var oBadliProcesss = this.CreateObjects<BadliProcess>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return oBadliProcesss;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public DateTime GetLastProcessDate()
|
|
{
|
|
DateTime lastProcessDate = DateTime.MinValue;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
DataReader oreader = new DataReader(BadliProcessDA.GetLastProcessDate(tc));
|
|
if (oreader.Read())
|
|
{
|
|
lastProcessDate = oreader.GetDateTime("LastProcessDate").HasValue
|
|
? oreader.GetDateTime("LastProcessDate").Value
|
|
: DateTime.Now;
|
|
}
|
|
|
|
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 lastProcessDate;
|
|
}
|
|
|
|
public List<BadliProcess> Get(DateTime processDate, int WorkPlanGroupID)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(BadliProcessDA.Get(tc, processDate, WorkPlanGroupID));
|
|
var oBadliProcesss = this.CreateObjects<BadliProcess>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return oBadliProcesss;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<BadliProcess> Get(DateTime fromDate, DateTime toDate)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(BadliProcessDA.Get(tc, fromDate, toDate));
|
|
var oBadliProcesss = this.CreateObjects<BadliProcess>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return oBadliProcesss;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<BadliProcess> Get(DateTime fromDate, DateTime toDate, int WorkPlanGroupID)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(BadliProcessDA.Get(tc, fromDate, toDate, WorkPlanGroupID));
|
|
var oBadliProcesss = this.CreateObjects<BadliProcess>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return oBadliProcesss;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<BadliProcess> Get(int WorkPlanGroupID)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(BadliProcessDA.Get(tc, WorkPlanGroupID));
|
|
var oBadliProcesss = this.CreateObjects<BadliProcess>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return oBadliProcesss;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public List<BadliProcess> Get(string WorkPlanGroupIDs)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(BadliProcessDA.Get(tc, WorkPlanGroupIDs));
|
|
var oBadliProcesss = this.CreateObjects<BadliProcess>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
return oBadliProcesss;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void Save(BadliProcess oBadliProcess, List<BadliDailyPayment> oBadliDailyPayments,
|
|
List<BadliDailyRecruit> oBadliDailyRecruits)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
int id = tc.GenerateID("BadliProcess", "BadliProcessID");
|
|
base.SetObjectID(oBadliProcess, (id));
|
|
if (BadliProcessDA.IsExist(tc, oBadliProcess.WorkPlanGroupID, oBadliProcess.FromDate))
|
|
{
|
|
BadliProcessDA.Delete(tc, oBadliProcess.WorkPlanGroupID, oBadliProcess.FromDate);
|
|
}
|
|
|
|
BadliProcessDA.Insert(tc, oBadliProcess);
|
|
oBadliDailyPayments.ForEach(x => x.BadliProcessID = (id));
|
|
oBadliDailyRecruits.ForEach(x => x.IsPaid = true);
|
|
(new BadliDailyPaymentService()).Save(oBadliDailyPayments, tc);
|
|
(new BadliDailyRecruitService()).Save(oBadliDailyRecruits, tc);
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |