399 lines
10 KiB
C#
399 lines
10 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;
|
|
namespace HRM.DA.Fund
|
|
{
|
|
public class ProcessActivityService : ServiceTemplate
|
|
{
|
|
public ProcessActivityService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(ProcessActivity ProcessActivity, DataReader dr)
|
|
{
|
|
base.SetObjectID(ProcessActivity, dr.GetInt32("ActivityID").Value);
|
|
ProcessActivity.Serial = dr.GetInt32("Serial").Value;
|
|
ProcessActivity.FundTypeID = dr.GetInt32("ProjectID").Value;
|
|
ProcessActivity.ProcessID = dr.GetInt32("ProcessID").Value;
|
|
ProcessActivity.Description = dr.GetString("Description");
|
|
ProcessActivity.ActivityRelatedTo = dr.GetInt32("ActivityRelatedTo").Value;
|
|
ProcessActivity.RelatedValue = dr.GetInt32("RelatedValue").Value;
|
|
|
|
ProcessActivity.CreatedBy = dr.GetInt32("CreatedBy").Value;
|
|
ProcessActivity.CreatedDate = dr.GetDateTime("CreatedDate").Value;
|
|
ProcessActivity.ModifiedBy =
|
|
dr.GetInt32("ModifiedBy").Value != null ? dr.GetInt32("ModifiedBy").Value : (0);
|
|
ProcessActivity.ModifiedDate = dr.GetDateTime("ModifiedDate") != null
|
|
? dr.GetDateTime("ModifiedDate")
|
|
: DateTime.MinValue;
|
|
base.SetObjectState(ProcessActivity, ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader dr)
|
|
{
|
|
ProcessActivity ProcessActivity = new ProcessActivity();
|
|
|
|
MapObject(ProcessActivity, dr);
|
|
|
|
return ProcessActivity as T;
|
|
}
|
|
|
|
private ProcessActivity CreateObject(DataReader oReader)
|
|
{
|
|
ProcessActivity oProcessActivity = new ProcessActivity();
|
|
MapObject(oProcessActivity, oReader);
|
|
return oProcessActivity;
|
|
}
|
|
|
|
private List<ProcessActivity> CreateObjects(IDataReader oReader)
|
|
{
|
|
List<ProcessActivity> oProcessActivitys = new List<ProcessActivity>();
|
|
DataReader oreader = new DataReader(oReader);
|
|
while (oreader.Read())
|
|
{
|
|
ProcessActivity oItem = CreateObject(oreader);
|
|
oProcessActivitys.Add(oItem);
|
|
}
|
|
|
|
return oProcessActivitys;
|
|
}
|
|
|
|
#region Service Implementation
|
|
|
|
#region GetMaxSerial
|
|
|
|
public int GetMaxSerial()
|
|
{
|
|
int maxSerial = 0;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
maxSerial = ProcessActivityDA.GetMaxSerial(tc);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw e;
|
|
}
|
|
|
|
return maxSerial;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Insert
|
|
|
|
|
|
#endregion
|
|
|
|
#region UpdatePosition
|
|
|
|
public void UpdatePosition(List<ProcessActivity> processActivitys)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
foreach (ProcessActivity item in processActivitys)
|
|
{
|
|
ProcessActivityDA.UpdatePosition(tc, item);
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new ServiceException("Failed to update position ProcessActivity", e);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Delete
|
|
|
|
public void Delete(int id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
ProcessActivityDA.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 ProcessActivity Get(int ID)
|
|
{
|
|
#region Cache Header
|
|
|
|
ProcessActivity ProcessActivity = new ProcessActivity();
|
|
if (ProcessActivity != null)
|
|
return ProcessActivity;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
IDataReader dr = ProcessActivityDA.Get(tc, ID);
|
|
DataReader oreader = new DataReader(dr);
|
|
ProcessActivity = CreateObject(oreader);
|
|
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 ProcessActivity;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GetbyProjectID(By ID)
|
|
|
|
public List<ProcessActivity> GetbyProjectID(int ID)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<ProcessActivity> ProcessActivity = new List<ProcessActivity>();
|
|
if (ProcessActivity != null)
|
|
return ProcessActivity;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
IDataReader dr = ProcessActivityDA.GetbyProjectID(tc, ID);
|
|
ProcessActivity = CreateObjects(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 ProcessActivity;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GetbyProcessID(By ID)
|
|
|
|
public List<ProcessActivity> GetbyProcessID(int ID)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<ProcessActivity> ProcessActivity = new List<ProcessActivity>();
|
|
if (ProcessActivity != null)
|
|
return ProcessActivity;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
IDataReader dr = ProcessActivityDA.GetbyProcessID(tc, ID);
|
|
ProcessActivity = CreateObjects(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 ProcessActivity;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GetbyProjectProcessID(By ID)
|
|
|
|
public List<ProcessActivity> GetbyProjectProcessID(int Projectid, int Processid)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<ProcessActivity> ProcessActivity = new List<ProcessActivity>();
|
|
if (ProcessActivity != null)
|
|
return ProcessActivity;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
IDataReader dr = ProcessActivityDA.GetbyProjectProcessID(tc, Projectid, Processid);
|
|
ProcessActivity = CreateObjects(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 ProcessActivity;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get()
|
|
|
|
public List<ProcessActivity> Getbyfundtype(int fundtypeid)
|
|
{
|
|
#region Cache Header
|
|
|
|
List<ProcessActivity> ProcessActivitys = new List<ProcessActivity>();
|
|
|
|
if (ProcessActivitys != null)
|
|
return ProcessActivitys;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
IDataReader dr = ProcessActivityDA.Get(tc, fundtypeid);
|
|
ProcessActivitys = CreateObjects(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 ProcessActivitys;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GetTable
|
|
|
|
public DataTable GetTable(int fundtypeid)
|
|
{
|
|
DataTable dTbl = new DataTable("ProcessActivitys");
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
IDataReader ir = ProcessActivityDA.Get(tc, fundtypeid);
|
|
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
|
|
}
|
|
} |