コード例 #1
0
        //Custom Code Start | Replaced Code Block
        //Replaced Code Block Start
        //public CreatePickBatchPickingDialog(string id, IPickBatchPickingService pickbatchpickingService, PickBatchPickingPost pickbatchpickingPost, BotSpielUserStateAccessors statePropertyAccessor)
        //Replaced Code Block End
        public CreatePickBatchPickingDialog(string id, IPickBatchPickingService pickbatchpickingService, PickBatchPickingPost pickbatchpickingPost, BotSpielUserStateAccessors statePropertyAccessor
                                            , IPickBatchesService pickbatchesService
                                            , CommonLookUps commonLookUps
                                            , Picking picking
                                            , IInventoryUnitsService inventoryunitsService
                                            , IMoveQueuesService movequeuesService
                                            , IHandlingUnitsService handlingunitsService
                                            , IOutboundOrderLinesInventoryAllocationService outboundorderlinesinventoryallocationService
                                            , IOutboundOrderLinePackingService outboundorderlinepackingService
                                            )
        //Custom Code End
            : base(id)
        {
            InitialDialogId             = Id;
            _botSpielUserStateAccessors = statePropertyAccessor ?? throw new System.ArgumentNullException("state accessor can't be null");

            _pickbatchpickingService = pickbatchpickingService;
            _pickbatchpickingPost    = pickbatchpickingPost;

            //Custom Code Start | Added Code Block
            _pickbatchesService    = pickbatchesService;
            _commonLookUps         = commonLookUps;
            _picking               = picking;
            _inventoryunitsService = inventoryunitsService;
            _movequeuesService     = movequeuesService;
            _handlingunitsService  = handlingunitsService;
            _outboundorderlinesinventoryallocationService = outboundorderlinesinventoryallocationService;
            _outboundorderlinepackingService = outboundorderlinepackingService;

            PromptValidator <string> pickBatchPickValidator = async(promptContext, cancellationToken) =>
            {
                var value = promptContext.Recognized.Value.Trim().ToLower();
                if (!_pickbatchesService.IndexDb().Where(x => x.sPickBatch.Trim().ToLower() == value && x.ixStatus != _commonLookUps.getStatuses().Where(s => s.sStatus == "Complete").Select(s => s.ixStatus).FirstOrDefault()).Any())
                {
                    await promptContext.Context.SendActivityAsync(MessageFactory.Text($"The pick batch {value} does not exist or is already complete. Please enter a different value or exit."), cancellationToken);

                    return(false);
                }
                else
                {
                    if (_pickbatchesService.IndexDb().Where(x => x.sPickBatch.Trim().ToLower() == value && x.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Started").Select(s => s.ixStatus).FirstOrDefault() && !x.bMultiResource).Any())
                    {
                        await promptContext.Context.SendActivityAsync(MessageFactory.Text($"The pick batch {value} has already been started and is flagged for a single picker. Please enter a different value or exit."), cancellationToken);

                        return(false);
                    }
                    else if (_pickbatchesService.IndexDb().Where(x => x.sPickBatch.Trim().ToLower() == value && x.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Inactive").Select(s => s.ixStatus).FirstOrDefault()).Any())
                    {
                        await promptContext.Context.SendActivityAsync(MessageFactory.Text($"The pick batch {value} has not been activated. Please activate or enter a different value or exit."), cancellationToken);

                        return(false);
                    }
                    return(true);
                }
            };

            PromptValidator <float> baseUnitQuantityPickedValidator = async(promptContext, cancellationToken) =>
            {
                var value = promptContext.Recognized.Value;
                var currentBotUserData = await _botSpielUserStateAccessors.BotUserDataAccessor.GetAsync(promptContext.Context, () => _botUserData);

                if (value > currentBotUserData.pickSuggestion.Item2)
                {
                    await promptContext.Context.SendActivityAsync(MessageFactory.Text($"The quantity picked {value.ToString()} must be less than or equal to the quantity suggested {currentBotUserData.pickSuggestion.Item2.ToString()}. Please enter a different value or exit."), cancellationToken);

                    return(false);
                }
                else
                {
                    return(true);
                }
            };

            //Custom Code End



            // Define the prompts used in the Dialog.
            //Custom Code Start | Replaced Code Block
            //Replaced Code Block Start
            //AddDialog(new TextPrompt(PickBatchPickPromptId));
            //Replaced Code Block End
            AddDialog(new TextPrompt(PickBatchPickPromptId, pickBatchPickValidator));
            //Custom Code End
            AddDialog(new ChoicePrompt(InventoryUnitPromptId));
            AddDialog(new NumberPrompt <float>(BaseUnitQuantityPickedPromptId, baseUnitQuantityPickedValidator));
            AddDialog(new TextPrompt(PackToHandlingUnitPromptId));

            // Define the conversation flow for the Dialog.
            WaterfallStep[] steps = new WaterfallStep[]
            {
                //PickBatchPickPrompt,
                //Custom Code Start | Removed Block
                //InventoryUnitPrompt,
                //Custom Code End
                BaseUnitQuantityPickedPrompt,
                PackToHandlingUnitPrompt,
                donePrompt,
            };
            AddDialog(new WaterfallDialog(Id, steps));
        }
コード例 #2
0
        //Custom Code Start | Replaced Code Block
        //Replaced Code Block Start
        //public CreateGetPickBatchesDialog(string id, IGetPickBatchesService getpickbatchesService, GetPickBatchesPost getpickbatchesPost, BotSpielUserStateAccessors statePropertyAccessor)
        //Replaced Code Block End
        public CreateGetPickBatchesDialog(string id, GetPickBatchesPost getpickbatchesPost, BotSpielUserStateAccessors statePropertyAccessor
                                          , IPickBatchesService pickbatchesService
                                          , CommonLookUps commonLookUps
                                          )
        //Custom Code End
            : base(id)
        {
            InitialDialogId             = Id;
            _botSpielUserStateAccessors = statePropertyAccessor ?? throw new System.ArgumentNullException("state accessor can't be null");

            //Custom Code Start | Removed Block
            //_getpickbatchesService = getpickbatchesService;
            //Custom Code End

            _getpickbatchesPost = getpickbatchesPost;


            //Custom Code Start | Added Code Block

            _pickbatchesService = pickbatchesService;
            _commonLookUps      = commonLookUps;

            PromptValidator <string> pickBatchPickValidator = async(promptContext, cancellationToken) =>
            {
                var value = promptContext.Recognized.Value.Trim().ToLower();
                if (!_pickbatchesService.IndexDb().Where(x => x.sPickBatch.Trim().ToLower() == value && x.ixStatus != _commonLookUps.getStatuses().Where(s => s.sStatus == "Complete").Select(s => s.ixStatus).FirstOrDefault()).Any())
                {
                    await promptContext.Context.SendActivityAsync(MessageFactory.Text($"The pick batch {value} does not exist or is already complete. Please enter a different value or exit."), cancellationToken);

                    return(false);
                }
                else
                {
                    if (_pickbatchesService.IndexDb().Where(x => x.sPickBatch.Trim().ToLower() == value && x.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Started").Select(s => s.ixStatus).FirstOrDefault() && !x.bMultiResource).Any())
                    {
                        await promptContext.Context.SendActivityAsync(MessageFactory.Text($"The pick batch {value} has already been started and is flagged for a single picker. Please enter a different value or exit."), cancellationToken);

                        return(false);
                    }
                    else if (_pickbatchesService.IndexDb().Where(x => x.sPickBatch.Trim().ToLower() == value && x.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Inactive").Select(s => s.ixStatus).FirstOrDefault()).Any())
                    {
                        await promptContext.Context.SendActivityAsync(MessageFactory.Text($"The pick batch {value} has not been activated. Please activate or enter a different value or exit."), cancellationToken);

                        return(false);
                    }
                    return(true);
                }
            };

            //Custom Code End


            // Define the prompts used in the Dialog.
            //Custom Code Start | Replaced Code Block
            //Replaced Code Block Start
            //AddDialog(new TextPrompt(GetPickBatchPromptId));
            //Replaced Code Block End
            AddDialog(new TextPrompt(GetPickBatchPromptId, pickBatchPickValidator));
            //Custom Code End


            // Define the conversation flow for the Dialog.
            WaterfallStep[] steps = new WaterfallStep[]
            {
                GetPickBatchPrompt,
                donePrompt,
            };
            AddDialog(new WaterfallDialog(Id, steps));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
        {
            // use state accessor to extract the didBotWelcomeUser flag
            var didBotWelcomeUser = await _botSpielUserStateAccessors.DidBotWelcomeUser.GetAsync(turnContext, () => false);

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

            string        conCat          = "";
            List <string> existInEntities = new List <string>();
            bool          DeleteOK        = true;

            if (turnContext.Activity.Type == ActivityTypes.Message)
            {
                // Establish dialog state from the conversation state.
                DialogContext dc = await _dialogs.CreateContextAsync(turnContext, cancellationToken);

                //Custom Code Start | Added Code Block
                if (turnContext.Activity.Text.ToLowerInvariant() == "cancel")
                {
                    await dc.CancelAllDialogsAsync(cancellationToken);
                }
                //Custom Code End

                // Continue any current dialog.
                DialogTurnResult dialogTurnResult = await dc.ContinueDialogAsync();

                // Process the result of any complete dialog.
                if (dialogTurnResult.Status is DialogTurnStatus.Complete)
                {
                    switch (dialogTurnResult.Result)
                    {
                    case BotUserEntityContext botUserEntityContext:
                        if (botUserEntityContext.module != "Choose an area")
                        {
                            // Store the results of the root dialog.
                            currentBotUserData.botUserEntityContext = botUserEntityContext;
                            await _botSpielUserStateAccessors.BotUserDataAccessor.SetAsync(turnContext, currentBotUserData, cancellationToken);

                            await _botSpielUserStateAccessors.UserState.SaveChangesAsync(turnContext);

                            await dc.PromptAsync(ConfirmPromptId, new PromptOptions { Prompt = MessageFactory.Text($"Please confirm that you want to {botUserEntityContext.entityIntent} {botUserEntityContext.entity}. Is that correct?") }, cancellationToken);
                        }
                        else
                        {
                            await turnContext.SendActivityAsync("OK, Let's choose a different area.", cancellationToken : cancellationToken);

                            await dc.BeginDialogAsync(RootDialogId, null, cancellationToken);
                        }
                        break;

                    case bool botYesNo:
                        if (botYesNo)
                        {
                            switch (currentBotUserData.botUserEntityContext.entity)
                            {
                            case "PickBatchPicking":
                                if (currentBotUserData.botUserEntityContext.entityIntent == "Create")
                                {
                                    //Custom Code Start | Replaced Code Block
                                    //Replaced Code Block Start
                                    //await dc.BeginDialogAsync(CreatePickBatchPickingDialogId, null, cancellationToken);
                                    //Replaced Code Block End
                                    await dc.BeginDialogAsync(CreatePickBatchPickingDialogId, new PickBatchPickingPost(), cancellationToken);

                                    //Custom Code End
                                }
                                break;

                            case "PutAwayHandlingUnits":
                                if (currentBotUserData.botUserEntityContext.entityIntent == "Create")
                                {
                                    await dc.BeginDialogAsync(CreatePutAwayHandlingUnitsDialogId, null, cancellationToken);
                                }
                                break;

                            case "SetUpExecutionParameters":
                                if (currentBotUserData.botUserEntityContext.entityIntent == "Create")
                                {
                                    await dc.BeginDialogAsync(CreateSetUpExecutionParametersDialogId, null, cancellationToken);
                                }
                                break;

                            case "DropInventoryUnits":
                                if (currentBotUserData.botUserEntityContext.entityIntent == "Create")
                                {
                                    await dc.BeginDialogAsync(CreateDropInventoryUnitsDialogId, null, cancellationToken);
                                }
                                break;

                            default:
                                // We shouldn't get here.
                                break;
                            }
                        }
                        else
                        {
                            await turnContext.SendActivityAsync(MessageFactory.Text("OK, let's try again."), cancellationToken);

                            await dc.BeginDialogAsync(RootDialogId, null, cancellationToken);
                        }
                        break;

                    case GetPickBatchesPost getpickbatchesPost:
                        if (currentBotUserData.botUserEntityContext.entityIntent == "Create")
                        {
                            //Custom Code Start | Removed Block
                            //ixGetPickBatch = await _getpickbatchesService.Create(getpickbatchesPost);
                            //await turnContext.SendActivityAsync(MessageFactory.Text($"The GetPickBatch {ixGetPickBatch} was created"), cancellationToken);
                            //currentBotUserData.ixGetPickBatch = ixGetPickBatch;
                            //Custom Code End

                            await _botSpielUserStateAccessors.BotUserDataAccessor.SetAsync(turnContext, currentBotUserData, cancellationToken);

                            await _botSpielUserStateAccessors.UserState.SaveChangesAsync(turnContext);

                            //await dc.BeginDialogAsync(RootDialogId, currentBotUserData.botUserEntityContext, cancellationToken);

                            //Custom Code Start | Added Code Block
                            //We can now set the pick batch status to started
                            var pickbatch = _pickbatchesService.GetPost(_pickbatchesService.IndexDb().Where(x => x.sPickBatch == getpickbatchesPost.sGetPickBatch).Select(x => x.ixPickBatch).FirstOrDefault());
                            pickbatch.ixStatus = _commonLookUps.getStatuses().Where(x => x.sStatus == "Started").Select(x => x.ixStatus).FirstOrDefault();
                            pickbatch.UserName = dc.Context.Activity.Conversation.Id;
                            await _pickbatchesService.Edit(pickbatch);

                            _pickbatchpickingPost.sPickBatchPick = getpickbatchesPost.sGetPickBatch;
                            await dc.BeginDialogAsync(CreatePickBatchPickingDialogId, _pickbatchpickingPost, cancellationToken);

                            //Custom Code End
                        }
                        break;

                    case PickBatchPickingPost pickbatchpickingPost:
                        if (currentBotUserData.botUserEntityContext.entityIntent == "Create")
                        {
                            ixPickBatchPick = await _pickbatchpickingService.Create(pickbatchpickingPost);

                            //Custom Code Start | Removed Block
                            //await turnContext.SendActivityAsync(MessageFactory.Text($"The PickBatchPick {ixPickBatchPick} was created"), cancellationToken);
                            //Custom Code End
                            //Custom Code Start | Added Code Block
                            //We check if the batch is complete
                            if (!_picking.isPickBatchComplete(pickbatchpickingPost.ixPickBatch))
                            {
                                currentBotUserData.ixPickBatchPick = ixPickBatchPick;
                                await _botSpielUserStateAccessors.BotUserDataAccessor.SetAsync(turnContext, currentBotUserData, cancellationToken);

                                await _botSpielUserStateAccessors.UserState.SaveChangesAsync(turnContext);

                                await dc.BeginDialogAsync(CreatePickBatchPickingDialogId, pickbatchpickingPost, cancellationToken);
                            }
                            else
                            {
                                currentBotUserData.ixPickBatchPick = 0;
                                await _botSpielUserStateAccessors.BotUserDataAccessor.SetAsync(turnContext, currentBotUserData, cancellationToken);

                                await _botSpielUserStateAccessors.UserState.SaveChangesAsync(turnContext);

                                //await dc.BeginDialogAsync(RootDialogId, currentBotUserData.botUserEntityContext, cancellationToken);
                                //We can now set the pick batch status to complete
                                var pickbatch = _pickbatchesService.GetPost(pickbatchpickingPost.ixPickBatch);
                                pickbatch.ixStatus = _commonLookUps.getStatuses().Where(x => x.sStatus == "Complete").Select(x => x.ixStatus).FirstOrDefault();
                                pickbatch.UserName = dc.Context.Activity.Conversation.Id;
                                await _pickbatchesService.Edit(pickbatch);

                                //We begin the drop cycle
                                await dc.BeginDialogAsync(CreateDropInventoryUnitsDialogId, pickbatchpickingPost, cancellationToken);
                            }
                            //Custom Code End
                        }
                        break;

                    case PutAwayHandlingUnitsPost putawayhandlingunitsPost:
                        if (currentBotUserData.botUserEntityContext.entityIntent == "Create")
                        {
                            ixPutAwayHandlingUnit = await _putawayhandlingunitsService.Create(putawayhandlingunitsPost);

                            //Custom Code Start | Removed Block
                            //await turnContext.SendActivityAsync(MessageFactory.Text($"The PutAwayHandlingUnit {ixPutAwayHandlingUnit} was created"), cancellationToken);
                            //Custom Code End
                            currentBotUserData.ixPutAwayHandlingUnit = ixPutAwayHandlingUnit;
                            await _botSpielUserStateAccessors.BotUserDataAccessor.SetAsync(turnContext, currentBotUserData, cancellationToken);

                            await _botSpielUserStateAccessors.UserState.SaveChangesAsync(turnContext);

                            //Custom Code Start | Replaced Code Block
                            //Replaced Code Block Start
                            //await dc.BeginDialogAsync(RootDialogId, currentBotUserData.botUserEntityContext, cancellationToken);
                            //Replaced Code Block End
                            await dc.BeginDialogAsync(CreatePutAwayHandlingUnitsDialogId, null, cancellationToken);

                            //Custom Code End
                        }
                        break;

                    case SetUpExecutionParametersPost setupexecutionparametersPost:
                        if (currentBotUserData.botUserEntityContext.entityIntent == "Create")
                        {
                            //Custom Code Start | Removed Block
                            //ixSetUpExecutionParameter = await _setupexecutionparametersService.Create(setupexecutionparametersPost);
                            //await turnContext.SendActivityAsync(MessageFactory.Text($"The SetUpExecutionParameter {ixSetUpExecutionParameter} was created"), cancellationToken);
                            //currentBotUserData.ixSetUpExecutionParameter = ixSetUpExecutionParameter;
                            //Custom Code End
                            //Custom Code Start | Added Code Block
                            currentBotUserData.ixFacility         = setupexecutionparametersPost.ixFacility;
                            currentBotUserData.ixCompany          = setupexecutionparametersPost.ixCompany;
                            currentBotUserData.ixFacilityWorkArea = setupexecutionparametersPost.ixFacilityWorkArea;
                            //We check if the user location exists - if not we create it
                            if (_userManager.Users.Where(x => x.UserName == dc.Context.Activity.Conversation.Id).Any())
                            {
                                if (!_inventorylocationsService.IndexDb().Where(x => x.sInventoryLocation.ToLower().Trim() == dc.Context.Activity.Conversation.Id.ToLower().Trim()).Any())
                                {
                                    InventoryLocationsPost inventoryLocationsPost = new InventoryLocationsPost();
                                    inventoryLocationsPost.sInventoryLocation  = dc.Context.Activity.Conversation.Id.ToLower().Trim();
                                    inventoryLocationsPost.ixLocationFunction  = _locationfunctionsService.IndexDb().Where(x => x.sLocationFunctionCode == "PE").Select(x => x.ixLocationFunction).FirstOrDefault();
                                    inventoryLocationsPost.ixFacility          = currentBotUserData.ixFacility;
                                    inventoryLocationsPost.ixFacilityFloor     = _inventorylocationsService.FacilityFloorsDb().Select(x => x.ixFacilityFloor).FirstOrDefault();
                                    inventoryLocationsPost.ixFacilityZone      = _inventorylocationsService.FacilityZonesDb().Select(x => x.ixFacilityZone).FirstOrDefault();
                                    inventoryLocationsPost.ixFacilityWorkArea  = _inventorylocationsService.FacilityWorkAreasDb().Select(x => x.ixFacilityWorkArea).FirstOrDefault();
                                    inventoryLocationsPost.ixFacilityAisleFace = _inventorylocationsService.FacilityAisleFacesDb().Select(x => x.ixFacilityAisleFace).FirstOrDefault();
                                    inventoryLocationsPost.nSequence           = 0;
                                    inventoryLocationsPost.bTrackUtilisation   = false;
                                    currentBotUserData.ixInventoryLocation     = await _inventorylocationsService.Create(inventoryLocationsPost);
                                }
                                else
                                {
                                    currentBotUserData.ixInventoryLocation = _inventorylocationsService.IndexDb().Where(x => x.sInventoryLocation.ToLower().Trim() == dc.Context.Activity.Conversation.Id.ToLower().Trim()).Select(x => x.ixInventoryLocation).FirstOrDefault();
                                    var inventoryLocationsPost = _inventorylocationsService.GetPost(currentBotUserData.ixInventoryLocation);
                                    inventoryLocationsPost.ixFacility = currentBotUserData.ixFacility;
                                    await _inventorylocationsService.Edit(inventoryLocationsPost);
                                }
                            }
                            //Custom Code End
                            await _botSpielUserStateAccessors.BotUserDataAccessor.SetAsync(turnContext, currentBotUserData, cancellationToken);

                            await _botSpielUserStateAccessors.UserState.SaveChangesAsync(turnContext);

                            //Custom Code Start | Removed Block
                            //await dc.BeginDialogAsync(RootDialogId, currentBotUserData.botUserEntityContext, cancellationToken);
                            //Custom Code End
                            //Custom Code Start | Added Code Block
                            await turnContext.SendActivityAsync(MessageFactory.Text($"The setup parameters have been updated. Say/type putaway, pick or cancel."), cancellationToken);

                            //Custom Code End
                        }
                        break;

                    case DropInventoryUnitsPost dropinventoryunitsPost:
                        if (currentBotUserData.botUserEntityContext.entityIntent == "Create")
                        {
                            //Custom Code Start | Removed Block
                            //ixDropInventoryUnit = await _dropinventoryunitsService.Create(dropinventoryunitsPost);
                            //await turnContext.SendActivityAsync(MessageFactory.Text($"The DropInventoryUnit {ixDropInventoryUnit} was created"), cancellationToken);
                            //currentBotUserData.ixDropInventoryUnit = ixDropInventoryUnit;
                            //await _botSpielUserStateAccessors.BotUserDataAccessor.SetAsync(turnContext, currentBotUserData, cancellationToken);
                            //await _botSpielUserStateAccessors.UserState.SaveChangesAsync(turnContext);
                            //await dc.BeginDialogAsync(RootDialogId, currentBotUserData.botUserEntityContext, cancellationToken);
                            //Custom Code End
                            await dc.BeginDialogAsync(CreateGetPickBatchesDialogId, null, cancellationToken);
                        }
                        break;

                    default:
                        // We shouldn't get here.
                        break;
                    }
                }

                // Proactively send a welcome message to a personal chat the first time
                // (and only the first time) a user initiates a personal chat.
                //Custom Code Start | Replaced Code Block
                //Replaced Code Block Start
                //if (didBotWelcomeUser == false)
                //Replaced Code Block End
                if (true == false)
                //Custom Code End
                {
                    // Update user state flag to reflect bot handled first user interaction.
                    await _botSpielUserStateAccessors.DidBotWelcomeUser.SetAsync(turnContext, true);

                    await _botSpielUserStateAccessors.UserState.SaveChangesAsync(turnContext);

                    // the channel should sends the user name in the 'From' object
                    var userName = turnContext.Activity.From.Name;

                    // We give the user the opportunity to say or request something using natural language and funnel through recognizer
                    await turnContext.SendActivityAsync($"What would like to do? You can say things like ... or help me.", cancellationToken : cancellationToken);
                }
                //Custom Code Start | Added Code Block
                else if (!currentBotUserData.bIsInitialSetUpParametersSet)
                {
                    currentBotUserData.bIsInitialSetUpParametersSet      = true;
                    currentBotUserData.botUserEntityContext.module       = "Execution";
                    currentBotUserData.botUserEntityContext.entity       = "SetUpExecutionParameters";
                    currentBotUserData.botUserEntityContext.entityIntent = "Create";
                    await _botSpielUserStateAccessors.BotUserDataAccessor.SetAsync(turnContext, currentBotUserData, cancellationToken);

                    await _botSpielUserStateAccessors.UserState.SaveChangesAsync(turnContext);

                    await dc.BeginDialogAsync(CreateSetUpExecutionParametersDialogId, null, cancellationToken);
                }
                //Custom Code End
                else if ((dialogTurnResult.Status is DialogTurnStatus.Empty) || turnContext.Activity.Text.ToLowerInvariant() == "putaway" || turnContext.Activity.Text.ToLowerInvariant() == "cancel")
                {
                    var text = turnContext.Activity.Text.ToLowerInvariant();

                    // Now attempt to infer the context (NLP)
                    // Placeholder for code to added

                    switch (text)
                    {
                    //Custom Code Start | Removed Block
                    //case "help me":
                    //    await turnContext.SendActivityAsync($"You said: {text}.", cancellationToken: cancellationToken);
                    //    break;
                    //Custom Code End
                    //Custom Code Start | Added Code Block
                    case "putaway":
                        currentBotUserData.botUserEntityContext.module       = "Execution";
                        currentBotUserData.botUserEntityContext.entity       = "PutAwayHandlingUnits";
                        currentBotUserData.botUserEntityContext.entityIntent = "Create";
                        await _botSpielUserStateAccessors.BotUserDataAccessor.SetAsync(turnContext, currentBotUserData, cancellationToken);

                        await _botSpielUserStateAccessors.UserState.SaveChangesAsync(turnContext);

                        await dc.BeginDialogAsync(CreatePutAwayHandlingUnitsDialogId, null, cancellationToken);

                        break;

                    case "pick":
                        currentBotUserData.botUserEntityContext.module       = "Execution";
                        currentBotUserData.botUserEntityContext.entity       = "PickBatchPicking";
                        currentBotUserData.botUserEntityContext.entityIntent = "Create";
                        await _botSpielUserStateAccessors.BotUserDataAccessor.SetAsync(turnContext, currentBotUserData, cancellationToken);

                        await _botSpielUserStateAccessors.UserState.SaveChangesAsync(turnContext);

                        //await dc.BeginDialogAsync(CreatePickBatchPickingDialogId, new PickBatchPickingPost(), cancellationToken);
                        await dc.BeginDialogAsync(CreateGetPickBatchesDialogId, null, cancellationToken);

                        break;

                    case "cancel":
                        await dc.CancelAllDialogsAsync(cancellationToken);

                        break;

                    //Custom Code End
                    default:
                        if (dc.ActiveDialog == null && (dialogTurnResult.Status is DialogTurnStatus.Complete || dialogTurnResult.Status is DialogTurnStatus.Empty || dialogTurnResult.Status is DialogTurnStatus.Cancelled))
                        {
                            await turnContext.SendActivityAsync("I do not understand, let's try something different.", cancellationToken : cancellationToken);

                            await dc.BeginDialogAsync(RootDialogId, null, cancellationToken);
                        }
                        break;
                    }
                }
            }
            else if (turnContext.Activity.Type == ActivityTypes.ConversationUpdate)
            {
                if (turnContext.Activity.MembersAdded.Any())
                {
                    // Iterate over all new members added to the conversation
                    foreach (var member in turnContext.Activity.MembersAdded)
                    {
                        if (member.Id != turnContext.Activity.Recipient.Id)
                        {
                            await turnContext.SendActivityAsync($"Hi there - {member.Name}. {WelcomeMessage}", cancellationToken : cancellationToken);
                        }
                    }
                }
            }
            else
            {
                // Default behaviour for all other type of activities.
                await turnContext.SendActivityAsync($"{turnContext.Activity.Type} activity detected");
            }

            // save any state changes made to your state objects.
            await _botSpielUserStateAccessors.UserState.SaveChangesAsync(turnContext);

            await _botSpielUserStateAccessors.ConversationState.SaveChangesAsync(turnContext);
        }