From 80fbfcbd319a633859dd8a2a84a45cabc2d5616c Mon Sep 17 00:00:00 2001 From: natalie beatty Date: Mon, 10 Aug 2026 11:52:45 -0400 Subject: [PATCH] switch ModelController PagedSearch overrides to derive RecordsPerPage from PageSize --- .../Controllers/OpenXDA/Assets/OpenXDAAssetController.cs | 6 +++--- .../OpenXDA/Meters/OpenXDAMeterConfigurationController.cs | 4 ++-- .../Controllers/OpenXDA/OpenXDAControllers.cs | 2 +- .../Controllers/OpenXDA/OpenXDALocationController.cs | 8 ++++---- .../Controllers/SystemCenter/SystemCenterController.cs | 2 +- Source/Applications/SystemCenter/Model/DataFile.cs | 6 +++--- .../Applications/SystemCenter/Model/DeviceHealthReport.cs | 3 +-- Source/Applications/SystemCenter/Model/Node.cs | 2 +- .../SystemCenter/Model/Security/SecurityGroup.cs | 2 +- .../SystemCenter/Model/Security/UserAccount.cs | 2 +- .../Controllers/EmailTypeController.cs | 2 +- 11 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Source/Applications/SystemCenter/Controllers/OpenXDA/Assets/OpenXDAAssetController.cs b/Source/Applications/SystemCenter/Controllers/OpenXDA/Assets/OpenXDAAssetController.cs index 3779cb0198..0edc75bf6b 100644 --- a/Source/Applications/SystemCenter/Controllers/OpenXDA/Assets/OpenXDAAssetController.cs +++ b/Source/Applications/SystemCenter/Controllers/OpenXDA/Assets/OpenXDAAssetController.cs @@ -71,7 +71,7 @@ public IHttpActionResult GetAssetLocationsPaged([FromBody] PostData postData, [F if (!GetAuthCheck()) return Unauthorized(); - int recordsPerPage = Take ?? 50; + int recordsPerPage = PageSize ?? 50; PagedResults results = new PagedResults(); @@ -164,7 +164,7 @@ public IHttpActionResult GetAssetMetersPaged([FromBody] PostData postData, [From { try { - int recordsPerPage = Take ?? 50; + int recordsPerPage = PageSize ?? 50; string[] sortFields = { "AssetKey", "Name", "Make", "Model" }; @@ -204,7 +204,7 @@ public IHttpActionResult GetAssetAssetConnections([FromBody] PostData postData, { try { - int recordsPerPage = Take ?? 50; + int recordsPerPage = PageSize ?? 50; string[] sortFields = { "AssetName", "AssetKey", "Name" }; diff --git a/Source/Applications/SystemCenter/Controllers/OpenXDA/Meters/OpenXDAMeterConfigurationController.cs b/Source/Applications/SystemCenter/Controllers/OpenXDA/Meters/OpenXDAMeterConfigurationController.cs index 2e07048530..bbfe79f3fd 100644 --- a/Source/Applications/SystemCenter/Controllers/OpenXDA/Meters/OpenXDAMeterConfigurationController.cs +++ b/Source/Applications/SystemCenter/Controllers/OpenXDA/Meters/OpenXDAMeterConfigurationController.cs @@ -45,7 +45,7 @@ public class OpenXDAMeterConfigurationController : ModelController param = new(); diff --git a/Source/Applications/SystemCenter/Controllers/OpenXDA/OpenXDALocationController.cs b/Source/Applications/SystemCenter/Controllers/OpenXDA/OpenXDALocationController.cs index 9038b85caf..bc943e78cc 100644 --- a/Source/Applications/SystemCenter/Controllers/OpenXDA/OpenXDALocationController.cs +++ b/Source/Applications/SystemCenter/Controllers/OpenXDA/OpenXDALocationController.cs @@ -217,7 +217,7 @@ public IHttpActionResult GetMetersForLocation(int locationID, int page, int asc, if (!string.IsNullOrEmpty(GetRoles) && User.IsInRole(GetRoles)) return Unauthorized(); - int recordsPerPage = 50; + int recordsPerPage = PageSize ?? 50; using (AdoDataConnection connection = new AdoDataConnection(Connection)) { int totalRecords = connection.ExecuteScalar($@" @@ -256,7 +256,7 @@ FROM Meter [HttpGet, Route("{locationID:int}/Assets/{page:int}/{asc:int}/{orderBy}")] public IHttpActionResult GetAssetsForLocation(int locationID, int page, int asc, string orderBy) { - int recordsPerPage = 50; + int recordsPerPage = PageSize ?? 50; if (!string.IsNullOrEmpty(GetRoles) && User.IsInRole(GetRoles)) return Unauthorized(); @@ -323,7 +323,7 @@ public IHttpActionResult GetImagesForLocation(int locationID, int page) if (Directory.Exists(Path.Combine(path, key))) { IEnumerable imagePaths = Directory.GetFiles(Path.Combine(path, key)).Select(fp => new FileInfo(fp).Name); - return Ok(PageImagePaths(imagePaths, page, Take ?? 50)); + return Ok(PageImagePaths(imagePaths, page, PageSize ?? 50)); } else return Ok(new PagedResults() @@ -331,7 +331,7 @@ public IHttpActionResult GetImagesForLocation(int locationID, int page) Data = JsonConvert.SerializeObject(new string[0]), TotalRecords = 0, NumberOfPages = 0, - RecordsPerPage = Take ?? 50 + RecordsPerPage = PageSize ?? 50 }); } else diff --git a/Source/Applications/SystemCenter/Controllers/SystemCenter/SystemCenterController.cs b/Source/Applications/SystemCenter/Controllers/SystemCenter/SystemCenterController.cs index 563d97416a..3b5ff0f9be 100644 --- a/Source/Applications/SystemCenter/Controllers/SystemCenter/SystemCenterController.cs +++ b/Source/Applications/SystemCenter/Controllers/SystemCenter/SystemCenterController.cs @@ -633,7 +633,7 @@ public IHttpActionResult GetAdditionalFieldsForTable(string openXDAParentTable, { string orderByExpression = DefaultSort; - int recordsPerPage = Take ?? 50; + int recordsPerPage = PageSize ?? 50; if (sort != null && sort != string.Empty) orderByExpression = $"{sort} {(ascending == 1 ? "ASC" : "DESC")}"; diff --git a/Source/Applications/SystemCenter/Model/DataFile.cs b/Source/Applications/SystemCenter/Model/DataFile.cs index cc3dd6d1c6..5aa8a88573 100644 --- a/Source/Applications/SystemCenter/Model/DataFile.cs +++ b/Source/Applications/SystemCenter/Model/DataFile.cs @@ -321,7 +321,7 @@ public override IHttpActionResult GetPagedList([FromBody] PostData postData, int }).ToArray(); int recordCount = CountSearchResults(postData); - int recordPerPage = Take ?? 50; + int recordPerPage = PageSize ?? 50; return Ok(new PagedResults() { Data = JsonConvert.SerializeObject(results), @@ -360,7 +360,7 @@ public override IHttpActionResult GetPagedList([FromBody] PostData postData, int }).ToArray(); int recordCount = CountSearchResults(postData); - int recordPerPage = Take ?? 50; + int recordPerPage = PageSize ?? 50; return Ok(new PagedResults() { Data = JsonConvert.SerializeObject(results), @@ -398,7 +398,7 @@ public override IHttpActionResult GetPagedList([FromBody] PostData postData, int }).ToArray(); int recordCount = CountSearchResults(postData); - int recordPerPage = Take ?? 50; + int recordPerPage = PageSize ?? 50; return Ok(new PagedResults() { Data = JsonConvert.SerializeObject(results), diff --git a/Source/Applications/SystemCenter/Model/DeviceHealthReport.cs b/Source/Applications/SystemCenter/Model/DeviceHealthReport.cs index b74dc2becf..a5a7bebc89 100644 --- a/Source/Applications/SystemCenter/Model/DeviceHealthReport.cs +++ b/Source/Applications/SystemCenter/Model/DeviceHealthReport.cs @@ -111,7 +111,6 @@ public class DeviceHealthReport [RoutePrefix("api/DeviceHealthReport")] public class DeviceHealthReportController : ModelController { - public int PagingAmount { get; set; } = 50; public class DailyStatisticsRecord { [PrimaryKey(true)] @@ -144,7 +143,7 @@ public override IHttpActionResult GetPagedList([FromBody] PostData postData, int { PagedResults pagedReports = new() { - RecordsPerPage = 50 + RecordsPerPage = PageSize ?? 50 }; PostData openMicRequestBody = new() diff --git a/Source/Applications/SystemCenter/Model/Node.cs b/Source/Applications/SystemCenter/Model/Node.cs index 2ecac66e82..4b94d86db6 100644 --- a/Source/Applications/SystemCenter/Model/Node.cs +++ b/Source/Applications/SystemCenter/Model/Node.cs @@ -30,7 +30,7 @@ namespace SystemCenter.Model { - [TableName("Node"), ReturnLimit(50), + [TableName("Node"), CustomView(@" SELECT Node.ID, diff --git a/Source/Applications/SystemCenter/Model/Security/SecurityGroup.cs b/Source/Applications/SystemCenter/Model/Security/SecurityGroup.cs index 2906643a64..857fc77111 100644 --- a/Source/Applications/SystemCenter/Model/Security/SecurityGroup.cs +++ b/Source/Applications/SystemCenter/Model/Security/SecurityGroup.cs @@ -274,7 +274,7 @@ protected override DataTable GetSearchResults(PostData postData, int? page) if (page is int p) // page manually, because filtering post-search requires it. { - int recordsPerPage = Take ?? 50; + int recordsPerPage = PageSize ?? 50; DataRow[] rows = dataTable.AsEnumerable() .Skip((p) * recordsPerPage) .Take(recordsPerPage) diff --git a/Source/Applications/SystemCenter/Model/Security/UserAccount.cs b/Source/Applications/SystemCenter/Model/Security/UserAccount.cs index 438efbf736..d5ee735dc1 100644 --- a/Source/Applications/SystemCenter/Model/Security/UserAccount.cs +++ b/Source/Applications/SystemCenter/Model/Security/UserAccount.cs @@ -242,7 +242,7 @@ protected override DataTable GetSearchResults(PostData postData, int? page) if (page is int p)// page manually, because filtering post-search requires it. { - int recordsPerPage = Take ?? 50; + int recordsPerPage = PageSize ?? 50; DataRow[] rows = dataTable.AsEnumerable() .Skip((p) * recordsPerPage) .Take(recordsPerPage) diff --git a/Source/Applications/SystemCenterNotification/Controllers/EmailTypeController.cs b/Source/Applications/SystemCenterNotification/Controllers/EmailTypeController.cs index 152d413c37..69a729bcd3 100644 --- a/Source/Applications/SystemCenterNotification/Controllers/EmailTypeController.cs +++ b/Source/Applications/SystemCenterNotification/Controllers/EmailTypeController.cs @@ -440,7 +440,7 @@ public IHttpActionResult SentEmailTimeline([FromBody] PostData postData, int Sen public IHttpActionResult SentEmailTimelinePaged([FromBody] PostData postData, [FromUri] int sentEmailID, [FromUri] int page) { PagedResults pagedResults = new PagedResults(); - int recordsPerPage = Take ?? 50; + int recordsPerPage = PageSize ?? 50; List timeline = GetEmailTimeline(postData, sentEmailID); int totalRecords = timeline.Count;