CEL_Payroll/Payroll.Service/Organogram/Service/OrganogramService.cs

927 lines
35 KiB
C#
Raw Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Data;
using System.Linq;
using Ease.CoreV35;
using Ease.CoreV35.Model;
using Ease.CoreV35.DataAccess;
using System.Collections.Generic;
using Payroll.BO;
using Ease.CoreV35.Caching;
namespace Payroll.Service
{
#region Organogram Service
[Serializable]
public class OrganogramService : ServiceTemplate,IOrganogramService
{
#region Private functions and declaration
Cache _cache = new Cache(typeof(OrganogramBasic));
public OrganogramService()
{ }
private void MapObject(OrganogramBasic oOrganogram, DataReader oReader)
{
base.SetObjectID(oOrganogram, oReader.GetID("OrganogramID"));
oOrganogram.PositionName = oReader.GetString("PositionName");
oOrganogram.ParentID = oReader.GetID("ParentID");
oOrganogram.Tier = oReader.GetInt32("Tier").Value;
oOrganogram.UniqueId = oReader.GetInt32("UniqueId").Value;
//oOrganogram.PositionTypeID = oReader.GetID("PositionTypeID");
oOrganogram.PositionNo = oReader.GetString("PositionNo");
oOrganogram.CompanyID = oReader.GetID("CompanyID");
oOrganogram.DepartmentID = oReader.GetID("DepartmentID");
oOrganogram.FunctionID = oReader.GetID("FunctionID");
oOrganogram.GradeID = oReader.GetID("GradeID");
oOrganogram.DesignationID = oReader.GetID("DesignationID");
oOrganogram.LocationID = oReader.GetID("LocationID");
//oOrganogram.ReportingNodeID = oReader.GetID("RepotingNodeID");
oOrganogram.Tier = oReader.GetInt32("Tier").Value;
oOrganogram.Sequence = oReader.GetInt32("SequenceNO").Value;
oOrganogram.Status = (EnumStatus)oReader.GetInt32("Status").Value;
oOrganogram.JDNo = oReader.GetString("JDNo");
oOrganogram.RevisionNo = oReader.GetString("RevisionNo");
oOrganogram.RevisionDate = oReader.GetDateTime("RevisionDate").Value;
oOrganogram.CreatedBy = oReader.GetID("CreatedBy");
oOrganogram.CreatedDate = oReader.GetDateTime("CreationDate").Value;
oOrganogram.ModifiedBy = oReader.GetID("ModifiedBy");
oOrganogram.ModifiedDate = oReader.GetDateTime("ModifiedDate");
this.SetObjectState(oOrganogram, Ease.CoreV35.ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
OrganogramBasic oOrganogram = new OrganogramBasic();
MapObject(oOrganogram, oReader);
return oOrganogram as T;
}
protected OrganogramBasic CreateObject(DataReader oReader)
{
OrganogramBasic oOrganogram = new OrganogramBasic();
MapObject(oOrganogram, oReader);
return oOrganogram;
}
private void MapOrganAuthorityObject(OrganogramAuthority organAuthority, DataReader oReader)
{
base.SetObjectID(organAuthority, oReader.GetID("OrganAuthorityID"));
organAuthority.NodeID = oReader.GetID("NodeID");
organAuthority.AuthorityType = (EnumAuthorityType)oReader.GetInt32("AuthorityType").Value;
organAuthority.ChildNodeID = oReader.GetID("ChildNodeID");
organAuthority.EmployeeID = oReader.GetID("EmployeeID");
//organAuthority.ModifiedBy = oReader.GetID("ModifiedBy");
// organAuthority.ModifiedDate = oReader.GetDateTime("ModifiedDate").Value;
this.SetObjectState(organAuthority, Ease.CoreV35.ObjectState.Saved);
}
protected ObjectsTemplate<OrganogramAuthority> CreateOrganAuthorityObject(DataReader oReader)
{
ObjectsTemplate<OrganogramAuthority> organAuthorities=new ObjectsTemplate<OrganogramAuthority>();
while (oReader.Read())
{
OrganogramAuthority organAuthority = new OrganogramAuthority();
MapOrganAuthorityObject(organAuthority, oReader);
organAuthorities.Add(organAuthority);
}
return organAuthorities;
}
private void MapOrganDelegationObject(OrganogramDelegation organDelegation, DataReader oReader)
{
base.SetObjectID(organDelegation, oReader.GetID("OrganDelegationID"));
organDelegation.NodeID = oReader.GetID("NodeID");
organDelegation.EmployeeID = oReader.GetID("EmployeeID");
organDelegation.FromDate= oReader.GetDateTime("FromDate").Value;
organDelegation.ToDate = oReader.GetDateTime("ToDate").Value;
organDelegation.DelegationType = oReader.GetString("DelegationType");
organDelegation.IsActive = oReader.GetBoolean("IsActive").Value;
organDelegation.CreatedBy = oReader.GetID("CreatedBy");
organDelegation.CreatedDate = oReader.GetDateTime("CreationDate").Value;
organDelegation.ModifiedBy = oReader.GetID("ModifiedBy");
organDelegation.ModifiedDate = oReader.GetDateTime("ModifiedDate").Value;
this.SetObjectState(organDelegation, Ease.CoreV35.ObjectState.Saved);
}
protected ObjectsTemplate<OrganogramDelegation> CreateOrganDelegationObject(DataReader oReader)
{
ObjectsTemplate<OrganogramDelegation> organDelegations = new ObjectsTemplate<OrganogramDelegation>();
while (oReader.Read())
{
OrganogramDelegation organDelegation = new OrganogramDelegation();
MapOrganDelegationObject(organDelegation, oReader);
organDelegations.Add(organDelegation);
}
return organDelegations;
}
private void MapOrganJobDescObject(OrganogramJobDesc organJobDesc, DataReader oReader)
{
base.SetObjectID(organJobDesc, oReader.GetID("OrganJobDescID"));
organJobDesc.NodeID = oReader.GetID("NodeID");
organJobDesc.Purpose = oReader.GetString("Purpose");
organJobDesc.JobSummery = oReader.GetString("JobSummery");
organJobDesc.Experience = oReader.GetString("Experience");
organJobDesc.Education = oReader.GetString("Education");
organJobDesc.CreatedBy = oReader.GetID("CreatedBy");
organJobDesc.CreatedDate = oReader.GetDateTime("CreationDate").Value;
organJobDesc.ModifiedBy = oReader.GetID("ModifiedBy");
// organJobDesc.ModifiedDate = oReader.GetDateTime("ModifiedDate").Value;
this.SetObjectState(organJobDesc, Ease.CoreV35.ObjectState.Saved);
}
protected ObjectsTemplate<OrganogramJobDesc> CreateOrganJobDescObject(DataReader oReader)
{
ObjectsTemplate<OrganogramJobDesc> organJobDescs = new ObjectsTemplate<OrganogramJobDesc>();
while (oReader.Read())
{
OrganogramJobDesc organJobDesc = new OrganogramJobDesc();
MapOrganJobDescObject(organJobDesc, oReader);
organJobDescs.Add(organJobDesc);
}
return organJobDescs;
}
private void MapOrganResponsibilityObject(OrganogramResponsibility organResp, DataReader oReader)
{
base.SetObjectID(organResp, oReader.GetID("OrganResponsibilityID"));
organResp.NodeID = oReader.GetID("NodeID");
organResp.Responsibility = oReader.GetString("Responsibility");
organResp.IsPrimary = oReader.GetBoolean("IsPrimary").Value;
//organResp.CreatedBy = oReader.GetID("CreatedBy");
//organResp.CreatedDate = oReader.GetDateTime("CreationDate").Value;
//organResp.ModifiedBy = oReader.GetID("ModifiedBy");
//organResp.ModifiedDate = oReader.GetDateTime("ModifiedDate").Value;
this.SetObjectState(organResp, Ease.CoreV35.ObjectState.Saved);
}
protected ObjectsTemplate<OrganogramResponsibility> CreateOrganResponsibilityObject(DataReader oReader)
{
ObjectsTemplate<OrganogramResponsibility> organResponsibilities = new ObjectsTemplate<OrganogramResponsibility>();
while (oReader.Read())
{
OrganogramResponsibility organResponsibility = new OrganogramResponsibility();
MapOrganResponsibilityObject(organResponsibility, oReader);
organResponsibilities.Add(organResponsibility);
}
return organResponsibilities;
}
private void MapOrganSkilLevelObject(OrganogramSkillLevel organSlilLevel, DataReader oReader)
{
base.SetObjectID(organSlilLevel, oReader.GetID("OrganSkillLevelID"));
organSlilLevel.NodeID = oReader.GetID("NodeID");
//organSlilLevel.NodeResponsibilityID = oReader.GetID("NodeResponsibilityID");
organSlilLevel.LevelID = oReader.GetID("LevelID");
organSlilLevel.SkillID = oReader.GetID("SkillID");
//organSlilLevel.CreatedBy = oReader.GetID("CreatedBy");
//organSlilLevel.CreatedDate = oReader.GetDateTime("CreationDate").Value;
//organSlilLevel.ModifiedBy = oReader.GetID("ModifiedBy");
//organSlilLevel.ModifiedDate = oReader.GetDateTime("ModifiedDate").Value;
this.SetObjectState(organSlilLevel, Ease.CoreV35.ObjectState.Saved);
}
protected ObjectsTemplate<OrganogramSkillLevel> CreateOrganSkilLevelObject(DataReader oReader)
{
ObjectsTemplate<OrganogramSkillLevel> organSkilLevels = new ObjectsTemplate<OrganogramSkillLevel>();
while (oReader.Read())
{
OrganogramSkillLevel organSkilLevel = new OrganogramSkillLevel();
MapOrganSkilLevelObject(organSkilLevel, oReader);
organSkilLevels.Add(organSkilLevel);
}
return organSkilLevels;
}
private void MapOrganPositionObject(OrganogramPosition OrganPosition, DataReader oReader)
{
base.SetObjectID(OrganPosition, oReader.GetID("OrganPositionID"));
OrganPosition.NodeID = oReader.GetID("NodeID");
OrganPosition.PositionTypeID = oReader.GetID("PositionTypeID");
OrganPosition.CreatedBy = oReader.GetID("CreatedBy");
//OrganPosition.CreatedDate = oReader.GetDateTime("CreationDate").Value;
// OrganPosition.ModifiedBy = oReader.GetID("ModifiedBy");
// OrganPosition.ModifiedDate = oReader.GetDateTime("ModifiedDate").Value;
this.SetObjectState(OrganPosition, Ease.CoreV35.ObjectState.Saved);
}
protected ObjectsTemplate<OrganogramPosition> CreateOrganPositionObject(DataReader oReader)
{
ObjectsTemplate<OrganogramPosition> organPositions = new ObjectsTemplate<OrganogramPosition>();
while (oReader.Read())
{
OrganogramPosition organPosition = new OrganogramPosition();
MapOrganPositionObject(organPosition, oReader);
organPositions.Add(organPosition);
}
return organPositions;
}
#endregion
#region Service implementation
#region Save
public ID Save(OrganogramBasic oOrganogram)
{
TransactionContext tc=null;
// string tableName = "Organogram";
try
{
tc = TransactionContext.Begin(true);
int id = tc.GenerateID("Organogram", "OrganogramID");
if (oOrganogram.IsNew)
{
base.SetObjectID(oOrganogram, ID.FromInteger(id));
OrganogramDA.Insert(tc, oOrganogram);
}
else
{
OrganogramDA.Update(tc, oOrganogram);
OrganogramDA.DeleteOrganAuthority(tc, oOrganogram.ID);
OrganogramDA.DeleteOrganDelegation(tc, oOrganogram.ID);
OrganogramDA.DeleteOranJobDesc(tc, oOrganogram.ID);
OrganogramDA.DeleteOrganResponsibility(tc, oOrganogram.ID);
OrganogramDA.DeleteOrganSkilLevel(tc, oOrganogram.ID);
OrganogramDA.DeleteOrganPosition(tc, oOrganogram.ID);
}
//tableName = "OrganAuthority";
foreach (OrganogramAuthority organAuthor in oOrganogram.OrganAuthority)
{
id = tc.GenerateID("OrganAuthority", "OrganAuthorityID");
organAuthor.NodeID = oOrganogram.ID;
base.SetObjectID(organAuthor, ID.FromInteger(id));
OrganogramDA.Insert(tc, organAuthor);
}
//tableName = "OrganDelegation";
foreach (OrganogramDelegation organDele in oOrganogram.OrganDelegation)
{
id = tc.GenerateID("OrganDelegation", "OrganDelegationID");
organDele.NodeID = oOrganogram.ID;
base.SetObjectID(organDele, ID.FromInteger(id));
OrganogramDA.Insert(tc, organDele);
}
//tableName = "OrganJobDescription";
foreach (OrganogramJobDesc organJob in oOrganogram.OrganJobDesc)
{
id = tc.GenerateID("OrganJobDescription", "OrganJobDescID");
organJob.NodeID = oOrganogram.ID;
organJob.CreatedBy = oOrganogram.CreatedBy;
organJob.CreatedDate = oOrganogram.CreatedDate;
base.SetObjectID(organJob, ID.FromInteger(id));
OrganogramDA.Insert(tc, organJob);
}
//tableName = "OrganResponsibility";
foreach (OrganogramResponsibility organRes in oOrganogram.OrganResponsibility)
{
id = tc.GenerateID("OrganResponsibility", "OrganResponsibilityID");
organRes.NodeID = oOrganogram.ID;
base.SetObjectID(organRes, ID.FromInteger(id));
OrganogramDA.Insert(tc, organRes);
}
//tableName = "OrganSkillLevel";
foreach (OrganogramSkillLevel organSkillLvl in oOrganogram.OrganSkillLevel)
{
id = tc.GenerateID("OrganSkillLevel", "OrganSkillLevelID");
organSkillLvl.NodeID = oOrganogram.ID;
base.SetObjectID(organSkillLvl, ID.FromInteger(id));
OrganogramDA.Insert(tc, organSkillLvl);
}
//tableName = "OrganPosition";
foreach (OrganogramPosition organPosn in oOrganogram.OrganPositions)
{
id = tc.GenerateID("OrganPosition", "OrganPositionID");
organPosn.NodeID = oOrganogram.ID;
base.SetObjectID(organPosn, ID.FromInteger(id));
OrganogramDA.Insert(tc, organPosn);
}
tc.End();
return oOrganogram.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);
OrganogramDA.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 OrganogramBasic GetbyEmployeeid(ID employeeid)
{
ObjectsTemplate<OrganogramBasic> Organograms = new ObjectsTemplate<OrganogramBasic>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(OrganogramDA.GetbyEmployeeID(tc, employeeid));
Organograms = this.CreateObjects<OrganogramBasic>(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
}
if(Organograms!=null && Organograms.Count >0)
return Organograms[0];
else return null;
}
public int GetMaxTier(TransactionContext tc)
{
int maxLevel = 0;
try
{
#region Retrieving data
maxLevel = OrganogramDA.GetMaxTier(tc);
#endregion
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
throw new ServiceException(e.Message, e);
#endregion
}
return maxLevel;
}
public OrganogramBasic Get(ID id)
{
OrganogramBasic oOrganogram = new OrganogramBasic();
#region Cache Header
oOrganogram = _cache["Get", id] as OrganogramBasic;
if (oOrganogram != null)
return oOrganogram;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(OrganogramDA.Get(tc, id));
if (oreader.Read())
{
oOrganogram = this.CreateObject<OrganogramBasic>(oreader);
}
oreader.Close();
if (oOrganogram != null)
{
OrganogramEmployeeService ore = new OrganogramEmployeeService();
oOrganogram.OrganEmployees = ore.Get(tc, oOrganogram.ID);
DataReader dr = new DataReader(OrganogramDA.Get4OrganPosition(tc, oOrganogram.ID));
oOrganogram.OrganPositions = this.CreateOrganPositionObject(dr);
dr.Close();
dr = new DataReader(OrganogramDA.Get4OrganAuthority(tc, oOrganogram.ID));
oOrganogram.OrganAuthority = this.CreateOrganAuthorityObject(dr);
dr.Close();
dr = new DataReader(OrganogramDA.Get4OrganJobDesc(tc, oOrganogram.ID));
oOrganogram.OrganJobDesc = this.CreateOrganJobDescObject(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(oOrganogram, "Get", id);
#endregion
return oOrganogram;
}
public ObjectsTemplate<OrganogramBasic> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<OrganogramBasic> Organograms = _cache["Get"] as ObjectsTemplate<OrganogramBasic>;
if (Organograms != null)
return Organograms;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(OrganogramDA.Get(tc, status));
Organograms = this.CreateObjects<OrganogramBasic>(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(Organograms, "Get");
#endregion
return Organograms;
}
public ObjectsTemplate<OrganogramBasic> GetbyPositionTypeID(ID postiontypeid)
{
ObjectsTemplate<OrganogramBasic> Organograms = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(OrganogramDA.GetbyPositionType(tc, postiontypeid));
Organograms = this.CreateObjects<OrganogramBasic>(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 Organograms;
}
public ObjectsTemplate<OrganogramBasic> GetTopParents(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<OrganogramBasic> items = _cache["GetTopParents"] as ObjectsTemplate<OrganogramBasic>;
if (items != null)
return items;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(OrganogramDA.GetTopParents(tc,status ));
items = this.CreateObjects<OrganogramBasic>(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(items, "Get");
#endregion
return items;
}
public ObjectsTemplate<OrganogramBasic> GetByParentID(ID parentID,EnumStatus status)
{
#region Cache Header
ObjectsTemplate<OrganogramBasic> items = _cache["Get", parentID] as ObjectsTemplate<OrganogramBasic>;
if (items != null)
return items;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(OrganogramDA.GetByParentID(tc, parentID.Integer,status));
items = this.CreateObjects<OrganogramBasic>(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(items, "Get", parentID);
#endregion
return items;
}
public ObjectsTemplate<OrganogramAuthority> Get4OrganAuthority(ID nodeID)
{
#region Cache Header
ObjectsTemplate<OrganogramAuthority> Organograms = _cache["Get4OrganAuthority", nodeID] as ObjectsTemplate<OrganogramAuthority>;
if (Organograms != null)
return Organograms;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(OrganogramDA.Get4OrganAuthority(tc, nodeID));
Organograms = this.CreateOrganAuthorityObject(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(Organograms, "Get4OrganAuthority", nodeID);
#endregion
return Organograms;
}
public ObjectsTemplate<OrganogramDelegation> Get4OrganDelegation(ID nodeID)
{
#region Cache Header
ObjectsTemplate<OrganogramDelegation> Organograms = _cache["Get4OrganDelegation", nodeID] as ObjectsTemplate<OrganogramDelegation>;
if (Organograms != null)
return Organograms;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(OrganogramDA.Get4OrganDelegation(tc, nodeID));
Organograms = this.CreateOrganDelegationObject(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(Organograms, "Get4OrganDelegation", nodeID);
#endregion
return Organograms;
}
public ObjectsTemplate<OrganogramJobDesc> Get4OrganJobDesc(ID nodeID)
{
#region Cache Header
ObjectsTemplate<OrganogramJobDesc> Organograms = _cache["Get4OrganJobDesc", nodeID] as ObjectsTemplate<OrganogramJobDesc>;
if (Organograms != null)
return Organograms;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(OrganogramDA.Get4OrganJobDesc(tc, nodeID));
Organograms = this.CreateOrganJobDescObject(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(Organograms, "Get4OrganJobDesc", nodeID);
#endregion
return Organograms;
}
public ObjectsTemplate<OrganogramResponsibility> Get4OrganResponsibility(ID nodeId)
{
#region Cache Header
ObjectsTemplate<OrganogramResponsibility> Organograms = _cache["Get4OrganResponsibility", nodeId] as ObjectsTemplate<OrganogramResponsibility>;
if (Organograms != null)
return Organograms;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(OrganogramDA.Get4OrganResponsibility(tc, nodeId));
Organograms = this.CreateOrganResponsibilityObject(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(Organograms, "Get4OrganResponsibility", nodeId);
#endregion
return Organograms;
}
public ObjectsTemplate<OrganogramSkillLevel> Get4OrganSkilLevel(ID nodeID)
{
#region Cache Header
ObjectsTemplate<OrganogramSkillLevel> Organograms = _cache["Get4OrganSkilLevel", nodeID] as ObjectsTemplate<OrganogramSkillLevel>;
if (Organograms != null)
return Organograms;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(OrganogramDA.Get4OrganSkilLevel(tc, nodeID));
Organograms = this.CreateOrganSkilLevelObject(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(Organograms, "Get4OrganSkilLevel", nodeID);
#endregion
return Organograms;
}
public ObjectsTemplate<OrganogramPosition> Get4OrganPosition(ID nodeID)
{
#region Cache Header
ObjectsTemplate<OrganogramPosition> Organograms = _cache["Get4OrganPosition", nodeID] as ObjectsTemplate<OrganogramPosition>;
if (Organograms != null)
return Organograms;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(OrganogramDA.Get4OrganPosition(tc, nodeID ));
Organograms = this.CreateOrganPositionObject(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(Organograms, "Get4OrganPosition", nodeID);
#endregion
return Organograms;
}
public ObjectsTemplate<OrganogramPosition> GetAllOrganPosition()
{
#region Cache Header
ObjectsTemplate<OrganogramPosition> Organograms = _cache["GetAllOrganPosition"] as ObjectsTemplate<OrganogramPosition>;
if (Organograms != null)
return Organograms;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(OrganogramDA.GetAllOrganPosition(tc));
Organograms = this.CreateOrganPositionObject(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(Organograms, "GetAllOrganPosition");
#endregion
return Organograms;
}
public void UpdateParentAndTier(ObjectsTemplate<OrganogramBasic> oNodes)
{
try
{
TransactionContext tc = null;
try
{
#region Update data
tc = TransactionContext.Begin(true);
foreach (OrganogramBasic oNode in oNodes)
{
OrganogramDA.UpdateParentAndTier(tc, oNode);
}
tc.End();
#endregion
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
throw new ServiceException(e.Message, e);
#endregion
}
}
catch (Exception e)
{
throw new ServiceException(e.Message, e);
}
}
public ID GetMinNodeIdByDept(ID deptID)
{
OrganogramBasic oOrganogram = null;
#region Cache Header
oOrganogram = _cache["GetMinNodeIdByDept", deptID] as OrganogramBasic;
if (oOrganogram != null)
return oOrganogram.ID;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(OrganogramDA.GetMinNodeIdByDept(tc, deptID));
if (oreader.Read())
{
oOrganogram = this.CreateObject<OrganogramBasic>(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(oOrganogram, "GetMinNodeIdByDept", deptID);
#endregion
if (oOrganogram == null) return null;
else return oOrganogram.ID;
}
public DataSet GetOrganogramNodes(int nNodeID)
{
DataSet ds = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
ds = OrganogramDA.GetOrganogramNodes(tc, nNodeID);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return ds;
}
public DataSet GetLMOrganogramNodes(int nNodeID)
{
DataSet ds = new DataSet();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
ds = OrganogramDA.GetLMOrganogramNodes(tc, nNodeID);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return ds;
}
#endregion
#endregion
}
#endregion
}