From 446d5cd11010c958efd832d43628b77e5e6739e7 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 19 Aug 2021 22:13:21 +0000 Subject: [PATCH] --- .../DataList/UnitMeterReadingDataList.cs | 89 +++++++++++++++++++ server/AyaNova/models/UnitMeterReading.cs | 2 +- server/AyaNova/util/AySchema.cs | 2 +- 3 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 server/AyaNova/DataList/UnitMeterReadingDataList.cs diff --git a/server/AyaNova/DataList/UnitMeterReadingDataList.cs b/server/AyaNova/DataList/UnitMeterReadingDataList.cs new file mode 100644 index 00000000..253ce046 --- /dev/null +++ b/server/AyaNova/DataList/UnitMeterReadingDataList.cs @@ -0,0 +1,89 @@ +using System.Collections.Generic; +using AyaNova.Biz; +using AyaNova.Models; + +namespace AyaNova.DataList +{ + internal class UnitMeterReadingDataList : DataListProcessingBase, IDataListInternalCriteria + { + public UnitMeterReadingDataList() + { + DefaultListAType = AyaType.UnitMeterReading; + SQLFrom = "from aunitmeterreading left join aunit on (aunitmeterreading.unitid=aunit.id) left join aworkorderitem on (aunitmeterreading.workorderitemid) left join aworkorder"; + var RoleSet = BizRoles.GetRoleSet(DefaultListAType); + AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; + DefaultColumns = new List() { "notedate", "UnitMeterReadingDescription", "Unit" }; + DefaultSortBy = new Dictionary() { { "notedate", "-" } }; + + FieldDefinitions = new List(); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "Unit", + FieldKey = "Unit", + AType = (int)AyaType.Unit, + UiFieldDataType = (int)UiFieldDataType.Text, + SqlIdColumnName = "aunit.id", + SqlValueColumnName = "aunit.name", + IsRowId = false + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "UnitMeterReadingDescription", + FieldKey = "UnitMeterReadingDescription", + AType = (int)AyaType.UnitMeterReading, + UiFieldDataType = (int)UiFieldDataType.Text, + SqlIdColumnName = "aunitmeterreading.id", + SqlValueColumnName = "aunitmeterreading.description", + IsRowId = false + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "UnitMeterReadingMeter", + FieldKey = "UnitMeterReadingMeter", + AType = (int)AyaType.UnitMeterReading, + UiFieldDataType = (int)UiFieldDataType.Integer, + SqlIdColumnName = "aunitmeterreading.id", + SqlValueColumnName = "aunitmeterreading.meter", + IsRowId = true + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "UnitMeterReadingMeterDate", + FieldKey = "UnitMeterReadingMeterDate", + UiFieldDataType = (int)UiFieldDataType.DateTime, + SqlValueColumnName = "aunitmeterreading.meterdate" + }); + + //META column + FieldDefinitions.Add(new DataListFieldDefinition + { + FieldKey = "metaunit", + UiFieldDataType = (int)UiFieldDataType.InternalId, + SqlIdColumnName = "aunitmeterreading.unitid", + SqlValueColumnName = "aunitmeterreading.unitid", + IsMeta = true + }); + } + + + public List DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria) + { + List ret = new List(); + //ClientCriteria MUST be CustomerId + if (string.IsNullOrWhiteSpace(clientCriteria)) + throw new System.ArgumentNullException("UnitMeterReadingDataList - ClientCriteria is empty, should be Customer ID"); + + DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metacustomer" }; + FilterOption.Items.Add(new DataListColumnFilter() { value = clientCriteria, op = DataListFilterComparisonOperator.Equality }); + + ret.Add(FilterOption); + return ret; + } + + + }//eoc +}//eons \ No newline at end of file diff --git a/server/AyaNova/models/UnitMeterReading.cs b/server/AyaNova/models/UnitMeterReading.cs index 139e0df0..6d21c1cf 100644 --- a/server/AyaNova/models/UnitMeterReading.cs +++ b/server/AyaNova/models/UnitMeterReading.cs @@ -18,7 +18,7 @@ namespace AyaNova.Models public long Meter { get; set; } public DateTime MeterDate { get; set; } public long UnitId { get; set; } - public long? WorkOrderItemId { get; set; } + public long? WorkOrderItemUnitId { get; set; } [NotMapped] public string UnitViz { get; set; } [NotMapped] diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index f7f3ba73..dd45f730 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -1120,7 +1120,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); //UNITMETERREADING await ExecQueryAsync("CREATE TABLE aunitmeterreading (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, meterdate TIMESTAMP NOT NULL, description TEXT, " - + "meter BIGINT NOT NULL, unitid BIGINT NOT NULL REFERENCES aunit(id) ON DELETE CASCADE, workorderitemid BIGINT REFERENCES aworkorderitem(id) ON DELETE SET NULL)"); + + "meter BIGINT NOT NULL, unitid BIGINT NOT NULL REFERENCES aunit(id) ON DELETE CASCADE, workorderitemunitid BIGINT REFERENCES aworkorderitemunit(id) ON DELETE SET NULL)"); //LOGO await ExecQueryAsync("CREATE TABLE alogo (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, "