当前位置: 首页>>代码示例>>C#>>正文


C# Smuggler.SmugglerDatabaseApi类代码示例

本文整理汇总了C#中Raven.Smuggler.SmugglerDatabaseApi的典型用法代码示例。如果您正苦于以下问题:C# SmugglerDatabaseApi类的具体用法?C# SmugglerDatabaseApi怎么用?C# SmugglerDatabaseApi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SmugglerDatabaseApi类属于Raven.Smuggler命名空间,在下文中一共展示了SmugglerDatabaseApi类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SmugglerBetweenOperationShouldNotCreateDatabases

        public void SmugglerBetweenOperationShouldNotCreateDatabases()
        {
            using (var store = NewRemoteDocumentStore())
            {
                var smugglerApi = new SmugglerDatabaseApi();

                var options = new SmugglerBetweenOptions<RavenConnectionStringOptions>
                              {
                                    From = new RavenConnectionStringOptions
                                    {
                                        Url = store.Url, 
                                        DefaultDatabase = "DB1"
                                    },
                                    To = new RavenConnectionStringOptions
                                    {
                                        Url = store.Url, 
                                        DefaultDatabase = "DB2"
                                    }
                              };

                var aggregateException = Assert.Throws<AggregateException>(() => smugglerApi.Between(options).Wait());
                var exception = aggregateException.ExtractSingleInnerException();
                Assert.True(exception.Message.StartsWith("Smuggler does not support database creation (database 'DB1' on server"));

                store.DatabaseCommands.GlobalAdmin.EnsureDatabaseExists("DB1");

                aggregateException = Assert.Throws<AggregateException>(() => smugglerApi.Between(options).Wait());
                exception = aggregateException.ExtractSingleInnerException();
                Assert.True(exception.Message.StartsWith("Smuggler does not support database creation (database 'DB2' on server"));
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:31,代码来源:RavenDB_2586.cs

示例2: Sample1

		public async void Sample1()
		{
			#region smuggler_api_2
			// import only Documents
			// from dump.raven file
			// to NewNorthwind database (must exist)
			// found on http://localhost:8080 server
			SmugglerDatabaseApi smugglerApi = new SmugglerDatabaseApi(new SmugglerDatabaseOptions
			{
				OperateOnTypes = ItemType.Documents,
				Incremental = false
			});

			SmugglerImportOptions<RavenConnectionStringOptions> importOptions = new SmugglerImportOptions<RavenConnectionStringOptions>
			{
				FromFile = "dump.raven",
				To = new RavenConnectionStringOptions
				{
					DefaultDatabase = "NewNorthwind",
					Url = "http://localhost:8080"
				}
			};

			await smugglerApi.ImportData(importOptions, null);
			#endregion
		}
开发者ID:modulexcite,项目名称:docs-8,代码行数:26,代码来源:ExportImport.cs

示例3: SmugglerShouldThrowIfDatabaseDoesNotExist

        public async Task SmugglerShouldThrowIfDatabaseDoesNotExist()
        {
            var path = Path.GetTempFileName();

            try
            {
                using (var store = NewRemoteDocumentStore())
                {
                    var connectionStringOptions =
                        new RavenConnectionStringOptions
                        {
                            Url = store.Url,
                            DefaultDatabase = "DoesNotExist"
                        };
                    var smuggler = new SmugglerDatabaseApi();

                    var e = await AssertAsync.Throws<SmugglerException>(() => smuggler.ImportData(
                        new SmugglerImportOptions<RavenConnectionStringOptions> { FromFile = path, To = connectionStringOptions }));

                    Assert.Equal(string.Format("Smuggler does not support database creation (database 'DoesNotExist' on server '{0}' must exist before running Smuggler).", store.Url), e.Message);

                    e = await AssertAsync.Throws<SmugglerException>(() => smuggler.ExportData(
                        new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = path, From = connectionStringOptions }));

                    Assert.Equal(string.Format("Smuggler does not support database creation (database 'DoesNotExist' on server '{0}' must exist before running Smuggler).", store.Url), e.Message);
                }
            }
            finally
            {
                IOExtensions.DeleteFile(path);
            }
        }
开发者ID:JackWangCUMT,项目名称:ravendb,代码行数:32,代码来源:SmugglerExecutionTests.cs

示例4: Sample2

		public async void Sample2()
		{
			#region smuggler_api_3
			// export Documents and Indexes
			// from Northwind database
			// found on http://localhost:8080
			// and import them to NewNorthwind
			// found on the same server
			SmugglerDatabaseApi smugglerApi = new SmugglerDatabaseApi(new SmugglerDatabaseOptions
			{
				OperateOnTypes = ItemType.Documents | ItemType.Indexes,
				Incremental = false
			});

			await smugglerApi.Between(
				new SmugglerBetweenOptions<RavenConnectionStringOptions>
				{
					From = new RavenConnectionStringOptions
					{
						Url = "http://localhost:8080",
						DefaultDatabase = "Northwind"
					},
					To = new RavenConnectionStringOptions
					{
						Url = "http://localhost:8080",
						DefaultDatabase = "NewNorthwind"
					}
				});
			#endregion
		}
开发者ID:modulexcite,项目名称:docs-8,代码行数:30,代码来源:ExportImport.cs

示例5: MaxNumberOfItemsToProcessInSingleBatchShouldBeRespectedBySmuggler

		public void MaxNumberOfItemsToProcessInSingleBatchShouldBeRespectedBySmuggler()
		{
			var path = Path.Combine(NewDataPath(forceCreateDir: true), "raven.dump");

			using (var server = GetNewServer(configureConfig: configuration => configuration.MaxNumberOfItemsToProcessInSingleBatch = 1234))
			{
                var smuggler = new SmugglerDatabaseApi(options: new SmugglerDatabaseOptions { BatchSize = 4321 });
				Assert.Equal(4321, smuggler.Options.BatchSize);

                smuggler.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = path, From = new RavenConnectionStringOptions { Url = server.Configuration.ServerUrl } }).ResultUnwrap();

				Assert.Equal(1234, smuggler.Options.BatchSize);

                smuggler = new SmugglerDatabaseApi(options: new SmugglerDatabaseOptions { BatchSize = 4321 });
				Assert.Equal(4321, smuggler.Options.BatchSize);

                smuggler.ImportData(new SmugglerImportOptions<RavenConnectionStringOptions> { FromFile = path, To = new RavenConnectionStringOptions { Url = server.Configuration.ServerUrl } }).Wait();

				Assert.Equal(1234, smuggler.Options.BatchSize);

                smuggler = new SmugglerDatabaseApi(options: new SmugglerDatabaseOptions { BatchSize = 1000 });
				Assert.Equal(1000, smuggler.Options.BatchSize);

                smuggler.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = path, From = new RavenConnectionStringOptions { Url = server.Configuration.ServerUrl } }).ResultUnwrap();

				Assert.Equal(1000, smuggler.Options.BatchSize);
			}
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:28,代码来源:RavenDB_2605.cs

示例6: Sample

		public async void Sample()
		{
			#region smuggler_api_1
			// export Documents, Indexes, Attachments and Transformers
			// to dump.raven file
			// from Northwind database
			// found on http://localhost:8080 server
			SmugglerDatabaseApi smugglerApi = new SmugglerDatabaseApi(new SmugglerDatabaseOptions
			{
				OperateOnTypes =
					ItemType.Documents | ItemType.Indexes | ItemType.Attachments | ItemType.Transformers,
				Incremental = false
			});

			SmugglerExportOptions<RavenConnectionStringOptions> exportOptions = new SmugglerExportOptions<RavenConnectionStringOptions>
			{
				ToFile = "dump.raven",
				From = new RavenConnectionStringOptions
				{
					DefaultDatabase = "Northwind",
					Url = "http://localhost:8080"
				}
			};

			await smugglerApi.ExportData(exportOptions);
			#endregion
		}
开发者ID:modulexcite,项目名称:docs-8,代码行数:27,代码来源:ExportImport.cs

示例7: ImportingReplicationDestinationsDocumentWithInvalidSourceShouldReportOneAlertOnly

        public void ImportingReplicationDestinationsDocumentWithInvalidSourceShouldReportOneAlertOnly()
        {
            var store1 = CreateStore();
            var store2 = CreateStore();
            var store3 = CreateStore();

            TellFirstInstanceToReplicateToSecondInstance();

            store2.Dispose();

            store1.DatabaseCommands.Put("1", null, new RavenJObject(), new RavenJObject());
            store1.DatabaseCommands.Put("2", null, new RavenJObject(), new RavenJObject());

            var smuggler = new SmugglerDatabaseApi();

	        smuggler.ExportData(
                new SmugglerExportOptions<RavenConnectionStringOptions>
		        {
			        ToFile = DumpFile,
			        From = new RavenConnectionStringOptions
			        {
				        Url = store1.Url,
				        DefaultDatabase = store1.DefaultDatabase
			        }
		        }).Wait(TimeSpan.FromSeconds(15));
            Assert.True(File.Exists(DumpFile));

            smuggler = new SmugglerDatabaseApi();
	        smuggler.ImportData(
                new SmugglerImportOptions<RavenConnectionStringOptions>
		        {
			        FromFile = DumpFile,
			        To = new RavenConnectionStringOptions
			        {
				        Url = store3.Url,
				        DefaultDatabase = store3.DefaultDatabase
			        }
		        }).Wait(TimeSpan.FromSeconds(15));

            Assert.NotNull(store3.DatabaseCommands.Get("1"));
            Assert.NotNull(store3.DatabaseCommands.Get("2"));

	        int retries = 5;
	        JsonDocument container = null;
			while (container == null && retries-- >0)
	        {
		        container = store3.DatabaseCommands.Get("Raven/Alerts");
				if(container == null)
					Thread.Sleep(100);
	        }
	        Assert.NotNull(container);

            var alerts = container.DataAsJson["Alerts"].Values<RavenJObject>()
                .ToList();
            Assert.Equal(1, alerts.Count);

            var alert = alerts.First();
            Assert.True(alert["Title"].ToString().StartsWith("Wrong replication source:"));
        }
开发者ID:GorelH,项目名称:ravendb,代码行数:59,代码来源:ReplicationAlerts.cs

示例8: NegativeFiltersShouldNotFilterOutWhenThereAreNoMatches

        public void NegativeFiltersShouldNotFilterOutWhenThereAreNoMatches()
        {
            var path = Path.GetTempFileName();

	        var options = new SmugglerDatabaseOptions
		        {
			        Filters =
				        new EquatableList<FilterSetting>
				        {
					        new FilterSetting
					        {
						        Path = "Value",
						        ShouldMatch = false,
						        Values = new EquatableList<string> {"Value1"}
					        }
				        }
		        };

            try
            {
                using (var store = NewRemoteDocumentStore())
                {
                    Initialize(store);

                    var smuggler = new SmugglerDatabaseApi(options);
                    smuggler.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = path, From = new RavenConnectionStringOptions { Url = store.Url, DefaultDatabase = store.DefaultDatabase } }).Wait(TimeSpan.FromSeconds(15));
                }

                using (var store = NewRemoteDocumentStore())
                {
                    var smuggler = new SmugglerDatabaseApi(options);
                    smuggler.ImportData(new SmugglerImportOptions<RavenConnectionStringOptions> { FromFile = path, To = new RavenConnectionStringOptions { Url = store.Url, DefaultDatabase = store.DefaultDatabase } }).Wait(TimeSpan.FromSeconds(15));

                    Assert.NotNull(store.DatabaseCommands.Get("key/1"));

                    using (var session = store.OpenSession())
                    {
                        var product1 = session.Load<Product>(1);
                        var product2 = session.Load<Product>(2);
                        var product3 = session.Load<Product>(3);

                        Assert.Null(product1);
                        Assert.Null(product2);
                        Assert.NotNull(product3);
                    }
                }
            }
            finally
            {
                IOExtensions.DeleteDirectory(path);
            }
        }
开发者ID:GorelH,项目名称:ravendb,代码行数:52,代码来源:RDBQA_7.cs

示例9: Using_smuggler_between_servers_should_take_into_accound_files_related_while_smuggling

        public async Task Using_smuggler_between_servers_should_take_into_accound_files_related_while_smuggling()
        {
            using (var server1 = GetNewServer(8090))
            using (var server2 = GetNewServer(8091))
            using (var store1 = NewRemoteDocumentStore(ravenDbServer: server1))
            using (var store2 = NewRemoteDocumentStore(ravenDbServer: server2))
            {
                var smugglerApi = new SmugglerDatabaseApi();

                var createdUsers = AddDocuments(store1);
                var users = new ConcurrentBag<User>();
                foreach (var user in createdUsers)
                    users.Add(user);

                var addDocsTask = Task.Run(() =>
                {
                    var createdUsersInParallel = AddDocuments(store1);
                    foreach(var user in createdUsersInParallel)
                        users.Add(user);
                });
                var smugglingTask = smugglerApi.Between(new SmugglerBetweenOptions<RavenConnectionStringOptions>
                {
                    From = new RavenConnectionStringOptions
                    {
                        Url = store1.Url,
                        DefaultDatabase = store1.DefaultDatabase
                    },
                    To = new RavenConnectionStringOptions
                    {
                        Url = store2.Url,
                        DefaultDatabase = store2.DefaultDatabase
                    }
                });
                
                await smugglingTask;
                await addDocsTask; //not necessary -> smuggling task should effectively do this as well

                WaitForIndexing(store2);
                using (var session = store2.OpenSession())
                    Assert.Equal(users.Count, session.Query<User>().Count());
            }
        }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:42,代码来源:RavenDB-4379.cs

示例10: DateTimePreserved

        public void DateTimePreserved()
        {
            var file = Path.GetTempFileName();

            try
            {
                var docId = string.Empty;

                using (var documentStore = NewRemoteDocumentStore())
                {
                    using (var session = documentStore.OpenSession())
                    {
                        var foo = new Foo {Created = DateTime.Today};
                        session.Store(foo);
                        docId = foo.Id;
                        session.SaveChanges();
                    }
                    var smugglerApi = new SmugglerDatabaseApi();
                    smugglerApi.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = file, From = new RavenConnectionStringOptions { Url = documentStore.Url, DefaultDatabase = documentStore.DefaultDatabase } }).Wait(TimeSpan.FromSeconds(15));
                }

                using (var documentStore = NewRemoteDocumentStore())
                {
                    var smugglerApi = new SmugglerDatabaseApi();
                    smugglerApi.ImportData(new SmugglerImportOptions<RavenConnectionStringOptions> { FromFile = file, To = new RavenConnectionStringOptions { Url = documentStore.Url, DefaultDatabase = documentStore.DefaultDatabase } }).Wait(TimeSpan.FromSeconds(15));
                    
                    using (var session = documentStore.OpenSession())
                    {
                        var created = session.Load<Foo>(docId).Created;
                        Assert.False(session.Advanced.HasChanges);
                    }
                }
            }
            finally
            {
                if (File.Exists(file))
                {
                    File.Delete(file);
                }
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:41,代码来源:SmugglerTests.cs

示例11: ShouldSmuggleIdentitiesBetweenDatabases

		public async Task ShouldSmuggleIdentitiesBetweenDatabases()
		{
			using (var server1 = GetNewServer(port: 8079))
            using (var store1 = NewRemoteDocumentStore(ravenDbServer: server1, databaseName: "Database1"))
			{
                using (var session = store1.OpenAsyncSession("Database1"))
                {
                    await session.StoreAsync(new User {Id = "users/", Name = "Arek"});
                    await session.SaveChangesAsync();
                }

				store1.DatabaseCommands.SeedIdentityFor("users/", 10);

                using (var server2 = GetNewServer(port: 8078))
                {
					using (var store2 = NewRemoteDocumentStore(ravenDbServer: server2, databaseName: "Database2"))
					{
                        var smugglerApi = new SmugglerDatabaseApi();
						await smugglerApi.Between(new SmugglerBetweenOptions<RavenConnectionStringOptions>
						{
							From = new RavenConnectionStringOptions {Url = "http://localhost:8079", DefaultDatabase = "Database1"},
							To = new RavenConnectionStringOptions {Url = "http://localhost:8078", DefaultDatabase = "Database2"}
						});
                    
                        using (var session = store2.OpenAsyncSession("Database2"))
                        {
							await session.StoreAsync(new User { Id = "users/", Name = "Oren" });
							await session.SaveChangesAsync();
                        }

						var documents = (await store2.AsyncDatabaseCommands.GetDocumentsAsync(0, 10)).OrderBy(x => x.Key).ToArray();

						Assert.Equal(2, documents.Length);
						Assert.Equal("users/1", documents[0].Key);
						Assert.Equal("users/11", documents[1].Key);
					}
                }
            }
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:39,代码来源:RavenDB_2764.cs

示例12: SmugglerShouldNotThrowIfDatabaseExist1

        public async Task SmugglerShouldNotThrowIfDatabaseExist1()
        {
            var path = Path.GetTempFileName();

            try
            {
                using (var store = NewRemoteDocumentStore())
                {
                    store.DatabaseCommands.GlobalAdmin.EnsureDatabaseExists("DoesNotExist");

                    var connectionStringOptions = new RavenConnectionStringOptions { Url = store.Url, DefaultDatabase = "DoesNotExist" };
                    var smuggler = new SmugglerDatabaseApi();

                    await smuggler.ImportData(new SmugglerImportOptions<RavenConnectionStringOptions> { FromFile = path, To = connectionStringOptions });
                    await smuggler.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = path, From = connectionStringOptions });
                }
            }
            finally
            {
                IOExtensions.DeleteFile(path);
            }
        }
开发者ID:JackWangCUMT,项目名称:ravendb,代码行数:22,代码来源:SmugglerExecutionTests.cs

示例13: SmugglerWithoutExcludeExpiredDocumentsShouldWork

        public void SmugglerWithoutExcludeExpiredDocumentsShouldWork()
        {
            var path = Path.GetTempFileName();

            try
            {
                using (var store = NewRemoteDocumentStore())
                {
                    Initialize(store);

                    var smuggler = new SmugglerDatabaseApi();

                    smuggler.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = path, From = new RavenConnectionStringOptions { Url = store.Url, DefaultDatabase = store.DefaultDatabase } }).Wait(TimeSpan.FromSeconds(15));
                }

                using (var store = NewRemoteDocumentStore())
                {
                    var smuggler = new SmugglerDatabaseApi();

                    smuggler.ImportData(new SmugglerImportOptions<RavenConnectionStringOptions> { FromFile = path, To = new RavenConnectionStringOptions { Url = store.Url, DefaultDatabase = store.DefaultDatabase } }).Wait(TimeSpan.FromSeconds(15));

                    using (var session = store.OpenSession())
                    {
                        var product1 = session.Load<Product>(1);
                        var product2 = session.Load<Product>(2);
                        var product3 = session.Load<Product>(3);

                        Assert.NotNull(product1);
                        Assert.Null(product2);
                        Assert.NotNull(product3);
                    }
                }
            }
            finally
            {
                IOExtensions.DeleteDirectory(path);
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:38,代码来源:RDBQA_11.cs

示例14: SmugglerShouldNotExportImportSubscribtionIdentities

        public async Task SmugglerShouldNotExportImportSubscribtionIdentities()
        {
            using (var store = NewRemoteDocumentStore())
            {
                store.Subscriptions.Create(new SubscriptionCriteria());

                var smuggler = new SmugglerDatabaseApi(new SmugglerDatabaseOptions { OperateOnTypes = ItemType.Documents });

                using (var stream = new MemoryStream())
                {
                    await smuggler.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions>
                    {
                        From = new RavenConnectionStringOptions
                        {
                            DefaultDatabase = store.DefaultDatabase,
                            Url = store.Url
                        },
                        ToStream = stream
                    });

                    stream.Position = 0;

                    store.DatabaseCommands.GlobalAdmin.EnsureDatabaseExists("Northwind");

                    await smuggler.ImportData(new SmugglerImportOptions<RavenConnectionStringOptions>
                    {
                        FromStream = stream,
                        To = new RavenConnectionStringOptions
                        {
                            DefaultDatabase = "Northwind",
                            Url = store.Url
                        }
                    });
                }
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:36,代码来源:RavenDB_3917.cs

示例15: CanDumpWhenHiddenDocsWithLimit_Smuggler

        public async Task CanDumpWhenHiddenDocsWithLimit_Smuggler()
        {
            var backupPath = NewDataPath("BackupFolder");
            try
            {
                using (GetNewServer())
                {
                    using (var store = new DocumentStore { Url = "http://localhost:8079" })
                    {
                        store.Initialize();

                        InsertHidenUsers(store, 2000);

                        var user1 = store.DatabaseCommands.Get("users/1");
                        Assert.Null(user1);

                        InsertUsers(store, 1, 25);

                        // now perform full backup
                        var dumper = new SmugglerDatabaseApi { Options = { Incremental = true } };
                        await dumper.ExportData(
                            new SmugglerExportOptions<RavenConnectionStringOptions>
                            {
                                ToFile = backupPath,
                                From = new RavenConnectionStringOptions
                                {
                                    Url = "http://localhost:8079",
                                    DefaultDatabase = store.DefaultDatabase,
                                }
                            });
                    }
                }

                VerifyDump(backupPath, store =>
                {
                    using (var session = store.OpenSession())
                    {
                        Assert.Equal(25, session.Query<User>().Customize(x => x.WaitForNonStaleResultsAsOfNow()).Count());
                    }
                });
            }
            finally
            {
                IOExtensions.DeleteDirectory(backupPath);
            }            
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:46,代码来源:RavenDB_1603.cs


注:本文中的Raven.Smuggler.SmugglerDatabaseApi类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。