Files
ayanova7/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/NotifyEventWorkorderStatusPickList.cs
2018-06-29 19:47:36 +00:00

203 lines
4.6 KiB
C#

///////////////////////////////////////////////////////////
// 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
/// <summary>
/// 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.
///
/// </summary>
[Serializable]
public class NotifyEventWorkorderStatusPickList : ReadOnlyCollectionBase
{
#region Data structure
/// <summary>
///
/// </summary>
[Serializable]
public struct NotifyEventWorkorderStatusPickListInfo
{
internal Guid mID;
internal string mName;
//Public properties
public Guid ID {get{return mID;}}
public string Name {get{return mName;}}
/// <summary>
///
/// </summary>
/// <param name="obj"></param>
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
/// <summary>
/// Get item by index
/// </summary>
/// <param name="Item"></param>
public NotifyEventWorkorderStatusPickListInfo this[int Item]
{
get
{
return (NotifyEventWorkorderStatusPickListInfo) List[Item];
}
}
/// <summary>
/// Returns NotifyEventWorkorderStatusPickListInfo item that matches passed in itemid value
/// </summary>
/// <param name="ItemID"></param>
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
/// <summary>
/// Check if item in collection
/// </summary>
/// <param name="obj"></param>
public bool Contains(NotifyEventWorkorderStatusPickListInfo obj)
{
foreach (NotifyEventWorkorderStatusPickListInfo child in List)
{
if(child.Equals(obj)) return true;
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Get all scheduleable users
/// </summary>
/// <returns></returns>
public static NotifyEventWorkorderStatusPickList GetList(NotifySubscriber ns)
{
return (NotifyEventWorkorderStatusPickList) DataPortal.Fetch(new Criteria(ns));
}
#endregion
#region DAL DATA ACCESS
///
/// <param name="Criteria"></param>
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
/// <summary>
/// Criteria for identifying existing object
/// </summary>
[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