using System; using System.Collections.Generic; namespace HRM.BO { /// /// Common virtual-scrolling grid ("virtual grid") contracts. /// /// Every large list screen shares ONE BO / DA / Service / Controller: a screen is just a registered /// grid definition (HRM.DA/Service/VirtualGrid/Definitions) identified by . /// The server pages, sorts, searches and exports; the browser only ever holds one window of rows. /// See HRM.DA/Service/VirtualGrid/README.md for how to add a grid. /// public enum EnumVirtualGridColumnType { Text = 1, Number = 2, Money = 3, Date = 4, DateTime = 5 } /// A column as the screen sees it (from the layout endpoint). public class VirtualGridColumnInfo { public string Field { get; set; } public string Title { get; set; } public int Width { get; set; } public EnumVirtualGridColumnType Type { get; set; } public bool Sortable { get; set; } } /// Everything the screen needs to draw an empty grid before any data is requested. public class VirtualGridLayout { public string GridKey { get; set; } public string Title { get; set; } public string DefaultSortField { get; set; } public string DefaultSortDir { get; set; } public int MaxPageSize { get; set; } public List Columns { get; set; } = new List(); } /// One window request: which grid, its filters, and the grid's skip/take, sort and search. public class VirtualGridRequest { public string GridKey { get; set; } /// /// Screen-specific filters (e.g. fromDate / toDate as "yyyy-MM-dd"). Each grid definition reads and /// validates the ones it needs; values are never spliced into SQL. /// public Dictionary Filters { get; set; } = new Dictionary(); public int Skip { get; set; } public int Take { get; set; } = 100; public string Search { get; set; } public string SortField { get; set; } public string SortDir { get; set; } /// /// True on Preview: reload the data instead of using the copy kept in server memory (list grids). /// Scrolling, sorting and searching send false and are answered from that copy. /// public bool Refresh { get; set; } } /// Excel export: the same request plus the grid's visible columns, in order. public class VirtualGridExportRequest : VirtualGridRequest { /// Fields of the columns to export, in grid order. Empty = every column of the grid. public List Fields { get; set; } = new List(); } public class VirtualGridPage { /// Rows matching the filters and the search. public int Total { get; set; } /// Rows matching the filters alone (equals Total when there is no search). public int TotalWithoutSearch { get; set; } /// One row per entry, keyed by column field. Values are raw (dates, numbers); the screen formats them. public List> Data { get; set; } = new List>(); } /// A generated file (Excel export). public class VirtualGridFile { public string FileName { get; set; } public string ContentType { get; set; } public byte[] Content { get; set; } } /// The signed-in user, as the grid definitions need it for scoping (payroll type) and access. public class VirtualGridContext { public int UserID { get; set; } public int? EmployeeID { get; set; } public int? PayrollTypeID { get; set; } public EnumUserType UserType { get; set; } } public interface IVirtualGridService { VirtualGridLayout GetLayout(string gridKey, VirtualGridContext context); VirtualGridPage GetPage(VirtualGridRequest request, VirtualGridContext context); VirtualGridFile ExportExcel(VirtualGridExportRequest request, VirtualGridContext context); } }