384 lines
9.7 KiB
C#
384 lines
9.7 KiB
C#
using System;
|
|
using System.Data;
|
|
using Ease.Core.Model;
|
|
using Ease.Core.DataAccess;
|
|
using Ease.Core;
|
|
using System.Collections.Generic;
|
|
using Ease.Core.Utility;
|
|
using HRM.BO;
|
|
using HRM.DA;
|
|
|
|
|
|
namespace HRM.DA.Fund
|
|
{
|
|
public class ProjectProcessService : ServiceTemplate, IProjectProcessService
|
|
{
|
|
private void MapObject(ProjectProcess ProjectProcess, DataReader dr)
|
|
{
|
|
base.SetObjectID(ProjectProcess, dr.GetInt32("ProcessID").Value);
|
|
ProjectProcess.FundTypeID = dr.GetInt32("FundTypeID").Value;
|
|
ProjectProcess.Description = dr.GetString("Description");
|
|
ProjectProcess.TranType = dr.GetInt32("TranTypeID").Value;
|
|
ProjectProcess.Category = (EnumTranTypeCategory)(dr.GetInt16("Category"));
|
|
ProjectProcess.FundProcessType = (EnumFundProcessType)(dr.GetInt16("FundProcessType"));
|
|
ProjectProcess.ProcessType = (EnumProcessReferenceType)dr.GetInt32("ProcessType").Value;
|
|
ProjectProcess.CreatedBy = dr.GetInt32("CreatedBy").Value;
|
|
ProjectProcess.CreatedDate = dr.GetDateTime("CreatedDate").Value;
|
|
ProjectProcess.ModifiedBy = dr.GetInt32("ModifiedBy")!= null ? dr.GetInt32("ModifiedBy").Value : (0);
|
|
ProjectProcess.ModifiedDate = dr.GetDateTime("ModifiedDate");
|
|
base.SetObjectState(ProjectProcess, ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader dr)
|
|
{
|
|
ProjectProcess ProjectProcess = new ProjectProcess();
|
|
|
|
MapObject(ProjectProcess, dr);
|
|
|
|
return ProjectProcess as T;
|
|
}
|
|
|
|
#region Service Implementation
|
|
|
|
#region Insert
|
|
|
|
public void Save(ProjectProcess ProjectProcess)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
if (ProjectProcess.IsNew)
|
|
{
|
|
int id = tc.GenerateID("ProjectProcess", "ProcessID");
|
|
base.SetObjectID(ProjectProcess, (id));
|
|
ProjectProcessDA.Insert(tc, ProjectProcess);
|
|
}
|
|
else
|
|
{
|
|
ProjectProcessDA.Update(tc, ProjectProcess);
|
|
}
|
|
|
|
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 Delete
|
|
|
|
public void Delete(int id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
ProjectProcessDA.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 Get(By ID)
|
|
|
|
public ProjectProcess Get(int ID, int fundtypeid)
|
|
{
|
|
#region Cache Header
|
|
|
|
ProjectProcess ProjectProcess = new ProjectProcess();
|
|
if (ProjectProcess != null)
|
|
return ProjectProcess;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ProjectProcessDA.Get(tc, ID, fundtypeid));
|
|
if (dr.Read())
|
|
{
|
|
ProjectProcess = this.CreateObject<ProjectProcess>(dr);
|
|
}
|
|
|
|
dr.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
|
|
|
|
#endregion
|
|
|
|
return ProjectProcess;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get(By ID)
|
|
|
|
public ProjectProcess GetByTypeId(int tranTypeIDinInt, int fundtypeid)
|
|
{
|
|
#region Cache Header
|
|
|
|
ProjectProcess ProjectProcess = new ProjectProcess();
|
|
//if (ProjectProcess != null)
|
|
// return ProjectProcess;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ProjectProcessDA.GetByTranTypeId(tc, tranTypeIDinInt, fundtypeid));
|
|
if (dr.Read())
|
|
{
|
|
ProjectProcess = this.CreateObject<ProjectProcess>(dr);
|
|
}
|
|
|
|
dr.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
|
|
|
|
//
|
|
|
|
#endregion
|
|
|
|
return ProjectProcess;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get(By Code)
|
|
|
|
public ProjectProcess Get(string desc, int fundtypeid)
|
|
{
|
|
#region Cache Header
|
|
|
|
ProjectProcess ProjectProcess = new ProjectProcess();
|
|
if (ProjectProcess != null)
|
|
return ProjectProcess;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ProjectProcessDA.Get(tc, desc, fundtypeid));
|
|
if (dr.Read())
|
|
{
|
|
ProjectProcess = this.CreateObject<ProjectProcess>(dr);
|
|
}
|
|
|
|
dr.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
|
|
|
|
#endregion
|
|
|
|
return ProjectProcess;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GetByProject(By ID)
|
|
|
|
public List<ProjectProcess> GetByProject(int ID, EnumTranTypeCategory category)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<ProjectProcess> ProjectProcesss = new List<ProjectProcess>();
|
|
|
|
if (ProjectProcesss != null)
|
|
return ProjectProcesss;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ProjectProcessDA.GetbyProject(tc, ID, (int)category));
|
|
ProjectProcesss = this.CreateObjects<ProjectProcess>(dr);
|
|
dr.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
|
|
|
|
#endregion
|
|
|
|
return ProjectProcesss;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region Get()
|
|
|
|
public List<ProjectProcess> GetFundtype(int fundtypeid)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<ProjectProcess> ProjectProcesss = new List<ProjectProcess>();
|
|
|
|
if (ProjectProcesss != null)
|
|
return ProjectProcesss;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ProjectProcessDA.GetbyFundType(tc, fundtypeid));
|
|
ProjectProcesss = this.CreateObjects<ProjectProcess>(dr);
|
|
dr.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
|
|
|
|
#endregion
|
|
|
|
return ProjectProcesss;
|
|
}
|
|
|
|
|
|
public List<ProjectProcess> GetByFundType(int projectID)
|
|
{
|
|
List<ProjectProcess> ProjectProcesss = new List<ProjectProcess>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(ProjectProcessDA.GetByFundType(tc, projectID));
|
|
ProjectProcesss = this.CreateObjects<ProjectProcess>(dr);
|
|
dr.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 ProjectProcesss;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
} |