/////////////////////////////////////////////////////////// // UserMemoIdList.cs // Implementation of Class UserMemoIdList // CSLA type: Read only collection // Created on: 11-Dec-2008 // Object design: John // Coded: 11-Dec-2008 /////////////////////////////////////////////////////////// using System; using System.Data; using GZTW.Data; using CSLA.Data; using CSLA; namespace GZTW.AyaNova.BLL { /// /// List of UserMemoIds for internal migration processing /// /// [Serializable] public class UserMemoIdList : ReadOnlyCollectionBase { #region Data structure /// /// /// [Serializable] public struct UserMemoIdListInfo { public Guid mID; /// /// /// /// public bool Equals(UserMemoIdListInfo obj) { return this.mID.Equals(obj.mID); } }//end UserMemoIdListInfo #endregion #region Constructor protected UserMemoIdList() { // AllowSort=false; // AllowFind=true; // AllowEdit=false; // AllowNew=false; // AllowRemove=false; } #endregion #region Business properties and methods /// /// Get item by index /// /// public UserMemoIdListInfo this[int Item] { get { return (UserMemoIdListInfo)List[Item]; } } /// /// Returns UserMemoIdListInfo item that matches passed in itemid value /// /// public UserMemoIdListInfo this[Guid ItemID] { get { foreach (UserMemoIdListInfo child in List) { if (child.mID == ItemID) return child; } throw new ArgumentException("UserMemoIdList: ID not found:\r\n" + ItemID.ToString()); } } #endregion #region contains /// /// Check if item in collection /// /// public bool Contains(UserMemoIdListInfo obj) { foreach (UserMemoIdListInfo child in List) { if (child.Equals(obj)) return true; } return false; } #endregion #region Static methods /// /// Get all for user /// /// public static UserMemoIdList GetList(Guid UserId) { return (UserMemoIdList)DataPortal.Fetch(new Criteria(UserId)); } #endregion #region DAL DATA ACCESS /// /// protected override void DataPortal_Fetch(object Criteria) { Criteria crit = (Criteria)Criteria; SafeDataReader dr = null; try { //case 1163 //SmartDate rightnow=new SmartDate(DateTime.Now); DateTime dtNowUTC = DateTime.Now.ToUniversalTime(); dr = DBUtil.GetReaderFromSQLString( //************************************************************ "SELECT AMEMO.AID FROM AMEMO WHERE ATOID=@ID",crit.ID //************************************************************ ) ; while (dr.Read()) { //******************************************* UserMemoIdListInfo info = new UserMemoIdListInfo(); info.mID = dr.GetGuid("aID"); InnerList.Add(info); //******************************************* } } finally { if (dr != null) dr.Close(); } } #endregion #region criteria /// /// Criteria for identifying existing object /// [Serializable] private class Criteria { public Guid ID; public Criteria(Guid _ID) { ID = _ID; } } #endregion }//end UserMemoIdList }//end namespace GZTW.AyaNova.BLL