225 lines
4.5 KiB
C#
225 lines
4.5 KiB
C#
///////////////////////////////////////////////////////////
|
|
// CustomizableObjectList.cs
|
|
// Implementation of Class CustomizableObjectList
|
|
// CSLA type: Read only collection
|
|
// Created on: 14-Jan-2006
|
|
// Object design: John
|
|
// Coded: 14-Jan-2006
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using GZTW.Data;
|
|
using CSLA.Data;
|
|
using CSLA;
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
#pragma warning disable 1591
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Read only list of CustomizableObjects
|
|
///
|
|
/// </summary>
|
|
[Serializable]
|
|
public class CustomizableObjectList : ReadOnlyCollectionBase
|
|
{
|
|
#region Data structure
|
|
/// <summary>
|
|
/// Properties
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct CustomizableObjectListInfo
|
|
{
|
|
|
|
internal string mName;
|
|
internal string mKey;
|
|
|
|
|
|
|
|
public string LT_ObjectCustomField_Label_ObjectName
|
|
{
|
|
get
|
|
{
|
|
return mName;
|
|
}
|
|
}
|
|
|
|
|
|
public string Key
|
|
{
|
|
get
|
|
{
|
|
return mKey;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(CustomizableObjectListInfo obj)
|
|
{
|
|
return this.Key.Equals(obj.Key);
|
|
}
|
|
|
|
}//end CustomizableObjectListInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
protected CustomizableObjectList()
|
|
{
|
|
// AllowSort=false;
|
|
// AllowFind=true;
|
|
// AllowEdit=false;
|
|
// AllowNew=false;
|
|
// AllowRemove=false;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Business properties and methods
|
|
|
|
/// <summary>
|
|
/// Get item by index
|
|
/// </summary>
|
|
/// <param name="Item"></param>
|
|
public CustomizableObjectListInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (CustomizableObjectListInfo) List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
// /// <summary>
|
|
// /// Returns display text that matches passed in itemid value
|
|
// /// </summary>
|
|
// /// <param name="ItemID"></param>
|
|
// public string this[Guid ItemID]
|
|
// {
|
|
//
|
|
// get
|
|
// {
|
|
// foreach (CustomizableObjectListInfo child in List)
|
|
// {
|
|
// if(child.ID==ItemID) return child.ToString();
|
|
// }
|
|
// return "Missing: "+ItemID.ToString();
|
|
// }
|
|
// }
|
|
#endregion
|
|
|
|
#region contains
|
|
// /// <summary>
|
|
// /// Check if item in collection
|
|
// /// </summary>
|
|
//
|
|
// /// <param name="obj"></param>
|
|
// public bool Contains(CustomizableObjectListInfo obj)
|
|
// {
|
|
// foreach (CustomizableObjectListInfo child in List)
|
|
// {
|
|
// if(child.Equals(obj)) return true;
|
|
// }
|
|
// return false;
|
|
//
|
|
// }
|
|
#endregion
|
|
|
|
#region Static methods
|
|
/// <summary>
|
|
/// Get list
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static CustomizableObjectList GetList()
|
|
{
|
|
return (CustomizableObjectList) DataPortal.Fetch(new Criteria());
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Return an empty list
|
|
/// used for initializing grid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static CustomizableObjectList GetEmptyList()
|
|
{
|
|
return new CustomizableObjectList();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param name="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
|
|
|
|
SafeDataReader dr = null;
|
|
try
|
|
{
|
|
DBCommandWrapper cm = DBUtil.DB.GetSqlStringCommandWrapper(
|
|
"SELECT DISTINCT aKey FROM aLocalizedText WHERE aKey " +
|
|
"LIKE @aCUSTOMCRIT"
|
|
);
|
|
|
|
cm.AddInParameter("@aCUSTOMCRIT",DbType.String, "%.Label.Custom1");
|
|
dr=new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
|
|
|
|
|
|
while(dr.Read())
|
|
{
|
|
//*******************************************
|
|
CustomizableObjectListInfo info=new CustomizableObjectListInfo();
|
|
info.mKey=dr.GetString("aKey").Replace(".Label.Custom1","");
|
|
info.mName=LocalizedTextTable.GetLocalizedTextDirect("O."+info.mKey);
|
|
InnerList.Add(info);
|
|
//*******************************************
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
if(dr!=null) dr.Close();
|
|
}
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
|
|
|
|
//public string CriteriaXML;
|
|
|
|
public Criteria( /*string _CriteriaXML*/)
|
|
{
|
|
//CriteriaXML=_CriteriaXML;
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end CustomizableObjectList
|
|
#pragma warning restore 1591
|
|
}//end namespace GZTW.AyaNova.BLL |