107 lines
2.7 KiB
C#
107 lines
2.7 KiB
C#
/*
|
|
|-------------------------------------------------------------------------------|
|
|
| Copyright © Computer Ease Limited |
|
|
| Address: 1/9 Bloack-A Lalmatia, Dhaka-1207, Bangladesh |
|
|
| Email: info@celimited.com, cease@bol-online.com, web: www.celimited.com |
|
|
| Unauthorized copy or distribution is strictly prohibited |
|
|
| Author: S. M. Russel, Last modified date: 18/04/2009 |
|
|
|-------------------------------------------------------------------------------|
|
|
*/
|
|
|
|
using System;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using Ease.Core.Model;
|
|
using System.Collections.Generic;
|
|
using Ease.Core;
|
|
using Ease.Core.DataAccess;
|
|
|
|
namespace Ease.Core.Model
|
|
{
|
|
#region Framework: Service base
|
|
|
|
public abstract class ServiceTemplate
|
|
{
|
|
private string _svcName;
|
|
private string _endPoint;
|
|
|
|
public ServiceTemplate(string svcName)
|
|
{
|
|
_svcName = svcName;
|
|
}
|
|
|
|
public ServiceTemplate()
|
|
{
|
|
_svcName = "";
|
|
}
|
|
|
|
|
|
public bool IsAlive
|
|
{
|
|
get { return true; }
|
|
}
|
|
|
|
public string ServiceName
|
|
{
|
|
get { return _svcName; }
|
|
set { _svcName = value; }
|
|
}
|
|
|
|
internal void SetEndPoint(string value)
|
|
{
|
|
_endPoint = value;
|
|
}
|
|
|
|
protected string EndPoint
|
|
{
|
|
get { return _endPoint; }
|
|
}
|
|
|
|
protected void SetObjectID(ObjectTemplate ot, int id)
|
|
{
|
|
ot.SetID(id);
|
|
}
|
|
|
|
protected void SetObjectID(ObjectTemplate ot, long id)
|
|
{
|
|
ot.SetID((int)id);
|
|
}
|
|
|
|
protected void SetObjectState(ObjectTemplate ot, ObjectState state)
|
|
{
|
|
ot.SetState(state);
|
|
}
|
|
|
|
protected void SetObjectReadOnlyProperties(ObjectTemplate ot, params object[] propertyValues)
|
|
{
|
|
ot.SetReadOnlyProperties(propertyValues);
|
|
}
|
|
|
|
protected abstract T CreateObject<T>(DataReader dr)
|
|
where T : ObjectTemplate;
|
|
|
|
/// <summary>
|
|
/// Return collection of objects of type T.
|
|
/// </summary>
|
|
/// <typeparam name="T">Type of object.</typeparam>
|
|
/// <param name="dr">A valid datareader.</param>
|
|
/// <returns>Return List of type T.</returns>
|
|
protected List<T> CreateObjects<T>(DataReader dr)
|
|
where T : ObjectTemplate
|
|
{
|
|
List<T> list = new List<T>();
|
|
|
|
while (dr.Read())
|
|
{
|
|
T ot = this.CreateObject<T>(dr);
|
|
|
|
ot.SetState(ObjectState.Saved);
|
|
list.Add(ot);
|
|
}
|
|
|
|
return list;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
} |