126 lines
5.3 KiB
C#
126 lines
5.3 KiB
C#
using System.Collections.Generic;
|
|
using AyaNova.Models;
|
|
using AyaNova.Biz;
|
|
namespace AyaNova.DataList
|
|
{
|
|
internal class OutsideUserDataList : DataListProcessingBase, IDataListInternalCriteria
|
|
{
|
|
|
|
public OutsideUserDataList()
|
|
{
|
|
DefaultListAType = AyaType.Customer;
|
|
SQLFrom = "from auser left join aheadoffice on (auser.headofficeid=aheadoffice.id) left join acustomer on (auser.customerid=acustomer.id)";
|
|
var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
|
|
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
|
DefaultColumns = new List<string>() { "name", "active", "usercustomer", "userheadoffice", "lastlogin" };
|
|
DefaultSortBy = new Dictionary<string, string>() { { "name", "+" } };
|
|
|
|
FieldDefinitions = new List<DataListFieldDefinition>();
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "User",
|
|
FieldKey = "name",
|
|
AType = (int)AyaType.User,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "auser.id",
|
|
SqlValueColumnName = "auser.name",
|
|
IsRowId = true
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UserEmployeeNumber",
|
|
FieldKey = "employeenumber",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "auser.employeenumber"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "Active",
|
|
FieldKey = "active",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "auser.active"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UserType",
|
|
FieldKey = "usertype",
|
|
UiFieldDataType = (int)UiFieldDataType.Enum,
|
|
EnumType = AyaNova.Util.StringUtil.TrimTypeName(typeof(UserType).ToString()),
|
|
SqlValueColumnName = "auser.usertype"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "AuthorizationRoles",
|
|
FieldKey = "roles",
|
|
UiFieldDataType = (int)UiFieldDataType.Roles,
|
|
//NOTE: not technically an enum list but this will trigger datagrid at client to fetch roles for special handling
|
|
EnumType = AyaNova.Util.StringUtil.TrimTypeName(typeof(AuthorizationRoles).ToString()),
|
|
SqlValueColumnName = "auser.roles"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "LastLogin",
|
|
FieldKey = "lastlogin",
|
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
SqlValueColumnName = "auser.lastlogin"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "HeadOffice",
|
|
FieldKey = "userheadoffice",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AType = (int)AyaType.HeadOffice,
|
|
SqlIdColumnName = "aheadoffice.id",
|
|
SqlValueColumnName = "aheadoffice.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "Customer",
|
|
FieldKey = "usercustomer",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AType = (int)AyaType.Customer,
|
|
SqlIdColumnName = "acustomer.id",
|
|
SqlValueColumnName = "acustomer.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "AuthTwoFactor",
|
|
FieldKey = "AuthTwoFactor",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "auser.twofactorenabled"
|
|
});
|
|
|
|
//META COLUMNS
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "metausertype",
|
|
UiFieldDataType = (int)UiFieldDataType.Enum,
|
|
EnumType = AyaNova.Util.StringUtil.TrimTypeName(typeof(UserType).ToString()),
|
|
SqlValueColumnName = "auser.usertype",
|
|
IsMeta = true
|
|
});
|
|
}
|
|
|
|
public List<DataListFilterOption> DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria)
|
|
{
|
|
List<DataListFilterOption> ret = new List<DataListFilterOption>();
|
|
|
|
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metausertype" };
|
|
FilterOption.Any = true;
|
|
FilterOption.Items.Add(new DataListColumnFilter() { value = ((int)UserType.Customer).ToString(), op = DataListFilterComparisonOperator.Equality });
|
|
FilterOption.Items.Add(new DataListColumnFilter() { value = ((int)UserType.HeadOffice).ToString(), op = DataListFilterComparisonOperator.Equality });
|
|
|
|
ret.Add(FilterOption);
|
|
return ret;
|
|
}
|
|
|
|
}//eoc
|
|
}//eons |