This commit is contained in:
58
server/AyaNova/DataList/AyaDataList.cs
Normal file
58
server/AyaNova/DataList/AyaDataList.cs
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Immutable;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using AyaNova.Biz;
|
||||||
|
|
||||||
|
namespace AyaNova.DataList
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DataList object base class
|
||||||
|
/// </summary>
|
||||||
|
internal abstract class AyaDataList : IAyaDataList
|
||||||
|
{
|
||||||
|
|
||||||
|
internal AyaDataList()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// private string _listKey = string.Empty;
|
||||||
|
// public string ListKey
|
||||||
|
// {
|
||||||
|
// get
|
||||||
|
// {
|
||||||
|
// return _listKey;
|
||||||
|
// }
|
||||||
|
// set
|
||||||
|
// {
|
||||||
|
// _listKey = value;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//private readonly string _sqlFrom = string.Empty;
|
||||||
|
public string SQLFrom { get; set; }
|
||||||
|
|
||||||
|
// private readonly List<AyaDataListFieldDefinition> _fieldDefinitions = new List<AyaDataListFieldDefinition>();
|
||||||
|
public List<AyaDataListFieldDefinition> FieldDefinitions { get; set; }
|
||||||
|
|
||||||
|
public AuthorizationRoles AllowedRoles { get; set; }
|
||||||
|
|
||||||
|
public AyaType DefaultListObjectType { get; set; }
|
||||||
|
|
||||||
|
public string ListKey { get; set; }
|
||||||
|
|
||||||
|
public string GenerateMINIListColumnsJSON()
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GenerateListColumnsJSONFromTemplate(string template)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}//eoc
|
||||||
|
|
||||||
|
}//eons
|
||||||
@@ -5,19 +5,23 @@ namespace AyaNova.DataList
|
|||||||
internal interface IAyaDataList
|
internal interface IAyaDataList
|
||||||
{
|
{
|
||||||
//Unique key to identify this list
|
//Unique key to identify this list
|
||||||
string ListKey { get; }
|
string ListKey { get; set; }
|
||||||
|
|
||||||
//sql query from fragment with table joins et
|
//sql query from fragment with table joins et
|
||||||
string SQLFrom { get; }
|
string SQLFrom { get; set; }
|
||||||
|
|
||||||
//List of fields for this object
|
//List of fields for this object
|
||||||
List<AyaDataListFieldDefinition> FieldDefinitions { get; }
|
List<AyaDataListFieldDefinition> FieldDefinitions { get; set; }
|
||||||
|
|
||||||
//allowed roles to access this list
|
//allowed roles to access this list
|
||||||
AuthorizationRoles AllowedRoles { get; }
|
AuthorizationRoles AllowedRoles { get; set; }
|
||||||
|
|
||||||
//Default object type to open for rows of this list (use no object if no)
|
//Default object type to open for rows of this list (use no object if no)
|
||||||
AyaType DefaultListObjectType { get; }
|
AyaType DefaultListObjectType { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
string GenerateMINIListColumnsJSON();
|
||||||
|
string GenerateListColumnsJSONFromTemplate(string template);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ using System.Collections.Generic;
|
|||||||
using AyaNova.Biz;
|
using AyaNova.Biz;
|
||||||
namespace AyaNova.DataList
|
namespace AyaNova.DataList
|
||||||
{
|
{
|
||||||
internal class TestWidgetUserEmailDataList : IAyaDataList
|
internal class TestWidgetUserEmailDataList : AyaDataList
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Select awidget.id, awidget.name, auser.name, auser.id, auseroptions.emailaddress
|
Select awidget.id, awidget.name, auser.name, auser.id, auseroptions.emailaddress
|
||||||
@@ -11,55 +11,49 @@ namespace AyaNova.DataList
|
|||||||
left outer join auseroptions on (auser.id=auseroptions.userid)
|
left outer join auseroptions on (auser.id=auseroptions.userid)
|
||||||
order by auseroptions.emailaddress desc
|
order by auseroptions.emailaddress desc
|
||||||
*/
|
*/
|
||||||
public string ListKey => nameof(TestWidgetUserEmailDataList);
|
|
||||||
|
|
||||||
public string SQLFrom => "from awidget left outer join auser on (awidget.userid=auser.id) left outer join auseroptions on (auser.id=auseroptions.userid)";
|
|
||||||
|
|
||||||
public List<AyaDataListFieldDefinition> FieldDefinitions
|
public TestWidgetUserEmailDataList()
|
||||||
{
|
{
|
||||||
get
|
ListKey = nameof(TestWidgetUserEmailDataList);
|
||||||
|
SQLFrom = "from awidget left outer join auser on (awidget.userid=auser.id) left outer join auseroptions on (auser.id=auseroptions.userid)";
|
||||||
|
AllowedRoles = AuthorizationRoles.AllInternalStaff;//anyone but clients and subcontractors (just for test)
|
||||||
|
DefaultListObjectType = AyaType.Widget;
|
||||||
|
|
||||||
|
FieldDefinitions = new List<AyaDataListFieldDefinition>();
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.Widget, SqlIdColumnName = "awidget.id" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
{
|
{
|
||||||
List<AyaDataListFieldDefinition> l = new List<AyaDataListFieldDefinition>();
|
FieldKey = "widgetname",
|
||||||
l.Add(new AyaDataListFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.Widget, SqlIdColumnName = "awidget.id" });
|
LtKey = "WidgetName",
|
||||||
l.Add(new AyaDataListFieldDefinition
|
UiFieldDataType = (int)AyaUiFieldDataType.Text,
|
||||||
{
|
AyaObjectType = (int)AyaType.Widget,
|
||||||
FieldKey = "widgetname",
|
SqlIdColumnName = "awidget.id",
|
||||||
LtKey = "WidgetName",
|
SqlValueColumnName = "awidget.name"
|
||||||
UiFieldDataType = (int)AyaUiFieldDataType.Text,
|
});
|
||||||
AyaObjectType = (int)AyaType.Widget,
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
SqlIdColumnName = "awidget.id",
|
{
|
||||||
SqlValueColumnName = "awidget.name"
|
FieldKey = "username",
|
||||||
});
|
LtKey = "User",
|
||||||
l.Add(new AyaDataListFieldDefinition
|
UiFieldDataType = (int)AyaUiFieldDataType.Text,
|
||||||
{
|
AyaObjectType = (int)AyaType.User,
|
||||||
FieldKey = "username",
|
SqlIdColumnName = "auser.id",
|
||||||
LtKey = "User",
|
SqlValueColumnName = "auser.name"
|
||||||
UiFieldDataType = (int)AyaUiFieldDataType.Text,
|
});
|
||||||
AyaObjectType = (int)AyaType.User,
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
SqlIdColumnName = "auser.id",
|
{
|
||||||
SqlValueColumnName = "auser.name"
|
LtKey = "UserEmailAddress",
|
||||||
});
|
FieldKey = "emailaddress",
|
||||||
l.Add(new AyaDataListFieldDefinition
|
SqlValueColumnName = "auseroptions.emailaddress",
|
||||||
{
|
UiFieldDataType = (int)AyaUiFieldDataType.EmailAddress
|
||||||
LtKey = "UserEmailAddress",
|
});
|
||||||
FieldKey = "emailaddress",
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
SqlValueColumnName = "auseroptions.emailaddress",
|
{
|
||||||
UiFieldDataType = (int)AyaUiFieldDataType.EmailAddress
|
LtKey = "Active",
|
||||||
});
|
FieldKey = "widgetactive",
|
||||||
l.Add(new AyaDataListFieldDefinition
|
SqlValueColumnName = "awidget.active",
|
||||||
{
|
UiFieldDataType = (int)AyaUiFieldDataType.Bool
|
||||||
LtKey = "Active",
|
});
|
||||||
FieldKey = "widgetactive",
|
|
||||||
SqlValueColumnName = "awidget.active",
|
|
||||||
UiFieldDataType = (int)AyaUiFieldDataType.Bool
|
|
||||||
});
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}//eoc
|
||||||
public AuthorizationRoles AllowedRoles => AuthorizationRoles.AllInternalStaff;//anyone but clients and subcontractors (just for test)
|
}//eons
|
||||||
public AyaType DefaultListObjectType => AyaType.Widget;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -467,7 +467,7 @@ namespace AyaNova.Biz
|
|||||||
qWhere = DataListSqlFilterCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, DataList.FieldDefinitions, UserId);
|
qWhere = DataListSqlFilterCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, DataList.FieldDefinitions, UserId);
|
||||||
//ORDER BY CLAUSE - SORT
|
//ORDER BY CLAUSE - SORT
|
||||||
//BUILD ORDER BY AND APPEND IT
|
//BUILD ORDER BY AND APPEND IT
|
||||||
qOrderBy = SqlFilterOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);
|
qOrderBy = DataListSqlFilterOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
//LIMIT AND OFFSET CLAUSE - PAGING
|
//LIMIT AND OFFSET CLAUSE - PAGING
|
||||||
|
|||||||
Reference in New Issue
Block a user