示例#1
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));
        }