436 lines
11 KiB
C#
436 lines
11 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;
|
|
|
|
//using HRM.BO.Fund;
|
|
|
|
namespace HRM.DA.Fund
|
|
{
|
|
public class ProjectProcessService : ServiceTemplate
|
|
{
|
|
private void MapObject(ProjectProcess ProjectProcess, DataReader dr)
|
|
{
|
|
base.SetObjectID(ProjectProcess, dr.GetInt32("ProcessID").Value);
|
|
ProjectProcess.CurrentProjectID = dr.GetInt32("ProjectID").Value;
|
|
ProjectProcess.Description = dr.GetString("Description");
|
|
ProjectProcess.TranType = dr.GetInt32("TranTypeID").Value;
|
|
ProjectProcess.Category = (EnumTranTypeCategory)(dr.GetInt16("Category"));
|
|
ProjectProcess.MapSubsidiaryObjectName_1 = dr.GetString("MapSubObjectName_1");
|
|
ProjectProcess.MapSubsidiaryObjectName_2 = dr.GetString("MapSubObjectName_2");
|
|
ProjectProcess.FasSubsidiaryTranObjectName = dr.GetString("FasSubTranObjectName");
|
|
ProjectProcess.ActivityRelatedSourceObjID = dr.GetInt32("ActivityRelatedSourceID").Value;
|
|
ProjectProcess.IsTranElementRequiredForVoucher = dr.GetBoolean("IsTEReqForVoucher").Value;
|
|
ProjectProcess.SourceTable = dr.GetString("SourceTable");
|
|
ProjectProcess.ElementType = dr.GetUInt16("ElementType").HasValue
|
|
? (EnumElementType)dr.GetUInt16("ElementType").Value
|
|
: (EnumElementType?)null;
|
|
ProjectProcess.CreatedBy = dr.GetInt32("CreatedBy").Value;
|
|
ProjectProcess.CreatedDate = dr.GetDateTime("CreatedDate").Value;
|
|
ProjectProcess.ModifiedBy = dr.GetInt32("ModifiedBy").Value != 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> GetByProject(int projectID)
|
|
{
|
|
#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, 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
|
|
}
|
|
|
|
#region Cache Footer
|
|
|
|
#endregion
|
|
|
|
return ProjectProcesss;
|
|
}
|
|
|
|
#endregion
|
|
|
|
//#region GetTable
|
|
//public DataTable GetTable(int projecttypeid)
|
|
//{
|
|
// DataTable dTbl = new DataTable("ActivityRelatedSources");
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin();
|
|
|
|
// IDataReader ir = ProjectProcessDA.Get(tc, projecttypeid);
|
|
// dTbl.Load(ir);
|
|
// ir.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 dTbl;
|
|
//}
|
|
//#endregion
|
|
|
|
#endregion
|
|
}
|
|
} |