/////////////////////////////////////////////////////////// // 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 /// /// Read only list of CustomizableObjects /// /// [Serializable] public class CustomizableObjectList : ReadOnlyCollectionBase { #region Data structure /// /// Properties /// [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; } } /// /// /// /// public bool Equals(CustomizableObjectListInfo obj) { return this.Key.Equals(obj.Key); } }//end CustomizableObjectListInfo #endregion #region Constructor /// /// /// protected CustomizableObjectList() { // AllowSort=false; // AllowFind=true; // AllowEdit=false; // AllowNew=false; // AllowRemove=false; } #endregion #region Business properties and methods /// /// Get item by index /// /// public CustomizableObjectListInfo this[int Item] { get { return (CustomizableObjectListInfo) List[Item]; } } // /// // /// Returns display text that matches passed in itemid value // /// // /// // 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 // /// // /// Check if item in collection // /// // // /// // public bool Contains(CustomizableObjectListInfo obj) // { // foreach (CustomizableObjectListInfo child in List) // { // if(child.Equals(obj)) return true; // } // return false; // // } #endregion #region Static methods /// /// Get list /// /// public static CustomizableObjectList GetList() { return (CustomizableObjectList) DataPortal.Fetch(new Criteria()); } /// /// Return an empty list /// used for initializing grid /// /// public static CustomizableObjectList GetEmptyList() { return new CustomizableObjectList(); } #endregion #region DAL DATA ACCESS /// /// 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 /// /// Criteria for identifying existing object /// [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