540 lines
21 KiB
C#
540 lines
21 KiB
C#
///////////////////////////////////////////////////////////
|
|
// ClientServiceRequestListRI.cs
|
|
// Implementation of Class ClientServiceRequestListRI
|
|
// CSLA type: Read only collection
|
|
// Created on: 16-Feb-2016
|
|
///////////////////////////////////////////////////////////
|
|
|
|
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
|
|
/// <summary>
|
|
/// Read only list of <see cref="ClientServiceRequestListRI.ClientServiceRequestListRIInfo"/> objects representing <see cref="ClientServiceRequest"/> objects
|
|
/// Used by AyaNova RI interface
|
|
/// </summary>
|
|
[Serializable]
|
|
public class ClientServiceRequestListRI : ReadOnlyCollectionBase
|
|
{
|
|
#region Data structure
|
|
/// <summary>
|
|
/// Properties
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct ClientServiceRequestListRIInfo
|
|
{
|
|
internal SmartDate mCreated;
|
|
internal string mCreator;
|
|
internal GridNameValueCellItem mTitle;
|
|
internal string mClient;
|
|
internal GridNameValueCellItem mHeadOffice;
|
|
|
|
//case 1976
|
|
//internal string mUnit;
|
|
internal GridNameValueCellItem mSerial;
|
|
|
|
internal GridNameValueCellItem mWorkorder;
|
|
internal string mClientRef;
|
|
internal ClientServiceRequestStatus mStatus;
|
|
internal ClientServiceRequestPriority mPriority;
|
|
internal string mRequestedBy;
|
|
|
|
[SqlColumnNameAttribute("aClientServiceRequest.aCreated"), Display(DisplayType.DateTime)]
|
|
public object LT_Common_Label_Created
|
|
{ get { return mCreated.DBValue; } }
|
|
|
|
[SqlColumnNameAttribute("aUser.aInitials"), Display(DisplayType.Text)]
|
|
public string LT_Common_Label_Creator
|
|
{ get { return mCreator; } }
|
|
|
|
[SqlColumnNameAttribute("aClientServiceRequest.aTitle", "aClientServiceRequest.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.ClientServiceRequest)]
|
|
public GridNameValueCellItem LT_O_ClientServiceRequest
|
|
{ get { return mTitle; } }
|
|
|
|
[SqlColumnNameAttribute("aClient.aName"), Display(DisplayType.Text)]
|
|
public string LT_O_Client { get { return mClient; } }
|
|
|
|
|
|
[SqlColumnNameAttribute("aHeadOffice.aName", "aClient.aHeadOfficeID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.HeadOffice)]
|
|
public GridNameValueCellItem LT_O_HeadOffice { get { return mHeadOffice; } }
|
|
|
|
|
|
|
|
//case 1976
|
|
//[SqlColumnNameAttribute("aUnit.aSerial"), Display(DisplayType.Text)]
|
|
//public string LT_Unit_Label_Serial { get { return mUnit; } }
|
|
|
|
[SqlColumnNameAttribute("AUNIT.ASERIAL", "ACLIENTSERVICEREQUEST.AUNITID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Unit)]
|
|
public GridNameValueCellItem LT_Unit_Label_Serial { get { return mSerial; } }
|
|
|
|
|
|
|
|
[SqlColumnNameAttribute("aWorkorderService.aServiceNumber", "aWorkorder.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.WorkorderItem, CompareAs = CompareType.StringToInt32)]
|
|
public GridNameValueCellItem LT_O_Workorder { get { return mWorkorder; } }
|
|
|
|
|
|
[SqlColumnNameAttribute("aClientServiceRequest.ACLIENTREF"), Display(DisplayType.Text)]
|
|
public string LT_ClientServiceRequest_Label_CustomerReferenceNumber
|
|
{ get { return this.mClientRef; } }
|
|
|
|
[Display(DisplayType.ListClientServiceRequestStatus)]
|
|
public ClientServiceRequestStatus LT_ClientServiceRequest_Label_Status
|
|
{ get { return mStatus; } }
|
|
|
|
[Display(DisplayType.ListClientServiceRequestPriority, Color = true, ColorField = "FIXED")]
|
|
public ClientServiceRequestPriority LT_ClientServiceRequest_Label_Priority
|
|
{ get { return mPriority; } }
|
|
|
|
//Case 58
|
|
internal GridNameValueCellItem mRegion;
|
|
[SqlColumnNameAttribute("aRegion.aName", "aRegion.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Region)]
|
|
public GridNameValueCellItem LT_O_Region
|
|
{
|
|
get
|
|
{
|
|
return mRegion;
|
|
}
|
|
}
|
|
|
|
[SqlColumnNameAttribute("aClientServiceRequest.AREQUESTEDBY"), Display(DisplayType.Text)]
|
|
public string LT_ClientServiceRequest_Label_RequestedBy
|
|
{ get { return this.mRequestedBy; } }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(ClientServiceRequestListRIInfo obj)
|
|
{
|
|
return this.mTitle.Value.Equals(obj.mTitle.Value);
|
|
}
|
|
|
|
}//end ClientServiceRequestListRIInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
protected ClientServiceRequestListRI()
|
|
{
|
|
// 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 ClientServiceRequestListRIInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (ClientServiceRequestListRIInfo)List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns display text that matches passed in itemid value
|
|
/// </summary>
|
|
/// <param name="ItemID"></param>
|
|
public string this[Guid ItemID]
|
|
{
|
|
|
|
get
|
|
{
|
|
foreach (ClientServiceRequestListRIInfo child in List)
|
|
{
|
|
if (child.mTitle.Value == ItemID) return child.ToString();
|
|
}
|
|
return "Missing: " + ItemID.ToString();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region contains
|
|
/// <summary>
|
|
/// Check if item in collection
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Contains(ClientServiceRequestListRIInfo obj)
|
|
{
|
|
foreach (ClientServiceRequestListRIInfo child in List)
|
|
{
|
|
if (child.Equals(obj)) return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Reporting and shared UI editor helpers
|
|
|
|
/// <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 "ClientServiceRequestListRI";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the Detailed report key
|
|
/// which is used to determine which reports and objects
|
|
/// will be used for detailed reports
|
|
///
|
|
/// If empty string then indicates there is no detailed report object or reports
|
|
/// </summary>
|
|
public static string DetailedReportKey
|
|
{
|
|
get
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Base object that this list is reporting on
|
|
/// used by shared UI editor to instantiate new objects
|
|
/// when user selects new in UI elements that display this list
|
|
///
|
|
/// (I.E. when user clicks on new in a read only list grid, this is the object type created)
|
|
/// </summary>
|
|
public static RootObjectTypes BaseObjectType
|
|
{
|
|
get
|
|
{
|
|
return RootObjectTypes.ClientServiceRequest;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Locale key so that generic list editor
|
|
/// UI code knows what title to give the list in a
|
|
/// grid
|
|
/// </summary>
|
|
public string LocaleKey
|
|
{
|
|
get
|
|
{
|
|
return "ClientServiceRequest.Label.List";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// The Type of the struct used to store list records
|
|
/// Used to fetch the custom display attributes of the fields
|
|
/// contained within the record to modify the grid display accordingly
|
|
/// <see cref="DisplayAttribute"/>
|
|
/// </summary>
|
|
public static Type ListRecordType
|
|
{
|
|
get
|
|
{
|
|
return typeof(ClientServiceRequestListRIInfo);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Field that contains the ID of the objects
|
|
/// that are the basis of this list.
|
|
///
|
|
/// Used for compiling an ID list for reporting from user
|
|
/// selections in a grid.
|
|
/// </summary>
|
|
public static string IDField
|
|
{
|
|
get
|
|
{
|
|
return "LT_O_ClientServiceRequest";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Same as IDField but for detailed reports
|
|
/// </summary>
|
|
public static string IDFieldDetailed
|
|
{
|
|
get
|
|
{
|
|
return IDField;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Static methods
|
|
|
|
///// <summary>
|
|
///// Internal method used by list factory
|
|
///// </summary>
|
|
//internal static ClientServiceRequestListRI Get(string Filter, int MaxRecords, List<Guid> IDList)
|
|
//{
|
|
// return (ClientServiceRequestListRI)DataPortal.Fetch(new Criteria(Filter,IDList, MaxRecords, Guid.Empty, Guid.Empty));
|
|
//}
|
|
|
|
///// <summary>
|
|
///// Get all ClientServiceRequest (filtered by crit)
|
|
///// </summary>
|
|
///// <param name="xmlCriteria">Use AyaNova UI to easily build xmlCriteria and Ctrl-Alt-g keyboard command to display it for use in your code</param>
|
|
///// <returns>list of <see cref="ClientServiceRequestListRI.ClientServiceRequestListRIInfo"/> objects</returns>
|
|
//public static ClientServiceRequestListRI GetList(string xmlCriteria)
|
|
//{
|
|
// return (ClientServiceRequestListRI)DataPortal.Fetch(new Criteria(xmlCriteria,null, -1, Guid.Empty, Guid.Empty));
|
|
//}
|
|
|
|
|
|
////added for case 1975 RI
|
|
///// <summary>
|
|
///// Get MaxRecord Quotes filtered by criteria
|
|
///// </summary>
|
|
///// <param name="xmlCriteria"></param>
|
|
///// <param name="MaxRecords"></param>
|
|
///// <param name="clientID"></param>
|
|
///// <returns></returns>
|
|
//public static ClientServiceRequestListRI GetList(string xmlCriteria, int MaxRecords, Guid clientID)
|
|
//{
|
|
// return (ClientServiceRequestListRI)DataPortal.Fetch(new Criteria(xmlCriteria, null, MaxRecords, Guid.Empty, clientID));
|
|
//}
|
|
|
|
//added for case 1975 RI
|
|
/// <summary>
|
|
/// Get MaxRecord Quotes filtered by criteria
|
|
/// </summary>
|
|
/// <param name="xmlCriteria"></param>
|
|
/// <param name="MaxRecords"></param>
|
|
/// <returns></returns>
|
|
public static ClientServiceRequestListRI GetList(string xmlCriteria, int MaxRecords)
|
|
{
|
|
return (ClientServiceRequestListRI)DataPortal.Fetch(new Criteria(xmlCriteria, null, MaxRecords, Guid.Empty, Guid.Empty));
|
|
}
|
|
|
|
|
|
///// <summary>
|
|
///// Get all ClientServiceRequest for a specified head office
|
|
///// (returns all requests for all clients under headOfficeID)
|
|
///// </summary>
|
|
///// <param name="headOfficeID"></param>
|
|
///// <returns>list of <see cref="ClientServiceRequestListRI.ClientServiceRequestListRIInfo"/> objects</returns>
|
|
//public static ClientServiceRequestListRI GetListForHeadOffice(Guid headOfficeID)
|
|
//{
|
|
// return (ClientServiceRequestListRI)DataPortal.Fetch(new Criteria("",null, -1, headOfficeID, Guid.Empty));
|
|
//}
|
|
|
|
///// <summary>
|
|
///// Get all ClientServiceRequest for a specified client
|
|
///// </summary>
|
|
///// <param name="clientID"></param>
|
|
///// <returns>list of <see cref="ClientServiceRequestListRI.ClientServiceRequestListRIInfo"/> objects</returns>
|
|
//public static ClientServiceRequestListRI GetListForClient(Guid clientID)
|
|
//{
|
|
// return (ClientServiceRequestListRI)DataPortal.Fetch(new Criteria("",null, -1, Guid.Empty, clientID));
|
|
//}
|
|
|
|
///// <summary>
|
|
///// Get list by items indicated in IDList
|
|
///// </summary>
|
|
///// <param name="IDList">Generic list of Guid's</param>
|
|
///// <returns>list of <see cref="ClientServiceRequestListRI.ClientServiceRequestListRIInfo"/> objects</returns>
|
|
//public static ClientServiceRequestListRI GetListFromIDList(List<Guid> IDList)
|
|
//{
|
|
// //case 556
|
|
// //Handle empty list
|
|
// if (IDList.Count == 0)
|
|
// return new ClientServiceRequestListRI();
|
|
// return (ClientServiceRequestListRI)DataPortal.Fetch(new Criteria("", IDList, -1, Guid.Empty, Guid.Empty));
|
|
//}
|
|
|
|
|
|
///// <summary>
|
|
///// Return an empty list
|
|
///// used for initializing grid
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public static ClientServiceRequestListRI GetEmptyList()
|
|
//{
|
|
// return new ClientServiceRequestListRI();
|
|
//}
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param name="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
|
|
Criteria crit = (Criteria)Criteria;
|
|
|
|
SafeDataReader dr = null;
|
|
try
|
|
{
|
|
string q = "";
|
|
|
|
|
|
|
|
|
|
//Generic full list fetch (regionalized)
|
|
//************************************************************
|
|
q = "SELECT ~MAXRECS~ " +
|
|
" ACLIENTSERVICEREQUEST.*, " +
|
|
" AUNIT.ASERIAL, AUNIT.ADESCRIPTION, " +//case 3150
|
|
" AUNITMODEL.ANAME AS AUNITMODELNAME, aUnitModel.aModelNumber, " +//Case9
|
|
" AVENDOR.ANAME AS AUNITVENDORNAME, " +
|
|
" AUSER.AFIRSTNAME, " +
|
|
" AUSER.ALASTNAME, " +
|
|
" AUSER.AINITIALS, " +
|
|
" AUSER.AEMPLOYEENUMBER, " +
|
|
" ACLIENT.ANAME AS ACLIENTNAME, " +
|
|
" ACLIENT.aRegionID, ACLIENT.AHEADOFFICEID, aRegion.aName AS aRegionName, " + //case 58
|
|
" AHEADOFFICE.ANAME AS AHEADOFFICENAME, " +
|
|
" AWORKORDERSERVICE.ASERVICENUMBER, " +
|
|
" AWORKORDERITEM.AWORKORDERID " +
|
|
" FROM " +
|
|
" ACLIENTSERVICEREQUEST " +
|
|
" INNER JOIN AUSER ON (ACLIENTSERVICEREQUEST.ACREATOR = AUSER.AID) " +
|
|
" INNER JOIN ACLIENT ON (ACLIENTSERVICEREQUEST.ACLIENTID = ACLIENT.AID) " +
|
|
" LEFT OUTER JOIN aRegion ON aClient.aRegionID = aRegion.aID " + //Case 58
|
|
" LEFT OUTER JOIN AHEADOFFICE ON (ACLIENT.AHEADOFFICEID = AHEADOFFICE.AID) " +
|
|
" LEFT OUTER JOIN AUNIT ON (ACLIENTSERVICEREQUEST.AUNITID = AUNIT.AID) " +
|
|
" LEFT OUTER JOIN AWORKORDERITEM ON (ACLIENTSERVICEREQUEST.AWORKORDERITEMID = AWORKORDERITEM.AID) " +
|
|
" LEFT OUTER JOIN AWORKORDERSERVICE ON (AWORKORDERITEM.AWORKORDERID = AWORKORDERSERVICE.AWORKORDERID) " +
|
|
" LEFT OUTER JOIN AUNITMODEL ON (AUNIT.AUNITMODELID = AUNITMODEL.AID) " +
|
|
" LEFT OUTER JOIN AVENDOR ON (AUNITMODEL.AVENDORID = AVENDOR.AID) " +
|
|
AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML, true) + " " +
|
|
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML);
|
|
|
|
if (crit.MaxRecords > 0)
|
|
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
|
|
else
|
|
q = q.Replace("~MAXRECS~", "");
|
|
q = DBUtil.AddRegionFilter(q, "aClient", "");//case 58
|
|
dr = DBUtil.GetReaderFromSQLString(q);
|
|
|
|
//************************************************************
|
|
|
|
string accepted = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Accepted");
|
|
string declined = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Declined");
|
|
string open = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Open");
|
|
string closed = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestStatus.Closed");
|
|
|
|
string noturgent = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestPriority.NotUrgent");
|
|
string asap = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestPriority.ASAP");
|
|
string emergency = LocalizedTextTable.GetLocalizedTextDirect("ClientServiceRequestPriority.Emergency");
|
|
|
|
|
|
|
|
while (dr.Read())
|
|
{
|
|
//*******************************************
|
|
ClientServiceRequestListRIInfo info = new ClientServiceRequestListRIInfo();
|
|
info.mCreated = DBUtil.ToLocal(dr.GetSmartDate("ACREATED"));
|
|
info.mCreator = dr.GetString("AINITIALS");
|
|
info.mTitle = new GridNameValueCellItem(
|
|
dr.GetGuid("AID"),
|
|
dr.GetString("ATITLE"),
|
|
RootObjectTypes.ClientServiceRequest);
|
|
|
|
info.mClient = dr.GetString("ACLIENTNAME");
|
|
|
|
//Case 58
|
|
info.mRegion = new GridNameValueCellItem(
|
|
dr.GetGuid("aRegionID"),
|
|
dr.GetString("aRegionName"),
|
|
RootObjectTypes.Region);
|
|
|
|
info.mHeadOffice = new GridNameValueCellItem(
|
|
dr.GetGuid("AHEADOFFICEID"),
|
|
dr.GetString("AHEADOFFICENAME"),
|
|
RootObjectTypes.HeadOffice);
|
|
|
|
//case 1976
|
|
//info.mUnit = Unit.UnitNameFormatter(dr.GetString("aModelNumber"), dr.GetString("AUNITMODELNAME"), dr.GetString("AUNITVENDORNAME"), dr.GetString("ASERIAL"), AyaBizUtils.GlobalSettings.DefaultUnitNameDisplayFormat);
|
|
info.mSerial = new GridNameValueCellItem(
|
|
dr.GetGuid("AUNITID"),
|
|
Unit.UnitNameFormatter(
|
|
dr.GetString("AMODELNUMBER"),
|
|
dr.GetString("AUNITMODELNAME"),
|
|
dr.GetString("AUNITVENDORNAME"),
|
|
dr.GetString("ASERIAL"),
|
|
dr.GetString("ADESCRIPTION"),
|
|
AyaBizUtils.GlobalSettings.DefaultUnitNameDisplayFormat),
|
|
RootObjectTypes.Unit);
|
|
|
|
|
|
info.mWorkorder = new GridNameValueCellItem(
|
|
dr.GetGuid("AWORKORDERID"),
|
|
dr.GetInt32("ASERVICENUMBER") == 0 ? "" : dr.GetInt32("ASERVICENUMBER").ToString(),
|
|
RootObjectTypes.Workorder);
|
|
|
|
info.mClientRef = dr.GetString("ACLIENTREF");
|
|
info.mRequestedBy = dr.GetString("AREQUESTEDBY");
|
|
info.mStatus=(ClientServiceRequestStatus)dr.GetInt16("ASTATUS");
|
|
info.mPriority=(ClientServiceRequestPriority)dr.GetInt16("APRIORITY");
|
|
|
|
|
|
|
|
InnerList.Add(info);
|
|
//*******************************************
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
if (dr != null) dr.Close();
|
|
}
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
|
|
public List<Guid> IDList;
|
|
public string CriteriaXML;
|
|
public int MaxRecords;
|
|
public Guid HeadOfficeID;
|
|
public Guid ClientID;
|
|
public Criteria(string _CriteriaXML, List<Guid> _IDList, int _MaxRecords, Guid _HeadOfficeID, Guid _ClientID)
|
|
{
|
|
CriteriaXML = _CriteriaXML;
|
|
MaxRecords = _MaxRecords;
|
|
HeadOfficeID = _HeadOfficeID;
|
|
ClientID = _ClientID;
|
|
IDList = _IDList;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end ClientServiceRequestListRI
|
|
#pragma warning restore 1591
|
|
}//end namespace GZTW.AyaNova.BLL
|