123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- using System;
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using InABox.Core;
- namespace Comal.Classes
- {
- public interface IEmployeeAlert : IEntity
- {
- EmployeeLink Employee { get; set; }
- }
-
- public class EmployeeAlertUnionGenerator : AutoEntityUnionGenerator<IEmployeeAlert>
- {
- protected override void Configure()
- {
- AddTable<Employee>()
- .AliasField(ea => ea.Employee.ID, e => e.ID);
- }
- public override bool Distinct => false;
- public override Column<IEmployeeAlert>[] IDColumns => new Column<IEmployeeAlert>[]
- {
- new Column<IEmployeeAlert>(x => x.Employee.ID),
- };
- }
-
- [UserTracking(typeof(Employee))]
- [AutoEntity(typeof(EmployeeAlertUnionGenerator))]
- public class EmployeeAlert : Entity, IEmployeeAlert, IRemotable, IPersistent, IOneToMany<Employee>,
- ILicense<CoreLicense>
- {
- public EmployeeLink Employee { get; set; }
-
- private class NotificationsAggregate : ComplexFormulaGenerator<EmployeeAlert, int>
- {
- public override IComplexFormulaNode<EmployeeAlert, int> GetFormula() =>
- Aggregate<Notification>(
- AggregateCalculation.Count,
- x =>x.Constant(1),
- new Filter<Notification>(x => x.Closed).IsEqualTo(DateTime.MinValue))
- .WithLink(x => x.Employee.ID, x => x.ID);
- }
- [ComplexFormula(typeof(NotificationsAggregate))]
- [IntegerEditor(Editable = Editable.Hidden)]
- public int Notifications { get; set; }
-
-
- private class TasksAggregate : ComplexFormulaGenerator<EmployeeAlert, int>
- {
- public override IComplexFormulaNode<EmployeeAlert, int> GetFormula() =>
- Aggregate<Kanban>(
- AggregateCalculation.Count,
- x =>x.Constant(1),
- new Filter<Kanban>(x => x.Status).IsEqualTo(KanbanStatus.Complete))
- .WithLink(x => x.EmployeeLink.ID, x => x.ID);
- }
- [ComplexFormula(typeof(TasksAggregate))]
- [IntegerEditor(Editable = Editable.Hidden)]
- public int Tasks { get; set; }
-
- private class QualificationsAggregate : ComplexFormulaGenerator<EmployeeAlert, int>
- {
- public override IComplexFormulaNode<EmployeeAlert, int> GetFormula() =>
- Aggregate<EmployeeQualification>(
- AggregateCalculation.Count,
- x =>x.Constant(1),
- new Filter<EmployeeQualification>(x => x.Qualified).IsEqualTo(DateTime.MinValue)
- .Or(x=>x.FrontPhoto.ID).IsEqualTo(Guid.Empty)
- .Or(x=>x.Expiry).IsLessThan(FilterConstant.Today))
- .WithLink(x => x.Employee.ID, x => x.ID);
- }
- [ComplexFormula(typeof(QualificationsAggregate))]
- [IntegerEditor(Editable = Editable.Hidden)]
- public int Qualifications { get; set; }
-
- private class DigitalFormsAggregate : ComplexFormulaGenerator<EmployeeAlert, int>
- {
- public override IComplexFormulaNode<EmployeeAlert, int> GetFormula() =>
- Aggregate<EmployeeForm>(
- AggregateCalculation.Count,
- x =>x.Constant(1),
- new Filter<EmployeeForm>(x => x.FormCompleted).IsEqualTo(DateTime.MinValue)
- )
- .WithLink(x => x.Parent.ID, x => x.ID);
- }
- [ComplexFormula(typeof(QualificationsAggregate))]
- [IntegerEditor(Editable = Editable.Hidden)]
- public int DigitalForms { get; set; }
-
- }
-
- }
|