60 lines
1.9 KiB
C#
60 lines
1.9 KiB
C#
using AyaNova.Biz;
|
|
using AyaNova.DataList;
|
|
using System.Collections.Generic;
|
|
|
|
namespace AyaNova.KPI
|
|
{
|
|
internal class CSROpenList : IAyaKPI
|
|
{
|
|
private string _metaQuery = null;
|
|
private string _dataQuery = null;
|
|
private string _errorMessage = null;
|
|
|
|
public AuthorizationRoles AllowedRoles
|
|
{
|
|
get =>
|
|
AuthorizationRoles.BizAdmin |
|
|
AuthorizationRoles.BizAdminRestricted |
|
|
AuthorizationRoles.ServiceRestricted |
|
|
AuthorizationRoles.Service |
|
|
AuthorizationRoles.Tech |
|
|
AuthorizationRoles.TechRestricted;
|
|
}
|
|
|
|
public string MetaQuery => _metaQuery;
|
|
public string DataQuery => _dataQuery;
|
|
public string ErrorMessage => _errorMessage;
|
|
|
|
public void BuildQuery(KPIRequestOptions options, long userId)
|
|
{
|
|
//build data and meta queries
|
|
var custtags = options.Criteria["custtags"].ToObject<List<string>>();
|
|
|
|
//optional tags
|
|
string custTagsWhere = null;
|
|
if (custtags.Count > 0)
|
|
custTagsWhere = " AND " + DataListSqlFilterCriteriaBuilder.TagDataFilterToColumnCriteria("acustomer.tags", DataListFilterComparisonOperator.Contains, string.Join(",", custtags));
|
|
|
|
|
|
|
|
|
|
_dataQuery = @$"SELECT row_to_json(t) as res from (
|
|
SELECT ACUSTOMERSERVICEREQUEST.DATEREQUESTED,
|
|
ACUSTOMER.NAME AS CUSTOMERNAME,
|
|
ACUSTOMERSERVICEREQUEST.NAME AS CSRNAME,
|
|
ACUSTOMERSERVICEREQUEST.ID,
|
|
ACUSTOMERSERVICEREQUEST.PRIORITY
|
|
FROM ACUSTOMERSERVICEREQUEST
|
|
LEFT JOIN ACUSTOMER ON (ACUSTOMERSERVICEREQUEST.CUSTOMERID = ACUSTOMER.ID)
|
|
WHERE (ACUSTOMERSERVICEREQUEST.STATUS = 0) {custTagsWhere}
|
|
ORDER BY ACUSTOMERSERVICEREQUEST.DATEREQUESTED ASC
|
|
) t";
|
|
_metaQuery = string.Empty;
|
|
// @"SELECT row_to_json(t) as res from (
|
|
// select name from auser where id = 10
|
|
// ) t";
|
|
}
|
|
|
|
|
|
}//eoc
|
|
}//eons |