871 lines
29 KiB
C#
871 lines
29 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Ease.CoreV35;
|
|
using Ease.CoreV35.Model;
|
|
using Ease.CoreV35.DataAccess;
|
|
using Ease.CoreV35.Caching;
|
|
using Payroll.BO;
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
public class WFMovementTranService : ServiceTemplate, IWFMovementTranService
|
|
{
|
|
|
|
#region Cache
|
|
Cache _cache = new Cache(typeof(WFMovementTran));
|
|
#endregion
|
|
|
|
#region Constructor
|
|
public WFMovementTranService()
|
|
{ }
|
|
#endregion
|
|
|
|
#region WFMovementTran
|
|
private void MapObject(WFMovementTran wfMovementTran, DataReader oReader)
|
|
{
|
|
base.SetObjectID(wfMovementTran, oReader.GetID("WFMOVEMENTTRANID"));
|
|
wfMovementTran.FromEmployeeID = oReader.GetID("FROMEMPLOYEEID");
|
|
wfMovementTran.FromNodeID = oReader.GetID("FROMNODEID");
|
|
wfMovementTran.SetupID = oReader.GetID("WFSETUPID");
|
|
wfMovementTran.WFRuleID = oReader.GetID("WFRULEID");
|
|
wfMovementTran.ObjectID = oReader.GetID("OBJECTID");
|
|
wfMovementTran.IsActive = oReader.GetBoolean("ISACTIVE").Value;
|
|
wfMovementTran.Senttime = oReader.GetDateTime("SENTTIME").HasValue ? oReader.GetDateTime("SENTTIME").Value : DateTime.MinValue;
|
|
wfMovementTran.Status = (enumwfStatus)oReader.GetInt32("STATUS").Value;
|
|
wfMovementTran.Uniquenumber = oReader.GetInt32("UNIQUENUMBER").Value;
|
|
wfMovementTran.Remarks = oReader.GetString("REMARKS");
|
|
wfMovementTran.Tier = oReader.GetInt32("TIER").Value;
|
|
wfMovementTran.ObjectDescription = oReader.GetString("OBJECTDESCRIPTION");
|
|
this.SetObjectState(wfMovementTran, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
WFMovementTran wfMovementTran = new WFMovementTran();
|
|
MapObject(wfMovementTran, oReader);
|
|
return wfMovementTran as T;
|
|
}
|
|
protected WFMovementTran CreateObject(DataReader oReader)
|
|
{
|
|
WFMovementTran wfMovementTran = new WFMovementTran();
|
|
MapObject(wfMovementTran, oReader);
|
|
return wfMovementTran;
|
|
}
|
|
|
|
//protected WFMovementTask CreateWFMovementTaskObject(DataReader oReader)
|
|
//{
|
|
// WFMovementTask wfMTask = new WFMovementTask();
|
|
// MapWFMTaskObject(wfMTask, oReader);
|
|
// return wfMTask;
|
|
//}
|
|
#endregion
|
|
|
|
#region WFMovementTask
|
|
private void MapWFMTaskObject(WFMovementTask wfMTask, DataReader oReader)
|
|
{
|
|
base.SetObjectID(wfMTask, oReader.GetID("WFMOVEMENTTASKID"));
|
|
wfMTask.WFMovementTranID = oReader.GetID("WFMOVEMENTTRANID");
|
|
wfMTask.EmployeeID = oReader.GetID("EMPLOYEEID");
|
|
wfMTask.NodeID = oReader.GetID("NODEID");
|
|
wfMTask.Status = oReader.GetBoolean("STATUS").Value;
|
|
wfMTask.Remarks = oReader.GetString("REMARKS");
|
|
wfMTask.TasksType = (EnumWFNotifyType)oReader.GetInt32("TASKSTYPE").Value;
|
|
wfMTask.MailSendType = (enumMailSendType)oReader.GetInt32("MAILSENDTYPE").Value;
|
|
wfMTask.SentTime = oReader.GetDateTime("SENTTIME").HasValue ? oReader.GetDateTime("SENTTIME").Value : DateTime.MinValue;
|
|
wfMTask.Description = oReader.GetString("DESCRIPTION");
|
|
wfMTask.ReceiveStatus = (EnumWFReceiveStatus)oReader.GetInt32("RECEIVESTATUS").Value;
|
|
|
|
this.SetObjectState(wfMTask, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
|
|
protected WFMovementTask CreateWFMovementTaskObject(DataReader oReader)
|
|
{
|
|
WFMovementTask wfMTask = new WFMovementTask();
|
|
MapWFMTaskObject(wfMTask, oReader);
|
|
return wfMTask;
|
|
}
|
|
|
|
protected ObjectsTemplate<WFMovementTask> CreateWFMovementTaskObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<WFMovementTask> wfMTasks = new ObjectsTemplate<WFMovementTask>();
|
|
while (oReader.Read())
|
|
{
|
|
WFMovementTask wfMTask = new WFMovementTask();
|
|
MapWFMTaskObject(wfMTask, oReader);
|
|
wfMTasks.Add(wfMTask);
|
|
}
|
|
return wfMTasks;
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
public int GetUniqueNumber()
|
|
{
|
|
#region WF Movement
|
|
int nUniqueNumber = 0;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
nUniqueNumber = WFMovementTranDA.GetUniqueNumber(tc);
|
|
tc.End();
|
|
}
|
|
catch (ServiceException ex)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(ex);
|
|
throw new ServiceException(ex.Message);
|
|
#endregion
|
|
}
|
|
#endregion
|
|
return nUniqueNumber;
|
|
}
|
|
|
|
public OrganogramBasic InitiatorNode(int nUniqueNumber)
|
|
{
|
|
OrganogramBasic oNode = null;
|
|
#region WF Movements
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
int nTranID = WFMovementTranDA.InitialTranID(tc, nUniqueNumber);
|
|
tc.End();
|
|
|
|
if (nTranID > 0)
|
|
{
|
|
WFMovementTran oTran = this.Get(ID.FromInteger(nTranID));
|
|
oNode = OrganogramBasic.Get(oTran.FromNodeID);
|
|
}
|
|
else
|
|
{
|
|
throw new ServiceException("Initiator not found.");
|
|
}
|
|
}
|
|
catch (ServiceException ex)
|
|
{
|
|
#region Handle Error
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(ex);
|
|
throw new ServiceException("Failed to get Initiator");
|
|
#endregion
|
|
}
|
|
#endregion
|
|
return oNode;
|
|
}
|
|
|
|
#region WFMovementNext
|
|
private void MapWFMNextObject(WFMovementNext wfMNext, DataReader oReader)
|
|
{
|
|
base.SetObjectID(wfMNext, oReader.GetID("WFMOVEMENTNEXTID"));
|
|
wfMNext.WFMovementTranID = oReader.GetID("WFMOVEMENTTRANID");
|
|
wfMNext.EmployeeID = oReader.GetID("EMPLOYEEID");
|
|
wfMNext.NodeID = oReader.GetID("NODEID");
|
|
wfMNext.Status = (enumwfStatus)oReader.GetInt32("STATUS").Value;
|
|
wfMNext.Remarks = oReader.GetString("REMARKS");
|
|
wfMNext.Description = oReader.GetString("DESCRIPTION");
|
|
wfMNext.ReceiveStatus = (EnumWFReceiveStatus)oReader.GetInt32("RECEIVESTATUS").Value;
|
|
|
|
this.SetObjectState(wfMNext, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
|
|
|
|
protected ObjectsTemplate<WFMovementNext> CreateWFMovementNextObjects(DataReader oReader)
|
|
{
|
|
ObjectsTemplate<WFMovementNext> wfMNexts = new ObjectsTemplate<WFMovementNext>();
|
|
while (oReader.Read())
|
|
{
|
|
WFMovementNext wfMNext = new WFMovementNext();
|
|
MapWFMNextObject(wfMNext, oReader);
|
|
wfMNexts.Add(wfMNext);
|
|
}
|
|
return wfMNexts;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Service Implementation
|
|
|
|
#region Save
|
|
|
|
public void Submit(WFMovementTran PrvMove, WFMovementTran NextMove)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
|
|
#region Update PreviousItem
|
|
int id;
|
|
WFMovementTranDA.Update(tc, PrvMove);
|
|
foreach (WFMovementNext oItem in PrvMove.WFMNexts)
|
|
{
|
|
WFMovementTranDA.Update_WFMovementNext(tc, oItem);
|
|
}
|
|
#endregion Update PreviousItem
|
|
|
|
|
|
if (NextMove.IsNew)
|
|
{
|
|
id = tc.GenerateID("WFMOVEMENTTRAN", "WFMOVEMENTTRANID");
|
|
this.SetObjectID(NextMove, ID.FromInteger(id));
|
|
WFMovementTranDA.Insert(tc, NextMove);
|
|
}
|
|
else
|
|
{
|
|
WFMovementTranDA.Update(tc, NextMove);
|
|
}
|
|
|
|
#region Save Child
|
|
foreach (WFMovementNext oWFMovementNext in NextMove.WFMNexts)
|
|
{
|
|
if (oWFMovementNext.IsNew)
|
|
{
|
|
id = tc.GenerateID("WFMOVEMENTNEXT", "WFMOVEMENTNEXTID");
|
|
this.SetObjectID(oWFMovementNext, ID.FromInteger(id));
|
|
oWFMovementNext.WFMovementTranID = NextMove.ID;
|
|
WFMovementTranDA.Insert(tc, oWFMovementNext);
|
|
}
|
|
else
|
|
{
|
|
WFMovementTranDA.Update_WFMovementNext(tc, oWFMovementNext);
|
|
}
|
|
}
|
|
|
|
foreach (WFMovementTask otask in NextMove.WFMTasks)
|
|
{
|
|
if (otask.IsNew)
|
|
{
|
|
id = tc.GenerateID("WFMOVEMENTTASK", "WFMOVEMENTTASKID");
|
|
this.SetObjectID(otask, ID.FromInteger(id));
|
|
otask.WFMovementTranID = NextMove.ID;
|
|
WFMovementTranDA.Insert(tc, otask);
|
|
|
|
}
|
|
else
|
|
{
|
|
WFMovementTranDA.Update_WFMovementTask(tc, otask);
|
|
}
|
|
}
|
|
#endregion Save Child
|
|
|
|
WFMovementTranDA.UpdateObjectStatus(tc, NextMove);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
public void UpdateSysNotification(ID movementTaskID, bool status)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
WFMovementTranDA.Update_SysNotification(tc, movementTaskID, status);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void Update_MovementNext(ID tranID, ID newEmployeeID, ID empID, ID NodeID, string remarks)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
WFMovementTranDA.Update_WFMovementNext(tc, tranID, newEmployeeID, empID, NodeID, remarks);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
public ID Save(WFMovementTran wfMTran)
|
|
{
|
|
TransactionContext tc = null;
|
|
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
int id = tc.GenerateID("WFMOVEMENTTRAN", "WFMOVEMENTTRANID");
|
|
if (wfMTran.IsNew)
|
|
{
|
|
base.SetObjectID(wfMTran, ID.FromInteger(id));
|
|
WFMovementTranDA.Insert(tc, wfMTran);
|
|
}
|
|
else
|
|
{
|
|
WFMovementTranDA.Update(tc, wfMTran);
|
|
|
|
}
|
|
|
|
#region Save Child
|
|
foreach (WFMovementNext oWFMovementNext in wfMTran.WFMNexts)
|
|
{
|
|
if (oWFMovementNext.IsNew)
|
|
{
|
|
id = tc.GenerateID("WFMOVEMENTNEXT", "WFMOVEMENTNEXTID");
|
|
this.SetObjectID(oWFMovementNext, ID.FromInteger(id));
|
|
oWFMovementNext.WFMovementTranID = wfMTran.ID;
|
|
WFMovementTranDA.Insert(tc, oWFMovementNext);
|
|
}
|
|
else
|
|
{
|
|
WFMovementTranDA.Update_WFMovementNext(tc, oWFMovementNext);
|
|
}
|
|
}
|
|
|
|
foreach (WFMovementTask otask in wfMTran.WFMTasks)
|
|
{
|
|
if (otask.IsNew)
|
|
{
|
|
id = tc.GenerateID("WFMOVEMENTTASK", "WFMOVEMENTTASKID");
|
|
this.SetObjectID(otask, ID.FromInteger(id));
|
|
otask.WFMovementTranID = wfMTran.ID;
|
|
WFMovementTranDA.Insert(tc, otask);
|
|
|
|
}
|
|
else
|
|
{
|
|
WFMovementTranDA.Update_WFMovementTask(tc, otask);
|
|
}
|
|
}
|
|
#endregion Save Child
|
|
|
|
WFMovementTranDA.UpdateObjectStatus(tc, wfMTran);
|
|
|
|
tc.End();
|
|
|
|
return wfMTran.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
//string smessage = "Faliled to save Organogram (table:" + tableName + ") for the Position:("
|
|
// + oOrganogram.PositionNo + ") " + oOrganogram.PositionName + ". Error :";
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Delete
|
|
|
|
public void Delete(ID id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
WFMovementTranDA.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
|
|
|
|
public WFMovementNext GetReceivedWFNext(int wfsetupID, int objectID)
|
|
{
|
|
ObjectsTemplate<WFMovementNext> onext = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader oreader = new DataReader(WFMovementTranDA.GetReceivedWFNext(tc, wfsetupID, objectID));
|
|
if (oreader.Read())
|
|
{
|
|
onext = this.CreateWFMovementNextObjects(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
|
|
}
|
|
if (onext == null) return null;
|
|
else
|
|
if (onext.Count == 0) return null;
|
|
else return onext[0];
|
|
}
|
|
|
|
public WFMovementTran Get(ID id)
|
|
{
|
|
WFMovementTran oWFMTran = new WFMovementTran();
|
|
#region Cache Header
|
|
oWFMTran = _cache["Get", id] as WFMovementTran;
|
|
if (oWFMTran != null)
|
|
return oWFMTran;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(WFMovementTranDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oWFMTran = this.CreateObject<WFMovementTran>(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
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oWFMTran, "Get", id);
|
|
#endregion
|
|
return oWFMTran;
|
|
}
|
|
public ObjectsTemplate<WFMovementTran> ReceivedItems(ID employeeid)
|
|
{
|
|
ObjectsTemplate<WFMovementTran> wfMovementTrans = new ObjectsTemplate<WFMovementTran>();
|
|
|
|
#region WF Movements
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(WFMovementTranDA.ReceivedItems(tc, employeeid));
|
|
wfMovementTrans = this.CreateObjects<WFMovementTran>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
}
|
|
catch (ServiceException ex)
|
|
{
|
|
#region Handle Error
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(ex);
|
|
throw new ServiceException(ex.Message);
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
return wfMovementTrans;
|
|
}
|
|
|
|
public ObjectsTemplate<WFMovementNext> GetPendingItems(ID employeeid)
|
|
{
|
|
ObjectsTemplate<WFMovementNext> wfMovementTrans = new ObjectsTemplate<WFMovementNext>();
|
|
|
|
#region WF Movements
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(WFMovementTranDA.PendingItems(tc, employeeid));
|
|
wfMovementTrans = this.CreateObjects<WFMovementNext>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
}
|
|
catch (ServiceException ex)
|
|
{
|
|
#region Handle Error
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(ex);
|
|
throw new ServiceException(ex.Message);
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
return wfMovementTrans;
|
|
}
|
|
|
|
public ObjectsTemplate<WFMovementTask> GetNotificationItems(ID employeeid)
|
|
{
|
|
ObjectsTemplate<WFMovementTask> wfMovementTrans = new ObjectsTemplate<WFMovementTask>();
|
|
|
|
#region WF Movements
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(WFMovementTranDA.NotificationItems(tc, employeeid));
|
|
wfMovementTrans = this.CreateWFMovementTaskObjects(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
}
|
|
catch (ServiceException ex)
|
|
{
|
|
#region Handle Error
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(ex);
|
|
throw new ServiceException(ex.Message);
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
return wfMovementTrans;
|
|
}
|
|
|
|
|
|
public int ReceivedItemsCount(ID employeeid)
|
|
{
|
|
|
|
#region WF Movements
|
|
TransactionContext tc = null;
|
|
int nCount = 0;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
nCount = WFMovementTranDA.ReceivedItemsCount(tc, employeeid);
|
|
tc.End();
|
|
}
|
|
catch (ServiceException ex)
|
|
{
|
|
#region Handle Error
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(ex);
|
|
throw new ServiceException(ex.Message);
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
return nCount;
|
|
}
|
|
|
|
public int GetNotificationItemCount(ID employeeid)
|
|
{
|
|
|
|
#region WF Movements
|
|
TransactionContext tc = null;
|
|
int nCount = 0;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
nCount = WFMovementTranDA.NotificationItemsCount(tc, employeeid);
|
|
tc.End();
|
|
}
|
|
catch (ServiceException ex)
|
|
{
|
|
#region Handle Error
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(ex);
|
|
throw new ServiceException(ex.Message);
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
return nCount;
|
|
}
|
|
|
|
public ObjectsTemplate<WFMovementTran> Get()
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<WFMovementTran> wfMTrans = _cache["Get"] as ObjectsTemplate<WFMovementTran>;
|
|
if (wfMTrans != null)
|
|
return wfMTrans;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(WFMovementTranDA.Get(tc));
|
|
wfMTrans = this.CreateObjects<WFMovementTran>(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
|
|
_cache.Add(wfMTrans, "Get");
|
|
#endregion
|
|
return wfMTrans;
|
|
}
|
|
|
|
|
|
public ObjectsTemplate<WFMovementTask> Get4WFMovementTask(ID id)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<WFMovementTask> wfMTasks = _cache["Get4WFMovementTask", id] as ObjectsTemplate<WFMovementTask>;
|
|
if (wfMTasks != null)
|
|
return wfMTasks;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(WFMovementTranDA.Get4WFMovementTask(tc, id));
|
|
wfMTasks = this.CreateWFMovementTaskObjects(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
|
|
_cache.Add(wfMTasks, "Get4WFMovementTask", id);
|
|
#endregion
|
|
return wfMTasks;
|
|
}
|
|
public ObjectsTemplate<WFMovementTask> GetWFMovementTasks()
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<WFMovementTask> wfMTasks = _cache["GetWFMovementTasks"] as ObjectsTemplate<WFMovementTask>;
|
|
if (wfMTasks != null)
|
|
return wfMTasks;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(WFMovementTranDA.GetWFMovementTasks(tc));
|
|
wfMTasks = this.CreateWFMovementTaskObjects(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
|
|
_cache.Add(wfMTasks, "GetWFMovementTasks");
|
|
#endregion
|
|
return wfMTasks;
|
|
}
|
|
|
|
public ObjectsTemplate<WFMovementTran> GetAllItems(int nUniqueNumber)
|
|
{
|
|
ObjectsTemplate<WFMovementTran> wfMovementTrans = new ObjectsTemplate<WFMovementTran>();
|
|
|
|
#region WF Movements
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(WFMovementTranDA.GetAllItem(tc, nUniqueNumber));
|
|
wfMovementTrans = this.CreateObjects<WFMovementTran>(dr);
|
|
dr.Close();
|
|
tc.End();
|
|
}
|
|
catch (ServiceException ex)
|
|
{
|
|
#region Handle Error
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(ex);
|
|
throw new ServiceException(ex.Message);
|
|
#endregion
|
|
}
|
|
#endregion
|
|
return wfMovementTrans;
|
|
}
|
|
public WFMovementTask GetWFMovementTask(ID id)
|
|
{
|
|
WFMovementTask wfMTask = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader oreader = new DataReader(WFMovementTranDA.GetWFMovementTask(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
wfMTask = this.CreateWFMovementTaskObject(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 wfMTask;
|
|
}
|
|
|
|
public ObjectsTemplate<WFMovementNext> Get4WFMovementNext(ID tranid)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<WFMovementNext> wfMNexts = _cache["Get4WFMovementNext", tranid] as ObjectsTemplate<WFMovementNext>;
|
|
if (wfMNexts != null)
|
|
return wfMNexts;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(WFMovementTranDA.Get4WFMovementNext(tc, tranid));
|
|
wfMNexts = this.CreateWFMovementNextObjects(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
|
|
_cache.Add(wfMNexts, "Get4WFMovementNext", tranid);
|
|
#endregion
|
|
return wfMNexts;
|
|
}
|
|
|
|
public ObjectsTemplate<WFMovementNext> Get4WFMovementNext(int UniqueNumber)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<WFMovementNext> wfMNexts = _cache["Get4WFMovementNext", UniqueNumber] as ObjectsTemplate<WFMovementNext>;
|
|
if (wfMNexts != null)
|
|
return wfMNexts;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(WFMovementTranDA.Get4WFMovementNext(tc, UniqueNumber));
|
|
wfMNexts = this.CreateWFMovementNextObjects(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
|
|
_cache.Add(wfMNexts, "Get4WFMovementNext", UniqueNumber);
|
|
#endregion
|
|
return wfMNexts;
|
|
}
|
|
public ObjectsTemplate<WFMovementTran> GetWFMovementByWFType(ID wFTypeID)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<WFMovementTran> wfMTrans = _cache["Get"] as ObjectsTemplate<WFMovementTran>;
|
|
if (wfMTrans != null)
|
|
return wfMTrans;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(WFMovementTranDA.GetWFMovementByWFType(tc, wFTypeID));
|
|
wfMTrans = this.CreateObjects<WFMovementTran>(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
|
|
_cache.Add(wfMTrans, "Get");
|
|
#endregion
|
|
return wfMTrans;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
}
|