示例#1
0
        //Custom Code Start | Replaced Code Block
        //Replaced Code Block Start
        //public CreateDropInventoryUnitsDialog(string id, IDropInventoryUnitsService dropinventoryunitsService, DropInventoryUnitsPost dropinventoryunitsPost, BotSpielUserStateAccessors statePropertyAccessor)
        //Replaced Code Block End
        public CreateDropInventoryUnitsDialog(string id, IDropInventoryUnitsService dropinventoryunitsService, DropInventoryUnitsPost dropinventoryunitsPost, BotSpielUserStateAccessors statePropertyAccessor, Shipping shipping, IInventoryLocationsService inventorylocationsService, CommonLookUps commonLookUps, IMoveQueuesService movequeuesService)
        //Custom Code End
            : base(id)
        {
            InitialDialogId             = Id;
            _botSpielUserStateAccessors = statePropertyAccessor ?? throw new System.ArgumentNullException("state accessor can't be null");

            _dropinventoryunitsService = dropinventoryunitsService;
            _dropinventoryunitsPost    = dropinventoryunitsPost;

            //Custom Code Start | Added Code Block
            _shipping = shipping;
            _inventorylocationsService = inventorylocationsService;
            _commonLookUps             = commonLookUps;
            _movequeuesService         = movequeuesService;
            //Custom Code End

            //Custom Code Start | Added Code Block
            PromptValidator <string> inventoryDropLocationValidator = async(promptContext, cancellationToken) =>
            {
                var value = promptContext.Recognized.Value.Trim().ToLower();
                var currentBotUserData = await _botSpielUserStateAccessors.BotUserDataAccessor.GetAsync(promptContext.Context, () => _botUserData);

                if (!_inventorylocationsService.IndexDb().Where(x => x.sInventoryLocation.Trim().ToLower() == value && x.ixFacility == currentBotUserData.ixFacility).Any())
                {
                    await promptContext.Context.SendActivityAsync(MessageFactory.Text($"The inventory location {value} does not exist in the facility. Please enter a different value or exit."), cancellationToken);

                    return(false);
                }
                //else
                //{
                //    if (currentBotUserData.sPutAwaySuggestion.Trim().ToLower() != value)
                //    {
                //        await promptContext.Context.SendActivityAsync(MessageFactory.Text($"The inventory location {value} does not match the suggested location {currentBotUserData.sPutAwaySuggestion}. Please enter a different value or exit."), cancellationToken);
                //        return false;
                //    }
                //    return true;
                //}
                return(true);
            };

            //Custom Code End

            // Define the prompts used in the Dialog.
            AddDialog(new TextPrompt(DropInventoryUnitPromptId, inventoryDropLocationValidator));


            // Define the conversation flow for the Dialog.
            WaterfallStep[] steps = new WaterfallStep[]
            {
                DropInventoryUnitPrompt,
                donePrompt,
            };
            AddDialog(new WaterfallDialog(Id, steps));
        }
        public Task Delete(DropInventoryUnitsPost dropinventoryunitsPost)
        {
            // Additional validations

            // Pre-process

            // Process
            this._dropinventoryunitsRepository.RegisterDelete(dropinventoryunitsPost);
            try
            {
                this._dropinventoryunitsRepository.Commit();
            }
            catch (Exception ex)
            {
                this._dropinventoryunitsRepository.Rollback();
                // Log exception
                throw;
            }

            // Post-process

            return(Task.CompletedTask);
        }
        public Task <Int64> Create(DropInventoryUnitsPost dropinventoryunitsPost)
        {
            // Additional validations

            // Pre-process

            // Process
            this._dropinventoryunitsRepository.RegisterCreate(dropinventoryunitsPost);
            try
            {
                this._dropinventoryunitsRepository.Commit();
            }
            catch (Exception ex)
            {
                this._dropinventoryunitsRepository.Rollback();
                // Log exception
                throw;
            }

            // Post-process

            return(Task.FromResult(dropinventoryunitsPost.ixDropInventoryUnit));
        }
        //Custom Code Start | Replaced Code Block
        //Replaced Code Block Start
        // public BotSpielBot(ILoggerFactory loggerFactory, BotSpielUserStateAccessors statePropertyAccessor, BotUserData botUserData, BotUserEntityContext botUserEntityContext, NavigationEntityData navigationEntityData
        //, PutAwayHandlingUnitsPost putawayhandlingunitsPost
        //    , IPutAwayHandlingUnitsService putawayhandlingunitsService
        // )
        //Replaced Code Block End
        public BotSpielBot(ILoggerFactory loggerFactory, BotSpielUserStateAccessors statePropertyAccessor, BotUserData botUserData, BotUserEntityContext botUserEntityContext, NavigationEntityData navigationEntityData
                           , DropInventoryUnitsPost dropinventoryunitsPost
                           , PickBatchPickingPost pickbatchpickingPost
                           , PutAwayHandlingUnitsPost putawayhandlingunitsPost
                           , SetUpExecutionParametersPost setupexecutionparametersPost
                           , IPutAwayHandlingUnitsService putawayhandlingunitsService
                           , ISetUpExecutionParametersService setupexecutionparametersService
                           , IHandlingUnitsService handlingunitsService
                           , UserManager <ApplicationUser> userManager
                           , IFacilitiesService facilitiesService
                           , PutAway putAway
                           , IInventoryLocationsService inventorylocationsService
                           , ILocationFunctionsService locationfunctionsService
                           , IMoveQueueTypesService movequeuetypesService
                           , IMoveQueueContextsService movequeuecontextsService
                           , IInventoryUnitsService inventoryunitsService
                           , IStatusesService statusesService
                           , IMoveQueuesService movequeuesService
                           , IPickBatchesService pickbatchesService
                           , CommonLookUps commonLookUps
                           , Picking picking
                           , Shipping shipping
                           , IPickBatchPickingService pickbatchpickingService
                           , IOutboundOrderLinesInventoryAllocationService outboundorderlinesinventoryallocationService
                           , IOutboundOrderLinePackingService outboundorderlinepackingService
                           )
        //Custom Code End

        {
            if (loggerFactory == null)
            {
                throw new System.ArgumentNullException(nameof(loggerFactory));
            }

            _logger = loggerFactory.CreateLogger <BotSpielBot>();

            _botUserData          = botUserData;
            _botUserEntityContext = botUserEntityContext;
            _navigationEntityData = navigationEntityData;

            _botSpielUserStateAccessors = statePropertyAccessor ?? throw new System.ArgumentNullException("state accessor can't be null");

            _dropinventoryunitsPost          = dropinventoryunitsPost;
            _pickbatchpickingPost            = pickbatchpickingPost;
            _putawayhandlingunitsPost        = putawayhandlingunitsPost;
            _setupexecutionparametersPost    = setupexecutionparametersPost;
            _putawayhandlingunitsService     = putawayhandlingunitsService;
            _setupexecutionparametersService = setupexecutionparametersService;
            //Custom Code Start | Added Code Block
            _handlingunitsService = handlingunitsService;
            _userManager          = userManager;
            _facilitiesService    = facilitiesService;
            _putAway = putAway;
            _inventorylocationsService = inventorylocationsService;
            _locationfunctionsService  = locationfunctionsService;
            _movequeuetypesService     = movequeuetypesService;
            _movequeuecontextsService  = movequeuecontextsService;
            _inventoryunitsService     = inventoryunitsService;
            _statusesService           = statusesService;
            _movequeuesService         = movequeuesService;
            _pickbatchesService        = pickbatchesService;
            _commonLookUps             = commonLookUps;
            _picking  = picking;
            _shipping = shipping;
            _pickbatchpickingService = pickbatchpickingService;
            _outboundorderlinesinventoryallocationService = outboundorderlinesinventoryallocationService;
            _outboundorderlinepackingService = outboundorderlinepackingService;
            //Custom Code End

            // The DialogSet needs a DialogState accessor, it will call it when it has a turn context.
            _dialogs = new DialogSet(statePropertyAccessor.DialogStateAccessor)
                       .Add(new RootDialog(RootDialogId, _botUserEntityContext, _navigationEntityData))
                       .Add(new CreatePickBatchPickingDialog(CreatePickBatchPickingDialogId, _pickbatchpickingService, _pickbatchpickingPost, _botSpielUserStateAccessors, _pickbatchesService, _commonLookUps, _picking, _inventoryunitsService, _movequeuesService, _handlingunitsService, _outboundorderlinesinventoryallocationService, _outboundorderlinepackingService))
                       //Custom Code Start | Replaced Code Block
                       //Replaced Code Block Start
                       //.Add(new CreatePutAwayHandlingUnitsDialog(CreatePutAwayHandlingUnitsDialogId, _putawayhandlingunitsService, _putawayhandlingunitsPost, _botSpielUserStateAccessors))
                       //Replaced Code Block End
                       .Add(new CreatePutAwayHandlingUnitsDialog(
                                CreatePutAwayHandlingUnitsDialogId
                                , _putawayhandlingunitsService
                                , _putawayhandlingunitsPost
                                , _botSpielUserStateAccessors
                                , _handlingunitsService
                                , _putAway
                                , _botUserData
                                , _inventorylocationsService
                                , _movequeuetypesService
                                , _movequeuecontextsService
                                , _inventoryunitsService
                                , _statusesService
                                , _movequeuesService
                                ))
                       //Custom Code End
                       .Add(new CreateSetUpExecutionParametersDialog(CreateSetUpExecutionParametersDialogId, _setupexecutionparametersService, _setupexecutionparametersPost, _botSpielUserStateAccessors))
                       .Add(new CreateDropInventoryUnitsDialog(CreateDropInventoryUnitsDialogId, _dropinventoryunitsService, _dropinventoryunitsPost, _botSpielUserStateAccessors, _shipping, _inventorylocationsService, _commonLookUps, _movequeuesService))
                       .Add(new ConfirmPrompt(ConfirmPromptId, defaultLocale: Culture.English))
                       //Custom Code Start | Added Code Block
                       .Add(new ChoicePrompt(ChoicesPromptId, defaultLocale: Culture.English))
                       .Add(new CreateGetPickBatchesDialog(CreateGetPickBatchesDialogId, new GetPickBatchesPost(), _botSpielUserStateAccessors, _pickbatchesService, _commonLookUps));
            //Custom Code End
        }