| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 | using System;using System.Collections.Generic;using System.Linq.Expressions;using InABox.Core;namespace Comal.Classes{    public class DeliveryItemDocumentCount : CoreAggregate<DeliveryItem, DeliveryDocument, Guid>    {        public override Expression<Func<DeliveryDocument, Guid>> Aggregate => x => x.ID;        public override AggregateCalculation Calculation => AggregateCalculation.Count;        public override Dictionary<Expression<Func<DeliveryDocument, object>>, Expression<Func<DeliveryItem, object>>> Links =>            new Dictionary<Expression<Func<DeliveryDocument, object>>, Expression<Func<DeliveryItem, object>>>()            {                { DeliveryDocument => DeliveryDocument.EntityLink.ID, DeliveryItem => DeliveryItem.Delivery.ID }            };    }    public class DeliveryItemArea : IFormula<DeliveryItem, double>    {        public Expression<Func<DeliveryItem, double>> Value => x => x.Height;        public Expression<Func<DeliveryItem, double>>[] Modifiers => new Expression<Func<DeliveryItem, double>>[] { x => x.Width, x => 0.000001F };        public FormulaOperator Operator => FormulaOperator.Multiply;        public FormulaType Type => FormulaType.Virtual;    }    public class DeliveryItemVolume : IFormula<DeliveryItem, double>    {        public Expression<Func<DeliveryItem, double>> Value => x => x.Height;        public Expression<Func<DeliveryItem, double>>[] Modifiers => new Expression<Func<DeliveryItem, double>>[] { x => x.Width, x => x.Length };        public FormulaOperator Operator => FormulaOperator.Multiply;        public FormulaType Type => FormulaType.Virtual;    }    public enum DeliveryItemType    {        ManufacturedItem,        RequisitionItem,        TreatmentItem,        EquipmentItem,        OtherItem    }    [UserTracking(typeof(Delivery))]    [Caption("Delivery Items")]    public class DeliveryItem : Entity, IPersistent, IRemotable, IOneToMany<Job>, IOneToMany<Delivery>,        IOneToMany<ManufacturingPacket>, IOneToMany<Shipment>, ILicense<LogisticsLicense>, IExportable    {        // If Packet then Packet.Title        // If requisition then Requisition.Title        public string Title { get; set; }        // if PAcket, then Packet.Description        // If Requitision then BOX X OF Y        [TextBoxEditor]        public string Description { get; set; }        // If Packet, then Packet.Refreence        // If Requisition then Requi.Employee        [TextBoxEditor]        public string Reference { get; set; }        [TextBoxEditor(Editable = Editable.Hidden)]        [SecondaryIndex]        public string Barcode { get; set; }        public int Sequence { get; set; }        public string Piece { get; set; }        [SecondaryIndex]        public DateTime DeliveredDate { get; set; }        public DateTime InstalledDate { get; set; }        public DateTime DueDate { get; set; }        public JobLink JobLink { get; set; }        [EntityRelationship(DeleteAction.Cascade)]        public ManufacturingPacketLink ManufacturingPacketLink { get; set; }        public RequisitionLink RequisitionLink { get; set; }        public SetoutLink SetoutLink { get; set; }        public ShipmentLink ShipmentLink { get; set; }        [CodeEditor(Editable = Editable.Disabled)]        public string ShipmentCode { get; set; }                //public PackableList<CoreAttribute> CustomAttributes { get; set; }        [MemoEditor]        public string Attributes { get; set; }        public Location Location { get; set; }        public DeliveryLink Delivery { get; set; }        public PurchaseOrderItemLink OrderItem { get; set; }        public double Cost { get; set; }        public double Height { get; set; }        public double Width { get; set; }        public double Length { get; set; }        [DoubleEditor(Editable = Editable.Hidden)]        [Formula(typeof(DeliveryItemArea))]        public double Area { get; set; }        [DoubleEditor(Editable = Editable.Hidden)]        [Formula(typeof(DeliveryItemVolume))]        public double Volume { get; set; }        [Aggregate(typeof(DeliveryItemDocumentCount))]        [IntegerEditor(Editable = Editable.Hidden)]        public int Documents { get; set; }        [EnumLookupEditor(typeof(DeliveryItemType))]        public DeliveryItemType Type { get; set; }        protected override void Init()        {            base.Init();            Description = "";            JobLink = new JobLink();            SetoutLink = new SetoutLink();            ManufacturingPacketLink = new ManufacturingPacketLink();            RequisitionLink = new RequisitionLink();            ShipmentLink = new ShipmentLink(() => this);            Delivery = new DeliveryLink();            Location = new Location();            OrderItem = new PurchaseOrderItemLink();            Attributes = "";            Type = DeliveryItemType.OtherItem;        }        public override string ToString()        {            return string.Format("{0} : {1}", Barcode, Title);        }        static DeliveryItem()        {            LinkedProperties.Register<DeliveryItem, ShipmentLink, String>(x=>x.ShipmentLink, x => x.Code, x => x.ShipmentCode);        }    }}
 |