Пример #1
0
        protected void Application_Start()
        {
            try
            {
                Conversation.UpdateContainer(mybuilder =>
                {
                    mybuilder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));
                    var store = new TableBotDataStore(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
                    mybuilder.Register(c => store)
                    .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                    .AsSelf()
                    .SingleInstance();
                });
            }
            catch (Exception e)
            {
                Console.WriteLine("This is probably normal if running the code locally: '{0}'", e);
            }

            GlobalConfiguration.Configure(WebApiConfig.Register);

            // register our scorables
            var builder = new ContainerBuilder();

            builder.RegisterType <ScorableHelp>()
            .As <IScorable <IActivity, double> >()
            .InstancePerLifetimeScope();
            builder.RegisterType <ScorableWhoami>()
            .As <IScorable <IActivity, double> >()
            .InstancePerLifetimeScope();

            builder.Update(Conversation.Container);
        }
Пример #2
0
        protected void Application_Start()
        {
            Conversation.UpdateContainer(
                builder =>
            {
                builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));
                builder.RegisterModule <GlobalMessageModule>();


                // Bot Storage: Here we register the state storage for your bot.
                // Default store: volatile in-memory store - Only for prototyping!
                // We provide adapters for Azure Table, CosmosDb, SQL Azure, or you can implement your own!
                // For samples and documentation, see: https://github.com/Microsoft/BotBuilder-Azure
                //var store = new InMemoryDataStore();

                // Other storage options
                var store = new TableBotDataStore(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
                // var store = new DocumentDbBotDataStore("cosmos db uri", "cosmos db key"); // requires Microsoft.BotBuilder.Azure Nuget package

                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();
            });
            GlobalConfiguration.Configure(WebApiConfig.Register);
        }
Пример #3
0
        public static void Register(HttpConfiguration config)
        {
#if DEBUG
            Conversation.UpdateContainer(
                builder =>
            {
                var store = new InMemoryDataStore();
                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();
            });
#else
            Conversation.UpdateContainer(
                builder =>
            {
                //builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));
                var appKey = ConfigurationManager.ConnectionStrings["StorageConnectionString"];
                var store  = new TableBotDataStore(appKey.ConnectionString);
                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();

                // Register your Web API controllers.
                // builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
                // builder.RegisterWebApiFilterProvider(config);
            });

            //config.DependencyResolver = new AutofacWebApiDependencyResolver(Conversation.Container);
#endif
        }
Пример #4
0
        protected void Application_Start(object sender, EventArgs e)
        {
            {
                var config = GlobalConfiguration.Configuration;
                Conversation.UpdateContainer(
                    builder =>
                {
                    builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

                    var store = new TableBotDataStore(CloudStorageAccount.DevelopmentStorageAccount);
                    builder.Register(c => store)
                    .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                    .AsSelf()
                    .SingleInstance();

                    // Register your Web API controllers.
                    builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
                    builder.RegisterWebApiFilterProvider(config);
                });

                config.DependencyResolver = new AutofacWebApiDependencyResolver(Conversation.Container);
            }

            // WebApiConfig stuff
            GlobalConfiguration.Configure(config =>
            {
                config.MapHttpAttributeRoutes();

                config.Routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }
                    );
            });
        }
Пример #5
0
        protected void Application_Start()
        {
            System.Web.Http.GlobalConfiguration.Configure(WebApiConfig.Register);
            //var builder = new ContainerBuilder();
            //RegisterDependencies(builder);
            //var container = builder.Build();
            var store = new TableBotDataStore(ConfigurationManager.AppSettings["StorageConnectionString"]);

            Conversation.UpdateContainer(
                builder =>
            {
                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();

                builder.Register(c => new CachingBotDataStore(store,
                                                              CachingBotDataStoreConsistencyPolicy
                                                              .ETagBasedConsistency))
                .As <IBotDataStore <BotData> >()
                .AsSelf()
                .InstancePerLifetimeScope();

                bool traceAllActivities = false;
                bool.TryParse(ConfigurationManager.AppSettings["TraceAllActivities"], out traceAllActivities);
                if (traceAllActivities)
                {
                    builder.RegisterType <TraceActivityLogger>().AsImplementedInterfaces().InstancePerDependency();
                }
            });
        }
Пример #6
0
        private void RegisterBotModules()
        {
#if DEBUG
            var store = new InMemoryDataStore();
#else
            var storageConnectionString = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;
            var store = new TableBotDataStore(storageConnectionString);
#endif

            Conversation.UpdateContainer(builder =>
            {
                builder.RegisterModule(new ReflectionSurrogateModule());
                builder.RegisterModule <GlobalMessageHandlersBotModule>();

                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();

                builder.Register(c => new CachingBotDataStore(store,
                                                              CachingBotDataStoreConsistencyPolicy
                                                              .ETagBasedConsistency))
                .As <IBotDataStore <BotData> >()
                .AsSelf()
                .InstancePerLifetimeScope();
            });
        }
Пример #7
0
        protected void Application_Start()
        {
            // Try to get the connection string
            BotSettings botSettings      = new BotSettings();
            string      connectionString = botSettings[BotSettings.KeyRoutingDataStorageConnectionString];

            Conversation.UpdateContainer(
                builder =>
            {
                builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

                // Bot Storage: register state storage for your bot
                IBotDataStore <BotData> botDataStore = null;

                if (string.IsNullOrEmpty(connectionString))
                {
                    // Default store: volatile in-memory store - Only for prototyping!
                    System.Diagnostics.Debug.WriteLine("WARNING!!! Using InMemoryDataStore, which should be only used for prototyping, for the bot state!");
                    botDataStore = new InMemoryDataStore();
                }
                else
                {
                    // Azure Table Storage
                    System.Diagnostics.Debug.WriteLine("Using Azure Table Storage for the bot state");
                    botDataStore = new TableBotDataStore(connectionString);
                }

                builder.Register(c => botDataStore)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();
            });

            GlobalConfiguration.Configure(WebApiConfig.Register);
        }
Пример #8
0
        protected void Application_Start()
        {
            try
            {
                GlobalConfiguration.Configure(WebApiConfig.Register);

                var storage = new TableBotDataStore(ConfigurationManager.AppSettings["Storage.ConnectionString"]);

                Conversation.UpdateContainer(
                    builder =>
                {
                    builder.Register(c => storage)
                    .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                    .AsSelf()
                    .SingleInstance();

                    builder.Register(c => new CachingBotDataStore(storage,
                                                                  CachingBotDataStoreConsistencyPolicy
                                                                  .ETagBasedConsistency))
                    .As <IBotDataStore <BotData> >()
                    .AsSelf()
                    .InstancePerLifetimeScope();
                });
            }
            catch (Exception e)
            {
            }
        }
Пример #9
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            DocumentDBRepository <Passenger> .Initialize(); // Initialize DB

            Conversation.UpdateContainer(
                builder =>
            {
                builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

                // Using Azure Table Storage
                var store = new TableBotDataStore(ConfigurationManager.AppSettings["AzureWebJobsStorage"]);    // requires Microsoft.BotBuilder.Azure Nuget package

                // To use CosmosDb or InMemory storage instead of the default table storage, uncomment the corresponding line below
                // var store = new DocumentDbBotDataStore("cosmos db uri", "cosmos db key"); // requires Microsoft.BotBuilder.Azure Nuget package
                // var store = new InMemoryDataStore(); // volatile in-memory store

                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();
            });
            // GlobalConfiguration.Configure(WebApiConfig.Register);
        }
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);
            var store = new TableBotDataStore("DefaultEndpointsProtocol=https;AccountName=skbstate;AccountKey=Ft/dju7+FVoYvfAos0DCWz/bSSo5weHlVovSS2i7AhsBhw/yJI3KyYDr+87CauHX+898N5Gbz1CPYvBvI9XZzw==;EndpointSuffix=core.windows.net");

            //var uri = new Uri(ConfigurationManager.AppSettings["DocumentDbUrl"]);
            //var key = ConfigurationManager.AppSettings["DocumentDbKey"];
            //var store = new DocumentDbBotDataStore(uri, key);

            Conversation.UpdateContainer(
                builder =>
            {
                builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();

                builder.Register(c => new CachingBotDataStore(store,
                                                              CachingBotDataStoreConsistencyPolicy
                                                              .ETagBasedConsistency))
                .As <IBotDataStore <BotData> >()
                .AsSelf()
                .InstancePerLifetimeScope();
            });
        }
Пример #11
0
        protected void Application_Start()
        {
            Conversation.UpdateContainer(builder =>
            {
                builder.RegisterType <BotData>();

                builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

                var store = new TableBotDataStore(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);

                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();

                builder.Register(x => new FaceClient(new ApiKeyServiceClientCredentials(Consts.FaceAPIKey))
                {
                    BaseUri = new Uri(Consts.FaceAPIUri)
                })
                .Keyed <IFaceClient>(FiberModule.Key_DoNotSerialize)
                .AsImplementedInterfaces()
                .SingleInstance();

                builder.RegisterType <RootDialog>()
                .Named <IDialog <object> >(nameof(RootDialog))
                .SingleInstance();
            }
                                         );
            GlobalConfiguration.Configure(WebApiConfig.Register);
        }
Пример #12
0
        protected void Application_Start()
        {
            // Bot Storage: This is a great spot to register the private state storage for your bot.
            // We provide adapters for Azure Table, CosmosDb, SQL Azure, or you can implement your own!
            // For samples and documentation, see: https://github.com/Microsoft/BotBuilder-Azure

            Conversation.UpdateContainer(
                builder =>
            {
                builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

                // Using Azure Table Storage
                var store = new TableBotDataStore(ConfigurationManager.AppSettings["AzureWebJobsStorage"]);     // requires Microsoft.BotBuilder.Azure Nuget package

                // To use CosmosDb or InMemory storage instead of the default table storage, uncomment the corresponding line below
                // var store = new DocumentDbBotDataStore("cosmos db uri", "cosmos db key"); // requires Microsoft.BotBuilder.Azure Nuget package
                // var store = new InMemoryDataStore(); // volatile in-memory store

                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();
            });
            GlobalConfiguration.Configure(WebApiConfig.Register);
        }
Пример #13
0
        protected void Application_Start()
        {
            {
                Conversation.UpdateContainer(
                    builder =>
                {
                    builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

                    // Using Azure Table for storage
                    var store = new TableBotDataStore(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);

                    builder.Register(c => store)
                    .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                    .AsSelf()
                    .SingleInstance();

                    /*  builder.Register(c => new CachingBotDataStore(store,
                     * CachingBotDataStoreConsistencyPolicy.ETagBasedConsistency))
                     * .As<IBotDataStore<BotData>>()
                     * .AsSelf()
                     * .InstancePerLifetimeScope();*/
                });
                GlobalConfiguration.Configure(WebApiConfig.Register);
            }
        }
Пример #14
0
        protected void Application_Start()
        {
            // Bot Storage: This is a great spot to register the private state storage for your bot.
            // We provide adapters for Azure Table, CosmosDb, SQL Azure, or you can implement your own!
            // For samples and documentation, see: https://github.com/Microsoft/BotBuilder-Azure

            Conversation.UpdateContainer(
                builder =>
            {
                builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

                // Using Azure Table Storage
                var store = new TableBotDataStore("DefaultEndpointsProtocol=https;AccountName=csadaptivebe3d;AccountKey=Evv7UeLax5V4QHhZoVwcUx9pb9GekGw/J2a1ND7vKFh1/CeI8kWyY76eB6breXk4pz+V/+ymta8XPKno4LVHWw==;");     // requires Microsoft.BotBuilder.Azure Nuget package

                // To use CosmosDb or InMemory storage instead of the default table storage, uncomment the corresponding line below
                // var store = new DocumentDbBotDataStore("cosmos db uri", "cosmos db key"); // requires Microsoft.BotBuilder.Azure Nuget package
                // var store = new InMemoryDataStore(); // volatile in-memory store

                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();
            });
            GlobalConfiguration.Configure(WebApiConfig.Register);
        }
Пример #15
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            var store = new TableBotDataStore(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);

            Conversation.UpdateContainer(
                builder =>
            {
                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();

                builder.Register(c => new CachingBotDataStore(store,
                                                              CachingBotDataStoreConsistencyPolicy
                                                              .ETagBasedConsistency))
                .As <IBotDataStore <BotData> >()
                .AsSelf()
                .InstancePerLifetimeScope();

                builder.RegisterType <EntityFrameworkDataService>().As <IDataService>().SingleInstance();
                builder.RegisterType <TfsAPIService>().As <ITfsAPIService>().SingleInstance();
            });
        }
Пример #16
0
        public static void Configure()
        {
            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterType <RootDialog>().InstancePerDependency();
            builder.RegisterType <QnAMakerService>().Keyed <IQnAMakerService>(FiberModule.Key_DoNotSerialize).AsImplementedInterfaces();

            #region BotState

            string storageConnectionString = CloudConfigurationManager.GetSetting("Storage.ConnectionString");
            string storageStateTable       = CloudConfigurationManager.GetSetting("Storage.StateTable");

            var store = new TableBotDataStore(storageConnectionString, storageStateTable);

            builder.Register(c => store)
            .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
            .AsSelf()
            .SingleInstance();

            builder.Register(c => new CachingBotDataStore(store,
                                                          CachingBotDataStoreConsistencyPolicy
                                                          .ETagBasedConsistency))
            .As <IBotDataStore <BotData> >()
            .AsSelf()
            .InstancePerLifetimeScope();

            #endregion


            builder.Update(container: Conversation.Container);
        }
Пример #17
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            string connectionString = ConfigurationManager.AppSettings["StorageConnectionString"];

            var config = GlobalConfiguration.Configuration;

            Conversation.UpdateContainer(
                builder =>
            {
                builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

                var store = new TableBotDataStore(connectionString, BotStateTableName);
                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();

                // Register your Web API controllers.
                builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
                builder.RegisterWebApiFilterProvider(config);
            });

            config.DependencyResolver = new AutofacWebApiDependencyResolver(Conversation.Container);
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            // Store bot state in Azure table
            var store = new TableBotDataStore(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);

            Conversation.UpdateContainer(
                builder =>
            {
                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();

                builder.Register(c => new CachingBotDataStore(store,
                                                              CachingBotDataStoreConsistencyPolicy
                                                              .ETagBasedConsistency))
                .As <IBotDataStore <BotData> >()
                .AsSelf()
                .InstancePerLifetimeScope();

                builder.RegisterType <AgentStateSubscription>()
                .As <IAgentStateSubscription>()
                .As <IStartable>()
                .SingleInstance();
            });
        }
        private static async Task <IBotDataStore <BotData> > CreateTableStore(string tableName = "target")
        {
            var targetStore = new TableBotDataStore("UseDevelopmentStorage=true", tableName);
            await targetStore.Table.DeleteIfExistsAsync();

            await targetStore.Table.CreateIfNotExistsAsync();

            return(targetStore);
        }
Пример #20
0
        protected void Application_Start(object sender, EventArgs e)
        {
            {
                // http://docs.autofac.org/en/latest/integration/webapi.html#quick-start
                var builder = new ContainerBuilder();

                // register the Bot Builder module
                builder.RegisterModule(new DialogModule());
                // register the alarm dependencies
                builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

                builder
                .RegisterInstance(new EchoDialog())
                .As <IDialog <object> >();

                var store = new TableBotDataStore(CloudStorageAccount.DevelopmentStorageAccount);
                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();


                builder.Register(c => new CachingBotDataStore(store,
                                                              CachingBotDataStoreConsistencyPolicy.ETagBasedConsistency))
                .As <IBotDataStore <BotData> >()
                .AsSelf()
                .InstancePerLifetimeScope();

                // Get your HttpConfiguration.
                var config = GlobalConfiguration.Configuration;

                // Register your Web API controllers.
                builder.RegisterApiControllers(Assembly.GetExecutingAssembly());

                // OPTIONAL: Register the Autofac filter provider.
                builder.RegisterWebApiFilterProvider(config);

                // Set the dependency resolver to be Autofac.
                //var container = builder.Build();
                builder.Update(Conversation.Container);
                config.DependencyResolver = new AutofacWebApiDependencyResolver(Conversation.Container);
            }

            // WebApiConfig stuff
            GlobalConfiguration.Configure(config =>
            {
                config.MapHttpAttributeRoutes();

                config.Routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }
                    );
            });
        }
Пример #21
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            var builder = new ContainerBuilder();

            builder.RegisterModule(new LessonPlanModule());
            builder.RegisterModule(new BasicDialogModule());

            builder
            .RegisterType <AzureTableLogger>()
            .Keyed <ILogger>(FiberModule.Key_DoNotSerialize)
            .AsSelf()
            .As <ILogger>()
            .SingleInstance();

            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
            builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

            var store = new TableBotDataStore(ConfigurationManager.AppSettings["StorageConnectionString"]);
            var cache = new CachingBotDataStore(store,
                                                CachingBotDataStoreConsistencyPolicy
                                                .ETagBasedConsistency);

            MicrosoftAppCredentials.TrustServiceUrl("directline.botframework.com");

            builder.RegisterType <AzureActivityLogger>().As <IActivityLogger>().InstancePerDependency();

            Conversation.UpdateContainer(
                coversation =>
            {
                coversation.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();

                coversation.Register(c => cache)
                .As <IBotDataStore <BotData> >()
                .AsSelf()
                .InstancePerLifetimeScope();
            });



            var config = GlobalConfiguration.Configuration;

            var container = builder.Build();

            config.DependencyResolver = new AutofacWebApiDependencyResolver(container);

            Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", Server.MapPath("translation.json"));
        }
Пример #22
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            Microsoft.Bot.Builder.Dialogs.Conversation.UpdateContainer(
                builder =>
            {
                builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

                // Bot Storage: Here we register the state storage for your bot.
                // Default store: volatile in-memory store - Only for prototyping!
                // We provide adapters for Azure Table, CosmosDb, SQL Azure, or you can implement your own!
                // For samples and documentation, see: [https://github.com/Microsoft/BotBuilder-Azure](https://github.com/Microsoft/BotBuilder-Azure)
                //var store = new InMemoryDataStore();

                // Other storage options
                var store = new TableBotDataStore(ConfigurationManager.AppSettings["StorageConnectionString"]); // requires Microsoft.BotBuilder.Azure Nuget package
                // var store = new DocumentDbBotDataStore("cosmos db uri", "cosmos db key"); // requires Microsoft.BotBuilder.Azure Nuget package
                builder.RegisterModule(new ReflectionSurrogateModule());
                builder.RegisterModule <GlobalMessageHandlersBotModule>();

                // Hand Off Scorables, Provider and UserRoleResolver
                builder.Register(c => new RouterScorable(c.Resolve <IBotData>(), c.Resolve <ConversationReference>(), c.Resolve <Provider>()))
                .As <IScorable <IActivity, double> >().InstancePerLifetimeScope();
                builder.Register(c => new CommandScorable(c.Resolve <IBotData>(), c.Resolve <ConversationReference>(), c.Resolve <Provider>()))
                .As <IScorable <IActivity, double> >().InstancePerLifetimeScope();
                builder.RegisterType <Provider>()
                .SingleInstance();

                // Bot Scorables
                //builder.Register(c => new AgentLoginScorable(c.Resolve<IBotData>(), c.Resolve<Provider>()))
                //    .As<IScorable<IActivity, double>>()
                //    .InstancePerLifetimeScope();

                builder.RegisterType <SearchScorable>()
                .As <IScorable <IActivity, double> >()
                .InstancePerLifetimeScope();

                builder.RegisterType <ShowArticleDetailsScorable>()
                .As <IScorable <IActivity, double> >()
                .InstancePerLifetimeScope();


                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();
            });
        }
        Task IActivityLogger.LogAsync(IActivity activity)
        {
            var store = new TableBotDataStore(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);

            CloudTable _table;

            _table = store.Table;

            if (!activity.Timestamp.HasValue)
            {
                activity.Timestamp = DateTime.UtcNow;
            }

            return(Write(_table, activity));
        }
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            VerifyConfigurationIsValid();

            /*
             * // Use an in-memory store for bot data.
             * // This registers a IBotDataStore singleton that will be used throughout the app.
             * var store = new InMemoryDataStore();
             *
             * Conversation.UpdateContainer(builder =>
             * {
             *  builder.Register(c => new CachingBotDataStore(store,
             *           CachingBotDataStoreConsistencyPolicy
             *           .ETagBasedConsistency))
             *           .As<IBotDataStore<BotData>>()
             *           .AsSelf()
             *           .InstancePerLifetimeScope();
             * });
             */

            string connectionString = ConfigurationManager.AppSettings["StorageConnectionString"];
            var    tableStore       = new TableBotDataStore(connectionString);

            var tableName = "ChatHistory";
            var account   = CloudStorageAccount.Parse(connectionString);

            Conversation.UpdateContainer(
                builder =>
            {
                builder.Register(c => tableStore)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();

                builder.Register(c => new CachingBotDataStore(tableStore,
                                                              CachingBotDataStoreConsistencyPolicy
                                                              .ETagBasedConsistency))
                .As <IBotDataStore <BotData> >()
                .AsSelf()
                .InstancePerLifetimeScope();

                builder.RegisterModule(new TableLoggerModule(account, tableName));
            });

            _botJwtRefreshWorker = new BotJwtRefreshWorker();
        }
Пример #25
0
        protected void Application_Start()
        {
            Conversation.UpdateContainer(
                builder =>
            {
                builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));
                var store = new TableBotDataStore(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);

                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();
            });

            GlobalConfiguration.Configure(WebApiConfig.Register);
        }
Пример #26
0
        protected void Application_Start()
        {
            Conversation.UpdateContainer(
                builder =>
            {
                builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

                // Using Azure Table Storage
                var store = new TableBotDataStore(ConfigurationManager.AppSettings["AzureWebJobsStorage"]);     // requires Microsoft.BotBuilder.Azure Nuget package

                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();
            });
            GlobalConfiguration.Configure(WebApiConfig.Register);
        }
Пример #27
0
        public void Register(HttpConfiguration config)
        {
            var store = new TableBotDataStore(ConfigurationManager.AppSettings["StorageConnectionString"], botDataTableName);

            Conversation.UpdateContainer(builder =>
            {
                builder.RegisterModule(new DefaultExceptionMessageOverrideModule());
                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();

                builder.Register(c => new CachingBotDataStore(store,
                                                              CachingBotDataStoreConsistencyPolicy.LastWriteWins))
                .As <IBotDataStore <BotData> >()
                .AsSelf()
                .InstancePerLifetimeScope();
            });


            // Json settings
            config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver  = new CamelCasePropertyNamesContractResolver();
            config.Formatters.JsonFormatter.SerializerSettings.Formatting        = Formatting.Indented;
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
            {
                ContractResolver  = new CamelCasePropertyNamesContractResolver(),
                Formatting        = Newtonsoft.Json.Formatting.Indented,
                NullValueHandling = NullValueHandling.Ignore,
            };

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            var container = RegisterDIContainer();

            config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
        }
Пример #28
0
        public static void ConfigureStateStore()
        {
            // Configure bot state store to cosmosdb table storage
            var store = new TableBotDataStore(new CloudStorageAccount(new StorageCredentials(GetSetting("table:name"), GetSetting("table:key")), true));

            Conversation.UpdateContainer(
                builder =>
            {
                builder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();

                builder.Register(c => new CachingBotDataStore(store, CachingBotDataStoreConsistencyPolicy.ETagBasedConsistency))
                .As <IBotDataStore <BotData> >()
                .AsSelf()
                .InstancePerLifetimeScope();
            });
        }
Пример #29
0
        private static Task <BotData> GetConversationDataAsync(Activity activity)
        {
            if (Utils.GetAppSetting("UseTableStorageForConversationState") == "true")
            {
                IBotDataStore <BotData> store = new TableBotDataStore(Utils.GetAppSetting("AzureWebJobsStorage"));
                return(store.LoadAsync(
                           new Address(
                               activity.Recipient.Id,
                               activity.ChannelId,
                               activity.From.Id,
                               activity.Conversation.Id,
                               activity.ServiceUrl),
                           BotStoreType.BotConversationData,
                           CancellationToken.None));
            }

            StateClient stateClient = activity.GetStateClient();

            return(stateClient.BotState.GetConversationDataAsync(activity.ChannelId, activity.Conversation.Id));
        }
Пример #30
0
        protected void Application_Start()
        {
            // Bot Storage: This is a great spot to register the private state storage for your bot.
            // We provide adapters for Azure Table, CosmosDb, SQL Azure, or you can implement your own!
            // For samples and documentation, see: https://github.com/Microsoft/BotBuilder-Azure

            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <IMessageActivity, SqlDataStore.Models.Activity>()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.FromId, opt => opt.MapFrom(src => src.From.Id))
                .ForMember(dest => dest.RecipientId, opt => opt.MapFrom(src => src.Recipient.Id))
                .ForMember(dest => dest.FromName, opt => opt.MapFrom(src => src.From.Name))
                .ForMember(dest => dest.RecipientName, opt => opt.MapFrom(src => src.Recipient.Name));
            });

            Conversation.UpdateContainer(
                containerBuilder =>
            {
                containerBuilder.RegisterType <EntityFrameworkActivityLogger>().AsImplementedInterfaces().InstancePerDependency();
                containerBuilder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));
#if DEBUG
                ConfigurationManager.AppSettings["LuisAppId"]       = "fc5a8123-58b1-45ce-9e97-1e3d03869a72";
                ConfigurationManager.AppSettings["LuisAPIKey"]      = "462b9fade9d2421890f561b307c81e25";
                ConfigurationManager.AppSettings["LuisAPIHostName"] = "westeurope.api.cognitive.microsoft.com";
#else
                // Using Azure Table Storage
                var store = new TableBotDataStore(ConfigurationManager.AppSettings["AzureWebJobsStorage"]);     // requires Microsoft.BotBuilder.Azure Nuget package

                // To use CosmosDb or InMemory storage instead of the default table storage, uncomment the corresponding line below
                // var store = new DocumentDbBotDataStore("cosmos db uri", "cosmos db key"); // requires Microsoft.BotBuilder.Azure Nuget package
                // var store = new InMemoryDataStore(); // volatile in-memory store

                containerBuilder.Register(c => store)
                .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore)
                .AsSelf()
                .SingleInstance();
#endif
            });
            GlobalConfiguration.Configure(WebApiConfig.Register);
        }