This commit is contained in:
@@ -362,16 +362,36 @@ namespace AyaNova.Api.Controllers
|
|||||||
{
|
{
|
||||||
if (!serverState.IsOpen)
|
if (!serverState.IsOpen)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
UnitBiz biz = UnitBiz.GetBiz(ct, HttpContext);
|
UnitMeterReadingBiz biz = UnitMeterReadingBiz.GetBiz(ct, HttpContext);
|
||||||
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
if (!Authorized.HasCreateRole(HttpContext.Items, AyaType.Unit))
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
UnitMeterReading o = await biz.CreateMeterReadingAsync(newObject);
|
UnitMeterReading o = await biz.CreateAsync(newObject);
|
||||||
if (o == null)
|
if (o == null)
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
else
|
else
|
||||||
return CreatedAtAction(nameof(UnitController.GetUnit), new { id = o.UnitId, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
return CreatedAtAction(nameof(UnitController.GetUnitMeterReading), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get Unit Meter Reading entry
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns>Unit</returns>
|
||||||
|
[HttpGet("meter-reading/{id}")]
|
||||||
|
public async Task<IActionResult> GetUnitMeterReading([FromRoute] long id)
|
||||||
|
{
|
||||||
|
if (!serverState.IsOpen)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
UnitMeterReadingBiz biz = UnitMeterReadingBiz.GetBiz(ct, HttpContext);
|
||||||
|
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.Unit))
|
||||||
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
var o = await biz.GetAsync(id);
|
||||||
|
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||||
|
return Ok(ApiOkResponse.Response(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -217,10 +217,8 @@ namespace AyaNova.Biz
|
|||||||
if (item.WorkOrderItemPartRequestId != null)
|
if (item.WorkOrderItemPartRequestId != null)
|
||||||
{
|
{
|
||||||
po.HasPartRequest = true;
|
po.HasPartRequest = true;
|
||||||
var wid = (await WorkOrderBiz.GetWorkOrderIdFromRelativeAsync(AyaType.WorkOrderItemPartRequest, (long)item.WorkOrderItemPartRequestId, ct)).ParentId;
|
|
||||||
var WOSerial = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid).Select(x => new { x.Serial }).FirstOrDefaultAsync();
|
item.WorkOrderItemPartRequestViz=(await WorkOrderBiz.GetWorkOrderSerialFromRelativeAsync(AyaType.WorkOrderItemPartRequest, (long)item.WorkOrderItemPartRequestId, ct)).ToString();
|
||||||
if (WOSerial != null)
|
|
||||||
item.WorkOrderItemPartRequestViz = WOSerial.Serial.ToString();
|
|
||||||
if (item.PartRequestedById != null)
|
if (item.PartRequestedById != null)
|
||||||
item.PartRequestedByViz = await ct.User.AsNoTracking().Where(x => x.Id == item.PartRequestedById).Select(x => x.Name).FirstOrDefaultAsync();
|
item.PartRequestedByViz = await ct.User.AsNoTracking().Where(x => x.Id == item.PartRequestedById).Select(x => x.Name).FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ namespace AyaNova.Biz
|
|||||||
public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<UnitBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<UnitBiz>();
|
||||||
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
@@ -548,123 +548,21 @@ namespace AyaNova.Biz
|
|||||||
}//Contract expiry event
|
}//Contract expiry event
|
||||||
|
|
||||||
|
|
||||||
|
//#todo: METER READING EVENT
|
||||||
|
//MIGRATE_OUTSTANDING need meter reading object to complete unit notification for UnitMeterReadingMultipleExceeded
|
||||||
|
//UnitMeterReadingMultipleExceeded = 26,//* UnitMeterReading object, Created, conditional on DecValue as the Multiple threshold, if passed then notifies
|
||||||
|
//{
|
||||||
|
//first remove any existing, potentially stale notifyevents for this exact object and notifyeventtype
|
||||||
|
//await NotifyEventHelper.ClearPriorEventsForObject(ct, AyaType.Unit, o.Id, NotifyEventType.UnitMeterReadingMultipleExceeded);
|
||||||
|
|
||||||
|
//then check if unit is still metered etc etc and do the rest once the unit meter reading is coded
|
||||||
|
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}//end of process notifications
|
}//end of process notifications
|
||||||
|
|
||||||
////////////////// METER READING //////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//CREATE
|
|
||||||
//
|
|
||||||
internal async Task<UnitMeterReading> CreateMeterReadingAsync(UnitMeterReading newObject)
|
|
||||||
{
|
|
||||||
await ValidateMeterReadingAsync(newObject);
|
|
||||||
if (HasErrors)
|
|
||||||
return null;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await ct.UnitMeterReading.AddAsync(newObject);
|
|
||||||
await ct.SaveChangesAsync();
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
|
||||||
await SearchIndexAsync(newObject, true);
|
|
||||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
|
||||||
await MeterReadingHandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
|
||||||
return newObject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private async Task ValidateMeterReadingAsync(UnitMeterReading proposedObj)
|
|
||||||
{
|
|
||||||
//Unit required
|
|
||||||
var unit = await ct.Unit.AsNoTracking().FirstOrDefaultAsync(z => z.Id == proposedObj.UnitId);
|
|
||||||
if (unit == null)
|
|
||||||
{
|
|
||||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "UnitId", "Unit not found with that id");//api issue not user issue so no need to translate
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!unit.Metered){
|
|
||||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "UnitId", "This is not a metered unit, reading cannot be saved");//api issue not user issue so no need to translate
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(proposedObj.WorkOrderItemId!=null){
|
|
||||||
if(!await ct.WorkOrderItem.AnyAsync(z=>z.Id==proposedObj.WorkOrderItemId)){
|
|
||||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "WorkOrderItemId", "work order item id was not found");//api issue not user issue so no need to translate
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public async Task MeterReadingHandlePotentialNotificationEvent(AyaEvent ayaEvent, UnitMeterReading proposedObj)
|
|
||||||
{
|
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<UnitBiz>();
|
|
||||||
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{AyaType.UnitMeterReading}, AyaEvent:{ayaEvent}]");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//## CREATED EVENTS (only ever created)
|
|
||||||
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
|
||||||
{
|
|
||||||
|
|
||||||
// //# CONTRACT EXPIRY
|
|
||||||
// {
|
|
||||||
// if (o.ContractId != null && o.ContractExpires != null)
|
|
||||||
// {
|
|
||||||
// var ContractExpirydate = (DateTime)o.ContractExpires;
|
|
||||||
// //notify users about contract expiry (time delayed)
|
|
||||||
// var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ContractExpiring).ToListAsync();
|
|
||||||
// foreach (var sub in subs)
|
|
||||||
// {
|
|
||||||
// //not for inactive users
|
|
||||||
// if (!await UserBiz.UserIsActive(sub.UserId)) continue;
|
|
||||||
|
|
||||||
// //Tag match? (will be true if no sub tags so always safe to call this)
|
|
||||||
// if (NotifyEventHelper.ObjectHasAllSubscriptionTags(o.Tags, sub.Tags))
|
|
||||||
// {
|
|
||||||
// NotifyEvent n = new NotifyEvent()
|
|
||||||
// {
|
|
||||||
// EventType = NotifyEventType.ContractExpiring,
|
|
||||||
// UserId = sub.UserId,
|
|
||||||
// AyaType = o.AyaType,
|
|
||||||
// ObjectId = o.Id,
|
|
||||||
// NotifySubscriptionId = sub.Id,
|
|
||||||
// Name = o.Serial,
|
|
||||||
// EventDate = ContractExpirydate
|
|
||||||
// };
|
|
||||||
// await ct.NotifyEvent.AddAsync(n);
|
|
||||||
// log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
|
||||||
// await ct.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }//Contract expiry event
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}//end of process notifications
|
|
||||||
|
|
||||||
//#todo: METER READING EVENT
|
|
||||||
//MIGRATE_OUTSTANDING need meter reading object to complete unit notification for UnitMeterReadingMultipleExceeded
|
|
||||||
//UnitMeterReadingMultipleExceeded = 26,//* UnitMeterReading object, Created, conditional on DecValue as the Multiple threshold, if passed then notifies
|
|
||||||
//{
|
|
||||||
//first remove any existing, potentially stale notifyevents for this exact object and notifyeventtype
|
|
||||||
//await NotifyEventHelper.ClearPriorEventsForObject(ct, AyaType.Unit, o.Id, NotifyEventType.UnitMeterReadingMultipleExceeded);
|
|
||||||
|
|
||||||
//then check if unit is still metered etc etc and do the rest once the unit meter reading is coded
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
220
server/AyaNova/biz/UnitMeterReadingBiz.cs
Normal file
220
server/AyaNova/biz/UnitMeterReadingBiz.cs
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Linq;
|
||||||
|
using AyaNova.Util;
|
||||||
|
using AyaNova.Api.ControllerHelpers;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using AyaNova.Models;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace AyaNova.Biz
|
||||||
|
{
|
||||||
|
internal class UnitMeterReadingBiz : BizObject, ISearchAbleObject, IReportAbleObject, IExportAbleObject
|
||||||
|
{
|
||||||
|
internal UnitMeterReadingBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles UserRoles)
|
||||||
|
{
|
||||||
|
ct = dbcontext;
|
||||||
|
UserId = currentUserId;
|
||||||
|
UserTranslationId = userTranslationId;
|
||||||
|
CurrentUserRoles = UserRoles;
|
||||||
|
BizType = AyaType.UnitMeterReading;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static UnitMeterReadingBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext = null)
|
||||||
|
{
|
||||||
|
if (httpContext != null)
|
||||||
|
return new UnitMeterReadingBiz(ct, UserIdFromContext.Id(httpContext.Items), UserTranslationIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
|
||||||
|
else
|
||||||
|
return new UnitMeterReadingBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, AuthorizationRoles.BizAdmin);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//EXISTS
|
||||||
|
internal async Task<bool> ExistsAsync(long id)
|
||||||
|
{
|
||||||
|
return await ct.UnitMeterReading.AnyAsync(z => z.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//CREATE
|
||||||
|
//
|
||||||
|
internal async Task<UnitMeterReading> CreateAsync(UnitMeterReading newObject)
|
||||||
|
{
|
||||||
|
await ValidateAsync(newObject);
|
||||||
|
if (HasErrors)
|
||||||
|
return null;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
await ct.UnitMeterReading.AddAsync(newObject);
|
||||||
|
await ct.SaveChangesAsync();
|
||||||
|
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
||||||
|
await SearchIndexAsync(newObject, true);
|
||||||
|
await HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||||
|
return newObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//GET
|
||||||
|
//
|
||||||
|
internal async Task<UnitMeterReading> GetAsync(long id, bool logTheGetEvent = true)
|
||||||
|
{
|
||||||
|
var ret = await ct.UnitMeterReading.AsNoTracking().SingleOrDefaultAsync(m => m.Id == id);
|
||||||
|
if (logTheGetEvent && ret != null)
|
||||||
|
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//SEARCH
|
||||||
|
//
|
||||||
|
private async Task SearchIndexAsync(UnitMeterReading obj, bool isNew)
|
||||||
|
{
|
||||||
|
var SearchParams = new Search.SearchIndexProcessObjectParameters(UserTranslationId, obj.Id, BizType);
|
||||||
|
DigestSearchText(obj, SearchParams);
|
||||||
|
if (isNew)
|
||||||
|
await Search.ProcessNewObjectKeywordsAsync(SearchParams);
|
||||||
|
else
|
||||||
|
await Search.ProcessUpdatedObjectKeywordsAsync(SearchParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Search.SearchIndexProcessObjectParameters> GetSearchResultSummary(long id)
|
||||||
|
{
|
||||||
|
var obj = await GetAsync(id, false);
|
||||||
|
var SearchParams = new Search.SearchIndexProcessObjectParameters();
|
||||||
|
DigestSearchText(obj, SearchParams);
|
||||||
|
return SearchParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DigestSearchText(UnitMeterReading obj, Search.SearchIndexProcessObjectParameters searchParams)
|
||||||
|
{
|
||||||
|
if (obj != null)
|
||||||
|
searchParams.AddText(obj.Description)
|
||||||
|
.AddText(obj.Meter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//VALIDATION
|
||||||
|
//
|
||||||
|
|
||||||
|
private async Task ValidateAsync(UnitMeterReading proposedObj)
|
||||||
|
{
|
||||||
|
//Unit required
|
||||||
|
var unit = await ct.Unit.AsNoTracking().FirstOrDefaultAsync(z => z.Id == proposedObj.UnitId);
|
||||||
|
if (unit == null)
|
||||||
|
{
|
||||||
|
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "UnitId", "Unit not found with that id");//api issue not user issue so no need to translate
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!unit.Metered)
|
||||||
|
{
|
||||||
|
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "UnitId", "This is not a metered unit, reading cannot be saved");//api issue not user issue so no need to translate
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (proposedObj.WorkOrderItemId != null)
|
||||||
|
{
|
||||||
|
if (!await ct.WorkOrderItem.AnyAsync(z => z.Id == proposedObj.WorkOrderItemId))
|
||||||
|
{
|
||||||
|
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "WorkOrderItemId", "work order item id was not found");//api issue not user issue so no need to translate
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//REPORTING
|
||||||
|
//
|
||||||
|
public async Task<JArray> GetReportData(DataListSelectedRequest dataListSelectedRequest)
|
||||||
|
{
|
||||||
|
var idList = dataListSelectedRequest.SelectedRowIds;
|
||||||
|
JArray ReportData = new JArray();
|
||||||
|
while (idList.Any())
|
||||||
|
{
|
||||||
|
var batch = idList.Take(IReportAbleObject.REPORT_DATA_BATCH_SIZE);
|
||||||
|
idList = idList.Skip(IReportAbleObject.REPORT_DATA_BATCH_SIZE).ToArray();
|
||||||
|
//query for this batch, comes back in db natural order unfortunately
|
||||||
|
var batchResults = await ct.UnitMeterReading.AsNoTracking().Where(z => batch.Contains(z.Id)).ToArrayAsync();
|
||||||
|
//order the results back into original
|
||||||
|
var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
|
||||||
|
foreach (UnitMeterReading w in orderedList)
|
||||||
|
{
|
||||||
|
await PopulateVizFields(w);
|
||||||
|
var jo = JObject.FromObject(w);
|
||||||
|
ReportData.Add(jo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ReportData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//populate viz fields from provided object
|
||||||
|
private async Task PopulateVizFields(UnitMeterReading o)
|
||||||
|
{
|
||||||
|
o.UnitViz = await ct.Unit.AsNoTracking().Where(x => x.Id == o.UnitId).Select(x => x.Serial).FirstOrDefaultAsync();
|
||||||
|
if (o.WorkOrderItemId != null)
|
||||||
|
o.WorkOrderViz = (await WorkOrderBiz.GetWorkOrderSerialFromRelativeAsync(AyaType.WorkOrderItem, (long)o.WorkOrderItemId, ct)).ToString();//await ct.Unit.AsNoTracking().Where(x => x.Id == o.UnitId).Select(x => x.Serial).FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// IMPORT EXPORT
|
||||||
|
//
|
||||||
|
|
||||||
|
public async Task<JArray> GetExportData(DataListSelectedRequest dataListSelectedRequest)
|
||||||
|
{
|
||||||
|
//for now just re-use the report data code
|
||||||
|
//this may turn out to be the pattern for most biz object types but keeping it seperate allows for custom usage from time to time
|
||||||
|
return await GetReportData(dataListSelectedRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// NOTIFICATION PROCESSING
|
||||||
|
//
|
||||||
|
public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, UnitMeterReading proposedObj)
|
||||||
|
{
|
||||||
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<UnitMeterReadingBiz>();
|
||||||
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
|
await Task.CompletedTask;
|
||||||
|
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||||
|
//#todo: METER READING EVENT
|
||||||
|
//MIGRATE_OUTSTANDING need meter reading object to complete unit notification for UnitMeterReadingMultipleExceeded
|
||||||
|
//UnitMeterReadingMultipleExceeded = 26,//* UnitMeterReading object, Created, conditional on DecValue as the Multiple threshold, if passed then notifies
|
||||||
|
//{
|
||||||
|
//first remove any existing, potentially stale notifyevents for this exact object and notifyeventtype
|
||||||
|
//await NotifyEventHelper.ClearPriorEventsForObject(ct, AyaType.Unit, o.Id, NotifyEventType.UnitMeterReadingMultipleExceeded);
|
||||||
|
|
||||||
|
//then check if unit is still metered etc etc and do the rest once the unit meter reading is coded
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
}//end of process notifications
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}//eoc
|
||||||
|
|
||||||
|
|
||||||
|
}//eons
|
||||||
|
|
||||||
@@ -586,7 +586,15 @@ namespace AyaNova.Biz
|
|||||||
.SingleOrDefaultAsync();
|
.SingleOrDefaultAsync();
|
||||||
w.ChildItemId = woitemid;
|
w.ChildItemId = woitemid;
|
||||||
return w;
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//GET WORKORDER SERIAL FROM DESCENDANT TYPE AND ID
|
||||||
|
//
|
||||||
|
internal static async Task<long> GetWorkOrderSerialFromRelativeAsync(AyaType ayaType, long id, AyContext ct)
|
||||||
|
{
|
||||||
|
var wid = (await GetWorkOrderIdFromRelativeAsync(ayaType, id, ct)).ParentId;
|
||||||
|
return await ct.WorkOrder.AsNoTracking().Where(x => x.Id == wid).Select(x => x.Serial).FirstOrDefaultAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1033,7 +1041,7 @@ namespace AyaNova.Biz
|
|||||||
public async Task WorkOrderHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task WorkOrderHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]");
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
WorkOrder oProposed = (WorkOrder)proposedObj;
|
WorkOrder oProposed = (WorkOrder)proposedObj;
|
||||||
@@ -1443,7 +1451,7 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
|
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
@@ -2009,7 +2017,7 @@ namespace AyaNova.Biz
|
|||||||
public async Task ItemHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task ItemHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
@@ -2367,7 +2375,7 @@ namespace AyaNova.Biz
|
|||||||
public async Task ExpenseHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task ExpenseHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
@@ -2743,7 +2751,7 @@ namespace AyaNova.Biz
|
|||||||
public async Task LaborHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task LaborHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
@@ -3170,7 +3178,7 @@ namespace AyaNova.Biz
|
|||||||
public async Task LoanHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task LoanHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
@@ -3482,7 +3490,7 @@ namespace AyaNova.Biz
|
|||||||
OutsideServiceReceived = 17,//* Workorder object , WorkOrderItemOutsideService updated, instant notification when item received, tag filterable
|
OutsideServiceReceived = 17,//* Workorder object , WorkOrderItemOutsideService updated, instant notification when item received, tag filterable
|
||||||
*/
|
*/
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
@@ -4223,7 +4231,7 @@ namespace AyaNova.Biz
|
|||||||
public async Task PartHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task PartHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
@@ -4472,7 +4480,7 @@ namespace AyaNova.Biz
|
|||||||
public async Task PartRequestHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task PartRequestHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
@@ -4739,7 +4747,7 @@ namespace AyaNova.Biz
|
|||||||
public async Task ScheduledUserHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task ScheduledUserHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
@@ -5122,7 +5130,7 @@ namespace AyaNova.Biz
|
|||||||
public async Task TaskHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task TaskHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
@@ -5490,7 +5498,7 @@ namespace AyaNova.Biz
|
|||||||
public async Task TravelHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task TravelHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
@@ -5773,7 +5781,7 @@ namespace AyaNova.Biz
|
|||||||
public async Task UnitHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task UnitHandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<WorkOrderBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{proposedObj.AyaType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ namespace AyaNova.Models
|
|||||||
public DateTime MeterDate { get; set; }
|
public DateTime MeterDate { get; set; }
|
||||||
public long UnitId { get; set; }
|
public long UnitId { get; set; }
|
||||||
public long? WorkOrderItemId { get; set; }
|
public long? WorkOrderItemId { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string UnitViz { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string WorkOrderViz { get; set; }
|
||||||
|
|
||||||
public UnitMeterReading()
|
public UnitMeterReading()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user