/// <summary> /// Creates a new output order. /// </summary> /// <param name="copyExistingItems">if set to <c>true</c> items of a possible existing order.</param> /// <returns>Newly created order or null.</returns> private IOutputProcess CreateNewOrder(bool copyExistingItems) { OutputProcessPriority priority = OutputProcessPriority.Normal; switch (cmbPriority.SelectedIndex) { case 0: priority = OutputProcessPriority.Low; break; case 1: priority = OutputProcessPriority.Normal; break; case 2: priority = OutputProcessPriority.High; break; } var result = _storageSystem.CreateOutputProcess(txtOrderNumber.Text, (int)numDestination.Value, (int)numPoint.Value, priority, txtBoxNumber.Text); if ((copyExistingItems) && (_order != null)) { foreach (var criteria in _order.Criteria) { result.AddCriteria(criteria.ArticleId, criteria.Quantity, criteria.BatchNumber, criteria.ExternalId, criteria.MinimumExpiryDate, criteria.PackId, criteria.SubItemQuantity); } for (int i = 0; i < _order.Criteria.Length; ++i) { foreach (var label in _order.Criteria[i].Labels) { result.Criteria[i].AddLabel(label.TemplateId, label.Content); } } } return(result); }
/// <summary> /// Generates the orders on a regular base. /// </summary> private void GenerateRegularOrders() { OutputProcessPriority priority = OutputProcessPriority.Normal; switch (cmbPriority.SelectedIndex) { case 0: priority = OutputProcessPriority.Low; break; case 1: priority = OutputProcessPriority.Normal; break; case 2: priority = OutputProcessPriority.High; break; } var articleList = new List <string>(_articlePacks.Keys); var boxNumberList = new List <string>(); var boxNumberIndex = 0; if (string.IsNullOrWhiteSpace(txtBoxNumbers.Text) == false) { boxNumberList.AddRange(txtBoxNumbers.Text.Trim().Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries)); } foreach (var article in articleList.ToArray()) { if (article.Length > 20) { _articlePacks.Remove(article); articleList.Remove(article); } } if (string.IsNullOrEmpty(txtMachineLocation.Text) == false) { foreach (var article in articleList.ToArray()) { foreach (var pack in _articlePacks[article].ToArray()) { if (pack.MachineLocation != txtMachineLocation.Text) { _articlePacks[article].Remove(pack); } } if (_articlePacks[article].Count == 0) { _articlePacks.Remove(article); articleList.Remove(article); } } } for (int i = 0; i < numOrderCount.Value; ++i) { int orderNumber = Convert.ToInt32(numStartOrderNumber.Value) + i; string boxNumber = null; if (boxNumberList.Count > 0) { boxNumber = boxNumberList[boxNumberIndex++].Trim(); if (boxNumberIndex >= boxNumberList.Count) { boxNumberIndex = 0; } } else if (string.IsNullOrEmpty(txtStartBoxNumber.Text) == false) { int startBoxNumber = 0; if (int.TryParse(txtStartBoxNumber.Text, out startBoxNumber)) { boxNumber = (startBoxNumber + i).ToString(); } else { boxNumber = txtStartBoxNumber.Text + i.ToString(); } } var order = _storageSystem.CreateOutputProcess(orderNumber, Convert.ToInt32(numDestination.Value), 0, priority, boxNumber); int remainingPacks = Convert.ToInt32(numPackCount.Value); while (remainingPacks > 0) { foreach (var article in articleList.ToArray()) { int requestedPacks = Math.Min(remainingPacks, _articlePacks[article].Count); if (string.IsNullOrEmpty(txtMachineLocation.Text) == false) { order.AddCriteria(article, (uint)requestedPacks, null, null, null, 0, 0, null, txtMachineLocation.Text); } else { order.AddCriteria(article, (uint)requestedPacks); } _articlePacks[article].RemoveRange(0, requestedPacks); remainingPacks -= requestedPacks; if (_articlePacks[article].Count == 0) { _articlePacks.Remove(article); articleList.Remove(article); } if (remainingPacks == 0) { break; } } if (_articlePacks.Count == 0) { break; } } _orders.Add(order); } }