Пример #1
0
 public ProductRepository(DocumentDbSettings settings)
 {
     // Save the document db settings into a private data member and
     // instantiate an instance of the client.
     _documentDbSettings = settings;
     _documentClient     = new DocumentClient(new Uri(_documentDbSettings.Endpoint),
                                              _documentDbSettings.AuthKey);
 }
Пример #2
0
 public DocumentDbProvider(DocumentDbSettings settings)
 {
     _settings      = settings;
     _collectionUri = GetCollectionLink();
     //See https://azure.microsoft.com/documentation/articles/documentdb-performance-tips/ for performance tips
     _dbClient = new DocumentClient(_settings.DatabaseUri, _settings.DatabaseKey, new ConnectionPolicy()
     {
         MaxConnectionLimit = 100
     });
     _dbClient.OpenAsync().Wait();
 }
Пример #3
0
 public ConfigurationService(
     IMongoDatabase mongoDatabase,
     IConfigurationRoot configurationRoot,
     IOptions <InauguralSync> inauguralSync,
     IOptions <DocumentDbSettings> documentDbSettings,
     ILogger <ConfigurationService> logger)
 {
     _mongoDatabase      = mongoDatabase;
     _configurationRoot  = configurationRoot ?? throw new ArgumentNullException(nameof(configurationRoot));
     _documentDbSettings = documentDbSettings.Value;
     _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
     _inauguralSync      = inauguralSync?.Value ?? throw new ArgumentNullException(nameof(inauguralSync));
 }
        private async Task InitializeProductRepository()
        {
            var docDbSettings = new DocumentDbSettings
            {
                AuthKey      = "",
                CollectionId = "",
                DatabaseId   = "",
                Endpoint     = ""
            };

            _productRepository = new ProductRepository(docDbSettings);
            await _productRepository.Initialize();
        }
Пример #5
0
        private static void ClearTestDatabase(DocumentDbSettings documentDbSettings)
        {
            DocumentClient     client;
            DocumentCollection collection;

            GetDocumentClient(documentDbSettings, out client);

            GetDocumentCollection(documentDbSettings, client, out collection);

            if (collection != null)
            {
                DeleteAllDocsInCollection(client, collection);
            }
        }
Пример #6
0
 private static void GetDocumentCollection(DocumentDbSettings documentDbSettings, DocumentClient documentClient, out DocumentCollection collection)
 {
     collection = documentClient.ReadDocumentCollectionAsync(documentDbSettings.CollectionSelfLink()).Result;
 }
Пример #7
0
 private static void GetDocumentClient(DocumentDbSettings documentDbSettings, out DocumentClient documentClient)
 {
     documentClient = new DocumentDbClientFactory(documentDbSettings).GetDocumentClient();
 }
Пример #8
0
 public DocumentDbInitialiser(DocumentDbSettings settings)
 {
     this.settings       = settings;
     this.documentClient = new DocumentClient(new Uri(settings.EndpointUrl), settings.AuthorizationKey);
 }
Пример #9
0
        public async Task FindSpeaker(IDialogContext context, LuisResult result)
        {
            var    reply    = context.MakeMessage();
            string topic    = "";
            string location = "";

            if (result.Entities.Count > 0)
            {
                var  ent      = new EntityRecommendation();
                bool hasTopic = result.TryFindEntity("topic", out ent);
                topic = (hasTopic ? ent.Entity : "");
                bool hasLocation = result.TryFindEntity("location", out ent);
                location = (hasLocation ? ent.Entity : "");


                await context.PostAsync("Searching with *topic* = **" + topic + "** and *location* = **" + location + "**");

                if (!hasLocation)
                {
                    await context.PostAsync("What state do you want a speaker in?");

                    var adaptive = new HeroCard();
                    List <CardAction> cardButtons = new List <CardAction>();
                    CardAction        p1Button    = new CardAction("button")
                    {
                        Value = $"Find Speaker {topic} New South Wales", Title = "New South Wales", Type = ActionTypes.PostBack
                    };
                    CardAction p2Button = new CardAction("button")
                    {
                        Value = $"Find Speaker {topic} Victoria", Title = "Victoria", Type = ActionTypes.PostBack
                    };
                    CardAction p3Button = new CardAction("button")
                    {
                        Value = $"Find Speaker {topic} Queensland", Title = "Queensland", Type = ActionTypes.PostBack
                    };
                    cardButtons.Add(p1Button);
                    cardButtons.Add(p2Button);
                    cardButtons.Add(p3Button);
                    adaptive.Buttons = cardButtons;
                    var attach = adaptive.ToAttachment();
                    reply.Attachments.Add(attach);

                    await context.PostAsync(reply);

                    context.Wait(this.MessageReceived);
                }
                else if (hasTopic && hasLocation)
                {
                    if (location.Equals("nsw") || location.Equals("sydney"))
                    {
                        location = "new south wales";
                    }
                    else if (location.Equals("qld") || location.Equals("brisbane"))
                    {
                        location = "queensland";
                    }
                    else if (location.Equals("vic") || location.Equals("melbourne"))
                    {
                        location = "victoria";
                    }

                    if (!(location.Equals("new south wales") || location.Equals("queensland") || location.Equals("victoria")))
                    {
                        hasLocation = false;
                    }

                    if (hasLocation)
                    {
                        var db = new DocumentDbSettings();
                        db.Connect();
                        List <Profile> profiles = db.SearchTopic(topic);

                        Random rnd = new Random();
                        IEnumerable <Profile> res = profiles.Where(p => p.tags.Any(m => m.Contains(topic))).Where(c => c.states.Any(m => m.Contains(location)));
                        var filteredProfiles      = res.ToList <Profile>().OrderBy(p => rnd.Next());

                        if (filteredProfiles.Count() > 0)
                        {
                            reply.Attachments.Clear();
                            reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;

                            foreach (Profile p in filteredProfiles)
                            {
                                //Site and Email buttons on each card.
                                List <CardAction> buttons    = new List <CardAction>();
                                CardAction        siteButton = new CardAction("button")
                                {
                                    Value = $"{p.website}", Title = "Website", Type = ActionTypes.OpenUrl
                                };
                                CardAction emailButton = new CardAction("button")
                                {
                                    Value = $"mailto:{p.email}", Title = "Email", Type = ActionTypes.OpenUrl
                                };
                                buttons.Add(siteButton);
                                buttons.Add(emailButton);

                                var hero = new HeroCard();
                                hero.Subtitle = p.slogan;
                                hero.Title    = p.name;

                                var bioText = p.bio;
                                //var bioTrunc = TruncateText(bioText, 220);
                                //bioTrunc += "...";

                                hero.Text = bioText;
                                var image = new CardImage();
                                image.Url = "http://tebot2.azurewebsites.net" + p.picture;
                                hero.Images.Add(image);
                                hero.Buttons = buttons;
                                var heroAttach = hero.ToAttachment();
                                reply.Attachments.Add(heroAttach);
                            }

                            await context.PostAsync(reply);

                            context.Wait(this.MessageReceived);
                        }
                    }
                    else
                    {
                        await context.PostAsync("Please search for speakers in New South Wales, Queensland or Victoria");
                    }
                }
                else
                {
                    await context.PostAsync("Topic unable to be captured.");
                }
            }
            else
            {
                await context.PostAsync("Topic could not be found. Please try another topic.");
            }
        }
Пример #10
0
 public GetPaymentQuery(IDocumentClientFactory documentClientFactory, IOptions <DocumentDbSettings> dbSettings)
 {
     this.dbSettings     = dbSettings.Value;
     this.documentClient = documentClientFactory.Create(this.dbSettings).Result;
 }
Пример #11
0
 public static string DatabaseSelfLink(this DocumentDbSettings config)
 {
     return(UriFactory.CreateDatabaseUri(config.DatabaseName).ToString());
 }
 public OrderRepository() : this(DocumentDbSettings.GetDbSettings())
 {
 }
Пример #13
0
 private DataStoreConfiguration(DocumentDbSettings documentDbSettings, FileStorageSettings fileStorageSettings)
 {
     DocumentDbSettings  = documentDbSettings;
     FileStorageSettings = fileStorageSettings;
 }
Пример #14
0
 public static DataStoreConfiguration Create(DocumentDbSettings documentDbSettings, FileStorageSettings fileStorageSettings = null)
 {
     return(new DataStoreConfiguration(documentDbSettings, fileStorageSettings));
 }
 public DocumentDbRepository(DocumentDbSettings config)
 {
     this.documentClient = new DocumentDbClientFactory(config).GetDocumentClient();
     this.config         = config;
 }
 public PaymentsRepository(IDocumentClientFactory documentClientFactory, IOptions <DocumentDbSettings> settings)
 {
     this.settings = settings.Value;
     this.documentClientFactory = documentClientFactory.Create(this.settings).Result;
 }
Пример #17
0
 public static string CollectionSelfLink(this DocumentDbSettings config)
 {
     return(UriFactory.CreateDocumentCollectionUri(config.DatabaseName, config.CollectionSettings.CollectionName).ToString());
 }
Пример #18
0
 private DocumentDbTestHarness(DocumentDbSettings settings)
 {
     this.settings             = settings;
     this.documentDbRepository = new DocumentDbRepository(settings);
     DataStore = new DataStore(this.documentDbRepository, this.messageAggregator);
 }
 public DocumentDbClientFactory(DocumentDbSettings config)
 {
     this.config = config;
     new DocumentDbInitialiser(config).Initialise();
 }
Пример #20
0
        public static ITestHarness Create(DocumentDbSettings dbConfig)
        {
            ClearTestDatabase(dbConfig);

            return(new DocumentDbTestHarness(dbConfig));
        }
Пример #21
0
 public ProductRepository() : this(DocumentDbSettings.GetDbSettings())
 {
 }
Пример #22
0
 public SavePaymentCommand(IDocumentClientFactory documentClientFactory, IOptions <DocumentDbSettings> dbSettings)
 {
     this.dbSettings     = dbSettings.Value;
     this.documentClient = documentClientFactory.Create(this.dbSettings).Result;
 }
Пример #23
0
 public HomeController(DocumentDbSettings _settings)
 {
     //dependency injection of Azure DocDB connection settings.
     settings = _settings;
 }