private async Task <DialogTurnResult> BaseUnitQuantityPickedPrompt(
            WaterfallStepContext step,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            //Custom Code Start | Removed Block
            //FoundChoice _InventoryUnit = (FoundChoice)step.Result;
            //var ixInventoryUnit = _pickbatchpickingService.selectInventoryUnits().Where(ct => ct.sInventoryUnit == _InventoryUnit.Value).Select(ct => ct.ixInventoryUnit).First();
            //((PickBatchPickingPost)step.Values[DialogKey]).ixInventoryUnit = ixInventoryUnit;
            //Custom Code End

            //if (!(((PickBatchPickingPost)step.Options).ixPickBatch > 0))
            //{
            //    return await step.BeginDialogAsync(CreateGetPickBatchesDialogId, null, cancellationToken);
            //    //var sPickBatchPick = (string)step.Result;
            //    //((PickBatchPickingPost)step.Values[DialogKey]).sPickBatchPick = sPickBatchPick;
            //}
            //else
            //{
            step.Values[DialogKey] = new PickBatchPickingPost();
            ((PickBatchPickingPost)step.Values[DialogKey]).sPickBatchPick = ((PickBatchPickingPost)step.Options).sPickBatchPick;
            //}

            //Custom Code Start | Added Code Block
            var sPickBatchPick = ((PickBatchPickingPost)step.Options).sPickBatchPick;
            //((PickBatchPickingPost)step.Values[DialogKey]).sPickBatchPick = sPickBatchPick;

            var ixPickBatch = _pickbatchesService.IndexDb().Where(x => x.sPickBatch.Trim().ToLower() == sPickBatchPick.Trim().ToLower()).Select(x => x.ixPickBatch).FirstOrDefault();

            ((PickBatchPickingPost)step.Values[DialogKey]).ixPickBatch = ixPickBatch;
            //Now we get the pick suggestion
            var currentBotUserData = await _botSpielUserStateAccessors.BotUserDataAccessor.GetAsync(step.Context, () => _botUserData);

            var pickSuggestion = _picking.getPickSuggestion(ixPickBatch, currentBotUserData);

            currentBotUserData.pickSuggestion = pickSuggestion;
            await _botSpielUserStateAccessors.BotUserDataAccessor.SetAsync(step.Context, currentBotUserData, cancellationToken);

            await _botSpielUserStateAccessors.UserState.SaveChangesAsync(step.Context);

            var pickSuggestionText = "";

            if (pickSuggestion.Item1 > 0 && pickSuggestion.Item2 > 0)
            {
                var inventoryUnit = _inventoryunitsService.Get(pickSuggestion.Item1);
                pickSuggestionText = $@"Please pick inventory unit:
Inventory Location: {inventoryUnit.InventoryLocations.sInventoryLocation}
Handling Unit: {inventoryUnit.HandlingUnits.sHandlingUnit}
Material: {inventoryUnit.Materials.sMaterial}
Pick Quantity: {pickSuggestion.Item2}
and confirm the quantity picked.
";
                ((PickBatchPickingPost)step.Values[DialogKey]).ixInventoryUnit = inventoryUnit.ixInventoryUnit;
                step.Values[PickSuggestionKey]    = inventoryUnit;
                step.Values[PickSuggestionQtyKey] = pickSuggestion.Item2;
                //We update the queued qty on the iu
                var inventoryUnitPickedFrom = _inventoryunitsService.GetPost(inventoryUnit.ixInventoryUnit);
                inventoryUnitPickedFrom.nBaseUnitQuantityQueued += pickSuggestion.Item2;
                inventoryUnitPickedFrom.UserName = step.Context.Activity.Conversation.Id;
                await _inventoryunitsService.Edit(inventoryUnitPickedFrom, _commonLookUps.getInventoryUnitTransactionContext().Where(x => x.sInventoryUnitTransactionContext == "Inventory Adjustment").Select(x => x.ixInventoryUnitTransactionContext).FirstOrDefault());
            }
            else
            {
                pickSuggestionText = "I cannot find an inventory unit to pick, please exit and choose a different batch or correct the inventory.";
            }

            //Custom Code End

            return(await step.PromptAsync(
                       BaseUnitQuantityPickedPromptId,
                       new PromptOptions
            {
                //Custom Code Start | Replaced Code Block
                //Replaced Code Block Start
                //Prompt = MessageFactory.Text($"Please enter a BaseUnitQuantityPicked:"),
                //Replaced Code Block End
                Prompt = MessageFactory.Text($"{pickSuggestionText}"),
                //Custom Code End
                RetryPrompt = MessageFactory.Text("Please enter a number."),
            },
                       cancellationToken));
        }
Beispiel #2
0
        public Task Edit(MoveQueuesPost movequeuesPost)
        {
            // Additional validations

            // Pre-process

            // Process
            this._movequeuesRepository.RegisterEdit(movequeuesPost);
            try
            {
                this._movequeuesRepository.Commit();
            }
            catch (Exception ex)
            {
                this._movequeuesRepository.Rollback();
                // Log exception
                throw;
            }

            // Post-process
            //Custom Code Start | Added Code Block
            if (movequeuesPost.ixMoveQueueType == _commonLookUps.getMoveQueueTypes().Where(x => x.sMoveQueueType == "Consolidated Pickup - Consolidated Drop").Select(x => x.ixMoveQueueType).FirstOrDefault()
                //&& movequeuesPost.ixMoveQueueContext == _commonLookUps.getMoveQueueContexts().Where(x => x.sMoveQueueContext == "Putaway").Select(x => x.ixMoveQueueContext).FirstOrDefault()
                && movequeuesPost.ixSourceInventoryLocation != movequeuesPost.ixTargetInventoryLocation
                )
            {
                _inventoryunitsService.IndexDbPost().Where(x => x.ixHandlingUnit == movequeuesPost.ixTargetHandlingUnit).ToList().ForEach(iu =>
                {
                    iu.ixInventoryLocation = movequeuesPost.ixTargetInventoryLocation ?? 0;
                    iu.UserName            = movequeuesPost.UserName;
                    _inventoryunitsService.Edit(iu, _commonLookUps.getInventoryUnitTransactionContext().Where(x => x.sInventoryUnitTransactionContext == "Move Queue Execution").Select(x => x.ixInventoryUnitTransactionContext).FirstOrDefault());
                }
                                                                                                                                          );
                var targetInventoryLocation      = _inventorylocationsService.GetPost(movequeuesPost.ixTargetInventoryLocation ?? 0);
                var inventoryUnitsOnHandlingUnit = _inventoryunitsService.IndexDb().Where(x => x.ixHandlingUnit == movequeuesPost.ixTargetHandlingUnit).ToList();
                targetInventoryLocation.nQueuedUtilisationPercent = _volumeAndWeight.getNewLocationQueuedUtilisationPercent(movequeuesPost.ixTargetHandlingUnit ?? 0, inventoryUnitsOnHandlingUnit, targetInventoryLocation, false);
                targetInventoryLocation.UserName = movequeuesPost.UserName;
                _inventorylocationsService.Edit(targetInventoryLocation);
            }

            if (movequeuesPost.ixMoveQueueType == _commonLookUps.getMoveQueueTypes().Where(x => x.sMoveQueueType == "Unit Pickup - Consolidated Drop").Select(x => x.ixMoveQueueType).FirstOrDefault()
                //&& movequeuesPost.ixMoveQueueContext == _commonLookUps.getMoveQueueContexts().Where(x => x.sMoveQueueContext == "Putaway").Select(x => x.ixMoveQueueContext).FirstOrDefault()
                && movequeuesPost.ixSourceInventoryLocation != movequeuesPost.ixTargetInventoryLocation
                )
            {
                var targetInventoryUnit = _inventoryunitsService.GetPost(movequeuesPost.ixTargetInventoryUnit ?? 0);

                targetInventoryUnit.ixInventoryLocation = movequeuesPost.ixTargetInventoryLocation ?? 0;
                targetInventoryUnit.UserName            = movequeuesPost.UserName;
                _inventoryunitsService.Edit(targetInventoryUnit, _commonLookUps.getInventoryUnitTransactionContext().Where(x => x.sInventoryUnitTransactionContext == "Move Queue Execution").Select(x => x.ixInventoryUnitTransactionContext).FirstOrDefault());

                var targetInventoryLocation = _inventorylocationsService.GetPost(movequeuesPost.ixTargetInventoryLocation ?? 0);
                targetInventoryLocation.nQueuedUtilisationPercent = _volumeAndWeight.getNewLocationQueuedUtilisationPercent(targetInventoryUnit, targetInventoryLocation, false);
                targetInventoryLocation.UserName = movequeuesPost.UserName;
                _inventorylocationsService.Edit(targetInventoryLocation);
            }


            //Custom Code End

            return(Task.CompletedTask);
        }