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


C# Smuggler.SmugglerApi类代码示例

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


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

示例1: SmugglerShouldThrowIfDatabaseDoesNotExist

        public async Task SmugglerShouldThrowIfDatabaseDoesNotExist()
        {
            var options = new SmugglerOptions
            {
                BackupPath = Path.GetTempFileName()
            };

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

                    var e = await AssertAsync.Throws<SmugglerException>(() => smuggler.ImportData(options));

                    Assert.Equal("Smuggler does not support database creation (database 'DoesNotExist' on server 'http://localhost:8079' must exist before running Smuggler).", e.Message);

                    e = await AssertAsync.Throws<SmugglerException>(() => smuggler.ExportData(null, options, false));

                    Assert.Equal("Smuggler does not support database creation (database 'DoesNotExist' on server 'http://localhost:8079' must exist before running Smuggler).", e.Message);
                }
            }
            finally
            {
                IOExtensions.DeleteDirectory(options.BackupPath);
            }
        }
开发者ID:925coder,项目名称:ravendb,代码行数:27,代码来源:RDBQA_6.cs

示例2: 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 SmugglerApi(options: new SmugglerOptions { BatchSize = 4321 });
				Assert.Equal(4321, smuggler.SmugglerOptions.BatchSize);

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

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

				smuggler = new SmugglerApi(options: new SmugglerOptions { BatchSize = 4321 });
				Assert.Equal(4321, smuggler.SmugglerOptions.BatchSize);

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

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

				smuggler = new SmugglerApi(options: new SmugglerOptions { BatchSize = 1000 });
				Assert.Equal(1000, smuggler.SmugglerOptions.BatchSize);

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

				Assert.Equal(1000, smuggler.SmugglerOptions.BatchSize);
			}
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:28,代码来源:RavenDB_2605.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 SmugglerApi();

	                var e = await AssertAsync.Throws<SmugglerException>(() => smuggler.ImportData(
						new SmugglerImportOptions{ 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{ 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:cocytus,项目名称:ravendb,代码行数:32,代码来源:RDBQA_6.cs

示例4: Export_And_Import_Retains_HiLoState

		public void Export_And_Import_Retains_HiLoState()
		{
			using (var session = documentStore.OpenSession())
			{
				var foo = new Foo { Something = "something2" };
				Assert.Null(foo.Id);
				session.Store(foo);
				Assert.NotNull(foo.Id);
				session.SaveChanges();
			}

			var smugglerApi = new SmugglerApi(new RavenConnectionStringOptions { Url = "http://localhost:8079/" });
			smugglerApi.ExportData(new SmugglerOptions { File = DumpFile });
			Assert.True(File.Exists(DumpFile));

			using (var session = documentStore.OpenSession())
			{
				var hilo = session.Load<HiLoKey>("Raven/Hilo/foos");
				Assert.NotNull(hilo);
				Assert.Equal(32, hilo.Max);
			}

			server.Dispose();
			CreateServer();

			smugglerApi.ImportData(new SmugglerOptions { File = DumpFile });

			using (var session = documentStore.OpenSession())
			{
				var hilo = session.Load<HiLoKey>("Raven/Hilo/foos");
				Assert.NotNull(hilo);
				Assert.Equal(32, hilo.Max);
			}
		}
开发者ID:seankearon,项目名称:ravendb,代码行数:34,代码来源:HiLoServerKeysNotExported.cs

示例5: SmugglerBetweenOperationShouldNotCreateDatabases

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

				var options = new SmugglerBetweenOptions
				              {
									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:cocytus,项目名称:ravendb,代码行数:31,代码来源:RavenDB_2586.cs

示例6: 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 SmugglerApi();

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

	        smuggler = new SmugglerApi();
	        smuggler.ImportData(
		        new SmugglerImportOptions
		        {
			        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:cocytus,项目名称:ravendb,代码行数:59,代码来源:ReplicationAlerts.cs

示例7: TransformScriptFiltering

		public async Task TransformScriptFiltering()
		{
			var options = new SmugglerOptions
			{
				BackupPath = Path.GetTempFileName(),
				TransformScript = @"function(doc) { 
						var id = doc['@metadata']['@id']; 
						if(id === 'foos/1')
							return null;
						return doc;
					}"
			};

			try
			{
				using (var store = NewRemoteDocumentStore())
				{
					using (var session = store.OpenSession())
					{
						session.Store(new Foo {Name = "N1"});
						session.Store(new Foo {Name = "N2"});

						session.SaveChanges();
					}
					var smugglerApi = new SmugglerApi(options, new RavenConnectionStringOptions
					{
						Url = store.Url
					});
					await smugglerApi.ExportData(null, options, false);
				}

				using (var documentStore = NewRemoteDocumentStore())
				{
					var smugglerApi = new SmugglerApi(options, new RavenConnectionStringOptions
					{
						Url = documentStore.Url
					});
					await smugglerApi.ImportData(options);

					using (var session = documentStore.OpenSession())
					{
						var foos = session.Query<Foo>()
						                  .Customize(customization => customization.WaitForNonStaleResultsAsOfNow())
						                  .ToList();

						Assert.Equal(1, foos.Count);
						Assert.Equal("foos/2", foos[0].Id);
						Assert.Equal("N2", foos[0].Name);
					}
				}
			}
			finally
			{
				if (File.Exists(options.BackupPath))
				{
					File.Delete(options.BackupPath);
				}
			}
		}
开发者ID:nzaugg,项目名称:ravendb,代码行数:59,代码来源:RavenDB_895.cs

示例8: Export_WithoutCredentials_WillReturnWithStatus401

		public void Export_WithoutCredentials_WillReturnWithStatus401()
		{
			var smugglerApi = new SmugglerApi(new RavenConnectionStringOptions {Url = store.Url});

			var webException = Assert.Throws<WebException>(() => smugglerApi.ExportData(new SmugglerOptions { File = File }));
			Assert.Equal(WebExceptionStatus.ProtocolError, webException.Status);
			Assert.Equal(HttpStatusCode.Unauthorized, ((HttpWebResponse)webException.Response).StatusCode);
		}
开发者ID:neiz,项目名称:ravendb,代码行数:8,代码来源:SmugglerOAuth.cs

示例9: NegativeFiltersShouldNotFilterOutWhenThereAreNoMatches

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

            var options = new SmugglerOptions
            {
                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 SmugglerApi();

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

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

					smuggler.ImportData(new SmugglerImportOptions { FromFile = path, To = new RavenConnectionStringOptions { Url = store.Url, DefaultDatabase = store.DefaultDatabase } }, options).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:ReginaBricker,项目名称:ravendb,代码行数:54,代码来源:RDBQA_7.cs

示例10: Smuggler

 public Smuggler()
 {
     #region smuggler-api
     var connectionStringOptions = new RavenConnectionStringOptions
     {
         ApiKey = "ApiKey",
         Credentials = new NetworkCredential("username", "password", "domain"),
         DefaultDatabase = "database",
         Url = "http://localhost:8080",
     };
     var smugglerApi = new SmugglerApi(connectionStringOptions);
     smugglerApi.ExportData(new SmugglerOptions { File = "dump.raven", OperateOnTypes = ItemType.Documents | ItemType.Indexes | ItemType.Attachments });
     smugglerApi.ImportData(new SmugglerOptions { File = "dump.raven", OperateOnTypes = ItemType.Documents | ItemType.Indexes });
     #endregion
 }
开发者ID:jamesfarrer,项目名称:docs,代码行数:15,代码来源:Smuggler.cs

示例11: Sample

		public void Sample()
		{
			#region smuggler-api
			var smugglerOptions = new SmugglerOptions { };

			var connectionStringOptions = new RavenConnectionStringOptions
			{
				ApiKey = "ApiKey",
				Credentials = new NetworkCredential("username", "password", "domain"),
				DefaultDatabase = "database",
				Url = "http://localhost:8080",
			};

			var smugglerApi = new SmugglerApi(smugglerOptions, connectionStringOptions);
			smugglerApi.ExportData(null, new SmugglerOptions { BackupPath = "dump.raven", OperateOnTypes = ItemType.Documents | ItemType.Indexes | ItemType.Attachments | ItemType.Transformers }, incremental: false);
			smugglerApi.ImportData(new SmugglerOptions { BackupPath = "dump.raven", OperateOnTypes = ItemType.Documents | ItemType.Indexes });

			#endregion
		}
开发者ID:modulexcite,项目名称:docs-8,代码行数:19,代码来源:ExportImport.cs

示例12: SmugglerWithoutExcludeExpiredDocumentsShouldWork

        public void SmugglerWithoutExcludeExpiredDocumentsShouldWork()
        {
            var options = new SmugglerOptions
            {
                BackupPath = Path.GetTempFileName()
            };

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

                    var smuggler = new SmugglerApi(options, new RavenConnectionStringOptions { Url = store.Url });

                    smuggler.ExportData(null, options, false).Wait(TimeSpan.FromSeconds(15));
                }

                using (var store = NewRemoteDocumentStore())
                {
                    var smuggler = new SmugglerApi(options, new RavenConnectionStringOptions { Url = store.Url });

                    smuggler.ImportData(options).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(options.BackupPath);
            }
        }
开发者ID:925coder,项目名称:ravendb,代码行数:41,代码来源:RDBQA_11.cs

示例13: DateTimePreserved

        public void DateTimePreserved()
        {
            var options = new SmugglerOptions {BackupPath = 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 SmugglerApi(options, new RavenConnectionStringOptions() {Url = documentStore.Url});
                    smugglerApi.ExportData(null, options, false).Wait(TimeSpan.FromSeconds(15));
                }

                using (var documentStore = NewRemoteDocumentStore())
                {
                    var smugglerApi = new SmugglerApi(options, new RavenConnectionStringOptions() {Url = documentStore.Url});
                    smugglerApi.ImportData(options).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(options.BackupPath))
                {
                    File.Delete(options.BackupPath);
                }
            }
        }
开发者ID:925coder,项目名称:ravendb,代码行数:41,代码来源:SmugglerTests.cs

示例14: 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 SmugglerApi();
					smugglerApi.ExportData(new SmugglerExportOptions { ToFile = file, From = new RavenConnectionStringOptions { Url = documentStore.Url, DefaultDatabase = documentStore.DefaultDatabase } }).Wait(TimeSpan.FromSeconds(15));
                }

                using (var documentStore = NewRemoteDocumentStore())
                {
                    var smugglerApi = new SmugglerApi();
					smugglerApi.ImportData(new SmugglerImportOptions { 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:cocytus,项目名称:ravendb,代码行数:41,代码来源:SmugglerTests.cs

示例15: 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 SmugglerApi();

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


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