/////////////////////////////////////////////////////////// // NotifyEventWorkorderStatusPickList.cs // Implementation of Class NotifyEventWorkorderStatusPickList // CSLA type: Read only collection // Created on: 12-Oct-2005 // Object design: John // Coded: 12-Oct-2005 /////////////////////////////////////////////////////////// using System; using System.Data; using GZTW.Data; using CSLA.Data; using CSLA; namespace GZTW.AyaNova.BLL { #pragma warning disable 1591 /// /// List of Workorder statuses not already chosen /// in a subscribers event subscriptions for building pick lists /// /// Ensures user doesn't subscribe to same workorder status event /// more than once. /// /// [Serializable] public class NotifyEventWorkorderStatusPickList : ReadOnlyCollectionBase { #region Data structure /// /// /// [Serializable] public struct NotifyEventWorkorderStatusPickListInfo { internal Guid mID; internal string mName; //Public properties public Guid ID {get{return mID;}} public string Name {get{return mName;}} /// /// /// /// public bool Equals(NotifyEventWorkorderStatusPickListInfo obj) { return this.mID.Equals(obj.mID); } }//end NotifyEventWorkorderStatusPickListInfo #endregion #region Constructor protected NotifyEventWorkorderStatusPickList() { // AllowSort=false; // AllowFind=true; // AllowEdit=false; // AllowNew=false; // AllowRemove=false; } #endregion #region Business properties and methods /// /// Get item by index /// /// public NotifyEventWorkorderStatusPickListInfo this[int Item] { get { return (NotifyEventWorkorderStatusPickListInfo) List[Item]; } } /// /// Returns NotifyEventWorkorderStatusPickListInfo item that matches passed in itemid value /// /// public NotifyEventWorkorderStatusPickListInfo this[Guid ItemID] { get { foreach (NotifyEventWorkorderStatusPickListInfo child in List) { if(child.mID==ItemID) return child; } throw new ArgumentException("NotifyEventWorkorderStatusPickList: ID not found:\r\n"+ItemID.ToString()); } } #endregion #region contains /// /// Check if item in collection /// /// public bool Contains(NotifyEventWorkorderStatusPickListInfo obj) { foreach (NotifyEventWorkorderStatusPickListInfo child in List) { if(child.Equals(obj)) return true; } return false; } #endregion #region Static methods /// /// Get all scheduleable users /// /// public static NotifyEventWorkorderStatusPickList GetList(NotifySubscriber ns) { return (NotifyEventWorkorderStatusPickList) DataPortal.Fetch(new Criteria(ns)); } #endregion #region DAL DATA ACCESS /// /// protected override void DataPortal_Fetch(object Criteria) { Criteria crit = (Criteria)Criteria; SafeDataReader dr = null; try { dr=DBUtil.GetReaderFromSQLString( //************************************************************ "SELECT aID, aName FROM aWorkorderStatus" //************************************************************ ); while(dr.Read()) { //******************************************* if(crit.Subscriber.Subscriptions.Contains(RootObjectTypes.Workorder,(int)WorkorderEvent.Status,dr.GetGuid("aID"))) continue; NotifyEventWorkorderStatusPickListInfo info=new NotifyEventWorkorderStatusPickListInfo(); info.mID=dr.GetGuid("aID"); info.mName=dr.GetString("aName"); InnerList.Add(info); //******************************************* } } finally { if(dr!=null) dr.Close(); } } #endregion #region criteria /// /// Criteria for identifying existing object /// [Serializable] private class Criteria { public NotifySubscriber Subscriber; public Criteria(NotifySubscriber _Subscriber ) { Subscriber=_Subscriber; } } #endregion }//end NotifyEventWorkorderStatusPickList #pragma warning restore 1591 }//end namespace GZTW.AyaNova.BLL