142 lines
3.8 KiB
C#
142 lines
3.8 KiB
C#
///////////////////////////////////////////////////////////
|
|
// Bool.cs
|
|
// Implementation of Class NotifySubscribersListFetcher
|
|
// CSLA type: Read-only object
|
|
// Created on: 25-Nov-2009
|
|
// Object design: John
|
|
// Coded: John 25-Nov-2009
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using CSLA.Data;
|
|
using GZTW.Data;
|
|
using CSLA;
|
|
using System.Threading;
|
|
using CSLA.Security;
|
|
using System.Collections.Generic;
|
|
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
#pragma warning disable 1591
|
|
|
|
/// <summary>
|
|
/// Used to quickly fetch a generic list of Guids of users
|
|
/// who subscribe to a particular event
|
|
///
|
|
/// </summary>
|
|
[Serializable]
|
|
public class NotifySubscribersListFetcher : ReadOnlyBase
|
|
{
|
|
|
|
private List<Guid> mSubscriberList;
|
|
|
|
|
|
#region Constructor
|
|
|
|
/// <summary>
|
|
/// Private constructor to prevent direct instantiation
|
|
/// </summary>
|
|
private NotifySubscribersListFetcher()
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region Business properties
|
|
public List<Guid> SubscriberList { get { return mSubscriberList; } }
|
|
|
|
|
|
#endregion
|
|
|
|
#region Static methods
|
|
|
|
/// <summary>
|
|
/// Retrieve generic List of id's of subscribers to particular event specified
|
|
/// </summary>
|
|
/// <param name="EventType">Event type for object</param>
|
|
/// <param name="RootObjectType">Type of object</param>
|
|
/// <param name="GuidValue">GuidValue for event or Guid.Empty if event doesn't support particular Guid value</param>
|
|
/// <returns>NotifySubscribersListFetcher object</returns>
|
|
public static List<Guid> GetItem(int EventType, RootObjectTypes RootObjectType, Guid GuidValue)
|
|
{
|
|
|
|
return ((NotifySubscribersListFetcher)DataPortal.Fetch(new Criteria(EventType, RootObjectType, GuidValue))).SubscriberList;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param Bool="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
Criteria crit = (Criteria)Criteria;
|
|
mSubscriberList = new List<Guid>();
|
|
DBCommandWrapper cmSub = DBUtil.DB.GetSqlStringCommandWrapper(
|
|
"SELECT aUserID FROM aNotifySubscription " +
|
|
"WHERE (aRootObjectType = @RootObjectType) AND (aEventType = @EventType) " +
|
|
(crit.GuidValue == Guid.Empty ? "" : "AND (aGuidValue = @GuidValue)")
|
|
);
|
|
|
|
if (crit.GuidValue != Guid.Empty)
|
|
cmSub.AddInParameter("@GuidValue", DbType.Guid, crit.GuidValue);
|
|
|
|
cmSub.AddInParameter("@RootObjectType", DbType.Int16, (int)crit.RootObjectType);
|
|
cmSub.AddInParameter("@EventType", DbType.Int16, crit.EventType);
|
|
|
|
|
|
|
|
SafeDataReader dr = new SafeDataReader(DBUtil.DB.ExecuteReader(cmSub));
|
|
|
|
//There may not be an existing record yet so if it can't read
|
|
//assumes that there are no prior bank records for this object yet
|
|
while (dr.Read())
|
|
{
|
|
Guid id = dr.GetGuid("AUSERID");
|
|
if (!mSubscriberList.Contains(id))
|
|
mSubscriberList.Add(id);
|
|
|
|
|
|
}
|
|
dr.Close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
|
|
public int EventType;
|
|
public RootObjectTypes RootObjectType;
|
|
public Guid GuidValue;
|
|
|
|
public Criteria(int _EventType, RootObjectTypes _RootObjectType, Guid _GuidValue)
|
|
{
|
|
EventType=_EventType;
|
|
RootObjectType=_RootObjectType;
|
|
GuidValue = _GuidValue;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end Bool
|
|
#pragma warning restore 1591
|
|
}//end Boolspace GZTW.AyaNova.BLL |