409 lines
14 KiB
C#
409 lines
14 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Ease.CoreV35;
|
|||
|
using Ease.CoreV35.DataAccess;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using Payroll.BO;
|
|||
|
using Ease.CoreV35.Caching;
|
|||
|
|
|||
|
namespace Payroll.Service
|
|||
|
{
|
|||
|
#region WebAPPFormParam Service
|
|||
|
[Serializable]
|
|||
|
|
|||
|
public class WebAPPFormParamService : ServiceTemplate, IWebAPPFormParamService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
Cache _cache = new Cache(typeof(WebAPPFormParam));
|
|||
|
Cache _paramDetails = new Cache(typeof(WebAPPFormParamDetails));
|
|||
|
#endregion
|
|||
|
public WebAPPFormParamService() { }
|
|||
|
|
|||
|
#region MapObject For WebAPPFormParam
|
|||
|
private void MapObject(WebAPPFormParam owebAPPFormParam, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(owebAPPFormParam, oReader.GetID("WebAPPParamID"));
|
|||
|
owebAPPFormParam.AssessmentFormType = (EnumAssessmentFormType)oReader.GetInt32("AssessmentFormType").Value;
|
|||
|
owebAPPFormParam.FormID = oReader.GetInt32("FormID").Value;
|
|||
|
owebAPPFormParam.ObjectID = oReader.GetInt32("ObjectID").Value;
|
|||
|
owebAPPFormParam.AssessmentBy = oReader.GetID("AssessmentBy");
|
|||
|
owebAPPFormParam.AssessmentFor = (EnumAssessmentFor)oReader.GetInt32("AssessmentFor").Value;
|
|||
|
owebAPPFormParam.AssessmentDate = oReader.GetDateTime("AssessmentDate").GetValueOrDefault(DateTime.MinValue);
|
|||
|
owebAPPFormParam.CreatedBy = oReader.GetID("CreatedBy");
|
|||
|
owebAPPFormParam.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|||
|
owebAPPFormParam.ModifiedBy = oReader.GetID("ModifiedBy");
|
|||
|
owebAPPFormParam.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|||
|
this.SetObjectState(owebAPPFormParam, Ease.CoreV35.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
WebAPPFormParam owebAPPFormParam = new WebAPPFormParam();
|
|||
|
MapObject(owebAPPFormParam, oReader);
|
|||
|
return owebAPPFormParam as T;
|
|||
|
}
|
|||
|
|
|||
|
protected WebAPPFormParam CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
WebAPPFormParam owebAPPFormParam = new WebAPPFormParam();
|
|||
|
MapObject(owebAPPFormParam, oReader);
|
|||
|
return owebAPPFormParam;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region MapObject For WebAPPFormParamDetails
|
|||
|
private void MapWebAPPFormParamDetails(WebAPPFormParamDetails oWebAPPFormParamDetails, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oWebAPPFormParamDetails, oReader.GetID("ParamDetailsID"));
|
|||
|
oWebAPPFormParamDetails.WebAPPParamID = oReader.GetID("WebAPPParamID");
|
|||
|
oWebAPPFormParamDetails.ParamID = oReader.GetInt32("ParamID").Value;
|
|||
|
oWebAPPFormParamDetails.Value = (object)oReader.GetString("Value");
|
|||
|
oWebAPPFormParamDetails.DataType = (EnumColumnDataType)oReader.GetInt32("DataType").Value;
|
|||
|
|
|||
|
this.SetObjectState(oWebAPPFormParamDetails, Ease.CoreV35.ObjectState.Saved);
|
|||
|
}
|
|||
|
protected ObjectsTemplate<WebAPPFormParamDetails> CreateWebAPPFormParamDetailsObject(DataReader oReader)
|
|||
|
{
|
|||
|
ObjectsTemplate<WebAPPFormParamDetails> oWebAPPFormParamDetails = new ObjectsTemplate<WebAPPFormParamDetails>();
|
|||
|
while (oReader.Read())
|
|||
|
{
|
|||
|
WebAPPFormParamDetails oWebAPPFormParamDetail = new WebAPPFormParamDetails();
|
|||
|
MapWebAPPFormParamDetails(oWebAPPFormParamDetail, oReader);
|
|||
|
oWebAPPFormParamDetails.Add(oWebAPPFormParamDetail);
|
|||
|
}
|
|||
|
return oWebAPPFormParamDetails;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service Implementation
|
|||
|
public WebAPPFormParam Get(ID id)
|
|||
|
{
|
|||
|
WebAPPFormParam oWebAPPFormParam = new WebAPPFormParam();
|
|||
|
#region Cache Header
|
|||
|
oWebAPPFormParam = _cache["Get",id] as WebAPPFormParam;
|
|||
|
if (oWebAPPFormParam != null)
|
|||
|
return oWebAPPFormParam;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(WebAPPFormParamDA.Get(tc,id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oWebAPPFormParam = this.CreateObject<WebAPPFormParam>(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(oWebAPPFormParam, "Get",id);
|
|||
|
#endregion
|
|||
|
return oWebAPPFormParam;
|
|||
|
}
|
|||
|
|
|||
|
public WebAPPFormParam Get(int formId, int objectID)
|
|||
|
{
|
|||
|
WebAPPFormParam oWebAPPFormParam = new WebAPPFormParam();
|
|||
|
#region Cache Header
|
|||
|
oWebAPPFormParam = _cache["Get", formId, objectID] as WebAPPFormParam;
|
|||
|
if (oWebAPPFormParam != null)
|
|||
|
return oWebAPPFormParam;
|
|||
|
#endregion
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(WebAPPFormParamDA.Get(tc, formId, objectID));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oWebAPPFormParam = this.CreateObject<WebAPPFormParam>(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(oWebAPPFormParam, "Get", formId, objectID);
|
|||
|
#endregion
|
|||
|
return oWebAPPFormParam;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<WebAPPFormParam> Get()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<WebAPPFormParam> oWebAPPFormParams = _cache["Get"] as ObjectsTemplate<WebAPPFormParam>;
|
|||
|
if (oWebAPPFormParams != null)
|
|||
|
return oWebAPPFormParams;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(WebAPPFormParamDA.Get(tc));
|
|||
|
oWebAPPFormParams = this.CreateObjects<WebAPPFormParam>(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(oWebAPPFormParams, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return oWebAPPFormParams;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<WebAPPFormParam> GetParams(int formId, int objectID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<WebAPPFormParam> oWebAPPFormParams = _cache["Get"] as ObjectsTemplate<WebAPPFormParam>;
|
|||
|
if (oWebAPPFormParams != null)
|
|||
|
return oWebAPPFormParams;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(WebAPPFormParamDA.GetParams(tc, formId, objectID));
|
|||
|
oWebAPPFormParams = this.CreateObjects<WebAPPFormParam>(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(oWebAPPFormParams, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return oWebAPPFormParams;
|
|||
|
}
|
|||
|
|
|||
|
public ID Save(WebAPPFormParam oWebAPPFormParam)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
|
|||
|
if (oWebAPPFormParam.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("AssessmentMaster", "WebAPPParamID");
|
|||
|
base.SetObjectID(oWebAPPFormParam, ID.FromInteger(id));
|
|||
|
WebAPPFormParamDA.Insert(tc, oWebAPPFormParam);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
WebAPPFormParamDA.DeleteParamDetails(tc, oWebAPPFormParam.ID.Integer);
|
|||
|
WebAPPFormParamDA.Update(tc, oWebAPPFormParam);
|
|||
|
|
|||
|
}
|
|||
|
foreach (WebAPPFormParamDetails oWebAPPFormParamDetails in oWebAPPFormParam.ParamDetails)
|
|||
|
{
|
|||
|
oWebAPPFormParamDetails.WebAPPParamID = oWebAPPFormParam.ID;
|
|||
|
int paramDetailsID = tc.GenerateID("AssessmentDetail", "ParamDetailsID");
|
|||
|
base.SetObjectID(oWebAPPFormParamDetails, ID.FromInteger(paramDetailsID));
|
|||
|
WebAPPFormParamDA.InsertParamDetails(tc, oWebAPPFormParamDetails);
|
|||
|
}
|
|||
|
return oWebAPPFormParam.ID;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Delete(int formId, int objectID)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
WebAPPFormParamDA.Delete(tc, formId, objectID);
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Delete(ID id)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
|
|||
|
WebAPPFormParamDA.DeleteParamDetails(tc, id.Integer);
|
|||
|
WebAPPFormParamDA.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
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Save(ObjectsTemplate<WebAPPFormParam> oWebAPPFormParams)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oWebAPPFormParams.Count > 0)
|
|||
|
{
|
|||
|
foreach (WebAPPFormParam appItem in oWebAPPFormParams)
|
|||
|
{
|
|||
|
if (appItem.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("AssessmentMaster", "WebAPPParamID");
|
|||
|
base.SetObjectID(appItem, ID.FromInteger(id));
|
|||
|
WebAPPFormParamDA.Insert(tc, appItem);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
WebAPPFormParamDA.Update(tc, appItem);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<WebAPPFormParamDetails> GetParamDetails(int ParamId)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<WebAPPFormParamDetails> paramDetails = _paramDetails["GetParamDetails"] as ObjectsTemplate<WebAPPFormParamDetails>;
|
|||
|
if (paramDetails != null)
|
|||
|
return paramDetails;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(WebAPPFormParamDA.GetParamDetails(tc, ParamId));
|
|||
|
paramDetails = this.CreateWebAPPFormParamDetailsObject(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
|
|||
|
|
|||
|
_paramDetails.Add(paramDetails, "GetParamDetails");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return paramDetails;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|