using System; using InABox.Clients; using InABox.Core; namespace Comal.Classes { public abstract class BaseActivityLookupGenerator : LookupGenerator { public BaseActivityLookupGenerator(T[] items) : base(items) { AddColumn("Code", typeof(string)); AddColumn("Description", typeof(string)); AddColumn("Color", typeof(string)); AddColumn("Charge.Chargeable", typeof(bool)); } protected abstract Guid EmployeeID(); protected virtual Filter CreateFilter() { return new Filter(x => x.Employee.ID).IsEqualTo(EmployeeID()); } protected override void DoGenerateLookups() { Clear(); var eacts = new Client().Query( CreateFilter(), new Columns(x => x.Activity.ID) .Add(x => x.Activity.Code) .Add(x => x.Activity.Description) .Add(x => x.Activity.Color) .Add(x=>x.Activity.Charge.Chargeable), new SortOrder(x => x.Activity.Code) ); foreach (var row in eacts.Rows) AddValue( row.Get(col => col.Activity.ID), string.Format("{0}: {1}", row.Get(col => col.Activity.Code), row.Get(col => col.Activity.Description)), row.Get(col => col.Activity.Code), row.Get(col => col.Activity.Description), row.Get(col => col.Activity.Color), row.Get(col => col.Activity.Charge.Chargeable) ); } } }