99 lines
3.5 KiB
C#
99 lines
3.5 KiB
C#
using System.Collections.Generic;
|
|
using Newtonsoft.Json.Linq;
|
|
using AyaNova.Biz;
|
|
namespace AyaNova.DataList
|
|
{
|
|
internal class AttachmentDataList : AyaDataList
|
|
{
|
|
|
|
public AttachmentDataList()
|
|
{
|
|
DefaultListObjectType = AyaType.FileAttachment;
|
|
SQLFrom = "from afileattachment";
|
|
var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType);
|
|
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
|
|
|
//Default ListView
|
|
dynamic dlistView = new JArray();
|
|
|
|
dynamic cm = new JObject();
|
|
cm.fld = "displayfilename";
|
|
cm.sort = "+";
|
|
dlistView.Add(cm);
|
|
|
|
cm = new JObject();
|
|
cm.fld = "object";
|
|
dlistView.Add(cm);
|
|
|
|
cm = new JObject();
|
|
cm.fld = "size";
|
|
cm.sort = "-";
|
|
dlistView.Add(cm);
|
|
|
|
cm = new JObject();
|
|
cm.fld = "notes";
|
|
dlistView.Add(cm);
|
|
|
|
cm = new JObject();
|
|
cm.fld = "exists";
|
|
dlistView.Add(cm);
|
|
|
|
|
|
DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None);
|
|
|
|
|
|
|
|
//NOTE: Due to the join, all the sql id and name fields that can conflict with the joined (in this case User) table need to be specified completely
|
|
FieldDefinitions = new List<AyaDataListFieldDefinition>();
|
|
//DPRECATED FieldDefinitions.Add(new AyaDataListFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.User, SqlIdColumnName = "auser.id" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "FileAttachment",
|
|
FieldKey = "displayfilename",
|
|
AyaObjectType = (int)AyaType.FileAttachment,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "afileattachment.id",
|
|
SqlValueColumnName = "afileattachment.displayfilename",
|
|
IsRowId = true
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "AttachmentExists",
|
|
FieldKey = "exists",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "afileattachment.exists"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "Object",
|
|
FieldKey = "object",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "afileattachment.AttachToObjectid",
|
|
SqlValueColumnName = "AYGETNAME(afileattachment.AttachToObjectid, afileattachment.attachtoobjecttype)",
|
|
SqlAyTypeColumnName = "afileattachment.attachtoobjecttype"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "FileSize",
|
|
FieldKey = "size",
|
|
UiFieldDataType = (int)UiFieldDataType.MemorySize,
|
|
SqlValueColumnName = "afileattachment.size"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "AttachmentNotes",
|
|
FieldKey = "notes",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "afileattachment.notes"
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}//eoc
|
|
}//eons |