271 lines
8.8 KiB
C#
271 lines
8.8 KiB
C#
using Ease.Core.DataAccess;
|
|
using Ease.Core.Model;
|
|
using Ease.Core.Utility;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using HRM.BO;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
#region UserObject Service
|
|
|
|
public class UserObjectService : ServiceTemplate, IUserObjectService
|
|
{
|
|
#region Private functions and declaration
|
|
|
|
public UserObjectService() { }
|
|
|
|
private void MapObject(UserObject oUserObject, DataReader oReader)
|
|
{
|
|
this.SetObjectID(oUserObject, oReader.GetInt32("UserObjectID").Value);
|
|
oUserObject.Name = oReader.GetString("Name");
|
|
oUserObject.FieldValues = oReader.GetString("FieldValues");
|
|
oUserObject.FieldDataTypes = oReader.GetString("FieldDataTypes");
|
|
oUserObject.CreatedBy = oReader.GetInt32("CreatedBy").Value;
|
|
oUserObject.CreatedDate = oReader.GetDateTime("CreateDate").Value;
|
|
oUserObject.ModifiedBy = oReader.GetInt32("ModifiedBy");
|
|
oUserObject.ModifiedDate =oReader.GetDateTime("ModifiedDate");
|
|
oUserObject.FundTypeID = oReader.GetInt32("FundTypeID").Value;
|
|
this.SetObjectState(oUserObject, Ease.Core.ObjectState.Saved);
|
|
}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
UserObject oUserObject = new UserObject();
|
|
MapObject(oUserObject, oReader);
|
|
return oUserObject as T;
|
|
}
|
|
|
|
protected UserObject CreateObject(DataReader oReader)
|
|
{
|
|
UserObject oUserObject = new UserObject();
|
|
MapObject(oUserObject, oReader);
|
|
return oUserObject;
|
|
}
|
|
#endregion
|
|
|
|
#region Service implementation
|
|
//public UserObject Get(ID id)
|
|
//{
|
|
// UserObject oUserObject = new UserObject();
|
|
// #region Cache Header
|
|
// oUserObject = (UserObject)_cache["Get", id];
|
|
// if (oUserObject != null)
|
|
// return oUserObject;
|
|
// #endregion
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin(true);
|
|
// IDataReader oreader = UserObjectDA.Get(tc, id);
|
|
// NullHandler oReader = new NullHandler(oreader);
|
|
// if (oreader.Read())
|
|
// {
|
|
// oUserObject = CreateObject(oReader);
|
|
// }
|
|
// oreader.Close();
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
// throw new ServiceException("Failed to GetUserObject", e);
|
|
// #endregion
|
|
// }
|
|
// #region Cache Footer
|
|
// _cache.Add(oUserObject, "Get", id);
|
|
// #endregion
|
|
// return oUserObject;
|
|
//}
|
|
|
|
public List<UserObject> GetUserObjectByFundTypeID(int fundTypeID)
|
|
{
|
|
List<UserObject> oUserObjects = new List<UserObject>();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
DataReader oReader = new DataReader(UserObjectDA.Get(tc, fundTypeID));
|
|
oUserObjects = this.CreateObjects<UserObject> (oReader);
|
|
oReader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException("Failed to GetUserObject" + e.Message, e);
|
|
#endregion
|
|
}
|
|
return oUserObjects;
|
|
}
|
|
|
|
//public UserObjects GetByGLID(ID nGLID)
|
|
//{
|
|
// UserObjects oUserObjects = new UserObjects();
|
|
// #region Cache Header
|
|
// oUserObjects = (UserObjects)_cache["Get"];
|
|
// if (oUserObjects != null)
|
|
// return oUserObjects;
|
|
// #endregion
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin(true);
|
|
// IDataReader oReader = UserObjectDA.GetByGLID(tc,nGLID.Integer);
|
|
// oUserObjects = CreateObjects(oReader);
|
|
// oReader.Close();
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
// throw new ServiceException("Failed to GetUserObject", e);
|
|
// #endregion
|
|
// }
|
|
// #region Cache Footer
|
|
// _cache.Add(oUserObjects, "Get");
|
|
// #endregion
|
|
// return oUserObjects;
|
|
//}
|
|
//public ID Save(UserObject oUserObject)
|
|
//{
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin(true);
|
|
// if (oUserObject.IsNew)
|
|
// {
|
|
// #region Creator
|
|
// oUserObject.CreatedBy = User.CurrentUser.ID;
|
|
// oUserObject.CreateDate = DateTime.Now;
|
|
// #endregion
|
|
|
|
// this.SetObjectID(oUserObject, ID.FromInteger(UserObjectDA.GetNewID(tc)));
|
|
// UserObjectDA.Insert(tc, oUserObject);
|
|
// }
|
|
// else
|
|
// {
|
|
|
|
// #region Modifier
|
|
// oUserObject.Modifiedby = User.CurrentUser.ID;
|
|
// oUserObject.ModifiedDate = DateTime.Now;
|
|
// #endregion
|
|
// UserObjectDA.Update(tc, oUserObject);
|
|
// }
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
// throw new ServiceException(e.Message);
|
|
// #endregion
|
|
// }
|
|
// return oUserObject.ID;
|
|
//}
|
|
|
|
//public void Delete(ID id)
|
|
//{
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin(true);
|
|
// UserObjectDA.Delete(tc, id);
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(e);
|
|
// throw new ServiceException("Failed to GetUserObject", e);
|
|
// #endregion
|
|
// }
|
|
//}
|
|
|
|
//public bool IsExist(string name,int projectId)
|
|
//{
|
|
// bool valid = false;
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin(true);
|
|
// valid = UserObjectDA.IsExist(tc, name,projectId);
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
|
|
// throw new ServiceException(e.Message, e);
|
|
// #endregion
|
|
// }
|
|
// return valid;
|
|
//}
|
|
|
|
|
|
//public bool IsTranExist(int userObjectID)
|
|
//{
|
|
// bool exist = false;
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin(true);
|
|
|
|
// exist = UserObjectDA.IsTranExist(tc, userObjectID);
|
|
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
|
|
// throw new ServiceException(e.Message, e);
|
|
// #endregion
|
|
// }
|
|
// return exist;
|
|
//}
|
|
//public UserObjects GetByQueryString(string queryString)
|
|
//{
|
|
// UserObjects oUserObjects = new UserObjects();
|
|
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
// tc = TransactionContext.Begin(true);
|
|
// IDataReader oReader = UserObjectDA.GetByQueryString(tc, queryString);
|
|
// oUserObjects = CreateObjects(oReader);
|
|
// oReader.Close();
|
|
// tc.End();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// throw new ServiceException("Failed to GetUserObjects", e);
|
|
// }
|
|
|
|
// return oUserObjects;
|
|
//}
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
}
|