コード例 #1
0
ファイル: DocumentUrl.cs プロジェクト: JPT123/ravendb
		public void CanGetFullUrlWithSlashOnTheEnd()
		{
			using (var store = NewDocumentStore())
			using (var server = new RavenDbHttpServer(store.Configuration, store.DocumentDatabase))
			{
				server.Start();
				var documentStore = new DocumentStore
				{
					Url = "http://localhost:8080/"
				}.Initialize();

				var session = documentStore.OpenSession();

				var entity = new LinqIndexesFromClient.User();
				session.Store(entity);

				Assert.Equal("http://localhost:8080/docs/users/1",
					session.Advanced.GetDocumentUrl(entity));

			}
		}
コード例 #2
0
    	static public void WaitForUserToContinueTheTest(EmbeddableDocumentStore documentStore)
		{
			if (Debugger.IsAttached == false)
				return;

			documentStore.DatabaseCommands.Put("Pls Delete Me", null,

											   RavenJObject.FromObject(new { StackTrace = new StackTrace(true) }),
											   new RavenJObject());

			using (var server = new RavenDbHttpServer(documentStore.Configuration, documentStore.DocumentDatabase))
			{
				server.Start();
				Process.Start(documentStore.Configuration.ServerUrl); // start the server

				do
				{
					Thread.Sleep(100);
				} while (documentStore.DatabaseCommands.Get("Pls Delete Me") != null);
			}
		}
コード例 #3
0
 /// <summary>
 /// Initialize the document store access method to RavenDB
 /// </summary>
 protected override void InitializeInternal()
 {
     if (configuration != null && Url == null)
     {
         DocumentDatabase = new DocumentDatabase(configuration);
         DocumentDatabase.SpinBackgroundWorkers();
         if (UseEmbeddedHttpServer)
         {
             httpServer = new RavenDbHttpServer(configuration, DocumentDatabase);
             httpServer.Start();
         }
         databaseCommandsGenerator = () => new EmbededDatabaseCommands(DocumentDatabase, Conventions);
     }
     else
     {
         base.InitializeInternal();
     }
 }
コード例 #4
0
        public void CanProjectFromIndex()
        {
            using (var documentStore = NewDocumentStore())
            using (var httpServer = new RavenDbHttpServer(documentStore.Configuration, documentStore.DocumentDatabase))
            {
                httpServer.Start();
                documentStore.DatabaseCommands.PutIndex("ImagesByTag",
                                                        new IndexDefinition<Image, ImageByTagSearchModel>
                                                        {
                                                            Map = images => from image in images
                                                                        from tag in image.Tags
                                                                        select new
                                                                        {
                                                                            TagName = tag,
                                                                            Images = new[] { image.Id }
                                                                        },
                                                            Reduce = results => from result in results
                                                                                group result by result.TagName
                                                                                into g
                                                                                select new
                                                                                {
                                                                                    TagName = g.Key,
                                                                                    Images = g.SelectMany(x => x.Images).Distinct()
                                                                                },
                                                            Stores =

                                                                {
                                                                    {x => x.TagName, FieldStorage.Yes},
                                                                    {x => x.Images, FieldStorage.Yes}
                                                                }
                                                            ,
                                                            Indexes =

                                                                {
                                                                    {x => x.TagName, FieldIndexing.NotAnalyzed},
                                                                    {x => x.Images, FieldIndexing.No}
                                                                }
                                                        },true);

                using(var s = documentStore.OpenSession())
                {
                    s.Store(new Image
                    {
                        Id = "images/123",
                        Tags = new[]
                        {
                            "sport", "footbool"
                        }
                    });

                    s.Store(new Image
                    {
                        Id = "images/234",
                        Tags = new[]
                        {
                            "footbool", "live"
                        }
                    });

                    s.SaveChanges();
                }

                using (var s = documentStore.OpenSession())
                {
                    var imageByTagSearchModels = s.Advanced.LuceneQuery<ImageByTagSearchModel>("ImagesByTag")
                        .OrderBy("TagName")
                        .WaitForNonStaleResults()
                        .ToList();

                    Assert.Equal("footbool", imageByTagSearchModels[0].TagName);
                    Assert.Equal(2, imageByTagSearchModels[0].Images.Length);

                    Assert.Equal("live", imageByTagSearchModels[1].TagName);
                    Assert.Equal(1, imageByTagSearchModels[1].Images.Length);

                    Assert.Equal("sport", imageByTagSearchModels[2].TagName);
                    Assert.Equal(1, imageByTagSearchModels[2].Images.Length);
                }
            }
        }
コード例 #5
0
		/// <summary>
		/// Initialize the document store access method to RavenDB
		/// </summary>
		protected override void InitializeInternal()
		{
			if (configuration != null && Url == null)
			{
				if(configuration.RunInMemory || configuration.RunInUnreliableYetFastModeThatIsNotSuitableForProduction)
				{
					ResourceManagerId = Guid.NewGuid(); // avoid conflicts
				}
				DocumentDatabase = new DocumentDatabase(configuration);
				DocumentDatabase.SpinBackgroundWorkers();
				if (UseEmbeddedHttpServer)
				{
					httpServer = new RavenDbHttpServer(configuration, DocumentDatabase);
					httpServer.Start();
				}
				databaseCommandsGenerator = () => new EmbeddedDatabaseCommands(DocumentDatabase, Conventions, currentSessionId);
			}
			else
			{
				base.InitializeInternal();
			}
		}
コード例 #6
0
ファイル: WorkerRole.cs プロジェクト: skovborg/AzureRavenDB
 private void StartRaven(RavenConfiguration config)
 {
     try
     {
         _database = new DocumentDatabase(config);
         _database.SpinBackgroundWorkers();
         _server = new RavenDbHttpServer(config, _database);
         try
         {
             _server.Start();
         }
         catch (Exception)
         {
             _server.Dispose();
             _server = null;
             throw;
         }
     }
     catch (Exception)
     {
         _database.Dispose();
         _database = null;
         throw;
     }
 }