138 lines
4.6 KiB
C#
138 lines
4.6 KiB
C#
///////////////////////////////////////////////////////////
|
|
// DashBoardClientServiceRequestListRI.cs
|
|
// Implementation of Class DashBoardClientServiceRequestListRI
|
|
// CSLA type: Read only collection
|
|
// Created on: 25-Sept-2014
|
|
// Coded: John 25-Sept-2014
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using GZTW.Data;
|
|
using CSLA.Data;
|
|
using CSLA;
|
|
using System.Collections.Generic;
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
#pragma warning disable 1591
|
|
|
|
[Serializable]
|
|
public class DashBoardClientServiceRequestListRI : ReadOnlyBase
|
|
{
|
|
public long _Count = 0;
|
|
public Dictionary<Guid, string> list = null;
|
|
|
|
#region Constructor
|
|
|
|
protected DashBoardClientServiceRequestListRI()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Static methods
|
|
|
|
public static Dictionary<Guid, string> GetList(int MaxRecords = 3)
|
|
{
|
|
return ((DashBoardClientServiceRequestListRI)DataPortal.Fetch(new Criteria(false, MaxRecords))).list;
|
|
}
|
|
|
|
public static long GetCount()
|
|
{
|
|
return ((DashBoardClientServiceRequestListRI)DataPortal.Fetch(new Criteria(true, 0)))._Count;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param name="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
Criteria crit = (Criteria)Criteria;
|
|
SafeDataReader dr = null;
|
|
try
|
|
{
|
|
DBCommandWrapper cm = null;
|
|
string qFields = "";
|
|
if (crit.Count)
|
|
qFields = "SELECT COUNT(*) ";
|
|
else
|
|
qFields = "SELECT ~MAXRECS~ " +
|
|
" ACLIENTSERVICEREQUEST.AID, ACLIENTSERVICEREQUEST.ATITLE, ACLIENTSERVICEREQUEST.ACREATED, ACLIENTSERVICEREQUEST.AREQUESTEDBY," +
|
|
" ACLIENT.ANAME AS ACLIENTNAME ";
|
|
|
|
string q = qFields + " FROM " +
|
|
" ACLIENTSERVICEREQUEST " +
|
|
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
|
|
" WHERE ACLIENTSERVICEREQUEST.ASTATUS=0 ";
|
|
|
|
if (!crit.Count)
|
|
q = q + " ORDER BY ACLIENTSERVICEREQUEST.ACREATED ASC";
|
|
|
|
if (!crit.Count)
|
|
{
|
|
if (crit.MaxRecords > 0)
|
|
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
|
|
else
|
|
q = q.Replace("~MAXRECS~", "");
|
|
}
|
|
|
|
cm = DBUtil.DB.GetSqlStringCommandWrapper(q);
|
|
cm.AddInParameter("@ID", DbType.Guid, User.CurrentThreadUserID);
|
|
dr = new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
|
|
if (!crit.Count)
|
|
list = new Dictionary<Guid, string>(crit.MaxRecords);
|
|
while (dr.Read())
|
|
{
|
|
if (crit.Count)
|
|
{
|
|
object o = dr.GetValue(0);
|
|
_Count = long.Parse(o.ToString());
|
|
}
|
|
else
|
|
{
|
|
//id = new TypeAndID(RootObjectTypes.ClientServiceRequest, i.ID);
|
|
//item = i.LT_Common_Label_Created.ToString() + " " + i.LT_O_Client + " " + i.LT_O_ClientServiceRequest + " " + i.LT_ClientServiceRequest_Label_RequestedBy;
|
|
|
|
list.Add(dr.GetGuid("AID"),
|
|
DBUtil.ToLocal(dr.GetSmartDate("ACREATED")).ToString() + " " +
|
|
dr.GetString("ACLIENTNAME") + " " +
|
|
dr.GetString("ATITLE") + " " +
|
|
dr.GetString("AREQUESTEDBY")
|
|
);
|
|
_Count++;
|
|
}
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
if (dr != null) dr.Close();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
public bool Count;
|
|
public int MaxRecords;
|
|
public Criteria(bool count, int maxRecords)
|
|
{
|
|
MaxRecords = maxRecords;
|
|
Count = count;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}//end DashBoardClientServiceRequestListRI
|
|
#pragma warning restore 1591
|
|
}//end namespace GZTW.AyaNova.BLL
|