示例#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 CreateSetUpExecutionParametersDialog(string id, ISetUpExecutionParametersService setupexecutionparametersService, SetUpExecutionParametersPost setupexecutionparametersPost, BotSpielUserStateAccessors statePropertyAccessor)
            : base(id)
        {
            InitialDialogId             = Id;
            _botSpielUserStateAccessors = statePropertyAccessor ?? throw new System.ArgumentNullException("state accessor can't be null");

            _setupexecutionparametersService = setupexecutionparametersService;
            _setupexecutionparametersPost    = setupexecutionparametersPost;

            // Define the prompts used in the Dialog.
            PromptValidator <string> setupexecutionparameterValidator = async(promptContext, cancellationToken) =>
            {
                var value = promptContext.Recognized.Value;
                if (!_setupexecutionparametersService.VerifySetUpExecutionParameterUnique(0L, value))
                {
                    await promptContext.Context.SendActivityAsync(MessageFactory.Text($"The setupexecutionparameter {value} already exists. Please enter a different value or exit."), cancellationToken);

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

            AddDialog(new ChoicePrompt(FacilityPromptId));
            AddDialog(new ChoicePrompt(CompanyPromptId));
            AddDialog(new ChoicePrompt(FacilityWorkAreaPromptId));


            // Define the conversation flow for the Dialog.
            WaterfallStep[] steps = new WaterfallStep[]
            {
                FacilityPrompt,
                CompanyPrompt,
                FacilityWorkAreaPrompt,
                donePrompt,
            };
            AddDialog(new WaterfallDialog(Id, steps));
        }
        //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));
        }
示例#4
0
        static void Main(string[] args)
        {
            var adapter  = new ConsoleAdapter();
            var services = new ServiceCollection()
                           .AddLogging();

            IConfiguration Configuration = new ConfigurationBuilder()
                                           //Custom Code Start | Replaced Code Block
                                           //Replaced Code Block Start
                                           //.AddJsonFile(@"C:\xInventory\xInventoryDev75\WebCore\BotSpiel\BotSpiel\appsettings.json", true, true)
                                           //Replaced Code Block End
                                           .AddJsonFile(@"C:\Software\SourceBotSpielInventory\WebCore\BotSpiel\BotSpiel\appsettings.json", true, true)
                                           //Custom Code End
                                           .Build();

            BotSpielModule.LoadModule(services, Configuration);
            services.AddTransient <BotUserData>();
            services.AddSingleton(new ApplicationDbContext(
                                      new DbContextOptionsBuilder <ApplicationDbContext>().UseSqlServer(Configuration.GetConnectionString("DefaultConnection")).Options)
                                  );

            services.AddIdentity <ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders();

            var serviceProvider = services.BuildServiceProvider();
            var ILoggerService  = serviceProvider.GetService <ILoggerFactory>();
            var logger          = ILoggerService.CreateLogger <BotSpielBot>();

            IStorage dataStore         = new MemoryStorage();
            var      conversationState = new ConversationState(dataStore);
            var      userState         = new UserState(dataStore);
            var      accessors         = new BotSpielUserStateAccessors(conversationState, userState)
            {
                DialogStateAccessor = conversationState.CreateProperty <DialogState>(BotSpielUserStateAccessors.DialogStateAccessorName),
                DidBotWelcomeUser   = userState.CreateProperty <bool>(BotSpielUserStateAccessors.DidBotWelcomeUserName),
                BotUserDataAccessor = userState.CreateProperty <BotUserData>(BotSpielUserStateAccessors.BotUserDataAccessorName),
            };


            //Custom Code Start | Added Code Block
            var _userManager = serviceProvider.GetService <UserManager <ApplicationUser> >();
            //Custom Code End

            var consoleBot = new BotSpielBot(serviceProvider.GetRequiredService <ILoggerFactory>(), accessors, serviceProvider.GetRequiredService <BotUserData>(), serviceProvider.GetRequiredService <BotUserEntityContext>(), serviceProvider.GetRequiredService <NavigationEntityData>()
                                             , serviceProvider.GetRequiredService <DropInventoryUnitsPost>()
                                             , serviceProvider.GetRequiredService <PickBatchPickingPost>()
                                             , serviceProvider.GetRequiredService <PutAwayHandlingUnitsPost>()
                                             , serviceProvider.GetRequiredService <SetUpExecutionParametersPost>()
                                             , serviceProvider.GetRequiredService <IPutAwayHandlingUnitsService>()
                                             , serviceProvider.GetRequiredService <ISetUpExecutionParametersService>()
                                             , serviceProvider.GetRequiredService <IHandlingUnitsService>()
                                             , _userManager
                                             , serviceProvider.GetRequiredService <IFacilitiesService>()
                                             , serviceProvider.GetRequiredService <PutAway>()
                                             , serviceProvider.GetRequiredService <IInventoryLocationsService>()
                                             , serviceProvider.GetRequiredService <ILocationFunctionsService>()
                                             , serviceProvider.GetRequiredService <IMoveQueueTypesService>()
                                             , serviceProvider.GetRequiredService <IMoveQueueContextsService>()
                                             , serviceProvider.GetRequiredService <IInventoryUnitsService>()
                                             , serviceProvider.GetRequiredService <IStatusesService>()
                                             , serviceProvider.GetRequiredService <IMoveQueuesService>()
                                             , serviceProvider.GetRequiredService <IPickBatchesService>()
                                             , serviceProvider.GetRequiredService <CommonLookUps>()
                                             , serviceProvider.GetRequiredService <Picking>()
                                             , serviceProvider.GetRequiredService <Shipping>()
                                             , serviceProvider.GetRequiredService <IPickBatchPickingService>()
                                             , serviceProvider.GetRequiredService <IOutboundOrderLinesInventoryAllocationService>()
                                             , serviceProvider.GetRequiredService <IOutboundOrderLinePackingService>()

                                             );

            //Custom Code Start | Removed Block
            //Console.WriteLine("Hello. Please type something to get us started.");
            //Custom Code End

            //Custom Code Start | Added Code Block
            Console.WriteLine(@"Hi. Enter your 
username/email.");
            //Custom Code End

            var UserName = Console.ReadLine();

            //var user = _userManager.FindByEmailAsync(UserName);
            //var debuf = _userManager.Users.Where(x => x.UserName == UserName).Count();
            //Console.WriteLine(user.Result.Email);

            adapter.ProcessActivityAsync(
                async(turnContext, cancellationToken) => await consoleBot.OnTurnAsync(turnContext)).Wait();
        }
示例#5
0
        //Custom Code Start | Replaced Code Block
        //Replaced Code Block Start
        //public CreatePutAwayHandlingUnitsDialog(string id, IPutAwayHandlingUnitsService putawayhandlingunitsService, PutAwayHandlingUnitsPost putawayhandlingunitsPost, BotSpielUserStateAccessors statePropertyAccessor)
        //Replaced Code Block End
        public CreatePutAwayHandlingUnitsDialog(string id
                                                , IPutAwayHandlingUnitsService putawayhandlingunitsService
                                                , PutAwayHandlingUnitsPost putawayhandlingunitsPost
                                                , BotSpielUserStateAccessors statePropertyAccessor
                                                , IHandlingUnitsService handlingunitsService
                                                , PutAway putAway
                                                , BotUserData botUserData
                                                , IInventoryLocationsService inventorylocationsService
                                                , IMoveQueueTypesService movequeuetypesService
                                                , IMoveQueueContextsService movequeuecontextsService
                                                , IInventoryUnitsService inventoryunitsService
                                                , IStatusesService statusesService
                                                , IMoveQueuesService movequeuesService
                                                )

        //Custom Code End
            : base(id)
        {
            InitialDialogId             = Id;
            _botSpielUserStateAccessors = statePropertyAccessor ?? throw new System.ArgumentNullException("state accessor can't be null");

            _putawayhandlingunitsService = putawayhandlingunitsService;
            _putawayhandlingunitsPost    = putawayhandlingunitsPost;

            //Custom Code Start | Added Code Block
            _handlingunitsService = handlingunitsService;
            _putAway     = putAway;
            _botUserData = botUserData;
            _inventorylocationsService = inventorylocationsService;
            _movequeuetypesService     = movequeuetypesService;
            _movequeuecontextsService  = movequeuecontextsService;
            _inventoryunitsService     = inventoryunitsService;
            _statusesService           = statusesService;
            _movequeuesService         = movequeuesService;

            PromptValidator <string> putAwayHandlingUnitValidator = async(promptContext, cancellationToken) =>
            {
                var value = promptContext.Recognized.Value.Trim().ToLower();
                if (!_handlingunitsService.IndexDb().Where(x => x.sHandlingUnit.Trim().ToLower() == value).Any())
                {
                    await promptContext.Context.SendActivityAsync(MessageFactory.Text($"The handling unit {value} does not exist. Please enter a different value or exit."), cancellationToken);

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

            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() && currentBotUserData.sPutAwaySuggestion == "No Suggestion")
                {
                    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);
                }
            };

            //Custom Code End


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

            AddDialog(new TextPrompt(InventoryDropLocationPromptId, inventoryDropLocationValidator));


            // Define the conversation flow for the Dialog.
            WaterfallStep[] steps = new WaterfallStep[]
            {
                PutAwayHandlingUnitPrompt,
                InventoryDropLocationPrompt,
                donePrompt,
            };
            AddDialog(new WaterfallDialog(Id, steps));
        }
        //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));
        }