Пример #1
0
        public void BaseDelete(DeletableDelete method)
        {
            var session    = this.strategy.Session;
            var derivation = new Derivations.Default.Derivation(session);

            this.SyncInventoryTransactions(derivation, this.InventoryItem, this.Quantity, new InventoryTransactionReasons(session).Consumption, true);
        }
        private void SyncInventoryItem()
        {
            var derivation    = new Derivations.Default.Derivation(this.Strategy.Session);
            var facility      = this.Facility ?? this.Part.DefaultFacility;
            var unitOfMeasure = this.UnitOfMeasure ?? this.Part.UnitOfMeasure;

            if (this.Part.InventoryItemKind.IsSerialised && (this.Quantity < -1 || this.Quantity > 1))
            {
                var message = "Invalid transaction";
                derivation.Validation.AddError(this, this.Meta.SerialisedItem, message);
            }

            if (this.Part.InventoryItemKind.IsSerialised)
            {
                var inventoryItems = this.SerialisedItem.SerialisedInventoryItemsWhereSerialisedItem;
                inventoryItems.Filter.AddEquals(M.InventoryItem.Part, this.Part);
                inventoryItems.Filter.AddEquals(M.InventoryItem.Facility, facility);
                var inventoryItem = inventoryItems.First;

                if (inventoryItem == null)
                {
                    var builder = new SerialisedInventoryItemBuilder(this.Strategy.Session)
                                  .WithFacility(facility)
                                  .WithUnitOfMeasure(unitOfMeasure)
                                  .WithSerialisedItem(this.SerialisedItem)
                                  .WithPart(this.Part)
                                  .WithSerialisedInventoryItemState(this.SerialisedInventoryItemState);

                    if (this.ExistLot)
                    {
                        builder.WithLot(this.Lot);
                    }

                    this.InventoryItem = builder.Build();
                }
            }
            else if (this.Part.InventoryItemKind.IsNonSerialised)
            {
                var inventoryItems = this.Part.InventoryItemsWherePart;
                inventoryItems.Filter.AddEquals(M.InventoryItem.Facility, facility);
                var inventoryItem = inventoryItems.First;

                if (inventoryItem == null)
                {
                    var builder = new NonSerialisedInventoryItemBuilder(this.Strategy.Session)
                                  .WithFacility(facility)
                                  .WithUnitOfMeasure(unitOfMeasure)
                                  .WithPart(this.Part)
                                  .WithNonSerialisedInventoryItemState(this.NonSerialisedInventoryItemState);

                    if (this.ExistLot)
                    {
                        builder.WithLot(this.Lot);
                    }

                    this.InventoryItem = builder.Build();
                }
            }
        }
Пример #3
0
        private void Derive(Extent extent)
        {
            var derivation = new Domain.Derivations.Default.Derivation(this.session);

            derivation.Mark(extent.Cast <Domain.Object>().ToArray());
            var validation = derivation.Derive();

            if (validation.HasErrors)
            {
                foreach (var error in validation.Errors)
                {
                    Console.WriteLine(error.Message);
                }

                throw new Exception("Derivation Error");
            }
        }
Пример #4
0
 internal Graph(Derivation derivation)
 {
     this.Derivation   = derivation;
     this.NodeByObject = new Dictionary <Object, Node>();
 }
Пример #5
0
 internal Cycle(Derivation derivation)
 {
     this.Derivation = derivation;
     this.ChangeSet  = new AccumulatedChangeSet();
 }