209 lines
5.2 KiB
C#
209 lines
5.2 KiB
C#
///////////////////////////////////////////////////////////
|
|
// Bool.cs
|
|
// Implementation of Class WorkorderDescriptionFetcher
|
|
// CSLA type: Read-only object
|
|
// Created on: 21-Oct-2005
|
|
// Object design: John
|
|
// Coded: John 21-Oct-2005
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using CSLA.Data;
|
|
using GZTW.Data;
|
|
using CSLA;
|
|
using System.Threading;
|
|
using CSLA.Security;
|
|
using System.ComponentModel;
|
|
|
|
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
/// <summary>
|
|
/// Used to quickly fetch descriptive information
|
|
/// for identifying a service workorder to user
|
|
/// during notification Processing
|
|
/// </summary>
|
|
[Serializable]
|
|
public class WorkorderDescriptionFetcher : ReadOnlyBase
|
|
{
|
|
|
|
#region Attributes
|
|
private string mWorkorderNumber="";
|
|
private string mClientName="";
|
|
private SmartDate mCloseByDate=new SmartDate();
|
|
private string mTemplateDescription = "";
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
/// <summary>
|
|
/// Private constructor to prevent direct instantiation
|
|
/// </summary>
|
|
private WorkorderDescriptionFetcher()
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region Business properties
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string WorkorderNumber
|
|
{
|
|
get
|
|
{
|
|
return mWorkorderNumber;
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string ClientName
|
|
{
|
|
get
|
|
{
|
|
return mClientName;
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public SmartDate CloseByDate
|
|
{
|
|
get
|
|
{
|
|
return mCloseByDate;
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string TemplateDescription
|
|
{
|
|
get
|
|
{
|
|
return mTemplateDescription;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region Static methods
|
|
|
|
/// <summary>
|
|
/// Get descriptive text fields for given workorder ID
|
|
/// </summary>
|
|
/// <param name="WorkorderID"></param>
|
|
/// <returns></returns>
|
|
public static WorkorderDescriptionFetcher GetItem(Guid WorkorderID)
|
|
{
|
|
|
|
return (WorkorderDescriptionFetcher)DataPortal.Fetch(new Criteria(WorkorderID, Guid.Empty ));
|
|
|
|
}
|
|
/// <summary>
|
|
/// Get descriptive text fields for given workorder's outside service record ID
|
|
/// </summary>
|
|
/// <param name="WorkorderItemOutsideServiceID"></param>
|
|
/// <returns></returns>
|
|
public static WorkorderDescriptionFetcher GetItemFromWorkorderItemOutsideServiceID(Guid WorkorderItemOutsideServiceID)
|
|
{
|
|
|
|
return (WorkorderDescriptionFetcher)DataPortal.Fetch(new Criteria(Guid.Empty, WorkorderItemOutsideServiceID ));
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param Bool="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
Criteria crit = (Criteria)Criteria;
|
|
SafeDataReader dr = null;
|
|
if(crit.WorkorderID!=Guid.Empty)
|
|
{
|
|
dr=DBUtil.GetReaderFromSQLString(
|
|
"SELECT aWorkorderService.aServiceNumber, aWorkorderService.aCloseByDate, aWorkorder.ATemplateDescription, " +
|
|
"aClient.aName " +
|
|
"AS CLIENTNAME FROM aWorkorder LEFT " +
|
|
"OUTER JOIN aWorkorderService ON aWorkorder.aID " +
|
|
"= aWorkorderService.aWorkorderID LEFT OUTER " +
|
|
"JOIN aClient ON aWorkorder.aClientID = " +
|
|
"aClient.aID WHERE aWorkorder.aID=@ID", crit.WorkorderID
|
|
);
|
|
}
|
|
else
|
|
{
|
|
//It's a workorder item outside service ID
|
|
dr=DBUtil.GetReaderFromSQLString(
|
|
"SELECT aClient.aName AS CLIENTNAME, aWorkorderService.aServiceNumber, aWorkorder.ATemplateDescription, " +
|
|
" aWorkorderService.aCloseByDate " +
|
|
"FROM aWorkorderItemOutsideService " +
|
|
"INNER JOIN aWorkorderItem ON aWorkorderItemOutsideService.aWorkorderItemID " +
|
|
"= aWorkorderItem.aID " +
|
|
"INNER JOIN aWorkorder ON aWorkorderItem.aWorkorderID " +
|
|
"= aWorkorder.aID LEFT OUTER " +
|
|
"JOIN aWorkorderService ON aWorkorder.aID " +
|
|
"= aWorkorderService.aWorkorderID LEFT OUTER JOIN " +
|
|
"aClient ON aWorkorder.aClientID = aClient.aID " +
|
|
"WHERE (aWorkorderItemOutsideService.aID " +
|
|
"= @ID)", crit.WorkorderItemOutsideServiceID
|
|
);
|
|
|
|
}
|
|
if(dr.Read())
|
|
{
|
|
this.mClientName=dr.GetString("CLIENTNAME");
|
|
this.mWorkorderNumber=dr.GetInt32("aServiceNumber").ToString();
|
|
this.mCloseByDate=DBUtil.ToLocal(dr.GetSmartDate("aCloseByDate"));
|
|
this.mTemplateDescription = dr.GetString("atemplatedescription");
|
|
}
|
|
|
|
//Changed: 09-June-2006 this was missing!
|
|
if (dr != null) dr.Close();
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
|
|
public Guid WorkorderID;
|
|
public Guid WorkorderItemOutsideServiceID;
|
|
|
|
public Criteria(Guid _WorkorderID, Guid _WorkorderItemOutsideServiceID)
|
|
{
|
|
WorkorderID=_WorkorderID;
|
|
WorkorderItemOutsideServiceID=_WorkorderItemOutsideServiceID;
|
|
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end Bool
|
|
|
|
}//end Boolspace GZTW.AyaNova.BLL |