206 lines
8.8 KiB
C#
206 lines
8.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using AyaNova.Biz;
|
|
using AyaNova.Models;
|
|
|
|
namespace AyaNova.DataList
|
|
{
|
|
internal class CustomerWorkOrderDataList : DataListProcessingBase, IDataListInternalCriteria
|
|
{
|
|
//CUSTOMER VERSION
|
|
public CustomerWorkOrderDataList(long translationId)
|
|
{
|
|
DefaultListAType = AyaType.CustomerServiceRequest;
|
|
SQLFrom = "from acustomerservicerequest " +
|
|
"left join acustomer on (acustomerservicerequest.customerid=acustomer.id) " +
|
|
"left join aheadoffice on (acustomer.headofficeid=aheadoffice.id) " +
|
|
"left join auser on (acustomerservicerequest.requestedbyuserid=auser.id) " +
|
|
"left join aunit on (acustomerservicerequest.unitid = aunit.id) " +
|
|
"left join aworkorderitem as wi on (acustomerservicerequest.workorderitemid=wi.id) " +
|
|
"left join aworkorder as w on (wi.workorderid=w.id)";
|
|
var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
|
|
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
|
DefaultColumns = new List<string>() { "Created", "Customer", "CustomerServiceRequestTitle", "CustomerServiceRequestPriority", "CustomerServiceRequestStatus", "CustomerServiceRequestItemUnitID", "WorkOrder" };
|
|
DefaultSortBy = new Dictionary<string, string>() { { "Created", "-" } };
|
|
|
|
FieldDefinitions = new List<DataListFieldDefinition>();
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "CustomerServiceRequestTitle",
|
|
FieldKey = "CustomerServiceRequestTitle",
|
|
AType = (int)AyaType.CustomerServiceRequest,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "acustomerservicerequest.id",
|
|
SqlValueColumnName = "acustomerservicerequest.name",
|
|
IsRowId = true
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "CustomerServiceRequestDetails",
|
|
FieldKey = "CustomerServiceRequestDetails",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "acustomerservicerequest.notes"
|
|
});
|
|
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "Created",
|
|
FieldKey = "Created",
|
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
SqlValueColumnName = "acustomerservicerequest.daterequested"
|
|
});
|
|
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "Customer",
|
|
TKey = "Customer",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "acustomer.name"
|
|
});
|
|
|
|
//Openable unit in case decide to allow customers to open a unit record of some kind
|
|
// FieldDefinitions.Add(new DataListFieldDefinition
|
|
// {
|
|
// FieldKey = "CustomerServiceRequestItemUnitID",
|
|
// TKey = "CustomerServiceRequestItemUnitID",
|
|
// UiFieldDataType = (int)UiFieldDataType.Text,
|
|
// AType = (int)AyaType.Unit,
|
|
// SqlIdColumnName = "aunit.id",
|
|
// SqlValueColumnName = "aunit.serial"
|
|
// });
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "CustomerServiceRequestItemUnitID",
|
|
TKey = "CustomerServiceRequestItemUnitID",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aunit.serial"
|
|
});
|
|
|
|
|
|
//Openable version for future consideration
|
|
// FieldDefinitions.Add(new DataListFieldDefinition
|
|
// {
|
|
// FieldKey = "WorkOrder",
|
|
// TKey = "WorkOrder",
|
|
// UiFieldDataType = (int)UiFieldDataType.Text,
|
|
// AType = (int)AyaType.WorkOrderItem,
|
|
// SqlIdColumnName = "wi.id",
|
|
// SqlValueColumnName = "w.serial"
|
|
// });
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "WorkOrder",
|
|
TKey = "WorkOrder",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "w.serial"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "CustomerServiceRequestRequestedBy",
|
|
TKey = "CustomerServiceRequestRequestedBy",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "auser.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "CustomerServiceRequestCustomerReferenceNumber",
|
|
FieldKey = "CustomerServiceRequestCustomerReferenceNumber",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "acustomerservicerequest.customerreferencenumber"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "CustomerServiceRequestStatus",
|
|
FieldKey = "CustomerServiceRequestStatus",
|
|
UiFieldDataType = (int)UiFieldDataType.Enum,
|
|
EnumType = AyaNova.Util.StringUtil.TrimTypeName(typeof(CustomerServiceRequestStatus).ToString()),
|
|
SqlValueColumnName = "acustomerservicerequest.status"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "CustomerServiceRequestPriority",
|
|
FieldKey = "CustomerServiceRequestPriority",
|
|
UiFieldDataType = (int)UiFieldDataType.Enum,
|
|
EnumType = AyaNova.Util.StringUtil.TrimTypeName(typeof(CustomerServiceRequestPriority).ToString()),
|
|
SqlValueColumnName = "acustomerservicerequest.priority"
|
|
});
|
|
|
|
|
|
//-----------
|
|
|
|
|
|
//META COLUMNS
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "metacustomer",
|
|
UiFieldDataType = (int)UiFieldDataType.InternalId,
|
|
SqlIdColumnName = "acustomer.id",
|
|
SqlValueColumnName = "acustomer.id",
|
|
IsMeta = true
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "metaheadoffice",
|
|
UiFieldDataType = (int)UiFieldDataType.InternalId,
|
|
SqlIdColumnName = "aheadoffice.id",
|
|
SqlValueColumnName = "aheadoffice.id",
|
|
IsMeta = true
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
public List<DataListFilterOption> DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria)
|
|
{
|
|
List<DataListFilterOption> ret = new List<DataListFilterOption>();
|
|
|
|
//ClientCriteria format for this list is "OBJECTID,AYATYPE"
|
|
var crit = (clientCriteria ?? "").Split(',').Select(z => z.Trim()).ToArray();
|
|
if (crit.Length > 1)
|
|
{
|
|
|
|
int nType = 0;
|
|
if (!int.TryParse(crit[1], out nType)) return ret;
|
|
AyaType forType = (AyaType)nType;
|
|
if (forType != AyaType.Customer && forType != AyaType.HeadOffice) return ret;
|
|
|
|
long lId = 0;
|
|
if (!long.TryParse(crit[0], out lId)) return ret;
|
|
if (lId == 0) return ret;
|
|
|
|
//Have valid type, have an id, so filter away
|
|
switch (forType)
|
|
{
|
|
case AyaType.Customer:
|
|
{
|
|
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metacustomer" };
|
|
FilterOption.Items.Add(new DataListColumnFilter() { value = crit[0], op = DataListFilterComparisonOperator.Equality });
|
|
ret.Add(FilterOption);
|
|
}
|
|
break;
|
|
case AyaType.HeadOffice:
|
|
{
|
|
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metaheadoffice" };
|
|
FilterOption.Items.Add(new DataListColumnFilter() { value = crit[0], op = DataListFilterComparisonOperator.Equality });
|
|
ret.Add(FilterOption);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
}//eoc
|
|
}//eons |