public ActionResult Edit([Bind("ixMoveQueue,sMoveQueue,ixMoveQueueType,ixMoveQueueContext,ixSourceInventoryUnit,ixTargetInventoryUnit,ixSourceInventoryLocation,ixTargetInventoryLocation,ixSourceHandlingUnit,ixTargetHandlingUnit,sPreferredResource,nBaseUnitQuantity,dtStartBy,dtCompleteBy,dtStartedAt,dtCompletedAt,ixInboundOrderLine,ixOutboundOrderLine,ixPickBatch,ixStatus")] MoveQueuesPost movequeues)
        {
            if (ModelState.IsValid)
            {
                movequeues.UserName = User.Identity.Name;
                _movequeuesService.Edit(movequeues);
                return(RedirectToAction("Index"));
            }
            ViewBag.ixInboundOrderLine        = new SelectList(_movequeuesService.selectInboundOrderLinesNullable().Select(x => new { ixInboundOrderLine = x.Key, sInboundOrderLine = x.Value }), "ixInboundOrderLine", "sInboundOrderLine", movequeues.ixInboundOrderLine);
            ViewBag.ixMoveQueueContext        = new SelectList(_movequeuesService.selectMoveQueueContexts().Select(x => new { x.ixMoveQueueContext, x.sMoveQueueContext }), "ixMoveQueueContext", "sMoveQueueContext", movequeues.ixMoveQueueContext);
            ViewBag.ixMoveQueueType           = new SelectList(_movequeuesService.selectMoveQueueTypes().Select(x => new { x.ixMoveQueueType, x.sMoveQueueType }), "ixMoveQueueType", "sMoveQueueType", movequeues.ixMoveQueueType);
            ViewBag.ixOutboundOrderLine       = new SelectList(_movequeuesService.selectOutboundOrderLinesNullable().Select(x => new { ixOutboundOrderLine = x.Key, sOutboundOrderLine = x.Value }), "ixOutboundOrderLine", "sOutboundOrderLine", movequeues.ixOutboundOrderLine);
            ViewBag.ixPickBatch               = new SelectList(_movequeuesService.selectPickBatchesNullable().Select(x => new { ixPickBatch = x.Key, sPickBatch = x.Value }), "ixPickBatch", "sPickBatch", movequeues.ixPickBatch);
            ViewBag.ixSourceHandlingUnit      = new SelectList(_movequeuesService.selectHandlingUnitsNullable().Select(x => new { ixHandlingUnit = x.Key, sHandlingUnit = x.Value }), "ixHandlingUnit", "sHandlingUnit", movequeues.ixSourceHandlingUnit);
            ViewBag.ixSourceInventoryLocation = new SelectList(_movequeuesService.selectInventoryLocationsNullable().Select(x => new { ixInventoryLocation = x.Key, sInventoryLocation = x.Value }), "ixInventoryLocation", "sInventoryLocation", movequeues.ixSourceInventoryLocation);
            ViewBag.ixSourceInventoryUnit     = new SelectList(_movequeuesService.selectInventoryUnitsNullable().Select(x => new { ixInventoryUnit = x.Key, sInventoryUnit = x.Value }), "ixInventoryUnit", "sInventoryUnit", movequeues.ixSourceInventoryUnit);
            ViewBag.ixStatus                  = new SelectList(_movequeuesService.selectStatuses().Select(x => new { x.ixStatus, x.sStatus }), "ixStatus", "sStatus", movequeues.ixStatus);
            ViewBag.ixTargetHandlingUnit      = new SelectList(_movequeuesService.selectHandlingUnitsNullable().Select(x => new { ixHandlingUnit = x.Key, sHandlingUnit = x.Value }), "ixHandlingUnit", "sHandlingUnit", movequeues.ixTargetHandlingUnit);
            ViewBag.ixTargetInventoryLocation = new SelectList(_movequeuesService.selectInventoryLocationsNullable().Select(x => new { ixInventoryLocation = x.Key, sInventoryLocation = x.Value }), "ixInventoryLocation", "sInventoryLocation", movequeues.ixTargetInventoryLocation);
            ViewBag.ixTargetInventoryUnit     = new SelectList(_movequeuesService.selectInventoryUnitsNullable().Select(x => new { ixInventoryUnit = x.Key, sInventoryUnit = x.Value }), "ixInventoryUnit", "sInventoryUnit", movequeues.ixTargetInventoryUnit);

            return(View(movequeues));
        }
        private async Task <DialogTurnResult> PackToHandlingUnitPrompt(
            WaterfallStepContext step,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            var nBaseUnitQuantityPicked = step.Result;

            ((PickBatchPickingPost)step.Values[DialogKey]).nBaseUnitQuantityPicked = Convert.ToDouble(nBaseUnitQuantityPicked);

            //Custom Code Start | Added Code Block
            step.Values[IsCompleteInventoryUnitPickKey] = _picking.isCompleteInventoryUnitPick((InventoryUnits)step.Values[PickSuggestionKey], Convert.ToDouble(nBaseUnitQuantityPicked));
            step.Values[IsHandlingUnitPickKey]          = _picking.isHandlingUnitPick((InventoryUnits)step.Values[PickSuggestionKey], Convert.ToDouble(nBaseUnitQuantityPicked));

            //We adjust the queued qty down
            var inventoryUnitPickedFrom = _inventoryunitsService.GetPost(((InventoryUnits)step.Values[PickSuggestionKey]).ixInventoryUnit);

            inventoryUnitPickedFrom.nBaseUnitQuantityQueued -= (double)step.Values[PickSuggestionQtyKey];
            inventoryUnitPickedFrom.UserName = step.Context.Activity.Conversation.Id;
            await _inventoryunitsService.Edit(inventoryUnitPickedFrom, _commonLookUps.getInventoryUnitTransactionContext().Where(x => x.sInventoryUnitTransactionContext == "Inventory Adjustment").Select(x => x.ixInventoryUnitTransactionContext).FirstOrDefault());

            var currentBotUserData = await _botSpielUserStateAccessors.BotUserDataAccessor.GetAsync(step.Context, () => _botUserData);

            //If we pick complete inventory unit we move it to the picker else we adjust and create/consolidate and then move to the picker
            if ((bool)step.Values[IsCompleteInventoryUnitPickKey])
            {
                //We now create and execute the move queue for the pickup
                step.Values[PickedInventoryUnitKey] = ((InventoryUnits)step.Values[PickSuggestionKey]).ixInventoryUnit;
                MoveQueuesPost moveQueuePost = new MoveQueuesPost();
                if (_picking.isHandlingUnitPick((InventoryUnits)step.Values[PickSuggestionKey], Convert.ToDouble(nBaseUnitQuantityPicked)))
                {
                    moveQueuePost.ixMoveQueueType = _commonLookUps.getMoveQueueTypes().Where(x => x.sMoveQueueType == "Unit Pickup - Consolidated Drop").Select(x => x.ixMoveQueueType).FirstOrDefault();
                }
                else
                {
                    moveQueuePost.ixMoveQueueType = _commonLookUps.getMoveQueueTypes().Where(x => x.sMoveQueueType == "Consolidated Pickup - Consolidated Drop").Select(x => x.ixMoveQueueType).FirstOrDefault();
                }
                moveQueuePost.ixMoveQueueContext        = _commonLookUps.getMoveQueueContexts().Where(x => x.sMoveQueueContext == "Picking").Select(x => x.ixMoveQueueContext).FirstOrDefault();
                moveQueuePost.ixSourceInventoryUnit     = ((InventoryUnits)step.Values[PickSuggestionKey]).ixInventoryUnit;
                moveQueuePost.ixTargetInventoryUnit     = ((InventoryUnits)step.Values[PickSuggestionKey]).ixInventoryUnit;
                moveQueuePost.ixSourceInventoryLocation = ((InventoryUnits)step.Values[PickSuggestionKey]).ixInventoryLocation;
                moveQueuePost.ixTargetInventoryLocation = currentBotUserData.ixInventoryLocation;
                moveQueuePost.ixSourceHandlingUnit      = ((InventoryUnits)step.Values[PickSuggestionKey]).ixHandlingUnit > 0 ? ((InventoryUnits)step.Values[PickSuggestionKey]).ixHandlingUnit : null;
                moveQueuePost.ixTargetHandlingUnit      = ((InventoryUnits)step.Values[PickSuggestionKey]).ixHandlingUnit > 0 ? ((InventoryUnits)step.Values[PickSuggestionKey]).ixHandlingUnit : null;
                moveQueuePost.sPreferredResource        = step.Context.Activity.Conversation.Id;
                moveQueuePost.nBaseUnitQuantity         = Convert.ToDouble(nBaseUnitQuantityPicked);
                moveQueuePost.dtStartedAt = DateTime.Now;
                moveQueuePost.ixPickBatch = ((PickBatchPickingPost)step.Values[DialogKey]).ixPickBatch;
                moveQueuePost.ixStatus    = _commonLookUps.getStatuses().Where(x => x.sStatus == "Active").Select(x => x.ixStatus).FirstOrDefault();
                moveQueuePost.UserName    = step.Context.Activity.Conversation.Id;
                var ixMoveQueue = await _movequeuesService.Create(moveQueuePost);

                //We now complete the move queue for the pickup
                var moveQueuePickUp = _movequeuesService.GetPost(ixMoveQueue);
                moveQueuePickUp.dtCompletedAt = DateTime.Now;
                moveQueuePickUp.ixStatus      = _commonLookUps.getStatuses().Where(x => x.sStatus == "Complete").Select(x => x.ixStatus).FirstOrDefault();
                moveQueuePickUp.UserName      = moveQueuePost.UserName;
                await _movequeuesService.Edit(moveQueuePickUp);
            }
            else
            {
                //Now we adjust the iu remaining down
                inventoryUnitPickedFrom.nBaseUnitQuantity -= Convert.ToDouble(nBaseUnitQuantityPicked);
                inventoryUnitPickedFrom.UserName           = step.Context.Activity.Conversation.Id;
                await _inventoryunitsService.Edit(inventoryUnitPickedFrom, _commonLookUps.getInventoryUnitTransactionContext().Where(x => x.sInventoryUnitTransactionContext == "Inventory Adjustment").Select(x => x.ixInventoryUnitTransactionContext).FirstOrDefault());

                //Now we either create or edit an iu for the qty picked
                inventoryUnitPickedFrom.nBaseUnitQuantity   = Convert.ToDouble(nBaseUnitQuantityPicked);
                inventoryUnitPickedFrom.UserName            = step.Context.Activity.Conversation.Id;
                inventoryUnitPickedFrom.ixInventoryLocation = currentBotUserData.ixInventoryLocation;

                if (_inventoryunitsService.IndexDb().Where(x =>
                                                           x.ixFacility == inventoryUnitPickedFrom.ixFacility &&
                                                           x.ixCompany == inventoryUnitPickedFrom.ixCompany &&
                                                           x.ixMaterial == inventoryUnitPickedFrom.ixMaterial &&
                                                           x.ixInventoryState == inventoryUnitPickedFrom.ixInventoryState &&
                                                           x.ixHandlingUnit == inventoryUnitPickedFrom.ixHandlingUnit &&
                                                           x.ixInventoryLocation == inventoryUnitPickedFrom.ixInventoryLocation &&
                                                           x.sBatchNumber == inventoryUnitPickedFrom.sBatchNumber &&
                                                           x.dtExpireAt == inventoryUnitPickedFrom.dtExpireAt && x.ixStatus == 5
                                                           ).Select(x => x.ixInventoryUnit).Any()
                    )
                {
                    //We edit the iu
                    inventoryUnitPickedFrom.ixInventoryUnit = _inventoryunitsService.IndexDb().Where(x =>
                                                                                                     x.ixFacility == inventoryUnitPickedFrom.ixFacility &&
                                                                                                     x.ixCompany == inventoryUnitPickedFrom.ixCompany &&
                                                                                                     x.ixMaterial == inventoryUnitPickedFrom.ixMaterial &&
                                                                                                     x.ixInventoryState == inventoryUnitPickedFrom.ixInventoryState &&
                                                                                                     x.ixHandlingUnit == inventoryUnitPickedFrom.ixHandlingUnit &&
                                                                                                     x.ixInventoryLocation == inventoryUnitPickedFrom.ixInventoryLocation &&
                                                                                                     x.sBatchNumber == inventoryUnitPickedFrom.sBatchNumber &&
                                                                                                     x.dtExpireAt == inventoryUnitPickedFrom.dtExpireAt && x.ixStatus == 5
                                                                                                     ).Select(x => x.ixInventoryUnit).FirstOrDefault();
                    inventoryUnitPickedFrom.nBaseUnitQuantity = _inventoryunitsService.GetPost(inventoryUnitPickedFrom.ixInventoryUnit).nBaseUnitQuantity + Convert.ToDouble(nBaseUnitQuantityPicked);
                    await _inventoryunitsService.Edit(inventoryUnitPickedFrom, _commonLookUps.getInventoryUnitTransactionContext().Where(x => x.sInventoryUnitTransactionContext == "Inventory Adjustment").Select(x => x.ixInventoryUnitTransactionContext).FirstOrDefault());

                    step.Values[PickedInventoryUnitKey] = inventoryUnitPickedFrom.ixInventoryUnit;
                }
                else
                {
                    //We create an iu
                    step.Values[PickedInventoryUnitKey] = await _inventoryunitsService.Create(inventoryUnitPickedFrom, _commonLookUps.getInventoryUnitTransactionContext().Where(x => x.sInventoryUnitTransactionContext == "Inventory Adjustment").Select(x => x.ixInventoryUnitTransactionContext).FirstOrDefault());
                }
            }

            //We now allocate the picked qty to open allocation lines

            step.Values[LineQtysPickedKey] = new List <Tuple <Int64, double> >();

            var pickedQtyNotAllocated = Convert.ToDouble(nBaseUnitQuantityPicked);

            _outboundorderlinesinventoryallocationService.IndexDbPost().Where(x => (x.nBaseUnitQuantityAllocated - x.nBaseUnitQuantityPicked) > 0).OrderBy(x => (x.nBaseUnitQuantityAllocated - x.nBaseUnitQuantityPicked) > 0).ToList()
            .Join(_picking.getOrderLinesInBatchForMaterial(((PickBatchPickingPost)step.Values[DialogKey]).ixPickBatch, ((InventoryUnits)step.Values[PickSuggestionKey]).ixMaterial), ol => ol.ixOutboundOrderLine, olb => olb, (ol, olb) => new { Ol = ol, Olb = olb }).ToList()
            .ForEach(y =>
            {
                if ((y.Ol.nBaseUnitQuantityAllocated - y.Ol.nBaseUnitQuantityPicked) <= pickedQtyNotAllocated && pickedQtyNotAllocated > 0)
                {
                    ((List <Tuple <Int64, double> >)step.Values[LineQtysPickedKey]).Add(new Tuple <long, double>(y.Ol.ixOutboundOrderLine, y.Ol.nBaseUnitQuantityAllocated - y.Ol.nBaseUnitQuantityPicked));
                    y.Ol.nBaseUnitQuantityPicked += y.Ol.nBaseUnitQuantityAllocated - y.Ol.nBaseUnitQuantityPicked;
                    pickedQtyNotAllocated        -= y.Ol.nBaseUnitQuantityAllocated - y.Ol.nBaseUnitQuantityPicked;
                    y.Ol.UserName = step.Context.Activity.Conversation.Id;
                    _outboundorderlinesinventoryallocationService.Edit(y.Ol);
                }
                else if ((y.Ol.nBaseUnitQuantityAllocated - y.Ol.nBaseUnitQuantityPicked) > pickedQtyNotAllocated && pickedQtyNotAllocated > 0)
                {
                    ((List <Tuple <Int64, double> >)step.Values[LineQtysPickedKey]).Add(new Tuple <long, double>(y.Ol.ixOutboundOrderLine, pickedQtyNotAllocated));
                    y.Ol.nBaseUnitQuantityPicked += pickedQtyNotAllocated;
                    pickedQtyNotAllocated        -= pickedQtyNotAllocated;
                    y.Ol.UserName = step.Context.Activity.Conversation.Id;
                    _outboundorderlinesinventoryallocationService.Edit(y.Ol);
                }
            }
                     );

            //Custom Code End

            //We have to figure out whether this is a pick of a complete Handling Unit.
            //Custom Code Start | Replaced Code Block
            //Replaced Code Block Start
            //return await step.PromptAsync(
            //    PackToHandlingUnitPromptId,
            //    new PromptOptions
            //    {
            //        Prompt = MessageFactory.Text($"Please enter a PackToHandlingUnit:"),
            //        RetryPrompt = MessageFactory.Text("I didn't understand. Please try again."),
            //    },
            //    cancellationToken);
            //Replaced Code Block End
            if ((bool)step.Values[IsHandlingUnitPickKey])
            {
                ((PickBatchPickingPost)step.Values[DialogKey]).sPackToHandlingUnit = ((InventoryUnits)step.Values[PickSuggestionKey]).HandlingUnits.sHandlingUnit;
                ((PickBatchPickingPost)step.Values[DialogKey]).ixHandlingUnit      = ((InventoryUnits)step.Values[PickSuggestionKey]).HandlingUnits.ixHandlingUnit;

                //We create the packing record
                var orderLinesToPack = ((List <Tuple <Int64, double> >)step.Values[LineQtysPickedKey]).GroupBy(x => x.Item1).Select(x => new { ixOutboundOrderLine = x.Key, Total = x.Sum(s => s.Item2) }).ToList();

                orderLinesToPack.ForEach(x =>
                {
                    //We check if there is an existing pack record we can use
                    if (
                        _outboundorderlinepackingService.IndexDb().Where(p =>
                                                                         p.ixHandlingUnit == ((PickBatchPickingPost)step.Values[DialogKey]).ixHandlingUnit &&
                                                                         p.ixOutboundOrderLine == x.ixOutboundOrderLine
                                                                         ).Any()
                        )
                    {
                        var outboundorderlinepack = _outboundorderlinepackingService.GetPost(_outboundorderlinepackingService.IndexDb().Where(p =>
                                                                                                                                              p.ixHandlingUnit == ((PickBatchPickingPost)step.Values[DialogKey]).ixHandlingUnit &&
                                                                                                                                              p.ixOutboundOrderLine == x.ixOutboundOrderLine
                                                                                                                                              ).Select(p => p.ixOutboundOrderLinePack).FirstOrDefault()
                                                                                             );
                        outboundorderlinepack.nBaseUnitQuantityPacked += x.Total;
                        outboundorderlinepack.UserName = step.Context.Activity.Conversation.Id;
                        _outboundorderlinepackingService.Edit(outboundorderlinepack);
                    }
                    else
                    {
                        var outboundorderlinepack = new OutboundOrderLinePackingPost();
                        outboundorderlinepack.ixOutboundOrderLine     = x.ixOutboundOrderLine;
                        outboundorderlinepack.ixHandlingUnit          = ((PickBatchPickingPost)step.Values[DialogKey]).ixHandlingUnit;
                        outboundorderlinepack.nBaseUnitQuantityPacked = x.Total;
                        outboundorderlinepack.ixStatus = _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault();
                        outboundorderlinepack.UserName = step.Context.Activity.Conversation.Id;
                        _outboundorderlinepackingService.Create(outboundorderlinepack);
                    }
                }
                                         );

                return(await step.EndDialogAsync(
                           (PickBatchPickingPost)step.Values[DialogKey],
                           cancellationToken));
            }
            else
            {
                return(await step.PromptAsync(
                           PackToHandlingUnitPromptId,
                           new PromptOptions
                {
                    //Custom Code Start | Replaced Code Block
                    //Replaced Code Block Start
                    //Prompt = MessageFactory.Text($"Please enter a PackToHandlingUnit:"),
                    //Replaced Code Block End
                    Prompt = MessageFactory.Text($"Please enter/scan the Pack To Handling Unit:"),
                    //Custom Code End
                    RetryPrompt = MessageFactory.Text("I didn't understand. Please try again."),
                },
                           cancellationToken));
            }
            //Custom Code End
        }
Exemplo n.º 3
0
        private async Task <DialogTurnResult> InventoryDropLocationPrompt(
            WaterfallStepContext step,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            var sPutAwayHandlingUnit = (string)step.Result;

            ((PutAwayHandlingUnitsPost)step.Values[DialogKey]).sPutAwayHandlingUnit = sPutAwayHandlingUnit;

            //Custom Code Start | Added Code Block
            var currentBotUserData = await _botSpielUserStateAccessors.BotUserDataAccessor.GetAsync(step.Context, () => _botUserData);

            var ixHandlingUnit = _handlingunitsService.IndexDb().Where(x => x.sHandlingUnit.Trim().ToLower() == sPutAwayHandlingUnit).Select(x => x.ixHandlingUnit).FirstOrDefault();

            ((PutAwayHandlingUnitsPost)step.Values[DialogKey]).ixHandlingUnit = ixHandlingUnit;
            //We now create and execute the move queue for the pickup
            MoveQueuesPost moveQueuePost = new MoveQueuesPost();

            moveQueuePost.ixMoveQueueType           = _movequeuetypesService.IndexDb().Where(x => x.sMoveQueueType == "Consolidated Pickup - Consolidated Drop").Select(x => x.ixMoveQueueType).FirstOrDefault();
            moveQueuePost.ixMoveQueueContext        = _movequeuecontextsService.IndexDb().Where(x => x.sMoveQueueContext == "Putaway").Select(x => x.ixMoveQueueContext).FirstOrDefault();
            moveQueuePost.ixSourceInventoryLocation = _inventoryunitsService.IndexDbPost().Where(x => x.ixHandlingUnit == ixHandlingUnit).Select(x => x.ixInventoryLocation).FirstOrDefault();
            moveQueuePost.ixTargetInventoryLocation = currentBotUserData.ixInventoryLocation;
            moveQueuePost.ixSourceHandlingUnit      = ixHandlingUnit;
            moveQueuePost.ixTargetHandlingUnit      = ixHandlingUnit;
            moveQueuePost.sPreferredResource        = step.Context.Activity.Conversation.Id;
            moveQueuePost.nBaseUnitQuantity         = 0;
            moveQueuePost.dtStartedAt = DateTime.Now;
            moveQueuePost.ixStatus    = _statusesService.IndexDb().Where(x => x.sStatus == "Active").Select(x => x.ixStatus).FirstOrDefault();
            moveQueuePost.UserName    = step.Context.Activity.Conversation.Id;
            var ixMoveQueue = await _movequeuesService.Create(moveQueuePost);

            //We now complete the move queue for the pickup
            var moveQueuePickUp = _movequeuesService.GetPost(ixMoveQueue);

            moveQueuePickUp.dtCompletedAt = DateTime.Now;
            moveQueuePickUp.ixStatus      = _statusesService.IndexDb().Where(x => x.sStatus == "Complete").Select(x => x.ixStatus).FirstOrDefault();
            moveQueuePickUp.UserName      = moveQueuePost.UserName;
            await _movequeuesService.Edit(moveQueuePickUp);

            var    ixInventoryLocationSuggestion = _putAway.getPutAwaySuggestion(ixHandlingUnit, currentBotUserData.ixCompany, currentBotUserData.ixFacility, currentBotUserData.ixInventoryLocation);
            string sPutAwaySuggestion            = "";

            if (_inventorylocationsService.IndexDb().Where(x => x.ixInventoryLocation == ixInventoryLocationSuggestion).Any())
            {
                sPutAwaySuggestion = _inventorylocationsService.IndexDb().Where(x => x.ixInventoryLocation == ixInventoryLocationSuggestion).Select(x => x.sInventoryLocation).FirstOrDefault();
                //We now create the move queue for the drop
                MoveQueuesPost moveQueuePostDrop = new MoveQueuesPost();
                moveQueuePostDrop.ixMoveQueueType           = moveQueuePost.ixMoveQueueType;
                moveQueuePostDrop.ixMoveQueueContext        = moveQueuePost.ixMoveQueueContext;
                moveQueuePostDrop.ixSourceInventoryLocation = currentBotUserData.ixInventoryLocation;
                moveQueuePostDrop.ixTargetInventoryLocation = ixInventoryLocationSuggestion;
                moveQueuePostDrop.ixSourceHandlingUnit      = ixHandlingUnit;
                moveQueuePostDrop.ixTargetHandlingUnit      = ixHandlingUnit;
                moveQueuePostDrop.sPreferredResource        = step.Context.Activity.Conversation.Id;
                moveQueuePostDrop.nBaseUnitQuantity         = 0;
                moveQueuePostDrop.dtStartedAt = DateTime.Now;
                moveQueuePostDrop.ixStatus    = _statusesService.IndexDb().Where(x => x.sStatus == "Active").Select(x => x.ixStatus).FirstOrDefault();
                moveQueuePostDrop.UserName    = step.Context.Activity.Conversation.Id;
                var ixMoveQueueDrop = await _movequeuesService.Create(moveQueuePostDrop);

                step.Values[MoveQueuePostDropKey] = moveQueuePostDrop;
            }
            else
            {
                sPutAwaySuggestion = "No Suggestion";
            }
            step.Values[PutAwaySuggestionKey]     = sPutAwaySuggestion;
            currentBotUserData.sPutAwaySuggestion = sPutAwaySuggestion;
            await _botSpielUserStateAccessors.BotUserDataAccessor.SetAsync(step.Context, currentBotUserData, cancellationToken);

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

            //Custom Code End

            return(await step.PromptAsync(
                       InventoryDropLocationPromptId,
                       new PromptOptions
            {
                Prompt = MessageFactory.Text($"The suggested drop location is {sPutAwaySuggestion}.{Environment.NewLine} Please enter/scan the Inventory Drop Location."),
                RetryPrompt = MessageFactory.Text("I didn't understand. Please try again."),
            },
                       cancellationToken));
        }
Exemplo n.º 4
0
        private async Task <DialogTurnResult> donePrompt(
            WaterfallStepContext step,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            var sDropInventoryUnit = (string)step.Result;

            ((DropInventoryUnitsPost)step.Values[DialogKey]).sDropInventoryUnit = sDropInventoryUnit;

            //Custom Code Start | Added Code Block
            var currentBotUserData = await _botSpielUserStateAccessors.BotUserDataAccessor.GetAsync(step.Context, () => _botUserData);

            var ixInventoryLocationDrop = _inventorylocationsService.IndexDb().Where(x => x.sInventoryLocation.Trim().ToLower() == sDropInventoryUnit.Trim().ToLower() && x.ixFacility == currentBotUserData.ixFacility).Select(x => x.ixInventoryLocation).FirstOrDefault();

            //We drop all the inventory on the user
            //We now create and execute the move queue for the drop
            List <Int64> moveQueues = new List <long>();

            var handlingUnitsToDrop = _movequeuesService.InventoryUnitsDb().Where(x =>
                                                                                  x.ixInventoryLocation == currentBotUserData.ixInventoryLocation &&
                                                                                  x.nBaseUnitQuantity > 0 &&
                                                                                  x.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault() &&
                                                                                  x.ixHandlingUnit > 0
                                                                                  ).Select(x => x.ixHandlingUnit).Distinct().ToList();

            if (handlingUnitsToDrop.Count() > 0)
            {
                var moveQueueType    = _commonLookUps.getMoveQueueTypes().Where(mqt => mqt.sMoveQueueType == "Consolidated Pickup - Consolidated Drop").Select(mqt => mqt.ixMoveQueueType).FirstOrDefault();
                var moveQueueContext = _commonLookUps.getMoveQueueContexts().Where(mqc => mqc.sMoveQueueContext == "Picking").Select(mqc => mqc.ixMoveQueueContext).FirstOrDefault();
                var statusActive     = _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault();
                var statusComplete   = _commonLookUps.getStatuses().Where(s => s.sStatus == "Complete").Select(s => s.ixStatus).FirstOrDefault();
                handlingUnitsToDrop.ForEach(x =>
                {
                    var moveQueuePostDrop                       = new MoveQueuesPost();
                    moveQueuePostDrop.ixMoveQueueType           = moveQueueType;
                    moveQueuePostDrop.ixMoveQueueContext        = moveQueueContext;
                    moveQueuePostDrop.ixSourceInventoryLocation = currentBotUserData.ixInventoryLocation;
                    moveQueuePostDrop.ixTargetInventoryLocation = ixInventoryLocationDrop;
                    moveQueuePostDrop.ixSourceHandlingUnit      = x;
                    moveQueuePostDrop.ixTargetHandlingUnit      = x;
                    moveQueuePostDrop.sPreferredResource        = step.Context.Activity.Conversation.Id;
                    moveQueuePostDrop.nBaseUnitQuantity         = 0;
                    moveQueuePostDrop.dtStartedAt               = DateTime.Now;
                    moveQueuePostDrop.ixStatus                  = statusActive;
                    moveQueuePostDrop.UserName                  = step.Context.Activity.Conversation.Id;
                    moveQueues.Add(_movequeuesService.Create(moveQueuePostDrop).Result);
                }
                                            );
                moveQueues.ForEach(x =>
                {
                    var moveQueueDrop           = _movequeuesService.GetPost(x);
                    moveQueueDrop.dtCompletedAt = DateTime.Now;
                    moveQueueDrop.ixStatus      = statusComplete;
                    moveQueueDrop.UserName      = step.Context.Activity.Conversation.Id;
                    _movequeuesService.Edit(moveQueueDrop);
                }
                                   );
            }

            //Custom Code End


            return(await step.EndDialogAsync(
                       (DropInventoryUnitsPost)step.Values[DialogKey],
                       cancellationToken));
        }