private void MovePartToWorkstation(Store store, StoragePoint storagePoint, MovementRequest request)
        {
            var shelf = store.Shelves.FirstOrDefault(s => s.Number == request.SourceCompartment);

            if (null == shelf)
            {
                shelf = new Shelf {
                    Number = request.TargetCompartment, Store = store
                };
                StorageSystem.AddShelfToStore(store, shelf);
            }

            var position = shelf.Parts.Count - 1;

            for (int i = 0; i < request.Quantity; i++)
            {
                if (position < shelf.Parts.Count)
                {
                    var part = shelf.Parts.FirstOrDefault(p => p.Position == position);
                    StorageSystem.RemovePartFromShelf(shelf, part);
                    StorageSystem.AddPartToDeliveryPoint(storagePoint, part);
                }

                position--;
            }
        }
示例#2
0
        public StoragePointViewModel(StoragePoint storagePoint, IEventAggregator eventAggregator) : this()
        {
            _eventAggregator           = eventAggregator;
            Name                       = storagePoint.Name;
            _storagePoint              = storagePoint;
            _insertPartEvent           = _eventAggregator.GetEvent <PubSubEvent <InsertPartEvent> >();
            _insertPartToDeliveryEvent = _eventAggregator.GetEvent <PubSubEvent <InsertPartToDeliveryEvent> >();
            _removePartEvent           = _eventAggregator.GetEvent <PubSubEvent <RemovePartFromStoragePointEvent> >();
            if (Thread.CurrentThread.IsBackground)
            {
                _insertPartEvent.Subscribe(OnInsertPart);
                _removePartEvent.Subscribe(OnRemovePart);
                _insertPartToDeliveryEvent.Subscribe(OnInsertPartToDelivery);
            }
            else
            {
                _insertPartEvent.Subscribe(OnInsertPart, ThreadOption.UIThread);
                _removePartEvent.Subscribe(OnRemovePart, ThreadOption.UIThread);
                _insertPartToDeliveryEvent.Subscribe(OnInsertPartToDelivery, ThreadOption.UIThread);
            }

            foreach (var part in storagePoint.Parts)
            {
                Parts.Add(new PartViewModel(part));
            }
        }
示例#3
0
 public bool AddStoragePoint(StoragePoint p)
 {
     if (_points.ContainsKey(p.StorageId))
     {
         return(false);
     }
     _points.Add(p.StorageId, p);
     return(true);
 }
 public bool AddStoragePoint(StoragePoint point)
 {
     if (!_point.ContainsKey(point.StorageId))
     {
         _point[point.StorageId] = point;
         return(true);
     }
     return(false);
 }
示例#5
0
        public void AddStoragePointItem()
        {
            // Assert.AreEqual("Moi", "Moi");
            var storagepoint = new StoragePoint {
                StorageId = 0, Name = "Storage Point 1", Description = "Description 1"
            };

            Assert.IsTrue(_handler.AddStoragePoint(storagepoint), "Storage point add failed");
            // Assert.isFalse(_handler.AddStoragePoint(storagepoint), "Storage point add duplicate item failed");
        }
示例#6
0
        public void AnalyseMovementToWorkstationShouldAddStoreAndShelf()
        {
            var          expected        = "12345";
            Store        newStore        = null;
            StoragePoint newStoragePoint = null;
            var          storagePoint    = new StoragePoint {
                Name = "TV01"
            };
            var storagePoints = new List <StoragePoint> {
                storagePoint
            };
            var stores        = new List <Store>();
            var storageSystem = new Mock <IStorageSystem>();

            storageSystem.SetupGet(s => s.StoragePoints).Returns(new List <StoragePoint>());
            storageSystem.SetupGet(s => s.DeliveryPoints).Returns(storagePoints);
            storageSystem.Setup(s => s.AddDeliveryPoint(It.IsAny <StoragePoint>())).Callback <StoragePoint>(point =>
            {
                newStoragePoint = point;
                storageSystem.SetupGet(s => s.DeliveryPoints).Returns(new List <StoragePoint> {
                    newStoragePoint
                });
            });
            storageSystem.SetupGet(s => s.Stores).Returns(stores);
            storageSystem.Setup(s => s.AddStore(It.IsAny <Store>())).Callback <Store>(addStore =>
            {
                newStore = addStore;
                storageSystem.SetupGet(s => s.Stores).Returns(new List <Store> {
                    newStore
                });
            });
            _useCase.StorageSystem = storageSystem.Object;
            var request = new MovementRequest
            {
                Ticket            = Guid.NewGuid(), Info = "part to workstation", Quantity = 1, Target = "AV01",
                TargetCompartment = "1", Task = AutomationTasks.Transport, Source = "B01", SourceCompartment = "1", Timestamp = DateTime.UtcNow
            };

            request.Data.Add(new MovementData {
                Barcode = expected
            });

            _useCase.Execute(request);

            storageSystem.Verify(s => s.AddStore(It.IsAny <Store>()));
            storageSystem.Verify(s => s.AddDeliveryPoint(It.IsAny <StoragePoint>()));
            newStore.Name.Should().Be("B01");
            newStore.Shelves.Count.Should().Be(1);
            var shelf = newStore.Shelves.First();

            shelf.Number.Should().Be("1");
            shelf.Store.Should().Be(newStore);
            newStoragePoint.Name.Should().Be("AV01");
        }
        private void MovePartToStore(Store store, MovementRequest request)
        {
            var storagePoint = StorageSystem.StoragePoints.FirstOrDefault(sp => sp.Name == request.Source);

            if (storagePoint == null)
            {
                storagePoint = new StoragePoint {
                    Name = request.Source
                };
                StorageSystem.AddStoragePoint(storagePoint);
            }

            var shelf = store.Shelves.FirstOrDefault(s => s.Number == request.TargetCompartment);

            if (null == shelf)
            {
                shelf = new Shelf {
                    Number = request.TargetCompartment, Store = store
                };
                StorageSystem.AddShelfToStore(store, shelf);
            }

            var position = shelf.Parts.Count;

            for (int i = 0; i < request.Quantity; i++)
            {
                Part part;
                var  movementData = request.Data.FirstOrDefault(d => d.Index == (i + 1).ToString());
                if (null != movementData)
                {
                    part = storagePoint.Parts.FirstOrDefault(p => p.Barcode == movementData.Barcode);
                    if (part == null)
                    {
                        part = new Part {
                            Barcode = movementData.Barcode
                        };
                    }
                }
                else
                {
                    part = new Part {
                        Barcode = $"Part on position {position}"
                    };
                }

                part.Position = position;
                StorageSystem.RemovePartFromStoragePoint(storagePoint, part);
                StorageSystem.AddPartToShelf(shelf, part);

                position++;
            }
        }
示例#8
0
        public void AddStoragepointItem()
        {
            var storagePoint = new StoragePoint {
                StorageId = 0, Name = "Storage 1", Description = "Description 1"
            };

            Assert.IsTrue(_handler.AddStoragePoint(storagePoint), "Storage point add failed");
            Assert.IsFalse(_handler.AddStoragePoint(storagePoint), "Storage point add duplicate item failed");

            var list = _handler.StoragePoints();

            Assert.AreEqual(list[0].StorageId, storagePoint.StorageId, 0, "Added item does not match");
        }
示例#9
0
        private StoragePoint InitializeReadWriteStoragePoint()
        {
            string value        = "TestValue";
            var    storagePoint = new StoragePoint
            {
                StorageId   = 1,
                Name        = "Storage 1",
                Description = "Description 1",
                Value       = value
            };

            Assert.IsTrue(_handler.AddStoragePoint(storagePoint), "Storage point add failed");
            return(storagePoint);
        }
示例#10
0
        public string read(int id)
        {
            Console.WriteLine("Read {0} ", id);
            StoragePoint p = null;

            if (_points.TryGetValue(id, out p) && p.Value != null)
            {
                return(p.Value);
            }
            else
            {
                return("N/A");
            }
        }
        public void ReceivingInsertPartToDeliveryShouldAddPart()
        {
            var insertEvent = _eventAggregator.GetEvent <PubSubEvent <InsertPartToDeliveryEvent> >();
            var part        = new Part {
                Barcode = "expected"
            };
            var deliveryPoint = new StoragePoint {
                Name = "deliveryPoint"
            };
            var viewModel = new StoragePointViewModel(deliveryPoint, _eventAggregator);

            insertEvent.Publish(new InsertPartToDeliveryEvent {
                DeliveryPoint = deliveryPoint, Part = part
            });

            viewModel.Parts.Count.Should().Be(1);
            viewModel.Parts[0].Barcode.Should().Be("expected");
        }
        public void ReceivingRemovePartShouldRemovePart()
        {
            var removeEvent = _eventAggregator.GetEvent <PubSubEvent <RemovePartFromStoragePointEvent> >();
            var part        = new Part {
                Barcode = "expected"
            };
            var storagePoint = new StoragePoint {
                Name = "storagePoint"
            };

            storagePoint.Parts.Add(part);
            var viewModel = new StoragePointViewModel(storagePoint, _eventAggregator);

            removeEvent.Publish(new RemovePartFromStoragePointEvent {
                Part = part, StoragePoint = storagePoint
            });

            viewModel.Parts.Count.Should().Be(0);
        }
        public void ReceiveAddSDeliveryEventShouldAddStore()
        {
            var storagePoint = new StoragePoint {
                Name = "expected"
            };
            var deliveryPointEvent = _eventAggregator.GetEvent <PubSubEvent <AddDeliveryPointEvent> >();

            _storageSystem.Setup(s => s.DeliveryPoints).Returns(new List <StoragePoint>());
            var viewModel = new DeliveryPointListViewModel(_storageSystem.Object, _eventAggregator);

            deliveryPointEvent.Publish(new AddDeliveryPointEvent {
                DeliveryPoint = storagePoint
            });

            Task.Delay(5).Wait();
            viewModel.DeliveryPoints.Count.Should().Be(1);
            var storeViewModel = viewModel.DeliveryPoints.First();

            storeViewModel.Name.Should().Be("expected");
        }
        public void ConstructorShouldInitializeMember()
        {
            var storagePoint = new StoragePoint {
                Name = "expected"
            };

            for (int i = 0; i < 3; i++)
            {
                storagePoint.Parts.Add(new Part {
                    Barcode = $"{i}", Position = i
                });
            }

            var viewModel = new StoragePointViewModel(storagePoint, _eventAggregator);

            viewModel.Name.Should().Be("expected");
            viewModel.Parts.Count.Should().Be(3);
            for (int i = 0; i < 3; i++)
            {
                viewModel.Parts[i].Barcode.Should().Be(i.ToString());
                viewModel.Parts[i].Position.Should().Be(i);
            }
        }