832 lines
35 KiB
C#
832 lines
35 KiB
C#
///////////////////////////////////////////////////////////
|
|
// WorkorderPMCustomList.cs
|
|
// Implementation of Class WorkorderPMCustomList
|
|
// CSLA type: Read only collection
|
|
// Created on: 11-Dec-2005
|
|
// Object design: Joyce
|
|
// Coded: 11-Dec-2005
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using GZTW.Data;
|
|
using CSLA.Data;
|
|
using CSLA;
|
|
using System.Collections.Generic;
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
/// <summary>
|
|
/// Read only list of <see cref="WorkorderPMCustomList.WorkorderPMCustomListInfo"/> objects
|
|
/// </summary>
|
|
[Serializable]
|
|
public class WorkorderPMCustomList : ReadOnlyCollectionBase
|
|
{
|
|
#pragma warning disable 1591
|
|
#region Data structure
|
|
/// <summary>
|
|
/// Properties
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct WorkorderPMCustomListInfo
|
|
{
|
|
#region Workorder Service Level
|
|
|
|
#region Attributes
|
|
internal Guid mWorkorderID;
|
|
internal GridNameValueCellItem mWorkorder;
|
|
|
|
internal GridNameValueCellItem mClient;
|
|
internal GridNameValueCellItem mProject;
|
|
internal GridNameValueCellItem mRegion;
|
|
internal GridNameValueCellItem mCategory;
|
|
internal string mInternalReferenceNumber;
|
|
internal string mCustomerReferenceNumber;
|
|
internal string mCustomerContactName;
|
|
internal string mSummary;
|
|
internal bool mOnsite;
|
|
internal bool mServiceCompleted;
|
|
//internal bool mClosed;
|
|
internal GridNameValueCellItem mClientGroup;
|
|
internal GridNameValueCellItem mDispatchZone;
|
|
|
|
//PM -------------
|
|
internal SmartDate mStopGeneratingDate;
|
|
internal SmartDate mNextServiceDate;
|
|
internal SmartDate mCreatedDate;
|
|
internal AyaDayOfWeek mDayOfTheWeek;
|
|
internal bool mActive;
|
|
internal int mGenerateSpan;
|
|
internal int mThresholdSpan;
|
|
internal AyaUnitsOfTime mGenerateSpanUnit;
|
|
internal AyaUnitsOfTime mThresholdSpanUnit;
|
|
//----------------
|
|
|
|
|
|
#endregion attributes
|
|
|
|
#region Properties
|
|
|
|
[Display(DisplayType.Hidden)]
|
|
public Guid LT_Workorder_Label_ID { get { return mWorkorderID; } }
|
|
|
|
//PM -------------------
|
|
[SqlColumnNameAttribute("aWorkorderPreventiveMaintenance.aPreventiveMaintenanceNumber", "aWorkorder.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.WorkorderPreventiveMaintenance, CompareAs=CompareType.StringToInt32)]
|
|
public GridNameValueCellItem LT_O_WorkorderPreventiveMaintenance { get { return mWorkorder; } }
|
|
|
|
[Display(DisplayType.DateTime)]
|
|
public object LT_WorkorderPreventiveMaintenance_Label_StopGeneratingDate { get { return mStopGeneratingDate.DBValue; } }
|
|
|
|
[Display(DisplayType.DateTime)]
|
|
public object LT_WorkorderPreventiveMaintenance_Label_NextServiceDate { get { return mNextServiceDate.DBValue; } }
|
|
|
|
|
|
[SqlColumnNameAttribute("aWorkorderPreventiveMaintenance.aCreated"), Display(DisplayType.DateTime)]
|
|
public object LT_Common_Label_Created { get { return mCreatedDate.DBValue; } }
|
|
|
|
[Display(DisplayType.ListAyaDayOfWeek)]
|
|
public AyaDayOfWeek LT_WorkorderPreventiveMaintenance_Label_DayOfTheWeek { get { return mDayOfTheWeek; } }
|
|
|
|
|
|
[SqlColumnNameAttribute("aWorkorderPreventiveMaintenance.AACTIVE"), Display(DisplayType.TrueFalse)]
|
|
public bool LT_Common_Label_Active { get { return mActive; } }
|
|
|
|
[Display(DisplayType.WholeNumber)]
|
|
public int LT_WorkorderPreventiveMaintenance_Label_GenerateSpan { get { return mGenerateSpan; } }
|
|
|
|
[Display(DisplayType.WholeNumber)]
|
|
public int LT_WorkorderPreventiveMaintenance_Label_ThresholdSpan { get { return mThresholdSpan; } }
|
|
|
|
[Display(DisplayType.ListAyaUnitsOfTime)]
|
|
public AyaUnitsOfTime LT_WorkorderPreventiveMaintenance_Label_GenerateSpanUnit { get { return mGenerateSpanUnit; } }
|
|
|
|
[Display(DisplayType.ListAyaUnitsOfTime)]
|
|
public AyaUnitsOfTime LT_WorkorderPreventiveMaintenance_Label_ThresholdSpanUnit { get { return mThresholdSpanUnit; } }
|
|
|
|
|
|
//---------------------------
|
|
|
|
[SqlColumnNameAttribute("aClient.aName", "aClient.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Client)]
|
|
public GridNameValueCellItem LT_O_Client { get { return mClient; } }
|
|
|
|
[SqlColumnNameAttribute("aProject.aName", "aProject.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Project)]
|
|
public GridNameValueCellItem LT_O_Project { get { return mProject; } }
|
|
|
|
[SqlColumnNameAttribute("aRegion.aName", "aRegion.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Region)]
|
|
public GridNameValueCellItem LT_O_Region { get { return mRegion; } }
|
|
|
|
[SqlColumnNameAttribute("aWorkorderCategory.aName", "aWorkorderCategory.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.WorkorderCategory)]
|
|
public GridNameValueCellItem LT_O_WorkorderCategory { get { return mCategory; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Workorder_Label_InternalReferenceNumber { get { return mInternalReferenceNumber; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Workorder_Label_CustomerReferenceNumber { get { return mCustomerReferenceNumber; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Workorder_Label_CustomerContactName { get { return mCustomerContactName; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_Workorder_Label_Summary { get { return mSummary; } }
|
|
|
|
[Display(DisplayType.TrueFalse)]
|
|
public bool LT_Workorder_Label_Onsite { get { return mOnsite; } }
|
|
|
|
[Display(DisplayType.TrueFalse)]
|
|
public bool LT_Workorder_Label_ServiceCompleted { get { return mServiceCompleted; } }
|
|
|
|
//[Display(DisplayType.TrueFalse)]
|
|
//public bool LT_Workorder_Label_Closed { get { return mClosed; } }
|
|
|
|
[SqlColumnNameAttribute("aClientGroup.aName", "aClientGroup.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.ClientGroup)]
|
|
public GridNameValueCellItem LT_O_ClientGroup { get { return mClientGroup; } }
|
|
|
|
[SqlColumnNameAttribute("aDispatchZone.aName", "aDispatchZone.aID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.DispatchZone)]
|
|
public GridNameValueCellItem LT_O_DispatchZone { get { return mDispatchZone; } }
|
|
|
|
#endregion properties
|
|
|
|
#endregion workorderservice level
|
|
|
|
#region WorkorderServiceWorkorderItemsList Level
|
|
|
|
internal Guid mWorkorderItemID;
|
|
internal string mWorkorderItemSummary;
|
|
internal GridNameValueCellItem mWorkorderItemType;
|
|
internal SmartDate mRequestDate;
|
|
internal GridNameValueCellItem mPriority;
|
|
internal GridNameValueCellItem mWorkorderItemStatus;
|
|
internal GridNameValueCellItem mSerial;
|
|
internal GridNameValueCellItem mUnitModel;
|
|
internal GridNameValueCellItem mWorkorderItemUnitServiceType;
|
|
|
|
internal bool mWarrantyService;
|
|
|
|
[Display(DisplayType.Hidden)]
|
|
public Guid LT_WorkorderItem_Label_ID { get { return mWorkorderItemID; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_WorkorderItem_Label_Summary { get { return mWorkorderItemSummary; } }
|
|
|
|
[SqlColumnNameAttribute("aWorkorderItemType.aName", "aWorkorderItem.aTypeID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.WorkorderItemType)]
|
|
public GridNameValueCellItem LT_WorkorderItem_Label_TypeID { get { return mWorkorderItemType; } }
|
|
|
|
[Display(DisplayType.DateTime)]
|
|
public object LT_WorkorderItem_Label_RequestDate { get { return mRequestDate.DBValue; } }
|
|
|
|
[SqlColumnNameAttribute("aPriority.aName", "aWorkorderItem.aPriorityID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Priority)]
|
|
public GridNameValueCellItem LT_WorkorderItem_Label_PriorityID { get { return mPriority; } }
|
|
|
|
|
|
|
|
//Changed: 26-April-2006 added sqlcolumnname attribute that was missing causing errors filtering on that column in grid
|
|
[SqlColumnNameAttribute("aWorkorderItemStatus.aName", "aWorkorderItem.aWorkorderStatusID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.WorkorderStatus,
|
|
Color = true, ColorField = "WorkorderItemStatusARGB")/*Case 40*/]
|
|
public GridNameValueCellItem LT_WorkorderItem_Label_WorkorderStatusID { get { return mWorkorderItemStatus; } }
|
|
|
|
/// <summary>
|
|
/// Case 40
|
|
/// Not for viewing directly, sets the color of the status button
|
|
///
|
|
/// </summary>
|
|
[Display(DisplayType.Hidden)]
|
|
public int WorkorderItemStatusARGB { get { return mWorkorderItemStatusARGB; } }
|
|
internal int mWorkorderItemStatusARGB;
|
|
|
|
|
|
[SqlColumnNameAttribute("aUnit.aSerial", "aWorkorderItem.aUnitID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.Unit)]
|
|
public GridNameValueCellItem LT_Unit_Label_Serial { get { return mSerial; } }
|
|
|
|
|
|
[SqlColumnNameAttribute("aUnitModel.aName", "aUnit.aUnitModelID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.UnitModel)]
|
|
public GridNameValueCellItem LT_O_UnitModel { get { return mUnitModel; } }
|
|
|
|
|
|
[SqlColumnNameAttribute("aUnitServiceType.aName", "aWorkorderItem.aWorkorderItemUnitServiceTypeID"),
|
|
Display(DisplayType.Button, RootObjectType = RootObjectTypes.UnitServiceType)]
|
|
public GridNameValueCellItem LT_O_UnitServiceType { get { return mWorkorderItemUnitServiceType; } }
|
|
|
|
[Display(DisplayType.TrueFalse)]
|
|
public bool LT_WorkorderItem_Label_WarrantyService { get { return mWarrantyService; } }
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region WorkorderServiceWorkorderItemsListDetailed (custom fields) Level
|
|
internal string mCustom1;
|
|
internal string mCustom2;
|
|
internal string mCustom3;
|
|
internal string mCustom4;
|
|
internal string mCustom5;
|
|
internal string mCustom6;
|
|
internal string mCustom7;
|
|
internal string mCustom8;
|
|
internal string mCustom9;
|
|
internal string mCustom0;
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_WorkorderItem_Label_Custom1 { get { return mCustom1; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_WorkorderItem_Label_Custom2 { get { return mCustom2; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_WorkorderItem_Label_Custom3 { get { return mCustom3; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_WorkorderItem_Label_Custom4 { get { return mCustom4; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_WorkorderItem_Label_Custom5 { get { return mCustom5; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_WorkorderItem_Label_Custom6 { get { return mCustom6; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_WorkorderItem_Label_Custom7 { get { return mCustom7; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_WorkorderItem_Label_Custom8 { get { return mCustom8; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_WorkorderItem_Label_Custom9 { get { return mCustom9; } }
|
|
|
|
[Display(DisplayType.Text)]
|
|
public string LT_WorkorderItem_Label_Custom0 { get { return mCustom0; } }
|
|
|
|
#endregion workorderserviceworkorderitemslistdetailed (custom fields) level
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
public bool Equals(WorkorderPMCustomListInfo obj)
|
|
{
|
|
return this.mWorkorder.Value.Equals(obj.mWorkorder.Value);
|
|
}
|
|
|
|
}//end WorkorderPMCustomListInfo
|
|
#endregion
|
|
|
|
#region Constructor
|
|
private RelativeTimeFormatter rtfm = null;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
protected WorkorderPMCustomList()
|
|
{
|
|
rtfm = RelativeTimeFormatter.GetItem(User.CurrentUserLanguage);
|
|
// 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 WorkorderPMCustomListInfo this[int Item]
|
|
{
|
|
|
|
get
|
|
{
|
|
return (WorkorderPMCustomListInfo)List[Item];
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Returns display text that matches passed in itemid value
|
|
/// </summary>
|
|
/// <param name="ItemID"></param>
|
|
public string this[Guid ItemID]
|
|
{
|
|
|
|
get
|
|
{
|
|
foreach (WorkorderPMCustomListInfo child in List)
|
|
{
|
|
if (child.mWorkorder.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(WorkorderPMCustomListInfo obj)
|
|
{
|
|
foreach (WorkorderPMCustomListInfo 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 "WorkorderPMCustomList";
|
|
}
|
|
}
|
|
|
|
/// <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.WorkorderPreventiveMaintenance;
|
|
}
|
|
}
|
|
|
|
/// <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(WorkorderPMCustomListInfo);
|
|
}
|
|
}
|
|
|
|
/// <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 "WorkorderItem.Label.CustomFields";
|
|
}
|
|
}
|
|
|
|
|
|
/// <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_WorkorderItem_Label_ID";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Same as IDField but for detailed reports
|
|
/// </summary>
|
|
public static string IDFieldDetailed
|
|
{
|
|
get
|
|
{
|
|
return WorkorderPMList.IDFieldDetailed;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Static methods
|
|
/// <summary>
|
|
/// Internal method used by list factory
|
|
/// </summary>
|
|
internal static WorkorderPMCustomList Get(string Filter, int MaxRecords, List<Guid> IDList)
|
|
{
|
|
return (WorkorderPMCustomList)DataPortal.Fetch(new Criteria(Filter, IDList, MaxRecords));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get all Items (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="WorkorderPMCustomList.WorkorderPMCustomListInfo"/> objects</returns>
|
|
public static WorkorderPMCustomList GetList(string xmlCriteria)
|
|
{
|
|
return (WorkorderPMCustomList)DataPortal.Fetch(new Criteria(xmlCriteria, null, -1));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Takes a single ID and returns a "list" of one object
|
|
/// </summary>
|
|
/// <param name="WorkorderItemID">ID of WorkorderItem object</param>
|
|
/// <returns>list of <see cref="WorkorderPMCustomList.WorkorderPMCustomListInfo"/> objects</returns>
|
|
public static WorkorderPMCustomList GetListForSingleItem(Guid WorkorderItemID)
|
|
{
|
|
//Case 556
|
|
List<Guid> l = new List<Guid>();
|
|
l.Add(WorkorderItemID);
|
|
return GetListFromIDList(l);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get list by items indicated in IDList
|
|
/// </summary>
|
|
/// <param name="IDList">Generic list of Guid's</param>
|
|
/// <returns>list of <see cref="WorkorderPMCustomList.WorkorderPMCustomListInfo"/> objects</returns>
|
|
public static WorkorderPMCustomList GetListFromIDList(List<Guid> IDList)
|
|
{
|
|
//case 556
|
|
//Handle empty list
|
|
if (IDList.Count == 0)
|
|
return new WorkorderPMCustomList();
|
|
return (WorkorderPMCustomList)DataPortal.Fetch(new Criteria("", IDList, -1));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return an empty list
|
|
/// used for initializing grid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static WorkorderPMCustomList GetEmptyList()
|
|
{
|
|
return new WorkorderPMCustomList();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param name="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
//case 799
|
|
|
|
////Users
|
|
//UserPickList users = UserPickList.GetList();
|
|
|
|
Criteria crit = (Criteria)Criteria;
|
|
DateTime dtNow = DBUtil.CurrentWorkingDateTime;
|
|
SafeDataReader dr = null;
|
|
try
|
|
{
|
|
DBCommandWrapper cm = null;
|
|
//Base query
|
|
string q =
|
|
//***********************************************************************************************************
|
|
"SELECT ~MAXRECS~ ACLIENT.aName AS aClientName, ACLIENT.aID " +
|
|
"AS aClientID, aWorkorder.aInternalReferenceNumber, " +
|
|
" aWorkorder.aCustomerReferenceNumber, " +
|
|
" aProject.aName AS aProjectName, aProject.aID " +
|
|
"AS aProjectID, aRegion.aName AS aRegionName, " +
|
|
" aRegion.aID AS aRegionID, aWorkorder.aOnsite, " +
|
|
" aWorkorder.aClosed, aWorkorder.aServiceCompleted, " +
|
|
" aWorkorder.aCustomerContactName, " +
|
|
" aWorkorder.aSummary, aWorkorderCategory.aName " +
|
|
"AS aWorkorderCategoryName, aWorkorderCategory.aID " +
|
|
"AS aWorkorderCategoryID, aWorkorder.aFromPMID, " +
|
|
" aWorkorder.aFromQuoteID, ACLIENT.aDispatchZoneID, " +
|
|
" aDispatchZone.aName AS aDispatchZoneName, " +
|
|
" ACLIENT.aClientGroupID, aClientGroup.aName " +
|
|
"AS aClientGroupName, AWORKORDERITEM.aSummary " +
|
|
"AS aWORKORDERITEMSUMMARY, AWORKORDERITEM.aTypeID, " +
|
|
" aWorkorderItemType.aName " +
|
|
"AS aTypeName, AWORKORDERITEM.aRequestDate, aPriority.aName " +
|
|
"AS aPriorityName, AWORKORDERITEM.aPriorityID, " +
|
|
" AWORKORDERITEM.aWorkorderStatusID " +
|
|
"AS aWorkorderItemStatusID, aWorkorderItemStatus.aName " +
|
|
"AS aWorkorderItemStatusName, aWorkorderItemStatus.aargb AS aWIARGB, AWORKORDERITEM.aUnitID, " +//Case 40
|
|
" aUnitModel.aName AS aUnitModelName, aUnitModel.aModelNumber, " + //Case 139
|
|
" aUnitModelVendor.aName AS aUnitVendorName, " +
|
|
" aUnit.aSerial, AUNIT.ADESCRIPTION AS AUNITDESCRIPTION, aUnit.aUnitModelID, AWORKORDERITEM.aWorkorderItemUnitServiceTypeID, " +
|
|
" " +
|
|
"aUnitServiceType.aName AS aWIUnitServiceTypeName, " +
|
|
" AWORKORDERITEM.aTechNotes, AWORKORDERITEM.aWarrantyService, " +
|
|
" AWORKORDERITEM.aID AS " +
|
|
"aWorkorderItemID, aWorkorderPreventiveMaintenance.aCreated, " +
|
|
" aWorkorderPreventiveMaintenance.aStopGeneratingDate, " +
|
|
" aWorkorderPreventiveMaintenance.aDayOfTheWeek, " +
|
|
" aWorkorderPreventiveMaintenance.AACTIVE, " +
|
|
" aWorkorderPreventiveMaintenance.aPreventiveMaintenanceNumber, " +
|
|
" aWorkorderPreventiveMaintenance.aNextServiceDate, " +
|
|
" aWorkorderPreventiveMaintenance.aGenerateSpan, " +
|
|
" aWorkorderPreventiveMaintenance.aGenerateSpanUnit, " +
|
|
" aWorkorderPreventiveMaintenance.aThresholdSpan, " +
|
|
" aWorkorderPreventiveMaintenance.aThresholdSpanUnit, " +
|
|
" aWorkorderStatus.aName AS aWorkorderStatusName, " +
|
|
" aWorkorderStatus.AARGB, aWorkorderPreventiveMaintenance.aWorkorderID, " +
|
|
" AWORKORDERITEM.aCustom1, " +
|
|
" AWORKORDERITEM.aCustom3, AWORKORDERITEM.aCustom2, " +
|
|
" AWORKORDERITEM.aCustom4, " +
|
|
" AWORKORDERITEM.aCustom5, AWORKORDERITEM.aCustom6, " +
|
|
" AWORKORDERITEM.aCustom7, AWORKORDERITEM.aCustom9, " +
|
|
" AWORKORDERITEM.aCustom8, " +
|
|
" AWORKORDERITEM.aCustom0 " +
|
|
|
|
"FROM " +
|
|
" AWORKORDER " +
|
|
" LEFT OUTER JOIN AWORKORDERITEM ON (AWORKORDER.AID=AWORKORDERITEM.AWORKORDERID) " +
|
|
" LEFT OUTER JOIN AWORKORDERITEMOUTSIDESERVICE ON (AWORKORDERITEM.AID=AWORKORDERITEMOUTSIDESERVICE.AWORKORDERITEMID) " +
|
|
" LEFT OUTER JOIN AWORKORDERSTATUS aWorkorderItemStatus ON (AWORKORDERITEM.AWORKORDERSTATUSID=aWorkorderItemStatus.AID) " +
|
|
" LEFT OUTER JOIN AVENDOR aVendorSentToTable ON (AWORKORDERITEMOUTSIDESERVICE.AVENDORSENTTOID=aVendorSentToTable.AID) " +
|
|
" LEFT OUTER JOIN AVENDOR aVendorSentViaTable ON (AWORKORDERITEMOUTSIDESERVICE.AVENDORSENTVIAID=aVendorSentViaTable.AID) " +
|
|
" LEFT OUTER JOIN APRIORITY ON (AWORKORDERITEM.APRIORITYID=APRIORITY.AID) " +
|
|
" LEFT OUTER JOIN AUNITSERVICETYPE ON (AWORKORDERITEM.AWORKORDERITEMUNITSERVICETYPEID=AUNITSERVICETYPE.AID) " +
|
|
" LEFT OUTER JOIN AWORKORDERITEMTYPE ON (AWORKORDERITEM.ATYPEID=AWORKORDERITEMTYPE.AID) " +
|
|
" LEFT OUTER JOIN AUNIT ON (AUNIT.AID=AWORKORDERITEM.AUNITID) " +
|
|
" LEFT OUTER JOIN AUNITMODEL ON (AUNIT.AUNITMODELID=AUNITMODEL.AID) " +
|
|
" LEFT OUTER JOIN AVENDOR aUnitModelVendor ON (AUNITMODEL.AVENDORID=aUnitModelVendor.AID) " +
|
|
//" LEFT OUTER JOIN AREGION ON (ACLIENT.AREGIONID=AREGION.AID) " +
|
|
" LEFT OUTER JOIN AWORKORDERCATEGORY ON (AWORKORDER.AWORKORDERCATEGORYID=AWORKORDERCATEGORY.AID) " +
|
|
" LEFT OUTER JOIN APROJECT ON (AWORKORDER.APROJECTID=APROJECT.AID) " +
|
|
" INNER JOIN aWorkorderPreventiveMaintenance ON (aWorkorderPreventiveMaintenance.AWORKORDERID=AWORKORDER.AID) " +
|
|
" LEFT OUTER JOIN aWorkorderStatus ON (aWorkorderStatus.aID = aWorkorderPreventiveMaintenance.aWorkorderStatusID) " +
|
|
" LEFT OUTER JOIN ACLIENT ON (AWORKORDER.ACLIENTID=ACLIENT.AID) " +
|
|
" LEFT OUTER JOIN AREGION ON (ACLIENT.AREGIONID=AREGION.AID) " +//Changed:16-June-2006 Moved here
|
|
" LEFT OUTER JOIN ADISPATCHZONE ON (ACLIENT.ADISPATCHZONEID=ADISPATCHZONE.AID) " +
|
|
" LEFT OUTER JOIN ACLIENTGROUP ON (ACLIENT.ACLIENTGROUPID=ACLIENTGROUP.AID) " +
|
|
|
|
|
|
|
|
"WHERE (aWorkorder.aWorkorderType = 2) "
|
|
|
|
//***********************************************************************************************************
|
|
;
|
|
|
|
if (crit.MaxRecords > 0)
|
|
q = q.Replace("~MAXRECS~", "TOP " + crit.MaxRecords.ToString());
|
|
else
|
|
q = q.Replace("~MAXRECS~", "");
|
|
|
|
|
|
|
|
//Built in order for reporting
|
|
string qOrderBy =
|
|
" aWorkorder.aID ";
|
|
|
|
if (crit.IDList != null)
|
|
{
|
|
//Case 556
|
|
System.Text.StringBuilder sbIN = new System.Text.StringBuilder();
|
|
sbIN.Append(" AND (aWorkorderItem.aID in (");
|
|
foreach (Guid gItem in crit.IDList)
|
|
{
|
|
sbIN.Append("'");
|
|
sbIN.Append("{");
|
|
sbIN.Append(gItem.ToString().ToUpperInvariant());
|
|
sbIN.Append("}");
|
|
sbIN.Append("',");
|
|
}
|
|
sbIN.Length = sbIN.Length - 1;
|
|
sbIN.Append(")) ");
|
|
|
|
//One item:
|
|
cm = DBUtil.DB.GetSqlStringCommandWrapper(q + sbIN.ToString() + " ORDER BY " + qOrderBy);
|
|
}
|
|
else
|
|
{
|
|
//Grid criteria
|
|
cm = DBUtil.DB.GetSqlStringCommandWrapper(DBUtil.AddRegionFilter(//case 58
|
|
q +
|
|
AyaBizUtils.GetGridColumnCriteria(crit.CriteriaXML,false) + " " +
|
|
AyaBizUtils.GetGridSortOrderColumns(crit.CriteriaXML) /*+ ", "+ qOrderBy*/
|
|
)
|
|
);
|
|
}
|
|
|
|
|
|
|
|
dr=new SafeDataReader(DBUtil.DB.ExecuteReader(cm));
|
|
|
|
|
|
while(dr.Read())
|
|
{
|
|
//*******************************************
|
|
WorkorderPMCustomListInfo info=new WorkorderPMCustomListInfo();
|
|
|
|
#region Workorder Service Level
|
|
info.mWorkorderID = dr.GetGuid("aWorkorderID");
|
|
|
|
//PM --------------------------
|
|
info.mWorkorder = new GridNameValueCellItem(
|
|
dr.GetGuid("aWorkorderID"),
|
|
dr.GetInt32("aPreventiveMaintenanceNumber").ToString(),
|
|
RootObjectTypes.Workorder);
|
|
|
|
|
|
info.mStopGeneratingDate = DBUtil.ToLocal(dr.GetSmartDate("aStopGeneratingDate"));
|
|
info.mNextServiceDate = DBUtil.ToLocal(dr.GetSmartDate("aNextServiceDate"));
|
|
info.mCreatedDate = DBUtil.ToLocal(dr.GetSmartDate("aCreated"));
|
|
info.mDayOfTheWeek = (AyaDayOfWeek)dr.GetInt16("aDayOfTheWeek");
|
|
info.mActive = dr.GetBoolean("AACTIVE");
|
|
info.mGenerateSpan = dr.GetInt32("aGenerateSpan");
|
|
info.mThresholdSpan = dr.GetInt32("aThresholdSpan");
|
|
info.mGenerateSpanUnit = (AyaUnitsOfTime)dr.GetInt16("aGenerateSpanUnit");
|
|
info.mThresholdSpanUnit = (AyaUnitsOfTime)dr.GetInt16("aThresholdSpanUnit");
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
info.mClient = new GridNameValueCellItem(
|
|
dr.GetGuid("aClientID"),
|
|
dr.GetString("aClientName"),
|
|
RootObjectTypes.Client);
|
|
|
|
info.mProject = new GridNameValueCellItem(
|
|
dr.GetGuid("aProjectID"),
|
|
dr.GetString("aProjectName"),
|
|
RootObjectTypes.Project);
|
|
|
|
info.mRegion = new GridNameValueCellItem(
|
|
dr.GetGuid("aRegionID"),
|
|
dr.GetString("aRegionName"),
|
|
RootObjectTypes.Region);
|
|
|
|
|
|
|
|
info.mCategory = new GridNameValueCellItem(
|
|
dr.GetGuid("aWorkorderCategoryID"),
|
|
dr.GetString("aWorkorderCategoryName"),
|
|
RootObjectTypes.WorkorderCategory);
|
|
|
|
|
|
|
|
info.mInternalReferenceNumber = dr.GetString("aInternalReferenceNumber");
|
|
info.mCustomerReferenceNumber = dr.GetString("aCustomerReferenceNumber");
|
|
info.mCustomerContactName = dr.GetString("aCustomerContactName");
|
|
info.mSummary = dr.GetString("aSummary");
|
|
|
|
|
|
info.mOnsite = dr.GetBoolean("aOnsite");
|
|
//info.mClosed = dr.GetBoolean("aClosed");
|
|
info.mServiceCompleted = dr.GetBoolean("aServiceCompleted");
|
|
|
|
info.mDispatchZone = new GridNameValueCellItem(
|
|
dr.GetGuid("aDispatchZoneID"),
|
|
dr.GetString("aDispatchZoneName"),
|
|
RootObjectTypes.DispatchZone);
|
|
|
|
info.mClientGroup = new GridNameValueCellItem(
|
|
dr.GetGuid("aClientGroupID"),
|
|
dr.GetString("aClientGroupName"),
|
|
RootObjectTypes.ClientGroup);
|
|
|
|
|
|
#endregion workorderservicelevel
|
|
|
|
|
|
#region WorkorderServiceWorkorderItemList Level
|
|
info.mWorkorderItemID = dr.GetGuid("aWorkorderItemID");
|
|
info.mWorkorderItemSummary = dr.GetString("aWORKORDERITEMSUMMARY");
|
|
info.mWorkorderItemType = new GridNameValueCellItem(
|
|
dr.GetGuid("aTypeID"),
|
|
dr.GetString("aTypeName"),
|
|
RootObjectTypes.WorkorderItemType);
|
|
|
|
info.mRequestDate = DBUtil.ToLocal(dr.GetSmartDate("aRequestDate"));
|
|
|
|
info.mPriority = new GridNameValueCellItem(
|
|
dr.GetGuid("aPriorityID"),
|
|
dr.GetString("aPriorityName"),
|
|
RootObjectTypes.Priority);
|
|
|
|
info.mWorkorderItemStatus = new GridNameValueCellItem(
|
|
dr.GetGuid("aWorkorderItemStatusID"),
|
|
dr.GetString("aWorkorderItemStatusName"),
|
|
RootObjectTypes.WorkorderStatus);
|
|
|
|
//Case 40
|
|
info.mWorkorderItemStatusARGB = dr.GetInt32("aWIARGB");
|
|
|
|
|
|
info.mSerial = new GridNameValueCellItem(
|
|
dr.GetGuid("aUnitID"),
|
|
Unit.UnitNameFormatter(dr.GetString("aModelNumber"), dr.GetString("aUnitModelName"), dr.GetString("aUnitVendorName"), dr.GetString("aSerial"),
|
|
dr.GetString("AUNITDESCRIPTION"), AyaBizUtils.GlobalSettings.DefaultUnitNameDisplayFormat),
|
|
RootObjectTypes.Unit);
|
|
|
|
//Case 139
|
|
//info.mUnitModel = new GridNameValueCellItem(
|
|
// dr.GetGuid("aUnitModelID"),
|
|
// dr.GetString("aUnitModelName"),
|
|
// RootObjectTypes.UnitModel);
|
|
|
|
info.mUnitModel = new GridNameValueCellItem(
|
|
dr.GetGuid("aUnitModelID"),
|
|
AyaBizUtils.SS("", dr.GetString("aUnitModelName"), " ") + dr.GetString("aModelNumber"),
|
|
RootObjectTypes.UnitModel);
|
|
|
|
|
|
info.mWorkorderItemUnitServiceType = new GridNameValueCellItem(
|
|
dr.GetGuid("aWorkorderItemUnitServiceTypeID"),
|
|
dr.GetString("aWIUnitServiceTypeName"),
|
|
RootObjectTypes.UnitServiceType);
|
|
|
|
|
|
|
|
info.mWarrantyService = dr.GetBoolean("aWarrantyService");
|
|
#endregion workorderserviceworkorderitemlist fields
|
|
|
|
#region WorkorderServiceWorkorderItemsListDetailed (custom fields) Level
|
|
info.mCustom0=dr.GetString("aCustom0");
|
|
info.mCustom1=dr.GetString("aCustom1");
|
|
info.mCustom2=dr.GetString("aCustom2");
|
|
info.mCustom3=dr.GetString("aCustom3");
|
|
info.mCustom4=dr.GetString("aCustom4");
|
|
info.mCustom5=dr.GetString("aCustom5");
|
|
info.mCustom6=dr.GetString("aCustom6");
|
|
info.mCustom7=dr.GetString("aCustom7");
|
|
info.mCustom8=dr.GetString("aCustom8");
|
|
info.mCustom9=dr.GetString("aCustom9");
|
|
#endregion workorderserviceworkorderitemslistdetailed (custom fields) level
|
|
|
|
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 Criteria(string _CriteriaXML, List<Guid> _IDList, int _MaxRecords)
|
|
{
|
|
CriteriaXML = _CriteriaXML;
|
|
IDList = _IDList;
|
|
MaxRecords = _MaxRecords;
|
|
}
|
|
}
|
|
#endregion
|
|
#pragma warning restore 1591
|
|
}//end WorkorderPMCustomList
|
|
|
|
}//end namespace GZTW.AyaNova.BLL |