278 lines
6.9 KiB
C#
278 lines
6.9 KiB
C#
///////////////////////////////////////////////////////////
|
|
// NotifyDeliveryLogList.cs
|
|
// Implementation of Class NotifyDeliveryLogList
|
|
// CSLA type: Read only collection
|
|
// Created on: 17-Oct-2005
|
|
// Object design: John
|
|
// Coded: 17-Oct-2005
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using GZTW.Data;
|
|
using CSLA.Data;
|
|
using CSLA;
|
|
using System.Threading;
|
|
using CSLA.Security;
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
#pragma warning disable 1591
|
|
/// <summary>
|
|
/// Lightweight read only list of <see cref="NotifyDeliveryLogList.NotifyDeliveryLogListInfo"/> objects representing log entries regarding notification deliveries
|
|
/// </summary>
|
|
[Serializable]
|
|
public class NotifyDeliveryLogList : ReadOnlyCollectionBase
|
|
{
|
|
|
|
|
|
#region Data structure
|
|
/// <summary>
|
|
/// Log fields
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct NotifyDeliveryLogListInfo
|
|
{
|
|
//deliverydate, event, user, method, delivered, error
|
|
|
|
internal SmartDate mDeliveryDate;
|
|
internal string mEventKey;
|
|
internal string mToUser;
|
|
internal bool mDelivered;
|
|
internal NotifyDeliveryMethods mDeliveryMethod;
|
|
internal string mErrorMessage;
|
|
|
|
public object LT_NotifyDeliveryLog_Label_DeliveryDate
|
|
{
|
|
get
|
|
{
|
|
return mDeliveryDate.DBValue;
|
|
}
|
|
}
|
|
|
|
public string LT_NotifyDeliveryLog_Label_EventKey
|
|
{
|
|
get
|
|
{
|
|
return mEventKey;
|
|
}
|
|
}
|
|
|
|
public string LT_NotifyDeliveryLog_Label_ToUser
|
|
{
|
|
get
|
|
{
|
|
return mToUser;
|
|
}
|
|
}
|
|
|
|
|
|
public bool LT_NotifyDeliveryLog_Label_Delivered
|
|
{
|
|
get
|
|
{
|
|
return mDelivered;
|
|
}
|
|
}
|
|
|
|
public NotifyDeliveryMethods LT_O_NotifySubscriptionDelivery
|
|
{
|
|
get
|
|
{
|
|
return mDeliveryMethod;
|
|
}
|
|
}
|
|
|
|
public string LT_NotifyDeliveryLog_Label_ErrorMessage
|
|
{
|
|
get
|
|
{
|
|
return mErrorMessage;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}//end NotifyDeliveryLogListInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
protected NotifyDeliveryLogList()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Business properties and methods
|
|
|
|
/// <summary>
|
|
/// Get item by index
|
|
/// </summary>
|
|
/// <param name="Item"></param>
|
|
public NotifyDeliveryLogListInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (NotifyDeliveryLogListInfo) List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Reporting
|
|
|
|
/// <summary>
|
|
/// Returns the report key which is a property of
|
|
/// reports used to link all reports that can be used
|
|
/// with a particular data source.
|
|
/// </summary>
|
|
public static string ReportKey
|
|
{
|
|
get
|
|
{
|
|
return "NotifyDeliveryLogList";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Static methods
|
|
|
|
|
|
/// <summary>
|
|
/// Get all NotifyDeliveryLog entries
|
|
/// </summary>
|
|
/// <param name="AdminMode">True for all entries for any user, false for current logged in user's ID</param>
|
|
/// <returns>list of <see cref="NotifyDeliveryLogList.NotifyDeliveryLogListInfo"/> objects</returns>
|
|
public static NotifyDeliveryLogList GetList(bool AdminMode)
|
|
{
|
|
return (NotifyDeliveryLogList) DataPortal.Fetch(new Criteria(AdminMode));
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Return an empty list
|
|
/// used for initializing grid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static NotifyDeliveryLogList GetEmptyList()
|
|
{
|
|
return new NotifyDeliveryLogList();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param name="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
//Get a user list to use for displaying in grid
|
|
UserPickList upl=UserPickList.GetList(false);
|
|
ClientPickList cpl = null;
|
|
Criteria crit = (Criteria)Criteria;
|
|
|
|
SafeDataReader dr = null;
|
|
|
|
try
|
|
{
|
|
if(crit.AdminMode)
|
|
dr=DBUtil.GetReaderFromSQLString(
|
|
//************************************************************
|
|
"SELECT * FROM aNotifyDeliveryLog ORDER BY aDeliveryDate"
|
|
//************************************************************
|
|
);
|
|
else
|
|
dr=DBUtil.GetReaderFromSQLString(
|
|
//************************************************************
|
|
"SELECT * FROM aNotifyDeliveryLog WHERE aToUserID=@ID ORDER BY aDeliveryDate",User.CurrentThreadUserID
|
|
//************************************************************
|
|
);
|
|
|
|
|
|
if (crit.AdminMode)
|
|
cpl = ClientPickList.GetList();
|
|
|
|
while(dr.Read())
|
|
{
|
|
//*******************************************
|
|
NotifyDeliveryLogListInfo info=new NotifyDeliveryLogListInfo();
|
|
Guid clientID = dr.GetGuid("aToClientID");
|
|
//Only show client notifications when in admin mode
|
|
if (!crit.AdminMode && clientID!=Guid.Empty) continue;
|
|
|
|
info.mDelivered=dr.GetBoolean("aDelivered");
|
|
info.mDeliveryDate=DBUtil.ToLocal(dr.GetSmartDate("aDeliveryDate"));
|
|
info.mDeliveryMethod=(NotifyDeliveryMethods)dr.GetInt16("aDeliveryMethod");
|
|
info.mErrorMessage=dr.GetString("aErrorMessage");
|
|
|
|
if (clientID != Guid.Empty)
|
|
{
|
|
//case 1747
|
|
if (cpl.Contains(clientID))
|
|
{
|
|
info.mToUser = cpl[clientID].Name;
|
|
info.mEventKey = LocalizedTextTable.GetLocalizedTextDirect("Client.Label.Notification");
|
|
}
|
|
else
|
|
{
|
|
info.mToUser = "DELETED CLIENT";
|
|
info.mEventKey = LocalizedTextTable.GetLocalizedTextDirect("Client.Label.Notification");
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//case 1382
|
|
if (((RootObjectTypes)dr.GetInt16("aRootObjectType")) == RootObjectTypes.Nothing)
|
|
info.mToUser = "-";
|
|
else
|
|
info.mToUser=upl[dr.GetGuid("aToUserID")];
|
|
info.mEventKey=NotifyEventUIHelper.GetEventLocalizedTextKey((RootObjectTypes)dr.GetInt16("aRootObjectType"),dr.GetInt16("aEventType"));
|
|
}
|
|
|
|
|
|
InnerList.Add(info);
|
|
//*******************************************
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
if(dr!=null) dr.Close();
|
|
}
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
|
|
|
|
public bool AdminMode;
|
|
|
|
public Criteria( bool _AdminMode)
|
|
{
|
|
AdminMode=_AdminMode;
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end NotifyDeliveryLogList
|
|
#pragma warning restore 1591
|
|
}//end namespace GZTW.AyaNova.BLL |