From c59cc5969c3584451d1bdc57f336196d93ade792 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 27 Jan 2021 16:44:55 +0000 Subject: [PATCH] --- server/AyaNova/DataList/DataListOptions.cs | 24 ++++++++-- server/AyaNova/biz/DashboardViewBiz.cs | 2 +- server/AyaNova/biz/ReportBiz.cs | 38 ++++++++------- server/AyaNova/models/DataListBase.cs | 47 +++++++++++++++++++ server/AyaNova/models/DataListTableOptions.cs | 17 +++++++ server/AyaNova/models/DataListView.cs | 2 +- .../AyaNova/models/dto/DataListSelection.cs | 8 ++-- .../models/dto/RenderReportParameter.cs | 15 +++--- 8 files changed, 119 insertions(+), 34 deletions(-) create mode 100644 server/AyaNova/models/DataListBase.cs create mode 100644 server/AyaNova/models/DataListTableOptions.cs diff --git a/server/AyaNova/DataList/DataListOptions.cs b/server/AyaNova/DataList/DataListOptions.cs index 1ba4f655..0c18a2dc 100644 --- a/server/AyaNova/DataList/DataListOptions.cs +++ b/server/AyaNova/DataList/DataListOptions.cs @@ -1,11 +1,12 @@ using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; +using namespace AyaNova.DataList { - public sealed class DataListOptions + public sealed class DataListOptions : DataListBase { public const int MaxPageSize = 1000; public const int DefaultOffset = 0; @@ -20,7 +21,24 @@ namespace AyaNova.DataList [FromBody, Required] public string DataListKey { get; set; } - /* + [FromBody] + public DataListView View { get; set; } + + + // [FromBody] + // public List Columns { get; set; } + // [FromBody] + // public Dictionary SortBy { get; set; } + // [FromBody] + // public List Filter { get; set; } + // [FromBody] + // public string ClientCriteria { get; set; } + } + + + public class DataListView + { + /* OLD EXAMPLE: {"offset":0,"limit":10,"dataListKey":"CustomerDataList", "listView":"[ @@ -52,7 +70,7 @@ namespace AyaNova.DataList { public string Column { get; set; } public List items { get; set; } - public bool Any {get;set;}//means "or" the filter conditions + public bool Any { get; set; }//means "or" the filter conditions DataListFilterOption() { items = new List(); diff --git a/server/AyaNova/biz/DashboardViewBiz.cs b/server/AyaNova/biz/DashboardViewBiz.cs index e6304985..b16d6f4d 100644 --- a/server/AyaNova/biz/DashboardViewBiz.cs +++ b/server/AyaNova/biz/DashboardViewBiz.cs @@ -102,7 +102,7 @@ namespace AyaNova.Biz } catch (Newtonsoft.Json.JsonReaderException ex) { - AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "ListView", "ListView is not valid JSON string: " + ex.Message); + AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "DashboardView", "DashboardView is not valid JSON string: " + ex.Message); } } diff --git a/server/AyaNova/biz/ReportBiz.cs b/server/AyaNova/biz/ReportBiz.cs index a2319876..e1f57800 100644 --- a/server/AyaNova/biz/ReportBiz.cs +++ b/server/AyaNova/biz/ReportBiz.cs @@ -331,26 +331,27 @@ namespace AyaNova.Biz //REPORT DATA //Data fetched to return to report designer for Client report design usage - public async Task GetReportData(DataListSelection reportDataParam) + public async Task GetReportData(DataListSelection dataListSelection) { var log = AyaNova.Util.ApplicationLogging.CreateLogger("ReportBiz::GetReportData"); AuthorizationRoles effectiveRoles = CurrentUserRoles; - if (!AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(effectiveRoles, reportDataParam.ObjectType)) + if (!AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(effectiveRoles, dataListSelection.ObjectType)) { - AddError(ApiErrorCode.NOT_AUTHORIZED, null, $"User not authorized for {reportDataParam.ObjectType} type object"); + AddError(ApiErrorCode.NOT_AUTHORIZED, null, $"User not authorized for {dataListSelection.ObjectType} type object"); return null; } //Do we need to rehydrate the ID List from a DataList? - if (reportDataParam.SelectedRowIds.Length == 0) - reportDataParam.SelectedRowIds = await AyaNova.DataList.DataListFetcher.GetIdListResponseAsync(reportDataParam.DataListKey, reportDataParam.ListView, reportDataParam.MetaView, ct, effectiveRoles, log, UserId); + // if (dataListSelection.SelectedRowIds.Length == 0) + // dataListSelection.SelectedRowIds = await AyaNova.DataList.DataListFetcher.GetIdListResponseAsync(dataListSelection.DataListKey, dataListSelection.ListView, dataListSelection.MetaView, ct, effectiveRoles, log, UserId); + await dataListSelection.RehydrateIdList(ct, effectiveRoles, log, UserId); - log.LogDebug($"Instantiating biz object handler for {reportDataParam.ObjectType}"); - var biz = BizObjectFactory.GetBizObject(reportDataParam.ObjectType, ct); - log.LogDebug($"Fetching data for {reportDataParam.SelectedRowIds.Length} {reportDataParam.ObjectType} items"); - return await ((IReportAbleObject)biz).GetReportData(reportDataParam.SelectedRowIds); + log.LogDebug($"Instantiating biz object handler for {dataListSelection.ObjectType}"); + var biz = BizObjectFactory.GetBizObject(dataListSelection.ObjectType, ct); + log.LogDebug($"Fetching data for {dataListSelection.SelectedRowIds.Length} {dataListSelection.ObjectType} items"); + return await ((IReportAbleObject)biz).GetReportData(dataListSelection.SelectedRowIds); } @@ -393,15 +394,16 @@ namespace AyaNova.Biz //Get data - var ReportData = await GetReportData( - new DataListSelection() - { - ObjectType = report.ObjectType, - SelectedRowIds = reportParam.SelectedRowIds, - DataListKey = reportParam.DataListKey, - ListView = reportParam.ListView, - MetaView = reportParam.MetaView - }); + // var ReportData = await GetReportData( + // new DataListSelection() + // { + // ObjectType = report.ObjectType, + // SelectedRowIds = reportParam.SelectedRowIds, + // DataListKey = reportParam.DataListKey, + // ListView = reportParam.ListView, + // MetaView = reportParam.MetaView + // }); + var ReportData= await GetReportData(reportParam); //initialization log.LogDebug("Initializing report system"); diff --git a/server/AyaNova/models/DataListBase.cs b/server/AyaNova/models/DataListBase.cs new file mode 100644 index 00000000..1b69c675 --- /dev/null +++ b/server/AyaNova/models/DataListBase.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; +namespace AyaNova.Models +{ + + //common base class for data table display at client, reporting and mass bulk operations + public class DataListBase + { + public string DataListKey { get; set; } + public Dictionary SortBy { get; set; } + public List Filter { get; set; } + public string ClientCriteria { get; set; } + } + + /* + OLD EXAMPLE: + {"offset":0,"limit":10,"dataListKey":"CustomerDataList", + "listView":"[ + {\"fld\":\"customername\",\"sort\":\"+\",\"filter\":{\"items\":[{\"op\":\"=\",\"value\":\"dfdfdf\"},{\"op\":\"=\",\"value\":\"3333\"}],\"any\":true}}, + {\"fld\":\"customerphone1\",\"filter\":{\"items\":[{\"op\":\">\",\"value\":\"44444\"}, + {\"op\":\"<\",\"value\":\"7777\"}]}}, + {\"fld\":\"customeremail\"} + {\"fld\":\"customerheadoffice\"}, + {\"fld\":\"customertags\",\"sort\":\"+\"}]"} + + NEW: + columns:["PartInventoryTransactionEntryDate","PartPartNumber","PartWarehouseName","PartInventoryTransactionQuantity","PartInventoryTransactionDescription","PartInventoryTransactionSource","PartInventoryBalance"] + sortBy:[{"PartInventoryTransactionEntryDate":"-"}],//All sorted columns here as keyvalue pairs value is a string of "+" for ascending "-" for descending and are IN ORDER of how to be sorted + filter:[{column:"PartPartNumber",any:true/false,items:[{op: "=",value: "400735"}]}], + clientCriteria:"2" //could be anything here that makes sense to the list, in this case an example customer id for customernotedatalist + */ + public class DataListFilterOption + { + public string Column { get; set; } + public List items { get; set; } + public bool Any { get; set; }//means "or" the filter conditions + DataListFilterOption() + { + items = new List(); + } + } + + public class DataListColumnFilter + { + public string op { get; set; } + public string value { get; set; } + } +} diff --git a/server/AyaNova/models/DataListTableOptions.cs b/server/AyaNova/models/DataListTableOptions.cs new file mode 100644 index 00000000..4f83979e --- /dev/null +++ b/server/AyaNova/models/DataListTableOptions.cs @@ -0,0 +1,17 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; + + +namespace AyaNova.Models +{ + public sealed class DataListTableOptions : DataListBase + { + public List Columns { get; set; } + public const int MaxPageSize = 1000; + public const int DefaultOffset = 0; + public const int DefaultLimit = 25; + public int? Offset { get; set; } + public int? Limit { get; set; } + } +} \ No newline at end of file diff --git a/server/AyaNova/models/DataListView.cs b/server/AyaNova/models/DataListView.cs index 766eb02b..37c7afc9 100644 --- a/server/AyaNova/models/DataListView.cs +++ b/server/AyaNova/models/DataListView.cs @@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations; namespace AyaNova.Models { - +//TODO: Need to split this into a personal column order set and a personal filter collection public class DataListView { public long Id { get; set; } diff --git a/server/AyaNova/models/dto/DataListSelection.cs b/server/AyaNova/models/dto/DataListSelection.cs index 9f8ba03c..a3c7eedf 100644 --- a/server/AyaNova/models/dto/DataListSelection.cs +++ b/server/AyaNova/models/dto/DataListSelection.cs @@ -5,13 +5,13 @@ namespace AyaNova.Models //Used to drive processes that rely on selections made at client from a datalist //either a preselected list of id's or a datalist key and listview filter object that can //be used to rehydrate a list of id's - public class DataListSelection + public class DataListSelection : DataListBase { public AyaType ObjectType { get; set; } public long[] SelectedRowIds { get; set; } - public string DataListKey { get; set; } - public string ListView { get; set; }//optional, if null or empty will use default list view built into DataList - public string MetaView { get; set; }//optional meta list view to integrate into the standard list view. Used by client to add "meta" filter conditions above the user's choices e.g. customer notes customer id + // public string DataListKey { get; set; } + // public string ListView { get; set; }//optional, if null or empty will use default list view built into DataList + // public string MetaView { get; set; }//optional meta list view to integrate into the standard list view. Used by client to add "meta" filter conditions above the user's choices e.g. customer notes customer id public bool IsEmpty diff --git a/server/AyaNova/models/dto/RenderReportParameter.cs b/server/AyaNova/models/dto/RenderReportParameter.cs index f7664bfd..2b907660 100644 --- a/server/AyaNova/models/dto/RenderReportParameter.cs +++ b/server/AyaNova/models/dto/RenderReportParameter.cs @@ -2,15 +2,16 @@ using AyaNova.Biz; using Newtonsoft.Json.Linq; namespace AyaNova.Models { - - public class RenderReportParameter + + public class RenderReportParameter : DataListSelection { public long ReportId { get; set; } - public long[] SelectedRowIds { get; set; } - public string DataListKey { get; set; } - public string ListView { get; set; }//optional, if null or empty will use default list view built into DataList - public string MetaView { get; set; }//optional meta list view to integrate into the standard list view. Used by client to add "meta" filter conditions above the user's choices e.g. customer notes customer id - public JToken ClientMeta {get;set;}//meta JSON data passed from client, not part of biz object data + public JToken ClientMeta { get; set; }//meta JSON data passed from client, not part of biz object data + //public long[] SelectedRowIds { get; set; } + // public string DataListKey { get; set; } + // public string ListView { get; set; }//optional, if null or empty will use default list view built into DataList + // public string MetaView { get; set; }//optional meta list view to integrate into the standard list view. Used by client to add "meta" filter conditions above the user's choices e.g. customer notes customer id + }