diff --git a/server/AyaNova/Controllers/DataListSavedFilterController.cs b/server/AyaNova/Controllers/DataListSavedFilterController.cs index 460c967f..beb38353 100644 --- a/server/AyaNova/Controllers/DataListSavedFilterController.cs +++ b/server/AyaNova/Controllers/DataListSavedFilterController.cs @@ -1,18 +1,12 @@ -using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Authorization; - -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; - using AyaNova.Models; using AyaNova.Api.ControllerHelpers; using AyaNova.Biz; - namespace AyaNova.Api.Controllers { @@ -59,9 +53,6 @@ namespace AyaNova.Api.Controllers //Instantiate the business object handler DataListSavedFilterBiz biz = DataListSavedFilterBiz.GetBiz(ct, HttpContext); - // if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType)) - // return StatusCode(403, new ApiNotAuthorizedResponse()); - if (!ModelState.IsValid) return BadRequest(new ApiErrorResponse(ModelState)); @@ -141,10 +132,7 @@ namespace AyaNova.Api.Controllers //Instantiate the business object handler DataListSavedFilterBiz biz = DataListSavedFilterBiz.GetBiz(ct, HttpContext); - // //check roles - // if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType)) - // return StatusCode(403, new ApiNotAuthorizedResponse()); - + if (!ModelState.IsValid) return BadRequest(new ApiErrorResponse(ModelState)); @@ -186,42 +174,13 @@ namespace AyaNova.Api.Controllers if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND)); - // if (!Authorized.HasDeleteRole(HttpContext.Items, biz.BizType)) - // return StatusCode(403, new ApiNotAuthorizedResponse()); - if (!await biz.DeleteAsync(o)) return BadRequest(new ApiErrorResponse(biz.Errors)); return NoContent(); } - // /// - // /// Get default Columns and Sort for DataList - // /// - // /// Key of an existing DataList - // /// Columns and Sort - // [HttpGet("default/{dataListKey}")] - // public ActionResult GetDefaultDataListSavedFilter([FromRoute] string dataListKey) - // { - // if (!serverState.IsOpen) - // return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); - - // //Instantiate the business object handler - // DataListSavedFilterBiz biz = DataListSavedFilterBiz.GetBiz(ct, HttpContext); - - // if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType)) - // return StatusCode(403, new ApiNotAuthorizedResponse()); - - // if (!ModelState.IsValid) - // return BadRequest(new ApiErrorResponse(ModelState)); - - // var o = AyaNova.DataList.DataListFactory.GetAyaDataList(dataListKey); ; - // if (o == null) - // return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND)); - - // return Ok(ApiOkResponse.Response(new { Columns = o.DefaultColumns, SortBy = o.DefaultSortBy })); - // } - + //------------ diff --git a/server/AyaNova/DataList/AttachmentDataList.cs b/server/AyaNova/DataList/AttachmentDataList.cs index 1ac83cb2..fd728ce3 100644 --- a/server/AyaNova/DataList/AttachmentDataList.cs +++ b/server/AyaNova/DataList/AttachmentDataList.cs @@ -4,48 +4,18 @@ namespace AyaNova.DataList { internal class AttachmentDataList : DataListProcessingBase { - 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); - DefaultColumns = new List() { "displayfilename", "object", "size", "notes", "exists" }; DefaultSortBy = new Dictionary() { { "displayfilename", "+" }, { "size", "-" } }; - //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(); - //DPRECATED FieldDefinitions.Add(new AyaDataListFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.User, SqlIdColumnName = "auser.id" }); + FieldDefinitions.Add(new DataListFieldDefinition { TKey = "FileAttachment", diff --git a/server/AyaNova/DataList/CustomerDataList.cs b/server/AyaNova/DataList/CustomerDataList.cs index 13c1f322..68e7a363 100644 --- a/server/AyaNova/DataList/CustomerDataList.cs +++ b/server/AyaNova/DataList/CustomerDataList.cs @@ -10,38 +10,9 @@ namespace AyaNova.DataList SQLFrom = "from acustomer left join aheadoffice on (acustomer.headofficeid=aheadoffice.id) left join acontract on (acustomer.contractid=acontract.id)"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - - //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - // //Default ListView - // dynamic dlistView = new JArray(); - - // dynamic cm = new JObject(); - // cm.fld = "customername"; - // cm.sort = "+"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "customerphone1"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "customeremail"; - // dlistView.Add(cm); - - - // cm = new JObject(); - // cm.fld = "customerheadoffice"; - // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "customername", "customerphone1", "customeremail", "customerheadoffice" }; DefaultSortBy = new Dictionary() { { "customername", "+" } }; - - - //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition diff --git a/server/AyaNova/DataList/CustomerNoteDataList.cs b/server/AyaNova/DataList/CustomerNoteDataList.cs index dc974da3..6e25988e 100644 --- a/server/AyaNova/DataList/CustomerNoteDataList.cs +++ b/server/AyaNova/DataList/CustomerNoteDataList.cs @@ -12,31 +12,9 @@ namespace AyaNova.DataList SQLFrom = "from acustomernote left join auser on (acustomernote.userid=auser.id)"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - // //Default ListView - // dynamic dlistView = new JArray(); - - - // dynamic cm = new JObject(); - // cm.fld = "notedate"; - // cm.sort = "-"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "notes"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "username"; - // dlistView.Add(cm); - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "notedate", "notes", "username" }; DefaultSortBy = new Dictionary() { { "notedate", "-" } }; - - //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition @@ -89,7 +67,7 @@ namespace AyaNova.DataList if (string.IsNullOrWhiteSpace(clientCriteria)) throw new System.ArgumentNullException("CustomerNoteDataList - ClientCriteria is empty, should be Customer ID"); - DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metacustomer" }; + DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metacustomer" }; FilterOption.Items.Add(new DataListColumnFilter() { value = clientCriteria, op = DataListFilterComparisonOperator.Equality }); ret.Add(FilterOption); diff --git a/server/AyaNova/DataList/CustomerServiceRequestDataList.cs b/server/AyaNova/DataList/CustomerServiceRequestDataList.cs index b84b6bf5..4793c2dc 100644 --- a/server/AyaNova/DataList/CustomerServiceRequestDataList.cs +++ b/server/AyaNova/DataList/CustomerServiceRequestDataList.cs @@ -15,39 +15,9 @@ namespace AyaNova.DataList "left join aworkorder as w on (wi.workorderid=w.id)"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - // //Default ListView - // dynamic dlistView = new JArray(); - // dynamic cm = null; - - // cm = new JObject(); - // cm.fld = "Created"; - // cm.sort = "-"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "Customer"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "CustomerServiceRequestTitle"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "CustomerServiceRequestPriority"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "CustomerServiceRequestStatus"; - // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "Created", "Customer", "CustomerServiceRequestTitle", "CustomerServiceRequestPriority", "CustomerServiceRequestStatus" }; DefaultSortBy = new Dictionary() { { "Created", "-" } }; - //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition diff --git a/server/AyaNova/DataList/DataListFactory.cs b/server/AyaNova/DataList/DataListFactory.cs index 1a3f2402..b33cb52c 100644 --- a/server/AyaNova/DataList/DataListFactory.cs +++ b/server/AyaNova/DataList/DataListFactory.cs @@ -1,8 +1,6 @@ using System.Collections.Generic; using System.Linq; - - namespace AyaNova.DataList { internal static class DataListFactory diff --git a/server/AyaNova/DataList/DataListFetcher.cs b/server/AyaNova/DataList/DataListFetcher.cs index b6c78346..1dda2c0f 100644 --- a/server/AyaNova/DataList/DataListFetcher.cs +++ b/server/AyaNova/DataList/DataListFetcher.cs @@ -6,7 +6,6 @@ using Microsoft.Extensions.Logging; using AyaNova.Models; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; -using EnumsNET; namespace AyaNova.DataList { @@ -19,39 +18,7 @@ namespace AyaNova.DataList // internal static async Task GetResponseAsync(AyContext ct, DataListTableProcessingOptions dataListTableProcessingOptions, IDataListProcessing DataList, AuthorizationRoles userRoles, ILogger log, long userId) { - - // var DataList = DataListFactory.GetAyaDataList(dataListTableRequest.DataListKey); - - //was the name not found as a list? - // if (DataList == null) - // throw new System.ArgumentOutOfRangeException($"DataList \"{dataListTableRequest.DataListKey}\" specified does not exist"); - - //turn the DataListTableRequest into a DataListTableProcesingOptions object here - //hydrates filter and column selections etc - // = new DataListTableProcessingOptions(dataListTableRequest, DataList, ct); - - //#### TODO: below block into above method to clean it up and centralize it - - - // //STATIC filter options from server - // List StaticServerFilterOptions = new List(); - // if (DataList is IDataListInternalCriteria) - // StaticServerFilterOptions = ((IDataListInternalCriteria)DataList).DataListInternalCriteria(userId, userRoles, dataListTableOptions); - - - // //Get the public field key names in a list from the listview - // List PublicListViewFieldList = listOptions.Columns; - - //Get the combination of all unique fields from both StaticServerFilterOptions and listOptions - //NOTE: this assumes no list options filter colums that don't exist in listoptions.columns - // var AllUniqueFieldKeysRequiredForQuery = dataListTableOptions.Columns.Union(StaticServerFilterOptions.Select(z => z.Column).ToList()).ToList(); - - // //Add the internal filters into the listoptions existing filters - // //NOTE: There is currently no overlap between internal filtered columns and filters coming from the client - // foreach (DataListFilterOption dfo in StaticServerFilterOptions) - // dataListTableOptions.Filter.Add(dfo); - - //BUILD THE QUERY + //#BUILD THE QUERY //SELECT CLAUSE var qSelect = DataListSqlSelectBuilder.BuildForDataTableListResponse(DataList.FieldDefinitions, dataListTableProcessingOptions.AllUniqueColumnKeysReferenced); @@ -100,17 +67,13 @@ namespace AyaNova.DataList while (dr.Read()) { List row = new List(returnRowColumnCount); - - //INSERT REMAINING FIELDS FROM TEMPLATE INTO THE RETURN ROWS LIST foreach (string TemplateField in dataListTableProcessingOptions.Columns) { - //get the AyaObjectFieldDefinition DataListFieldDefinition f = DataList.FieldDefinitions.FirstOrDefault(z => z.FieldKey == TemplateField); if (f.IsCustomField) { - DataListField AyaField = new DataListField(); //could be null var rawValue = dr.GetValue(qSelect.map[f.GetSqlValueColumnName()]); @@ -123,7 +86,6 @@ namespace AyaNova.DataList //convert field name to cust name then get value var InternalCustomFieldName = FormFieldReference.TranslateLTCustomFieldToInternalCustomFieldName(TemplateField); //Sometimes a custom field is specified but doesn't exist in the collection so don't assume it's there - // AyaField.v = j[InternalCustomFieldName].Value(); JToken o = j[InternalCustomFieldName]; if (o != null) AyaField.v = o.Value(); @@ -131,29 +93,12 @@ namespace AyaNova.DataList AyaField.v = null; row.Add(AyaField); - }else{ - AyaField.v=null; + } + else + { + AyaField.v = null; } } - - /* - TODO: Custom field handling - GetName works just not with multipart identifiers - I could force naming by making all fields and AS, or - I could map the ordinal when generating the Select fields so that I have a map to refer to here - mapping in advance actually makes a lot of sense, then no more of this fragility of going by pointer index and hoping for the best - it would just be premapped out. - - dr.GetOrdinal(f.SqlValueColumnName) - 'dr.GetOrdinal(f.SqlValueColumnName)' threw an exception of type 'System.IndexOutOfRangeException' - f.SqlValueColumnName - "awidget.customfields" - dr.GetName(nCurrentColumnPointer) - "customfields" - dr.GetOrdinal("customfields"); - 5 - - */ } else { @@ -230,72 +175,22 @@ namespace AyaNova.DataList } } - - //BUILD THE COLUMNS RETURN PROPERTY JSON FRAGMENT Newtonsoft.Json.Linq.JArray ColumnsJSON = null; ColumnsJSON = DataList.GenerateReturnListColumns(dataListTableProcessingOptions.Columns); - - return new DataListReturnData(rows, totalRecordCount, ColumnsJSON, dataListTableProcessingOptions.SortBy, dataListTableProcessingOptions.Filter.Where(z => z.Column.StartsWith("meta") == false).ToList()); } + ///////////////////////////////////////////////////////////////// // Get a list of id's of the datalist results for reporting // // internal static async Task GetIdListResponseAsync(AyContext ct, DataListSelectedProcessingOptions dataListSelectionOptions, IDataListProcessing DataList, AuthorizationRoles userRoles, ILogger log, long userId) { - // // var DataList = DataListFactory.GetAyaDataList(dataListSelectionOptions.DataListKey); - // // //was the name not found as a list? - // // if (DataList == null) - // // throw new System.ArgumentOutOfRangeException($"DataList \"{dataListSelectionOptions.DataListKey}\" specified does not exist"); + //#BUILD THE QUERY - - - // //check rights - // if (!userRoles.HasAnyFlags(DataList.AllowedRoles)) - // throw new System.UnauthorizedAccessException("User roles insufficient for this datalist"); - - // // //do we need to default the listView? - // // if (string.IsNullOrWhiteSpace(listView)) - // // listView = DataList.DefaultListView; - - // DataList.SetListOptionDefaultsIfNecessary(dataListSelectionOptions); - - // // //parse the list view - // // var ListViewArray = JArray.Parse(listView); - - - // // //Hard coded extra criteria from server end - // // if (DataList is IAyaDataListServerCriteria) - // // { - // // var ServerCriteriaListView = JArray.Parse(((IAyaDataListServerCriteria)DataList).DataListServerCriteria(await ct.User.AsNoTracking().FirstOrDefaultAsync(z => z.Id == userId), ct)); - // // foreach (JToken jt in ServerCriteriaListView) - // // ListViewArray.Add(jt); - // // } - - // //STATIC filter options from server - // List StaticServerFilterOptions = null; - // if (DataList is IDataListInternalCriteria) - // StaticServerFilterOptions = ((IDataListInternalCriteria)DataList).DataListInternalCriteria(userId, userRoles, dataListSelectionOptions); - - // //Add the internal filters into the listoptions existing filters - // //NOTE: There is currently no overlap between internal filtered columns and filters coming from the client - // foreach (DataListFilterOption dfo in StaticServerFilterOptions) - // dataListSelectionOptions.Filter.Add(dfo); - - // // //Hard coded extra criteria from Client end - // // //parse and combine any additional listview hard coded from Client UI - // // var MetaListViewArray = JArray.Parse(metaListView ?? "[]"); - // // foreach (JToken jt in MetaListViewArray) - // // ListViewArray.Add(jt); - - // // //Get the field key names in a list from the listview - // // List ListViewFieldList = DataList.GetFieldListFromListView(ListViewArray); - - //BUILD THE QUERY //SELECT FRAGMENT COLUMNS FROM TEMPLATE var qSelect = DataListSqlSelectBuilder.BuildForIdListResponse(DataList.FieldDefinitions, dataListSelectionOptions); @@ -319,22 +214,6 @@ namespace AyaNova.DataList //RETURN OBJECTS var retList = new List(); - //GET ID COLUMN ORDINAL - int IDColumnOrdinal = 0; - - //NOTE: assuming change of code means id column is *always* the zeroth column - - // foreach (string TemplateField in ListViewFieldList) - // { - // //get the AyaObjectFieldDefinition - // AyaDataListFieldDefinition f = DataList.FieldDefinitions.FirstOrDefault(z => z.FieldKey == TemplateField); - // if (f.IsRowId) - // { - // IDColumnOrdinal = SelectBuild.map[f.SqlIdColumnName]; - // break; - // } - // } - using (var command = ct.Database.GetDbConnection().CreateCommand()) { await ct.Database.OpenConnectionAsync(); @@ -345,8 +224,9 @@ namespace AyaNova.DataList { while (dr.Read()) { - if (!dr.IsDBNull(IDColumnOrdinal)) - retList.Add(dr.GetInt64(IDColumnOrdinal)); + //only one column and it's the zeroth id column + if (!dr.IsDBNull(0)) + retList.Add(dr.GetInt64(0)); } } } diff --git a/server/AyaNova/DataList/DataListFieldDefinition.cs b/server/AyaNova/DataList/DataListFieldDefinition.cs index 6d664124..9a042d5c 100644 --- a/server/AyaNova/DataList/DataListFieldDefinition.cs +++ b/server/AyaNova/DataList/DataListFieldDefinition.cs @@ -1,10 +1,8 @@ using AyaNova.Biz; -using System.ComponentModel.DataAnnotations; using Newtonsoft.Json; namespace AyaNova.DataList { - //This class defines a field used for returning data in list format for UI grid lists and reporting public class DataListFieldDefinition { @@ -51,12 +49,9 @@ namespace AyaNova.DataList [JsonIgnore] public string SqlColorColumnName { get; set; }//column to fetch the color if applicable to this field - - public DataListFieldDefinition() { //most common defaults - IsCustomField = false; IsFilterable = true; IsSortable = true; @@ -66,7 +61,6 @@ namespace AyaNova.DataList AyaObjectType = (int)AyaType.NoType; SqlAyTypeColumnName = null;//must be null as that is checked against specifically SqlColorColumnName = null;//must be null to be ignored properly - } //Get column to query for display name or use FieldName if there is no difference diff --git a/server/AyaNova/DataList/DataListFilterComparisonOperator.cs b/server/AyaNova/DataList/DataListFilterComparisonOperator.cs index 4ac2a28c..037c2740 100644 --- a/server/AyaNova/DataList/DataListFilterComparisonOperator.cs +++ b/server/AyaNova/DataList/DataListFilterComparisonOperator.cs @@ -39,7 +39,5 @@ namespace AyaNova.DataList return operators; } } - - } } diff --git a/server/AyaNova/DataList/DataListOptions.cs b/server/AyaNova/DataList/DataListOptions.cs deleted file mode 100644 index b63707f3..00000000 --- a/server/AyaNova/DataList/DataListOptions.cs +++ /dev/null @@ -1,89 +0,0 @@ - -//MOVED TO MODELS AS DataListTableOptions AND BROKEN APART - -// using System.ComponentModel.DataAnnotations; -// using Microsoft.AspNetCore.Mvc; -// using System.Collections.Generic; -// using - -// namespace AyaNova.DataList -// { - -// public sealed class DataListOptions : DataListBase -// { -// public const int MaxPageSize = 1000; -// public const int DefaultOffset = 0; -// public const int DefaultLimit = 25; - -// [FromBody] -// public int? Offset { get; set; } - -// [FromBody] -// public int? Limit { get; set; } - -// [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":"[ -// {\"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 -// */ -// [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 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; } -// } - -// } \ No newline at end of file diff --git a/server/AyaNova/DataList/DataListProcessingBase.cs b/server/AyaNova/DataList/DataListProcessingBase.cs index 7b708d2f..2b83bfa0 100644 --- a/server/AyaNova/DataList/DataListProcessingBase.cs +++ b/server/AyaNova/DataList/DataListProcessingBase.cs @@ -19,23 +19,18 @@ namespace AyaNova.DataList public DataListProcessingBase() { /* + NOTE: all sql identifiers need to be explicitly identified as understood by postgres DefaultColumns = new List() { "XXX", "XXXX", "XXXX", "XXXX", "XXXX", "XXX", "XXXX", "XXXX", "XXXX", "XXXX" }; DefaultSortBy = new Dictionary() { { "XXXX", "+" }, { "XXXX", "-" } }; - */ - } public string SQLFrom { get; set; } public List FieldDefinitions { get; set; } public AuthorizationRoles AllowedRoles { get; set; } public AyaType DefaultListObjectType { get; set; } - - - public long CurrentUserId { get; set; } - public List DefaultColumns { get; set; } public Dictionary DefaultSortBy { get; set; } @@ -71,22 +66,6 @@ namespace AyaNova.DataList } } - - // //return array of field keys in list view - // public List GetFieldListFromListView(JArray listViewArray) - // { - // // [{key:"COLUMN UNIQUE KEY ID",sort:"-" or "+",filter:{any:true/false,items:[{FILTER OBJECT SEE BELOW}]} }, {key:"second column unique key"},{...etc...}] - // List ret = new List(); - // for (int i = 0; i < listViewArray.Count; i++) - // { - // var cm = listViewArray[i]; - // ret.Add(cm["fld"].Value()); - // } - // return ret; - // } - - - public Newtonsoft.Json.Linq.JArray GenerateReturnListColumns(List columns) { @@ -197,14 +176,7 @@ namespace AyaNova.DataList using (var ct = AyaNova.Util.ServiceProviderProvider.DBContext) { var fc = ct.FormCustom.AsNoTracking().SingleOrDefault(z => z.FormKey == ayatypename); - //This is normal and expected in an empty db, removing this block - // #if (DEBUG) - // if (fc == null) - // { - // throw new System.ArgumentNullException($"AyaDataList:GetCustomFieldDefinitionsForList, Custom field object type {ayatypename} has no FormCustom defined"); - // } - // #endif - //production handling of missing formcustom + //normal condition if (fc == null) continue; @@ -224,47 +196,6 @@ namespace AyaNova.DataList } } } - /*{[ - { - "fld": "Notes", - "required": true - }, - { - "fld": "WidgetCustom1", - "required": false, - "type": 1 - }, - { - "fld": "WidgetCustom2", - "required": true, - "type": 4 - }, - { - "fld": "WidgetCustom3", - "required": false, - "type": 5 - }, - { - "fld": "WidgetCustom4", - "required": false, - "type": 6 - }, - { - "fld": "WidgetCustom5", - "required": false, - "type": 8 - }, - { - "fld": "WidgetCustom6", - "required": false, - "type": 2 - }, - { - "fld": "WidgetCustom7", - "required": false, - "type": 3 - } - ]}*/ return ret; } diff --git a/server/AyaNova/DataList/DataListReturnData.cs b/server/AyaNova/DataList/DataListReturnData.cs index 5d281dc5..8e1ca6f9 100644 --- a/server/AyaNova/DataList/DataListReturnData.cs +++ b/server/AyaNova/DataList/DataListReturnData.cs @@ -2,10 +2,8 @@ using System.Collections.Generic; using AyaNova.Models; namespace AyaNova.DataList { - public class DataListReturnData { - public object Data { get; } public long TotalRecordCount { get; } public object Columns { get; } @@ -19,7 +17,6 @@ namespace AyaNova.DataList Columns = columns; SortBy = sortBy; Filter = filter; - } }//eoc diff --git a/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs b/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs index bfbe0299..d116cc06 100644 --- a/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs +++ b/server/AyaNova/DataList/DataListSqlFilterCriteriaBuilder.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System; using System.Globalization; using System.Text; -using Newtonsoft.Json.Linq; using System.Linq; using AyaNova.Models; using AyaNova.Biz; @@ -13,37 +12,16 @@ namespace AyaNova.DataList { public static string DataFilterToSQLCriteria(List objectFieldsList, Models.DataListProcessingBase listOptions) { - if (listOptions.Filter == null || listOptions.Filter.Count == 0) - { return ""; - } - - //List to compile each columns where clause fragment for later assembly into sql query List ColumnWhereClauses = new List(); - // for (int i = 0; i < listViewArray.Count; i++) - foreach (DataListFilterOption f in listOptions.Filter) { StringBuilder sb = new StringBuilder(); - // var cm = listViewArray[i]; - // //skip it if FILTER is not defined - // if (cm["filter"] == null) - // { - // continue; - // } - - - - //Get some info about this column / field - // var fld = cm["fld"].Value(); - - //var dataType = objectFieldsList.Find(z => z.FieldKey.ToLowerInvariant() == fld.ToLowerInvariant()).UiFieldDataType; DataListFieldDefinition DataListField = objectFieldsList.FirstOrDefault(z => z.FieldKey == f.Column); var dataType = DataListField.UiFieldDataType; - //No filtering on custom fields! if (DataListField.IsCustomField) { @@ -57,24 +35,10 @@ namespace AyaNova.DataList } #endif - //get filter items collection for this field view definition - // var filterItems = (JArray)cm["filter"]["items"]; - - // var IsOrFilter = false; - // if (cm["filter"]["any"] != null) - // { - // IsOrFilter = cm["filter"]["any"].Value(); - // } - - - - //Iterate filter items building this WHERE segment bool ThisIsTheFirstFilterItemForThisColumn = true; - //var ThereAreMultipleFilterItems = filterItems.Count > 1; var ThereAreMultipleFilterItems = f.Items.Count > 1; - // for (int y = 0; y < filterItems.Count; y++) foreach (DataListColumnFilter filterItem in f.Items) { //close or open another parenthetic group @@ -90,71 +54,26 @@ namespace AyaNova.DataList if (!ThisIsTheFirstFilterItemForThisColumn) { //Close last filter item and start new one - // if (IsOrFilter) if (f.Any) sb.Append(") OR ("); else sb.Append(") AND ("); - } - - //gather filter data - //var filterItem = (JObject)filterItems[y]; - // var opType = filterItem["op"].Value(); - - //#### Commented out this block as much of it is related to filter by ID as it says it's not used and I think that's true still when switched to new listOptions with split filter / view - // List tagList = new List(); - // string val = string.Empty; - // bool IsPossibleIdValue = filterItem["value"].Type == JTokenType.Integer; - // if (filterItem["value"].Type != JTokenType.Array) - // val = filterItem["value"].Value(); - // else - // { - // tagList = filterItem["value"].ToObject>(); - // } - // //prep for possible ID field filter instead - // string columnNameToFilter = string.Empty; - // UiFieldDataType DataTypeToFilter = UiFieldDataType.NoType; - // //Check if filtering by ID rather than by name - // //this is indicated by this column being an id type - // //and by the comparison operator being eq or neq - // //and the value being a number not a string - // //NOTE: This is not actually used anywhere at the client or on server, only defined here in this class - // //it was probabaly for supporting filtering by ID but I have found that unnecessary so far - // // if (DataListField.HasIdColumn() && IsPossibleIdValue && (opType == DataListFilterComparisonOperator.Equality || opType == DataListFilterComparisonOperator.NotEqual)) - // if (DataListField.HasIdColumn() && IsPossibleIdValue && (filterItem.op == DataListFilterComparisonOperator.Equality || filterItem.op == DataListFilterComparisonOperator.NotEqual)) - // { - // columnNameToFilter = DataListField.SqlIdColumnName; - // DataTypeToFilter = UiFieldDataType.InternalId; - // } - // else - // { - // DataTypeToFilter = (UiFieldDataType)dataType; - // columnNameToFilter = DataListField.GetSqlValueColumnName(); - // } - - //replaced above code that guessed if it was an ID column and instead I explicitly mark the id colunmns - //in the DataList definition with UiFieldDataType.InternalId string columnNameToFilter = string.Empty; UiFieldDataType DataTypeToFilter = UiFieldDataType.NoType; DataTypeToFilter = (UiFieldDataType)dataType; columnNameToFilter = DataListField.GetSqlValueColumnName(); //Append this filter's criteria sb.Append(DataFilterToColumnCriteria(columnNameToFilter, DataTypeToFilter, filterItem.op, filterItem.value, listOptions.ClientTimeStamp)); - - ThisIsTheFirstFilterItemForThisColumn = false; } - if (ThereAreMultipleFilterItems) { //The whole thing was in a group so close this group sb.Append(")"); } ColumnWhereClauses.Add(sb.ToString()); - - } if (ColumnWhereClauses.Count == 0) return string.Empty; @@ -176,23 +95,17 @@ namespace AyaNova.DataList } } - - //sTags is redundant now as the sValue can contain a array of strings and dataType already gives away if it's a tag filter or no - // private static string DataFilterToColumnCriteria(string SqlColumnNameToFilter, UiFieldDataType DataType, string sOperator, string sValue, List sTags)//, bool IsCompound) + //////////////////////////////////////////////////////////////////////// + // /// /// Translate DataFilter to Postgres friendly SQL criteria /// private static string DataFilterToColumnCriteria(string SqlColumnNameToFilter, UiFieldDataType DataType, string sOperator, string sValue, DateTimeOffset clientTimeStamp) { - - // bool TagFilter = sTags.Count < 0; Nope, the datatype already states if it's tags or not no need for redundancy - StringBuilder sb = new StringBuilder(); //Column name - //sb.Append(" "); sb.Append(SqlColumnNameToFilter); sb.Append(" "); - //handle null values separately if (DataType != UiFieldDataType.Tags && sValue == "*NULL*") { @@ -223,14 +136,8 @@ namespace AyaNova.DataList } } else - {//non null value - - //Changed 21-March-2006: - //But wait! Both mssql and firebird won't include a null result - //on the filter field so in some cases we need to include them - //i.e. if a value is supposed to be not equal to a specific non-null value - //then null is a valid value to return but won't be normally - //so.... + { + //non null value //Special addition to handle nulls if (DataType != UiFieldDataType.Tags) @@ -260,9 +167,6 @@ namespace AyaNova.DataList sb.Append(SqlColumnNameToFilter); sb.Append(" "); break; - // case "Like": - // //No change on like - // break; case DataListFilterComparisonOperator.NotEqual: //This is the big one: sb.Append("Is Null OR "); @@ -365,24 +269,6 @@ namespace AyaNova.DataList sb.Append("'"); break; - // case "DoesNotStartWith": - // sb.Append("Not Like '"); - // sb.Append(sValue); - // sb.Append("%'"); - // break; - - // case "DoesNotEndWith": - // sb.Append("Not Like '%"); - // sb.Append(sValue); - // sb.Append("'"); - // break; - - // case "NotLike": - // sb.Append("Not Like '"); - // sb.Append(sValue); - // sb.Append("%'"); - // break; - default: throw new System.ArgumentOutOfRangeException("OPERATOR_TYPE", sOperator, "DataListSqlFilterCriteriaBuilder unhandled operator type [" + sOperator + "] IN STRING"); @@ -421,19 +307,13 @@ namespace AyaNova.DataList case UiFieldDataType.DateTime: case UiFieldDataType.Time: { - //################################################################################################################## - //################################################################################################################## - - - if (sValue.StartsWith("*") && sValue.EndsWith("*")) { - //All below calcs done with Client provided current date/time and converted to UTC only at the end for sql + //Note: due to date token relativity, all below calcs done with Client provided current date/time and converted to UTC only at the end for sql DateTime ClientToday = clientTimeStamp.Date; DateTime ClientNow = clientTimeStamp.DateTime; - #region Build criteria for date RANGE TOKEN specified //Used as the basis point @@ -793,20 +673,8 @@ namespace AyaNova.DataList //suitable for the database to handle as all database dates are in UTC //Local display and parsing will be considered a CLIENT issue at all times - - //bugbug: comes with z at end indicating UTC so converts to local here, sb sticking to UTC, the z must be messing it up - //System.DateTime dtData = DateTime.Parse(sValue); - - //date comes to use as a string in iso8601 format including the "z" at the end - //parse needs to work exactly with it and not attempt to convert it to local time - - - // System.DateTime dtData = DateTime.ParseExact(sValue, "O", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind); - //Error=>System.FormatException: String '2021-02-05T17:40:35.094Z' was not recognized as a valid DateTime. - - System.DateTime dtData = DateTime.Parse(sValue).ToUniversalTime();//comes in UTC, parse converts it to local but touniversal puts it back in utc, weird but only thing that consistently work - - + //comes in UTC, parse converts it to local but touniversal puts it back in utc, weird but only thing that consistently work + System.DateTime dtData = DateTime.Parse(sValue).ToUniversalTime(); //Filter time resolution is in minutes only, you can't select seconds in a filter //so the filter code below must construct a filter time @@ -878,7 +746,7 @@ namespace AyaNova.DataList case UiFieldDataType.Integer: //whole numbers, not only integer { //case 1795 - it's numeric, convert to translation independant format - //RAVEN NOTE: this code looks suspect to me, but I'll leave it in for now + //RAVEN NOTE: no numbers are coming from the client in any culture format other than xx,xxx.00 but this is just insurance for api users NumberFormatInfo nfi = System.Globalization.CultureInfo.CurrentCulture.NumberFormat; switch (DataType) { @@ -908,8 +776,6 @@ namespace AyaNova.DataList break; } - - switch (sOperator) { case DataListFilterComparisonOperator.Equality: @@ -939,7 +805,6 @@ namespace AyaNova.DataList default: throw new System.ArgumentOutOfRangeException("OPERATOR_TYPE", sOperator, "DataListSqlFilterCriteriaBuilder unhandled operator type [" + sOperator + "] IN NUMBER"); - } break; } @@ -960,7 +825,6 @@ namespace AyaNova.DataList //sounds like it might fuck up when using other languages so... StringBuilder sbTags = new StringBuilder(); sbTags.Append("@> array["); - //List normalizedTags = TagBiz.NormalizeTags(sTags); //Note: with listOptions change to split filter and view the tags are now in sValue as a string of comma delimited strings so split them out here List normalizedTags = TagBiz.NormalizeTags(sValue.Split(',').ToList()); foreach (string s in normalizedTags) @@ -1002,18 +866,16 @@ namespace AyaNova.DataList private static DateTime ZeroSeconds(DateTime d) { - return new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, 0, DateTimeKind.Utc); } - + private static DateTime MaxSeconds(DateTime d) { - return new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, 59, 999, DateTimeKind.Utc); } - + /// /// Postgres compatible date format @@ -1022,1127 +884,9 @@ namespace AyaNova.DataList /// private static string PostgresDateFormat(DateTime theDate) { - - //If this was used it should be like this for a UTC date to iso8601 // ISO8601 with 7 decimal places return theDate.ToString("o", CultureInfo.InvariantCulture); - - // if (DBUtil.DB.DBType == DataBaseType.MSSQL) - // return "yyyy-MM-ddTHH:mm:ss"; - // else - // return "yyyy-MM-dd HH:mm:ss"; } }//eoc -}//ens -/* - - -Javascript relative date calculator -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Xeslint-disable -//////////////////////////////////////////////////////////////////////////////////////////////////////////// - -///////////////////////////////// -// Convert a date token to local -// date range to UTC for server -// dataListView consumption -// -export default { - /////////////////////////////// - // token to date range - // - tokenToDates: function(token) { - if (token == null || token.length == 0) { - throw new Error( - "relative-date-filter-calculator: date token is null or empty" - ); - } - - //return object contains the two dates that encompass the time period - //the token represents to the local browser time zone but in UTC - //and iso8601 format - - //NOTE: it's valid for one of the two ret values might be undefined as it's valid to have a single date for - //Past or Future - let ret = { after: undefined, before: undefined }; - let dtNow = window.$gz.DateTime.local(); - let dtToday = window.$gz.DateTime.local(dtNow.year, dtNow.month, dtNow.day); - let dtAfter = null; - let dtBefore = null; - - switch (token) { - case "*yesterday*": - //Between Day before yesterday at midnight and yesterday at midnight - ret.after = dtToday - .plus({ days: -1, seconds: -1 }) - .toUTC() - .toString(); - ret.before = dtToday.toUTC().toString(); - break; - - case "*today*": - //Between yesterday at midnight and tommorow at midnight - ret.after = dtToday - .plus({ seconds: -1 }) - .toUTC() - .toString(); - ret.before = dtToday - .plus({ days: 1 }) - .toUTC() - .toString(); - break; - - case "*tomorrow*": - //Between Tonight at midnight and day after tommorow at midnight - ret.after = dtToday - .plus({ days: 1, seconds: -1 }) - .toUTC() - .toString(); - ret.before = dtToday - .plus({ days: 2 }) - .toUTC() - .toString(); - break; - - case "*lastweek*": - //Between two Sundays ago at midnight and last sunday at midnight - - //go back a week - dtAfter = dtToday.plus({ days: -7 }); - //go backwards to Sunday (In Luxon Monday is 1, Sunday is 7) - while (dtAfter.weekday != 7) { - dtAfter = dtAfter.plus({ days: -1 }); - } - //go to very start of eighth dayahead - dtBefore = dtAfter.plus({ days: 8 }); - //remove a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*thisweek*": - //Between Sunday at midnight and Next sunday at midnight - - //Start with today - dtAfter = dtToday; - //SET dtAfter to Monday start of this week - //go backwards to monday (In Luxon Monday is 1, Sunday is 7) - while (dtAfter.weekday != 1) { - dtAfter = dtAfter.plus({ days: -1 }); - } - //Now go back to sunday last second - dtAfter = dtAfter.plus({ seconds: -1 }); - - //Start with today - dtBefore = dtToday; - - //SET dtBefore to next monday - //is it monday now? - if (dtBefore.weekday == 1) { - //Monday today? then go to next monday - dtBefore = dtBefore.plus({ days: 7 }); - } else { - //Find next monday... - while (dtBefore.weekday != 1) { - dtBefore = dtBefore.plus({ days: 1 }); - } - } - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*nextweek*": - //Between Next Sunday at midnight and Next Next sunday at midnight - - //Start with today - dtAfter = dtToday; - //If today is monday skip over it first, we're looking for *next* monday, not this one - if (dtAfter.weekday == 1) { - dtAfter = dtAfter.plus({ days: 1 }); - } - - //go forwards to next monday 12:00am (In Luxon Monday is 1, Sunday is 7) - while (dtAfter.weekday != 1) { - dtAfter = dtAfter.plus({ days: 1 }); - } - //Now go back to sunday last second - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set dtBefore 7 days ahead of dtAfter - //(sb BEFORE two mondays from now at zero hour so need to add a second due to prior removal of a second to make sunday) - dtBefore = dtAfter.plus({ days: 7, seconds: 1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*lastmonth*": - //start with the first day of this month - dtAfter = window.$gz.DateTime.local(dtNow.year, dtNow.month, 1); - //subtract a Month - dtAfter = dtAfter.plus({ months: -1 }); - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*thismonth*": - //start with the first day of this month - dtAfter = window.$gz.DateTime.local(dtNow.year, dtNow.month, 1); - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*nextmonth*": - //start with the first day of this month - dtAfter = window.$gz.DateTime.local(dtNow.year, dtNow.month, 1); - - //add a month - dtAfter = dtAfter.plus({ months: 1 }); - - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*14daywindow*": - //Start with today - dtAfter = dtToday; - - //subtract 7 days - dtAfter = dtAfter.plus({ days: -7 }); - - //Add 15 days to dtAfter to get end date - dtBefore = dtAfter.plus({ days: 15 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*past*": - //Any time before Now - //set return values from calculated values - ret.after = undefined; - ret.before = dtNow.toUTC().toString(); - break; - - case "*future*": - //Any time after Now - //set return values from calculated values - ret.after = dtNow.toUTC().toString(); - ret.before = undefined; - break; - - case "*lastyear*": - //"last year" means prior calendar year from start of january to end of december - //start with the first day of this year - dtAfter = window.$gz.DateTime.local(dtNow.year); - - //subtract a year - dtAfter = dtAfter.plus({ years: -1 }); - - //Before zero hour january 1st this year - dtBefore = window.$gz.DateTime.local(dtNow.year); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*thisyear*": - //From zero hour january 1 this year (minus a second) to zero hour jan 1 next year - //start with the first day of this year - dtAfter = window.$gz.DateTime.local(dtNow.year); - - //Before zero hour january 1st next year - dtBefore = window.$gz.DateTime.local(dtNow.year); - dtBefore = dtBefore.plus({ years: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*last3months*": - //From Now minus 3 months - dtAfter = dtToday.plus({ months: -3 }); - - //Before now - dtBefore = dtNow; - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*last6months*": - //From Now minus 6 months - dtAfter = dtToday.plus({ months: -6 }); - - //Before now - dtBefore = dtNow; - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*pastyear*": //within the prior 365 days before today - //From Now minus 365 days - dtAfter = dtToday.plus({ days: -365 }); - - //Before now - dtBefore = dtNow; - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*past90days*": - //From Now minus 90 days - dtAfter = dtNow.plus({ days: -90 }); - - //Before now - dtBefore = dtNow; - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*past30days*": - //From Now minus 30 days - dtAfter = dtNow.plus({ days: -30 }); - - //Before now - dtBefore = dtNow; - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*past7days*": - //From Now minus 7 days - dtAfter = dtNow.plus({ days: -7 }); - - //Before now - dtBefore = dtNow; - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*past24hours*": - //From Now minus 24 hours - dtAfter = dtNow.plus({ hours: -24 }); - - //Before now - dtBefore = dtNow; - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*past6hours*": - //From Now minus 6 hours - dtAfter = dtNow.plus({ hours: -6 }); - - //Before now - dtBefore = dtNow; - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - /////////////////////////////////////////////////////////////////////////// - case "*january*": - //This year specific month (month is 1 based) - dtAfter = window.$gz.DateTime.local(dtNow.year, 1, 1); - - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*february*": - //This year specific month (month is 1 based) - dtAfter = window.$gz.DateTime.local(dtNow.year, 2, 1); - - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*march*": - //This year specific month (month is 1 based) - dtAfter = window.$gz.DateTime.local(dtNow.year, 3, 1); - - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*april*": - //This year specific month (month is 1 based) - dtAfter = window.$gz.DateTime.local(dtNow.year, 4, 1); - - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*may*": - //This year specific month (month is 1 based) - dtAfter = window.$gz.DateTime.local(dtNow.year, 5, 1); - - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*june*": - //This year specific month (month is 1 based) - dtAfter = window.$gz.DateTime.local(dtNow.year, 6, 1); - - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*july*": - //This year specific month (month is 1 based) - dtAfter = window.$gz.DateTime.local(dtNow.year, 7, 1); - - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*august*": - //This year specific month (month is 1 based) - dtAfter = window.$gz.DateTime.local(dtNow.year, 8, 1); - - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*september*": - //This year specific month (month is 1 based) - dtAfter = window.$gz.DateTime.local(dtNow.year, 9, 1); - - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*october*": - //This year specific month (month is 1 based) - dtAfter = window.$gz.DateTime.local(dtNow.year, 10, 1); - - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*november*": - //This year specific month (month is 1 based) - dtAfter = window.$gz.DateTime.local(dtNow.year, 11, 1); - - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*december*": - //This year specific month (month is 1 based) - dtAfter = window.$gz.DateTime.local(dtNow.year, 12, 1); - - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*lastyearlastmonth*": - //start with the first day of this month - dtAfter = window.$gz.DateTime.local(dtNow.year, dtNow.month, 1); - //subtract a Year and a Month - dtAfter = dtAfter.plus({ years: -1, months: -1 }); - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*lastyearthismonth*": - //start with the first day of this month - dtAfter = window.$gz.DateTime.local(dtNow.year, dtNow.month, 1); - //subtract a Year - dtAfter = dtAfter.plus({ years: -1 }); - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - case "*lastyearnextmonth*": - //start with the first day of this month - dtAfter = window.$gz.DateTime.local(dtNow.year, dtNow.month, 1); - - //subtract a year, add a month - dtAfter = dtAfter.plus({ years: -1, months: 1 }); - - //Add one month to dtAfter to get end date - dtBefore = dtAfter.plus({ months: 1 }); - - //move after back a second for boundary - dtAfter = dtAfter.plus({ seconds: -1 }); - - //set return values from calculated values - ret.after = dtAfter.toUTC().toString(); - ret.before = dtBefore.toUTC().toString(); - break; - - default: - throw new Error( - "relative-date-time-filter-calculater: Date token [" + - token + - "] was not recognized" - ); - //-------------------------- - } - - return ret; - } - - - - { name: vm.$ay.t("DateRangeJanuary"), id: "*january*" }, - { name: vm.$ay.t("DateRangeFebruary"), id: "*february*" }, - { name: vm.$ay.t("DateRangeMarch"), id: "*march*" }, - { name: vm.$ay.t("DateRangeApril"), id: "*april*" }, - { name: vm.$ay.t("DateRangeMay"), id: "*may*" }, - { name: vm.$ay.t("DateRangeJune"), id: "*june*" }, - { name: vm.$ay.t("DateRangeJuly"), id: "*july*" }, - { name: vm.$ay.t("DateRangeAugust"), id: "*august*" }, - { name: vm.$ay.t("DateRangeSeptember"), id: "*september*" }, - { name: vm.$ay.t("DateRangeOctober"), id: "*october*" }, - { name: vm.$ay.t("DateRangeNovember"), id: "*november*" }, - { name: vm.$ay.t("DateRangeDecember"), id: "*december*" }, - { - name: vm.$ay.t("DateRangePreviousYearThisMonth"), - id: "*lastyearthismonth*" - }, - { - name: vm.$ay.t("DateRangePreviousYearLastMonth"), - id: "*lastyearlastmonth*" - }, - { - name: vm.$ay.t("DateRangePreviousYearNextMonth"), - id: "*lastyearnextmonth*" - } - - - //new functions above here -}; -//LUXON MATH: https://moment.github.io/luxon/docs/manual/zones.html#math-across-dsts -//https://moment.github.io/luxon/docs/manual/math.html -//luxon api ref: https://moment.github.io/luxon/docs/class/src/datetime.js~DateTime.html - -// //############################################################### OLD SERVER FILTERING CODE ########################## - -// //HOWEVER, if it's a relative date filter TOKEN like "nextMonth" then the users time zone offset will be taken into consideration - -// //So this is the core date time to work off of -// DateTime RelativeToday = DateTime.Today; -// DateTime RelativeNow = DateTime.Now; -// // ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("FilterSqlCriteriaBuilder::DataFilterToColumnCriteria"); -// // log.LogInformation("RelativeToday (before adjustment):"); -// // log.LogInformation(RelativeToday.ToString()); -// // log.LogInformation("RelativeNow (before adjustment):"); -// // log.LogInformation(RelativeNow.ToString()); - -// if (sValue.StartsWith("{[") && sValue.EndsWith("]}")) -// { - -// //Need to adjust RelativeToday to users time frame -// //Fetch useroptions object and relative time offset -// //See servers spec doc core-locale-currency-numbers-time-and-dates.txt for details about why this is necessary to be done this way -// AyaNova.Models.AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext; -// let u = ct.User.AsNoTracking().Where(a => a.Id == userId).Select(m => new { tz = m.UserOptions.TimeZoneOffset }).First(); - -// //Add this value to any time's hours to convert to user local time -// Double TimeZoneAdjustment = ((double)u.tz) * -1; - -// //Stock times used for many of the tokens: -// RelativeToday = RelativeToday;//flip the sign to adjust towards UTC -// RelativeNow = RelativeNow;//flip the sign to adjust towards UTC - -// //TESTING: -// //LOG THE CRIT AND QUERY -// // ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("FilterSqlCriteriaBuilder::DataFilterToColumnCriteria"); -// // log.LogInformation("RelativeToday (adjusted):"); -// // log.LogInformation(RelativeToday.ToString()); -// // log.LogInformation("RelativeNow (adjusted):"); -// // log.LogInformation(RelativeNow.ToString()); -// // log.LogInformation("Offset used:"); -// // log.LogInformation(u.tz.ToString()); - -// #region Build criteria for date RANGE TOKEN specified -// //Used as the basis point -// System.DateTime dtAfter; -// System.DateTime dtBefore; -// switch (sValue) -// { -// //Case 402 -// case DataListFilterSpecialToken.Yesterday: -// //Between Day before yesterday at midnight and yesterday at midnight -// dtAfter = RelativeToday.AddDays(-1); -// dtAfter = dtAfter.AddSeconds(-1); -// dtBefore = RelativeToday;//.AddDays(-1); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.Today: -// //Between yesterday at midnight and tommorow at midnight -// dtAfter = RelativeToday.AddSeconds(-1); -// dtBefore = RelativeToday.AddDays(1); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; -// case DataListFilterSpecialToken.Tomorrow: -// //Between Tonight at midnight and day after tommorow at midnight -// dtAfter = RelativeToday.AddDays(1); -// dtAfter = dtAfter.AddSeconds(-1); -// dtBefore = RelativeToday.AddDays(2); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// //Case 402 -// case DataListFilterSpecialToken.LastWeek: -// //Between two Sundays ago at midnight and last sunday at midnight -// dtAfter = RelativeToday; - -// //go back a week -// dtAfter = dtAfter.AddDays(-7); - -// //go backwards to Sunday -// while (dtAfter.DayOfWeek != DayOfWeek.Sunday) -// dtAfter = dtAfter.AddDays(-1); - -// //go to very start of eighth dayahead -// dtBefore = dtAfter.AddDays(8); - -// dtAfter = dtAfter.AddSeconds(-1); - -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.ThisWeek: -// //Between Sunday at midnight and Next sunday at midnight -// dtAfter = RelativeToday; -// //go backwards to monday -// while (dtAfter.DayOfWeek != DayOfWeek.Monday) -// dtAfter = dtAfter.AddDays(-1); - -// //Now go back to sunday last second -// dtAfter = dtAfter.AddSeconds(-1); - -// dtBefore = RelativeToday; -// //go forwards to monday -// if (RelativeToday.DayOfWeek == DayOfWeek.Monday) -// { -// //Monday today? then go to next monday -// dtBefore = dtBefore.AddDays(7); -// } -// else -// { -// while (dtBefore.DayOfWeek != DayOfWeek.Monday) -// dtBefore = dtBefore.AddDays(1); -// } - -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; -// case DataListFilterSpecialToken.NextWeek: -// //Between Next Sunday at midnight and Next Next sunday at midnight -// dtAfter = RelativeToday; - -// //If today is monday skip over it first -// if (dtAfter.DayOfWeek == DayOfWeek.Monday) -// dtAfter = dtAfter.AddDays(1); - -// //go forwards to next monday -// while (dtAfter.DayOfWeek != DayOfWeek.Monday) -// dtAfter = dtAfter.AddDays(1); - -// //Now go back to sunday last second -// dtAfter = dtAfter.AddDays(-1); - -// //go seven days ahead -// dtBefore = dtAfter.AddDays(7); - -// //case 1155 -// dtAfter = dtAfter.AddSeconds(-1); - -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; -// case DataListFilterSpecialToken.LastMonth: -// //start with the first day of this month -// dtAfter = new DateTime(RelativeToday.Year, RelativeToday.Month, 1, RelativeToday.Hour, RelativeToday.Minute, 00); -// //subtract a Month -// dtAfter = dtAfter.AddMonths(-1); - -// //Add one month to dtAfter to get end date -// dtBefore = dtAfter.AddMonths(1); - -// //case 1155 -// dtAfter = dtAfter.AddSeconds(-1); - -// // 'yyyy-mm-ddTHH:MM:SS' - -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; -// case DataListFilterSpecialToken.ThisMonth: -// //start with the first day of this month -// dtAfter = new DateTime(RelativeToday.Year, RelativeToday.Month, 1, RelativeToday.Hour, RelativeToday.Minute, 00); - -// //Add one month to dtAfter to get end date -// dtBefore = dtAfter.AddMonths(1); - -// //case 1155 -// dtAfter = dtAfter.AddSeconds(-1); - -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.NextMonth: -// //start with the first day of this month -// dtAfter = new DateTime(RelativeToday.Year, RelativeToday.Month, 1, RelativeToday.Hour, RelativeToday.Minute, 00); -// //Add a Month -// dtAfter = dtAfter.AddMonths(1); - -// //Add one month to dtAfter to get end date -// dtBefore = dtAfter.AddMonths(1); - -// //case 1155 -// dtAfter = dtAfter.AddSeconds(-1); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; -// case DataListFilterSpecialToken.FourteenDayWindow: -// //start with today zero hour -// dtAfter = new DateTime(RelativeToday.Year, RelativeToday.Month, RelativeToday.Day, RelativeToday.Hour, RelativeToday.Minute, 00); -// dtAfter = dtAfter.AddDays(-7); - -// //Add 15 days to get end date (zero hour so not really 15 full days) -// dtBefore = dtAfter.AddDays(15); - -// //case 1155 -// dtAfter = dtAfter.AddSeconds(-1); - -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// //case 2067 ADDITIONAL DATE RANGES ************ - -// case DataListFilterSpecialToken.Past: -// //Forever up to Now -// dtAfter = new DateTime(1753, 1, 2, 00, 00, 00); -// dtBefore = DateTime.UtcNow; -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.Future: -// //From Now to forever (999 years from now) -// dtAfter = DateTime.UtcNow; -// dtBefore = DateTime.UtcNow.AddYears(999); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.LastYear: -// //From zero hour january 1 a year ago -// dtAfter = new DateTime(RelativeNow.AddYears(-1).Year, 1, 1, 0, 0, 00).AddSeconds(-1); -// //To zero hour January 1 this year -// dtBefore = new DateTime(RelativeNow.Year, 1, 1, 0, 0, 00); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.ThisYear: -// //From zero hour january 1 this year -// dtAfter = new DateTime(RelativeNow.Year, 1, 1, 00, 00, 00).AddSeconds(-1); -// //To zero hour Jan 1 next year -// dtBefore = new DateTime(RelativeNow.AddYears(1).Year, 1, 1, 00, 00, 00); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.InTheLast3Months: -// //From Now minus 3 months -// dtAfter = DateTime.UtcNow.AddMonths(-3); -// //To Now -// dtBefore = DateTime.UtcNow; -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.InTheLast6Months: -// //From Now minus 6 months -// dtAfter = DateTime.UtcNow.AddMonths(-6); -// //To Now -// dtBefore = DateTime.UtcNow; -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.InTheLastYear: -// //From Now minus 365 days -// dtAfter = DateTime.UtcNow.AddDays(-365); -// //To Now -// dtBefore = DateTime.UtcNow; -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// //======================= -// //NEW ONES FOR RAVEN - -// case DataListFilterSpecialToken.YearToDate: -// //From zero hour january 1 this year -// dtAfter = new DateTime(RelativeNow.Year, 1, 1, 00, 00, 00).AddSeconds(-1); ; -// //To now -// dtBefore = RelativeNow; -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.Past90Days: -// //From Now minus 90 days -// dtAfter = DateTime.UtcNow.AddDays(-90); -// //To Now -// dtBefore = DateTime.UtcNow; -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; -// case DataListFilterSpecialToken.Past30Days: -// //From Now minus 30 days -// dtAfter = DateTime.UtcNow.AddDays(-30); -// //To Now -// dtBefore = DateTime.UtcNow; -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; -// case DataListFilterSpecialToken.Past24Hours: -// //From Now minus 24 hours -// dtAfter = DateTime.UtcNow.AddHours(-24); -// //To Now -// dtBefore = DateTime.UtcNow; -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.January: -// //From zero hour january 1 this year -// dtAfter = new DateTime(RelativeNow.Year, 1, 1, 00, 00, 00).AddSeconds(-1); -// //To zero hour feb 1 this year -// dtBefore = new DateTime(RelativeNow.Year, 2, 1, 00, 00, 00); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.February: -// dtAfter = new DateTime(RelativeNow.Year, 2, 1, 00, 00, 00).AddSeconds(-1); -// dtBefore = new DateTime(RelativeNow.Year, 3, 1, 00, 00, 00); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.March: -// dtAfter = new DateTime(RelativeNow.Year, 3, 1, 00, 00, 00).AddSeconds(-1); -// dtBefore = new DateTime(RelativeNow.Year, 4, 1, 00, 00, 00); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.April: -// dtAfter = new DateTime(RelativeNow.Year, 4, 1, 00, 00, 00).AddSeconds(-1); -// dtBefore = new DateTime(RelativeNow.Year, 5, 1, 00, 00, 00); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.May: -// dtAfter = new DateTime(RelativeNow.Year, 5, 1, 00, 00, 00).AddSeconds(-1); -// dtBefore = new DateTime(RelativeNow.Year, 6, 1, 00, 00, 00); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.June: -// dtAfter = new DateTime(RelativeNow.Year, 6, 1, 00, 00, 00).AddSeconds(-1); -// dtBefore = new DateTime(RelativeNow.Year, 7, 1, 00, 00, 00); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.July: -// dtAfter = new DateTime(RelativeNow.Year, 7, 1, 00, 00, 00).AddSeconds(-1); -// dtBefore = new DateTime(RelativeNow.Year, 8, 1, 00, 00, 00); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.August: -// dtAfter = new DateTime(RelativeNow.Year, 8, 1, 00, 00, 00).AddSeconds(-1); -// dtBefore = new DateTime(RelativeNow.Year, 9, 1, 00, 00, 00); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.September: -// dtAfter = new DateTime(RelativeNow.Year, 9, 1, 00, 00, 00).AddSeconds(-1); -// dtBefore = new DateTime(RelativeNow.Year, 10, 1, 00, 00, 00); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.October: -// dtAfter = new DateTime(RelativeNow.Year, 10, 1, 00, 00, 00).AddSeconds(-1); -// dtBefore = new DateTime(RelativeNow.Year, 11, 1, 00, 00, 00); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.November: -// dtAfter = new DateTime(RelativeNow.Year, 11, 1, 00, 00, 00).AddSeconds(-1); -// dtBefore = new DateTime(RelativeNow.Year, 12, 1, 00, 00, 00); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// case DataListFilterSpecialToken.December: -// //From zero hour dec 1 this year -// dtAfter = new DateTime(RelativeNow.Year, 12, 1, 00, 00, 00).AddSeconds(-1); -// //To zero hour Jan 1 next year -// dtBefore = new DateTime(RelativeNow.AddYears(1).Year, 1, 1, 00, 00, 00); -// BuildBetweenTwoDatesFragment(SqlColumnNameToFilter, sb, dtAfter, dtBefore); -// break; - -// -// //----- -// } - -// #endregion -// } -// else -// { - -################################################################################################### -Javascript version of date de-tokenizer taken from most recent grid code: - -// //////////////////// -// // -// function untokenizeListView(lvJson) { -// //if it has one or more tokens -// //iterate the array and build a new array with substituted tokens with the correct date and time in them - -// //format of a date token filter -// //[{"fld":"widgetname"},{"fld":"widgetstartdate","filter":{"items":[{"op":"=","value":"*past90days*","token":true}]}},{"fld":"widgetenddate"}] -// if (lvJson == null) { -// return lvJson; -// } -// //See if it has any date tokens -// if (lvJson.indexOf('"token":true') == -1) { -// return lvJson; -// } - -// //we have one or more tokens, substitute them in the filter array -// let ret = []; -// let lv = JSON.parse(lvJson); - -// //iterate the incoming and copy to the outgoing directly -// //except if a date token filter then substitute our own filter object in place -// for (let ilv = 0; ilv < lv.length; ilv++) { -// //listview object -// let lvo = lv[ilv]; -// //instantiate return object -// let reto = {}; -// //copy over field name to return object -// reto.fld = lvo.fld; -// //sort? -// if (lvo.sort) { -// reto.sort = lvo.sort; -// } -// //does it have a filter? -// if (lvo.filter) { -// //yes, so copy / transform as required - -// //create an empty filter items array on return object -// reto.filter = { items: [] }; - -// //"any" property set? -// if (lvo.filter.any) { -// reto.filter.any = true; -// } - -// //iterate the filter items in the source lvo object -// for (let j = 0; j < lvo.filter.items.length; j++) { -// //get this filter item -// let fi = lvo.filter.items[j]; -// //no token shortcut -// if (!fi.token) { -// //just copy it out -// reto.filter.items.push(fi); -// } else { -// //it has a date token so let's build it out -// //filter item value contains the token, op is always equals -// let filterDates = relativeDatefilterCalculator.tokenToDates(fi.value); -// //create and add a new filter item for each not undefined value -// //{ after: undefined, before: undefined } -// //AFTER DATE? -// if (filterDates.after) { -// reto.filter.items.push({ -// op: ">", //was GreaterThanOrEqualTo but that doesn't make sense, it's only greater than was seeing wrong return data as relative date filter already adjusts for boundaries -// value: filterDates.after -// }); -// } -// //BEFORE DATE? -// if (filterDates.before) { -// reto.filter.items.push({ -// op: "<", //was LessThanOrEqualTo but see above for after ===-----^ -// value: filterDates.before -// }); -// } -// } -// } - -// //end of has filter if condition -// } - -// //push the return object into the return array -// ret.push(reto); -// //end of iterate lv loop -// } - -// return JSON.stringify(ret); -// } //[{"fld":"widgetname"},{"fld":"widgetstartdate","filter":{"items":[{"op":"=","value":"*past90days*","token":true}]}},{"fld":"widgetenddate"}] - -*/ \ No newline at end of file +}//ens \ No newline at end of file diff --git a/server/AyaNova/DataList/DataListSqlFilterOrderByBuilder.cs b/server/AyaNova/DataList/DataListSqlFilterOrderByBuilder.cs index e20e39bb..9b9ee1e0 100644 --- a/server/AyaNova/DataList/DataListSqlFilterOrderByBuilder.cs +++ b/server/AyaNova/DataList/DataListSqlFilterOrderByBuilder.cs @@ -1,60 +1,36 @@ using System.Text; using System.Linq; -using Newtonsoft.Json.Linq; using System.Collections.Generic; -using AyaNova.Models; namespace AyaNova.DataList { public static class DataListSqlFilterOrderByBuilder { - - public static string DataFilterToSQLOrderBy(List objectFieldsList, Models.DataListProcessingBase listOptions) { - StringBuilder sb = new StringBuilder(); - - //iterate the datafilter and concatenate a sql query from it - // [{key:"COLUMN UNIQUE KEY ID",sort:"-" or "+",filter:{any:true/false,items:[{FILTER OBJECT SEE BELOW}]} }, {key:"second column unique key"},{...etc...}] bool SortItemAdded = false; - // for (int i = 0; i < listViewArray.Count; i++) - foreach(KeyValuePair kvSort in listOptions.SortBy) + foreach (KeyValuePair kvSort in listOptions.SortBy) { - // var cm = listViewArray[i]; - // //skip it if sort is not defined - // if (cm["sort"] == null) - // { - // continue; - // } - // var fld = cm["fld"].Value(); - // var dir = cm["sort"].Value(); - //Get the correct sql column name DataListFieldDefinition DataListField = objectFieldsList.FirstOrDefault(z => z.FieldKey == kvSort.Key); //No sorting on custom fields! if (DataListField.IsCustomField) - { continue; - } #if (DEBUG) //Developers little helper if (DataListField == null) - { throw new System.ArgumentNullException($"DEV ERROR in DataListSqlFilterOrderByBuilder.cs: field {kvSort.Key} specified in template was NOT found in ObjectFields list"); - } + #endif var SQLValueColumnName = DataListField.GetSqlValueColumnName(); - if (SortItemAdded) sb.Append(", "); else sb.Append(" "); sb.Append(SQLValueColumnName); sb.Append(" "); - //sb.Append(dir == "+" ? "ASC" : "DESC"); sb.Append(kvSort.Value == "+" ? "ASC" : "DESC"); - SortItemAdded = true; } @@ -63,22 +39,13 @@ namespace AyaNova.DataList //no sort specified so default it DataListFieldDefinition rid = objectFieldsList.FirstOrDefault(z => z.IsRowId == true); if (rid != null) - { return $"ORDER BY {rid.SqlIdColumnName} DESC"; - } else - { - //no default column so no idea how to sort - return string.Empty; - } + return string.Empty; //no default column so no idea how to sort } else - { return "ORDER BY" + sb.ToString(); - } } - - }//eoc }//ens diff --git a/server/AyaNova/DataList/DataListSqlSelectBuilder.cs b/server/AyaNova/DataList/DataListSqlSelectBuilder.cs index 68a0c5da..9dacc294 100644 --- a/server/AyaNova/DataList/DataListSqlSelectBuilder.cs +++ b/server/AyaNova/DataList/DataListSqlSelectBuilder.cs @@ -18,7 +18,6 @@ namespace AyaNova.DataList { StringBuilder sb = new StringBuilder(); sb.Append("SELECT "); - //keep track of which custom fields columns were added already //this ensures that if there is more than one set of custom fields like from two different objects in the list //only unique ones will be returned by query @@ -113,167 +112,15 @@ namespace AyaNova.DataList //Build the SELECT portion of a list query but only to return rowid's - internal static string BuildForIdListResponse(List fieldDefinitions, DataListSelectedProcessingOptions dataListSelectionOptions) { - //BugBug - is not including internalcriteria OR user filtered columns so they don't filter properly - //needs to be there and also return correct 0th column for id filtering or make sure it's always the zeroth I guess - StringBuilder sb = new StringBuilder(); sb.Append("SELECT "); - //map sql column name to ordinal name - // Dictionary map = new Dictionary(); - - //FIRST: find the rowid in the objectfields list and insert it - //this is now the zeroth column + //note: only need rowid column for these queries, the where conditions don't rely on any defined column names as they explicitly refer to the exact identifier known to postgres //Note: IsRowId field should *always* exist for any list that is intended to be used in an idlist response var o = fieldDefinitions.FirstOrDefault(z => z.IsRowId == true); sb.Append(o.SqlIdColumnName); - // map.Add(o.SqlIdColumnName, 0); - -//DO I NEED THIS? NO! You don't need to return columns that are mentioned in WHERE clause unless it's an AS scenario I guess - // //Now add any rows found in filter - // foreach(var filter in dataListSelectionOptions.Filter){ - // //add all columns being filtered but not rowId - // var fld=fieldDefinitions.FirstOrDefault(z=>z.FieldKey==filter.Column); - // if(!fld.IsRowId){ - // sb.Append($",{fld.SqlIdColumnName}"); - // //map.Add(fld.SqlIdColumnName); - // } - - // } - - - return sb.ToString(); }//eom - - - // internal static SqlSelectBuilderResult BuildForReportIdListOnly(List objectFieldsList) - // { - // //BugBug - is not including internalcriteria columns so they don't filter properly - // //needs to be there and also return correct 0th column for id filtering or make sure it's always the zeroth I guess - - // StringBuilder sb = new StringBuilder(); - // sb.Append("SELECT "); - // //map sql column name to ordinal name - // Dictionary map = new Dictionary(); - - // //find the rowid in the objectfields list and insert it - // var o = objectFieldsList.FirstOrDefault(z => z.IsRowId == true); - // if (o != null) - // { - // var idColumnName = o.SqlIdColumnName; - // if (!string.IsNullOrWhiteSpace(idColumnName)) - // { - // sb.Append(idColumnName); - // map.Add(idColumnName, 0); - // } - // } - - // return new SqlSelectBuilderResult() { map = map, Select = sb.ToString() }; - // }//eom - - - // //Build the SELECT portion of a list query but only to return rowid's - // internal static SqlSelectBuilderResult BuildForReportIdListOnly(List objectFieldsList, List listViewFieldList) - // { - // StringBuilder sb = new StringBuilder(); - // sb.Append("SELECT "); - // //map sql column name to ordinal name - // Dictionary map = new Dictionary(); - // int nOrdinal = 0; - - // var firstColumnAdded = false; - // foreach (string ColumnName in listViewFieldList) - // { - // AyaDataListFieldDefinition o = objectFieldsList.FirstOrDefault(z => z.FieldKey == ColumnName); - // #if (DEBUG) - // //Developers little helper - // if (o == null) - // { - // throw new System.ArgumentNullException($"DEV ERROR in DataListSqlSelectBuilder.cs:BuildForReportIdListOnly() field {ColumnName} specified in template was NOT found in ObjectFields list"); - // } - // #endif - // if (o != null && o.IsRowId)//only return the rowid column - // {//Ignore missing fields in production - // AddTheColumn(sb, map, ref nOrdinal, ref firstColumnAdded, o); - // } - // } - - - // //insert rowid if it wasn't specified already in the list view - // //this is legit as some datalists don't have a rowid visible to user e.g. PartInventoryOnHand - // if (map.Count == 0) - // { - // //find the rowid in the objectfields list and insert it since it wasn't in the view already - // var o = objectFieldsList.FirstOrDefault(z => z.IsRowId == true); - // if (o != null) - // { - // // if(!string.IsNullOrWhiteSpace(rowIdColumn.SqlIdColumnName)){ - // // map.Add(rowIdColumn.SqlIdColumnName, nOrdinal++); - // // }else{ - // // map.Add(rowIdColumn.GetSqlValueColumnName(), nOrdinal++); - // // } - // AddTheColumn(sb, map, ref nOrdinal, ref firstColumnAdded, o); - // } - - // } - // return new SqlSelectBuilderResult() { map = map, Select = sb.ToString() }; - // }//eof - - - - - // private static void AddTheColumn(StringBuilder sb, Dictionary map, ref int nOrdinal, ref bool firstColumnAdded, AyaDataListFieldDefinition o) - // { - // // var valueColumnName = o.GetSqlValueColumnName(); - // // if (!map.ContainsKey(valueColumnName)) - // // { - // // if (firstColumnAdded) - // // sb.Append(", "); - // // sb.Append(valueColumnName); - // // firstColumnAdded = true; - // // map.Add(valueColumnName, nOrdinal++); - // // } - - // // //does it also have an ID column? - // // var idColumnName = o.SqlIdColumnName; - // // if (!string.IsNullOrWhiteSpace(idColumnName)) - // // { - // // if (!map.ContainsKey(idColumnName)) - // // { - // // if (firstColumnAdded) - // // sb.Append(", "); - // // sb.Append(idColumnName); - // // firstColumnAdded = true; - // // map.Add(idColumnName, nOrdinal++); - // // } - // // } - - // // var valueColumnName = o.GetSqlValueColumnName(); - // // if (!map.ContainsKey(valueColumnName)) - // // { - // // if (firstColumnAdded) - // // sb.Append(", "); - // // sb.Append(valueColumnName); - // // firstColumnAdded = true; - // // map.Add(valueColumnName, nOrdinal++); - // // } - - // //does it also have an ID column? - // var idColumnName = o.SqlIdColumnName; - // if (!string.IsNullOrWhiteSpace(idColumnName)) - // { - // // if (!map.ContainsKey(idColumnName)) - // // { - // // if (firstColumnAdded) - // // sb.Append(", "); - // sb.Append(idColumnName); - // // firstColumnAdded = true; - // map.Add(idColumnName, 0); - // // } - // } - // } }//eoc }//ens diff --git a/server/AyaNova/DataList/EventDataList.cs b/server/AyaNova/DataList/EventDataList.cs index d1155568..ca92bb37 100644 --- a/server/AyaNova/DataList/EventDataList.cs +++ b/server/AyaNova/DataList/EventDataList.cs @@ -3,14 +3,7 @@ using AyaNova.Biz; namespace AyaNova.DataList { internal class EventDataList : DataListProcessingBase - {/* - Select aevent.id, aevent.created, aevent.ayid, aevent.ayatype, aevent.ayevent, - aevent.textra, auser.name, auser.id - from aevent - left join auser on (aevent.userid=auser.id) - - */ - + { public EventDataList() { //NOTE: used this type because it's full BizFull and read only BizLimited only which is appropriate and there is no event type @@ -18,38 +11,6 @@ namespace AyaNova.DataList SQLFrom = "from aevent left join auser on (aevent.userid=auser.id)"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - // //Default ListView - // dynamic dlistView = new JArray(); - - // dynamic cm = new JObject(); - // cm.fld = "eventcreated"; - // cm.sort = "-"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "event"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "object"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "AyaType"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "username"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "textra"; - // dlistView.Add(cm); - - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "eventcreated", "event", "object", "AyaType", "username", "textra" }; DefaultSortBy = new Dictionary() { { "eventcreated", "-" } }; @@ -108,9 +69,6 @@ namespace AyaNova.DataList UiFieldDataType = (int)UiFieldDataType.Text, SqlValueColumnName = "aevent.textra" }); - - } - }//eoc }//eons \ No newline at end of file diff --git a/server/AyaNova/DataList/HeadOfficeDataList.cs b/server/AyaNova/DataList/HeadOfficeDataList.cs index 79d522bd..850b9d43 100644 --- a/server/AyaNova/DataList/HeadOfficeDataList.cs +++ b/server/AyaNova/DataList/HeadOfficeDataList.cs @@ -10,30 +10,9 @@ namespace AyaNova.DataList SQLFrom = "from aheadoffice left join acontract on (aheadoffice.contractid=acontract.id)"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - // //Default ListView - // dynamic dlistView = new JArray(); - - // dynamic cm = new JObject(); - // cm.fld = "headofficename"; - // cm.sort = "+"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "headofficephone1"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "headofficeemail"; - // dlistView.Add(cm); - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "headofficename", "headofficephone1", "headofficeemail" }; DefaultSortBy = new Dictionary() { { "headofficename", "+" } }; - - //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition @@ -272,6 +251,5 @@ namespace AyaNova.DataList FieldDefinitions.Add(new DataListFieldDefinition { TKey = "HeadOfficeCustom16", FieldKey = "headofficecustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" }); } - }//eoc }//eons \ No newline at end of file diff --git a/server/AyaNova/DataList/IDataListProcessing.cs b/server/AyaNova/DataList/IDataListProcessing.cs index 29cc1119..8d129120 100644 --- a/server/AyaNova/DataList/IDataListProcessing.cs +++ b/server/AyaNova/DataList/IDataListProcessing.cs @@ -1,36 +1,21 @@ using System.Collections.Generic; -using Newtonsoft.Json.Linq; using AyaNova.Biz; -using AyaNova.Models; namespace AyaNova.DataList { internal interface IDataListProcessing { - //sql query from fragment with table joins et string SQLFrom { get; set; } - //List of fields for this object List FieldDefinitions { get; set; } - //allowed roles to access this list AuthorizationRoles AllowedRoles { get; set; } - //Default object type to open for rows of this list (use no object if no) AyaType DefaultListObjectType { get; set; } - //Defaults when none is specified (see DataListOptions for formats and notes) - List DefaultColumns { get; set; } - Dictionary DefaultSortBy { get; set; } - + List DefaultColumns { get; set; } + Dictionary DefaultSortBy { get; set; } void SetListOptionDefaultsIfNecessary(Models.DataListProcessingBase listOptions); - Newtonsoft.Json.Linq.JArray GenerateReturnListColumns(List columns); - // List GetFieldListFromListView(JArray listViewArray); - - - - } - } \ No newline at end of file diff --git a/server/AyaNova/DataList/InsideUserDataList.cs b/server/AyaNova/DataList/InsideUserDataList.cs index aa9a5cff..365b7668 100644 --- a/server/AyaNova/DataList/InsideUserDataList.cs +++ b/server/AyaNova/DataList/InsideUserDataList.cs @@ -13,38 +13,6 @@ namespace AyaNova.DataList SQLFrom = "from auser left join avendor on (auser.vendorid=avendor.id)"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - // //Default ListView - // dynamic dlistView = new JArray(); - - // dynamic cm = new JObject(); - // cm.fld = "name"; - // cm.sort = "+"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "employeenumber"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "active"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "usertype"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "lastlogin"; - // dlistView.Add(cm); - - - // cm = new JObject(); - // cm.fld = "roles"; - // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "name", "employeenumber", "active", "usertype", "lastlogin", "roles" }; DefaultSortBy = new Dictionary() { { "name", "+" } }; @@ -124,8 +92,6 @@ namespace AyaNova.DataList SqlValueColumnName = "auser.usertype", IsMeta = true }); - - } public List DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria) diff --git a/server/AyaNova/DataList/LoanUnitDataList.cs b/server/AyaNova/DataList/LoanUnitDataList.cs index a9270d65..0727c899 100644 --- a/server/AyaNova/DataList/LoanUnitDataList.cs +++ b/server/AyaNova/DataList/LoanUnitDataList.cs @@ -16,31 +16,9 @@ namespace AyaNova.DataList //todo: look at loanitemlist in v7 it surfaces due date, out date etc in the list and should here too once those fields are coded for var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - // //Default ListView - // dynamic dlistView = new JArray(); - // dynamic cm = null; - - // cm = new JObject(); - // cm.fld = "LoanUnitName"; - // cm.sort = "+"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "LoanUnitSerial"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "Tags"; - // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "LoanUnitName", "LoanUnitSerial", "Tags" }; DefaultSortBy = new Dictionary() { { "LoanUnitName", "+" } }; - FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition { @@ -85,7 +63,6 @@ namespace AyaNova.DataList SqlValueColumnName = "aloanunit.tags" }); - FieldDefinitions.Add(new DataListFieldDefinition { FieldKey = "LoanUnitCurrentWorkOrderItemLoan", @@ -163,7 +140,6 @@ namespace AyaNova.DataList SqlValueColumnName = "shadowunit.serial" }); - FieldDefinitions.Add(new DataListFieldDefinition { TKey = "LoanUnitCustom1", FieldKey = "loanunitcustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aloanunit.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "LoanUnitCustom2", FieldKey = "loanunitcustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aloanunit.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "LoanUnitCustom3", FieldKey = "loanunitcustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aloanunit.customfields" }); @@ -182,6 +158,5 @@ namespace AyaNova.DataList FieldDefinitions.Add(new DataListFieldDefinition { TKey = "LoanUnitCustom16", FieldKey = "loanunitcustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aloanunit.customfields" }); } - }//eoc }//eons \ No newline at end of file diff --git a/server/AyaNova/DataList/MemoDataList.cs b/server/AyaNova/DataList/MemoDataList.cs index 48233e9f..0efdbf67 100644 --- a/server/AyaNova/DataList/MemoDataList.cs +++ b/server/AyaNova/DataList/MemoDataList.cs @@ -12,36 +12,8 @@ namespace AyaNova.DataList SQLFrom = "from amemo left join auser on (amemo.fromid=auser.id)"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - // //Default ListView - // dynamic dlistView = new JArray(); - - - // dynamic cm = new JObject(); - // cm.fld = "MemoSubject"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "MemoFromID"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "MemoSent"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "MemoViewed"; - // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "MemoSubject", "MemoFromID", "MemoSent", "MemoViewed" }; - DefaultSortBy = new Dictionary() { { "MemoSent", "-" } };//added but wasnt' in original - - - //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely + DefaultSortBy = new Dictionary() { { "MemoSent", "-" } }; FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition @@ -147,7 +119,5 @@ namespace AyaNova.DataList return ret; } - - }//eoc }//eons \ No newline at end of file diff --git a/server/AyaNova/DataList/OutsideUserDataList.cs b/server/AyaNova/DataList/OutsideUserDataList.cs index 7c1cd890..71cea095 100644 --- a/server/AyaNova/DataList/OutsideUserDataList.cs +++ b/server/AyaNova/DataList/OutsideUserDataList.cs @@ -12,37 +12,9 @@ namespace AyaNova.DataList SQLFrom = "from auser left join aheadoffice on (auser.headofficeid=aheadoffice.id) left join acustomer on (auser.customerid=acustomer.id)"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - // //Default ListView - // dynamic dlistView = new JArray(); - - // dynamic cm = new JObject(); - // cm.fld = "name"; - // cm.sort = "+"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "active"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "usercustomer"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "userheadoffice"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "lastlogin"; - // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "name", "active", "usercustomer", "userheadoffice", "lastlogin" }; DefaultSortBy = new Dictionary() { { "name", "+" } }; - FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition { @@ -63,7 +35,6 @@ namespace AyaNova.DataList SqlValueColumnName = "auser.employeenumber" }); - FieldDefinitions.Add(new DataListFieldDefinition { TKey = "Active", @@ -119,7 +90,7 @@ namespace AyaNova.DataList SqlValueColumnName = "acustomer.name" }); - //META COLUMNS + //META COLUMNS FieldDefinitions.Add(new DataListFieldDefinition { FieldKey = "metausertype", @@ -130,12 +101,12 @@ namespace AyaNova.DataList }); } - public List DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles,string clientCriteria) + public List DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria) { List ret = new List(); DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metausertype" }; - FilterOption.Any=true; + FilterOption.Any = true; FilterOption.Items.Add(new DataListColumnFilter() { value = ((int)UserType.Customer).ToString(), op = DataListFilterComparisonOperator.Equality }); FilterOption.Items.Add(new DataListColumnFilter() { value = ((int)UserType.HeadOffice).ToString(), op = DataListFilterComparisonOperator.Equality }); diff --git a/server/AyaNova/DataList/PartAssemblyDataList.cs b/server/AyaNova/DataList/PartAssemblyDataList.cs index 7477d222..4a521b65 100644 --- a/server/AyaNova/DataList/PartAssemblyDataList.cs +++ b/server/AyaNova/DataList/PartAssemblyDataList.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Newtonsoft.Json.Linq; using AyaNova.Biz; namespace AyaNova.DataList { @@ -11,24 +10,8 @@ namespace AyaNova.DataList SQLFrom = "from apartassembly"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - // //Default ListView - // dynamic dlistView = new JArray(); - // dynamic cm = null; - - // cm = new JObject(); - // cm.fld = "partassemblyname"; - // cm.sort = "+"; - // dlistView.Add(cm); - - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "partassemblyname" }; DefaultSortBy = new Dictionary() { { "partassemblyname", "+" } }; - - FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition @@ -66,10 +49,6 @@ namespace AyaNova.DataList SqlValueColumnName = "apartassembly.tags" }); - - - //----------- - FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartAssemblyCustom1", FieldKey = "partassemblycustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "apartassembly.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartAssemblyCustom2", FieldKey = "partassemblycustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "apartassembly.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartAssemblyCustom3", FieldKey = "partassemblycustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "apartassembly.customfields" }); diff --git a/server/AyaNova/DataList/PartDataList.cs b/server/AyaNova/DataList/PartDataList.cs index 7026fa00..a030d150 100644 --- a/server/AyaNova/DataList/PartDataList.cs +++ b/server/AyaNova/DataList/PartDataList.cs @@ -7,48 +7,14 @@ namespace AyaNova.DataList public PartDataList() { DefaultListObjectType = AyaType.Part; - SQLFrom = "from apart " + "left join avendor as aman on (apart.manufacturerid=aman.id) " + "left join avendor as awhole on (apart.wholesalerid=awhole.id) " + "left join avendor as aaltwhole on (apart.alternativewholesalerid=aaltwhole.id)"; - var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - // //Default ListView - // dynamic dlistView = new JArray(); - // dynamic cm = null; - - // cm = new JObject(); - // cm.fld = "PartPartNumber"; - // cm.sort = "+"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "PartName"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "PartManufacturerID"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "PartWholesalerID"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "Tags"; - // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "PartPartNumber", "PartName", "PartManufacturerID", "PartWholesalerID", "Tags" }; DefaultSortBy = new Dictionary() { { "PartPartNumber", "+" } }; - - - //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition @@ -70,7 +36,6 @@ namespace AyaNova.DataList SqlValueColumnName = "apart.name" }); - FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartNotes", @@ -111,7 +76,6 @@ namespace AyaNova.DataList SqlValueColumnName = "apart.retail" }); - FieldDefinitions.Add(new DataListFieldDefinition { FieldKey = "PartManufacturerID", @@ -182,10 +146,6 @@ namespace AyaNova.DataList SqlValueColumnName = "apart.upc" }); - - - //----------- - FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartCustom1", FieldKey = "partcustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "apart.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartCustom2", FieldKey = "partcustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "apart.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartCustom3", FieldKey = "partcustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "apart.customfields" }); diff --git a/server/AyaNova/DataList/PartInventoryDataList.cs b/server/AyaNova/DataList/PartInventoryDataList.cs index db67ccb2..fd921c25 100644 --- a/server/AyaNova/DataList/PartInventoryDataList.cs +++ b/server/AyaNova/DataList/PartInventoryDataList.cs @@ -9,55 +9,16 @@ namespace AyaNova.DataList { public PartInventoryDataList() { - DefaultListObjectType = AyaType.PartInventory; SQLFrom = "from vpartinventorynow " + "left join apart on (vpartinventorynow.partid=apart.id) " + "left join apartwarehouse on (vpartinventorynow.partwarehouseid=apartwarehouse.id) "; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - // //Default ListView - show all transactions in order - // dynamic dlistView = new JArray(); - // dynamic cm = null; - - // cm = new JObject(); - // cm.fld = "PartPartNumber"; - // cm.sort = "+"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "PartWarehouseName"; - // cm.sort = "+"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "PartInventoryBalance"; - // dlistView.Add(cm); - - // // cm = new JObject(); - // // cm.fld = "PartInventoryTransactionDescription"; - // // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "PartPartNumber", "PartWarehouseName", "PartInventoryBalance", "PartInventoryTransactionDescription" }; DefaultSortBy = new Dictionary() { { "PartPartNumber", "+" }, { "PartWarehouseName", "+" } }; - - FieldDefinitions = new List(); - // FieldDefinitions.Add(new AyaDataListFieldDefinition - // { - // TKey = "PartInventoryTransactionSource", - // FieldKey = "PartInventoryTransactionSource", - // UiFieldDataType = (int)UiFieldDataType.Text, - // SqlIdColumnName = "vpartinventorynow.sourceid", - // SqlValueColumnName = "AYGETNAME(vpartinventorynow.sourceid, vpartinventorynow.sourcetype)", - // SqlAyTypeColumnName = "vpartinventorynow.sourcetype" - // }); - FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartPartNumber", @@ -90,22 +51,6 @@ namespace AyaNova.DataList IsRowId = true }); - // FieldDefinitions.Add(new AyaDataListFieldDefinition - // { - // TKey = "PartInventoryTransactionEntryDate", - // FieldKey = "PartInventoryTransactionEntryDate", - // UiFieldDataType = (int)UiFieldDataType.DateTime, - // SqlValueColumnName = "vpartinventorynow.entrydate" - // }); - - // FieldDefinitions.Add(new AyaDataListFieldDefinition - // { - // TKey = "PartInventoryTransactionQuantity", - // FieldKey = "PartInventoryTransactionQuantity", - // UiFieldDataType = (int)UiFieldDataType.Decimal, - // SqlValueColumnName = "vpartinventorynow.quantity" - // }); - FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartInventoryBalance", @@ -114,7 +59,6 @@ namespace AyaNova.DataList SqlValueColumnName = "vpartinventorynow.balance" }); - //META FieldDefinitions.Add(new DataListFieldDefinition { diff --git a/server/AyaNova/DataList/PartInventoryTransactionsDataList.cs b/server/AyaNova/DataList/PartInventoryTransactionsDataList.cs index 912c44db..85b02b66 100644 --- a/server/AyaNova/DataList/PartInventoryTransactionsDataList.cs +++ b/server/AyaNova/DataList/PartInventoryTransactionsDataList.cs @@ -9,57 +9,17 @@ namespace AyaNova.DataList { public PartInventoryTransactionsDataList() { - DefaultListObjectType = AyaType.PartInventory; SQLFrom = "from apartinventory " + "left join apart on (apartinventory.partid=apart.id) " + "left join apartwarehouse on (apartinventory.partwarehouseid=apartwarehouse.id) "; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - // //Default ListView - show all transactions in order - // dynamic dlistView = new JArray(); - // dynamic cm = null; - // cm = new JObject(); - - // cm.fld = "PartInventoryTransactionEntryDate"; - // cm.sort = "-"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "PartPartNumber"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "PartWarehouseName"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "PartInventoryTransactionQuantity"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "PartInventoryTransactionDescription"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "PartInventoryTransactionSource"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "PartInventoryBalance"; - // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "PartInventoryTransactionEntryDate", "PartPartNumber", "PartWarehouseName", "PartInventoryTransactionQuantity", "PartInventoryTransactionDescription", "PartInventoryTransactionSource", "PartInventoryBalance" }; DefaultSortBy = new Dictionary() { { "PartInventoryTransactionEntryDate", "-" } }; - - FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition @@ -147,10 +107,9 @@ namespace AyaNova.DataList SqlValueColumnName = "apartwarehouse.name", IsMeta = true }); - } - + public List DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria) { List ret = new List(); diff --git a/server/AyaNova/DataList/PartWarehouseDataList.cs b/server/AyaNova/DataList/PartWarehouseDataList.cs index 53e7abe5..a5fcc158 100644 --- a/server/AyaNova/DataList/PartWarehouseDataList.cs +++ b/server/AyaNova/DataList/PartWarehouseDataList.cs @@ -10,31 +10,8 @@ namespace AyaNova.DataList SQLFrom = "from apartwarehouse"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - // //Default ListView - // dynamic dlistView = new JArray(); - // dynamic cm = null; - - // cm = new JObject(); - // cm.fld = "PartWarehouseName"; - // cm.sort = "+"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "Active"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "Tags"; - // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "PartWarehouseName", "Active", "Tags" }; DefaultSortBy = new Dictionary() { { "PartWarehouseName", "+" } }; - - FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition @@ -72,10 +49,6 @@ namespace AyaNova.DataList SqlValueColumnName = "apartwarehouse.tags" }); - - - //----------- - FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartWarehouseCustom1", FieldKey = "partwarehousecustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "apartwarehouse.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartWarehouseCustom2", FieldKey = "partwarehousecustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "apartwarehouse.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "PartWarehouseCustom3", FieldKey = "partwarehousecustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "apartwarehouse.customfields" }); diff --git a/server/AyaNova/DataList/ProjectDataList.cs b/server/AyaNova/DataList/ProjectDataList.cs index 54a04f5a..e9bd52ee 100644 --- a/server/AyaNova/DataList/ProjectDataList.cs +++ b/server/AyaNova/DataList/ProjectDataList.cs @@ -10,48 +10,9 @@ namespace AyaNova.DataList SQLFrom = "from aproject left join auser on (aproject.projectoverseerid=auser.id)"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - // //Default ListView - // dynamic dlistView = new JArray(); - // dynamic cm = null; - - // cm = new JObject(); - // cm.fld = "projectname"; - // cm.sort = "+"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ProjectProjectOverseerID"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ProjectDateStarted"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ProjectDateCompleted"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ProjectAccountNumber"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "projectactive"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "projecttags"; - // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - - DefaultColumns = new List() { "projectname", "ProjectProjectOverseerID", "ProjectDateStarted", "ProjectDateCompleted", "ProjectAccountNumber", "projectactive", "projecttags" }; DefaultSortBy = new Dictionary() { { "projectname", "+" } }; - FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition @@ -89,9 +50,6 @@ namespace AyaNova.DataList SqlValueColumnName = "aproject.tags" }); - - //------------ - FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ProjectAccountNumber", @@ -125,7 +83,6 @@ namespace AyaNova.DataList UiFieldDataType = (int)UiFieldDataType.DateTime, SqlValueColumnName = "aproject.datecompleted" }); - //----------- FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ProjectCustom1", FieldKey = "projectcustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ProjectCustom2", FieldKey = "projectcustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" }); diff --git a/server/AyaNova/DataList/ReminderDataList.cs b/server/AyaNova/DataList/ReminderDataList.cs index e070c42f..2a16d29f 100644 --- a/server/AyaNova/DataList/ReminderDataList.cs +++ b/server/AyaNova/DataList/ReminderDataList.cs @@ -7,39 +7,12 @@ namespace AyaNova.DataList { public ReminderDataList() { - DefaultListObjectType = AyaType.Reminder; SQLFrom = "from areminder"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - - // dynamic dlistView = new JArray(); - - // dynamic cm = new JObject(); - // cm.fld = "ReminderName"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ReminderNotes"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ReminderStopDate"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ReminderStartDate"; - // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "ReminderName", "ReminderNotes", "ReminderStopDate", "ReminderStartDate" }; DefaultSortBy = new Dictionary() { { "ReminderStopDate", "-" } }; - - //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition @@ -62,7 +35,6 @@ namespace AyaNova.DataList SqlValueColumnName = "areminder.notes" }); - FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderStartDate", @@ -113,7 +85,6 @@ namespace AyaNova.DataList FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom14", FieldKey = "ReminderCustom14", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom15", FieldKey = "ReminderCustom15", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReminderCustom16", FieldKey = "ReminderCustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areminder.customfields" }); - } //Ensure only current user can fetch their reminders diff --git a/server/AyaNova/DataList/ReportDataList.cs b/server/AyaNova/DataList/ReportDataList.cs index 146963d2..2a05fc8a 100644 --- a/server/AyaNova/DataList/ReportDataList.cs +++ b/server/AyaNova/DataList/ReportDataList.cs @@ -4,38 +4,16 @@ namespace AyaNova.DataList { internal class ReportDataList : DataListProcessingBase { - public ReportDataList() { DefaultListObjectType = AyaType.Report; SQLFrom = "from aReport"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - // //Default ListView - // dynamic dlistView = new JArray(); - - // dynamic cm = new JObject(); - // cm.fld = "name"; - // cm.sort = "+"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "objecttype"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "active"; - // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "name", "objecttype", "active" }; DefaultSortBy = new Dictionary() { { "name", "+" } }; - - - FieldDefinitions = new List(); + FieldDefinitions.Add(new DataListFieldDefinition { TKey = "Report", @@ -47,7 +25,6 @@ namespace AyaNova.DataList IsRowId = true }); - FieldDefinitions.Add(new DataListFieldDefinition { TKey = "AyaType", @@ -57,7 +34,6 @@ namespace AyaNova.DataList SqlValueColumnName = "areport.ObjectType" }); - FieldDefinitions.Add(new DataListFieldDefinition { TKey = "Active", @@ -66,8 +42,6 @@ namespace AyaNova.DataList SqlValueColumnName = "aReport.active" }); - - } }//eoc }//eons \ No newline at end of file diff --git a/server/AyaNova/DataList/ReviewDataList.cs b/server/AyaNova/DataList/ReviewDataList.cs index 66a57adc..10d0b5c4 100644 --- a/server/AyaNova/DataList/ReviewDataList.cs +++ b/server/AyaNova/DataList/ReviewDataList.cs @@ -15,49 +15,10 @@ namespace AyaNova.DataList + "left join auser uassby on (areview.assignedbyuserid=uassby.id)"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - // //Default ListView - // dynamic dlistView = new JArray(); - // dynamic cm = null; - - // cm = new JObject(); - // cm.fld = "ReviewCompletedDate"; - // cm.sort = "-"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ReviewDueDate"; - // cm.sort = "+"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ReviewName"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "Object"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "AyaType"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ReviewNotes"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ReviewUserId"; - // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "ReviewCompletedDate", "ReviewDueDate", "ReviewName", "Object", "AyaType", "ReviewNotes", "ReviewUserId" }; DefaultSortBy = new Dictionary() { { "ReviewCompletedDate", "-" }, { "ReviewDueDate", "+" } }; - //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely + FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition @@ -202,51 +163,8 @@ namespace AyaNova.DataList } - - - - - // string IAyaDataListServerCriteria.DataListServerCriteria(long currentUserId, AyaNova.Biz.AuthorizationRoles userRoles, DataListOptions dataListOptions) - // { - - // bool HasSupervisorRole = - // userRoles.HasFlag(AuthorizationRoles.BizAdminFull) || - // userRoles.HasFlag(AuthorizationRoles.DispatchFull) || - // userRoles.HasFlag(AuthorizationRoles.InventoryFull) || - // userRoles.HasFlag(AuthorizationRoles.SalesFull) || - // userRoles.HasFlag(AuthorizationRoles.AccountingFull); - // if (!HasSupervisorRole) - // return "[{\"fld\":\"metareviewuser\",\"filter\":{\"items\":[{\"op\":\"=\",\"value\":" + currentUserId.ToString() + "}]}}]"; - // return "[]";//this means effectively don't process this at all - // } - public List DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria) { - //TODO: support this clientcriteria - // if (vm.objectId && vm.objectId != 0 && vm.objectType) { - // //REMOVE COMMENT BLOCK AFTER TESTING - // // //pre-filter - // // vm.metaView = JSON.stringify([ - // // { - // // fld: "metareviewobjectid", - // // filter: { - // // items: [{ op: "=", value: vm.objectId }] - // // } - // // }, - // // { - // // fld: "AyaType", - // // filter: { - // // items: [{ op: "=", value: vm.objectType }] - // // } - // // } - // // ]); - // // vm.name = await window.$gz.api.fetchBizObjectName( - // // vm.objectType, - // // vm.objectId - // // ); - // //OBJECTID,AYATYPE - // vm.clientCriteria = `${vm.objectId},${vm.objectType}`; - // } List ret = new List(); bool HasSupervisorRole = userRoles.HasFlag(AuthorizationRoles.BizAdminFull) diff --git a/server/AyaNova/DataList/ServiceBankDataList.cs b/server/AyaNova/DataList/ServiceBankDataList.cs index dec36bb5..541b9010 100644 --- a/server/AyaNova/DataList/ServiceBankDataList.cs +++ b/server/AyaNova/DataList/ServiceBankDataList.cs @@ -13,52 +13,6 @@ namespace AyaNova.DataList SQLFrom = "from aservicebank"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - - - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - // //Default ListView - // dynamic dlistView = new JArray(); - // dynamic cm = null; - - // cm = new JObject(); - // cm.fld = "ServiceBankCreated"; - // cm.sort = "-"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "Object"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ServiceBankCurrency"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ServiceBankCurrencyBalance"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ServiceBankIncidents"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ServiceBankIncidentsBalance"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ServiceBankHours"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ServiceBankHoursBalance"; - // dlistView.Add(cm); - - // cm = new JObject(); - // cm.fld = "ServiceBankDescription"; - // dlistView.Add(cm); - - // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); - DefaultColumns = new List() { "ServiceBankCreated", "Object", "ServiceBankCurrency", "ServiceBankCurrencyBalance", "ServiceBankIncidents", "ServiceBankIncidentsBalance", "ServiceBankHours", "ServiceBankHoursBalance", "ServiceBankDescription" @@ -66,7 +20,6 @@ namespace AyaNova.DataList DefaultSortBy = new Dictionary() { { "ServiceBankCreated", "-" } }; - //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely FieldDefinitions = new List(); FieldDefinitions.Add(new DataListFieldDefinition diff --git a/server/AyaNova/DataList/ServiceRateDataList.cs b/server/AyaNova/DataList/ServiceRateDataList.cs index 2b2e2e36..e99b3977 100644 --- a/server/AyaNova/DataList/ServiceRateDataList.cs +++ b/server/AyaNova/DataList/ServiceRateDataList.cs @@ -11,7 +11,7 @@ namespace AyaNova.DataList var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ + //######## DEFAULT VIEW ############ // //Default ListView // dynamic dlistView = new JArray(); diff --git a/server/AyaNova/DataList/TaxCodeDataList.cs b/server/AyaNova/DataList/TaxCodeDataList.cs index 05f97621..716a56bc 100644 --- a/server/AyaNova/DataList/TaxCodeDataList.cs +++ b/server/AyaNova/DataList/TaxCodeDataList.cs @@ -11,7 +11,7 @@ namespace AyaNova.DataList var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ + //######## DEFAULT VIEW ############ // //Default ListView // dynamic dlistView = new JArray(); diff --git a/server/AyaNova/DataList/TravelRateDataList.cs b/server/AyaNova/DataList/TravelRateDataList.cs index f70ab192..cd5255a3 100644 --- a/server/AyaNova/DataList/TravelRateDataList.cs +++ b/server/AyaNova/DataList/TravelRateDataList.cs @@ -11,7 +11,7 @@ namespace AyaNova.DataList var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ + //######## DEFAULT VIEW ############ // //Default ListView // dynamic dlistView = new JArray(); diff --git a/server/AyaNova/DataList/UnitDataList.cs b/server/AyaNova/DataList/UnitDataList.cs index 2e2964f2..9180c3c4 100644 --- a/server/AyaNova/DataList/UnitDataList.cs +++ b/server/AyaNova/DataList/UnitDataList.cs @@ -18,7 +18,7 @@ namespace AyaNova.DataList var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ + //######## DEFAULT VIEW ############ // //Default ListView // dynamic dlistView = new JArray(); diff --git a/server/AyaNova/DataList/UnitModelDataList.cs b/server/AyaNova/DataList/UnitModelDataList.cs index 99cb1688..8337ba4e 100644 --- a/server/AyaNova/DataList/UnitModelDataList.cs +++ b/server/AyaNova/DataList/UnitModelDataList.cs @@ -11,7 +11,7 @@ namespace AyaNova.DataList var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ + //######## DEFAULT VIEW ############ // //Default ListView // dynamic dlistView = new JArray(); diff --git a/server/AyaNova/DataList/VendorDataList.cs b/server/AyaNova/DataList/VendorDataList.cs index 6d56d47e..5095d01a 100644 --- a/server/AyaNova/DataList/VendorDataList.cs +++ b/server/AyaNova/DataList/VendorDataList.cs @@ -11,7 +11,7 @@ namespace AyaNova.DataList var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ + //######## DEFAULT VIEW ############ // //Default ListView // dynamic dlistView = new JArray(); diff --git a/server/AyaNova/biz/DataListSavedFilterBiz.cs b/server/AyaNova/biz/DataListSavedFilterBiz.cs index f55c972c..6cef9480 100644 --- a/server/AyaNova/biz/DataListSavedFilterBiz.cs +++ b/server/AyaNova/biz/DataListSavedFilterBiz.cs @@ -2,7 +2,6 @@ using System.Linq; using System.Threading.Tasks; using System.Collections.Generic; using Microsoft.EntityFrameworkCore; -using Newtonsoft.Json.Linq; using Newtonsoft.Json; using AyaNova.Util; using AyaNova.Api.ControllerHelpers; diff --git a/server/AyaNova/models/DataListFilterOption.cs b/server/AyaNova/models/DataListFilterOption.cs index 183489c1..f0deef97 100644 --- a/server/AyaNova/models/DataListFilterOption.cs +++ b/server/AyaNova/models/DataListFilterOption.cs @@ -14,17 +14,6 @@ namespace AyaNova.Models } /* - 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"}]}], diff --git a/server/AyaNova/models/DataListProcessingBase.cs b/server/AyaNova/models/DataListProcessingBase.cs index 0135212d..ea5e7044 100644 --- a/server/AyaNova/models/DataListProcessingBase.cs +++ b/server/AyaNova/models/DataListProcessingBase.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System; namespace AyaNova.Models { - //common base class for data table display at client, reporting and mass bulk operations public class DataListProcessingBase { @@ -18,6 +17,4 @@ namespace AyaNova.Models Filter = new List(); } } - - } diff --git a/server/AyaNova/models/DataListReportProcessingOptions.cs b/server/AyaNova/models/DataListReportProcessingOptions.cs index 12a6c9d5..347ba5f7 100644 --- a/server/AyaNova/models/DataListReportProcessingOptions.cs +++ b/server/AyaNova/models/DataListReportProcessingOptions.cs @@ -3,7 +3,6 @@ using AyaNova.DataList; using Newtonsoft.Json.Linq; namespace AyaNova.Models { - public class DataListReportProcessingOptions : DataListSelectedProcessingOptions { internal DataListReportProcessingOptions(DataListSelectedRequest request, IDataListProcessing dataList, DataListColumnView savedView, DataListSavedFilter savedFilter, long userId, AuthorizationRoles userRoles) : base(request, dataList, savedView, savedFilter, userId, userRoles) @@ -11,13 +10,6 @@ namespace AyaNova.Models } public long ReportId { get; set; } - 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 - + public JToken ClientMeta { get; set; }//meta JSON data passed from client, not part of biz object data } - - } diff --git a/server/AyaNova/models/DataListReportRequest.cs b/server/AyaNova/models/DataListReportRequest.cs index 5b453c61..5c9bdc22 100644 --- a/server/AyaNova/models/DataListReportRequest.cs +++ b/server/AyaNova/models/DataListReportRequest.cs @@ -1,7 +1,6 @@ using Newtonsoft.Json.Linq; namespace AyaNova.Models { - public class DataListReportRequest : DataListSelectedRequest { public long ReportId { get; set; } diff --git a/server/AyaNova/models/DataListRequestBase.cs b/server/AyaNova/models/DataListRequestBase.cs index bed85280..41e63d73 100644 --- a/server/AyaNova/models/DataListRequestBase.cs +++ b/server/AyaNova/models/DataListRequestBase.cs @@ -1,7 +1,6 @@ using System; namespace AyaNova.Models { - //common base class for REQUESTING a datalist from the client public class DataListRequestBase { diff --git a/server/AyaNova/models/DataListSavedFilter.cs b/server/AyaNova/models/DataListSavedFilter.cs index b32ad355..6a3de8eb 100644 --- a/server/AyaNova/models/DataListSavedFilter.cs +++ b/server/AyaNova/models/DataListSavedFilter.cs @@ -2,9 +2,7 @@ using System.ComponentModel.DataAnnotations; namespace AyaNova.Models -{ - //this is a hiearchical object so saving as a JSON fragment still best option - +{ public class DataListSavedFilter { public long Id { get; set; } diff --git a/server/AyaNova/models/DataListSelectedProcessingOptions.cs b/server/AyaNova/models/DataListSelectedProcessingOptions.cs index 5b2e0933..5a2f955a 100644 --- a/server/AyaNova/models/DataListSelectedProcessingOptions.cs +++ b/server/AyaNova/models/DataListSelectedProcessingOptions.cs @@ -11,12 +11,6 @@ namespace AyaNova.Models //be used to rehydrate a list of id's public class DataListSelectedProcessingOptions : DataListProcessingBase { - //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 - internal DataListSelectedProcessingOptions( DataListSelectedRequest request, IDataListProcessing dataList, @@ -71,14 +65,6 @@ namespace AyaNova.Models DataListSelectedProcessingOptions d = new DataListSelectedProcessingOptions(selectedRequest, DataList, SavedView, SavedFilter, userId, userRoles); - //hydrate the saved view and filter - // DataListSelectedProcessingOptions dataListSelectedOptions = new DataListSelectedProcessingOptions(selectedRequest, DataList, SavedView, SavedFilter, UserId, UserRoles); - // //------------------------ - - - // if (SelectedRowIds.Length == 0) - // SelectedRowIds = await AyaNova.DataList.DataListFetcher.GetIdListResponseAsync(ct, this, userRoles, log, userId); - return await AyaNova.DataList.DataListFetcher.GetIdListResponseAsync(ct, d, DataList, userRoles, log, userId); } diff --git a/server/AyaNova/models/DataListTableProcessingOptions.cs b/server/AyaNova/models/DataListTableProcessingOptions.cs index 495f39d8..b5b4060f 100644 --- a/server/AyaNova/models/DataListTableProcessingOptions.cs +++ b/server/AyaNova/models/DataListTableProcessingOptions.cs @@ -60,7 +60,7 @@ namespace AyaNova.Models return Columns.Union(base.Filter.Select(z => z.Column).ToList()).ToList(); } - } + } } \ No newline at end of file diff --git a/server/AyaNova/models/DataListTableRequest.cs b/server/AyaNova/models/DataListTableRequest.cs index 5b3108ad..26fa6a42 100644 --- a/server/AyaNova/models/DataListTableRequest.cs +++ b/server/AyaNova/models/DataListTableRequest.cs @@ -1,6 +1,5 @@ namespace AyaNova.Models { - //Handles posts from client public sealed class DataListTableRequest : DataListRequestBase { public int? Offset { get; set; }