本文整理汇总了C#中Raven.Smuggler.SmugglerApi.ExportData方法的典型用法代码示例。如果您正苦于以下问题:C# SmugglerApi.ExportData方法的具体用法?C# SmugglerApi.ExportData怎么用?C# SmugglerApi.ExportData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Raven.Smuggler.SmugglerApi
的用法示例。
在下文中一共展示了SmugglerApi.ExportData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: 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);
}
}
示例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);
}
}
示例5: 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:"));
}
示例6: 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);
}
}
}
示例7: 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);
}
示例8: 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);
}
}
示例9: 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
}
示例10: 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
}
示例11: 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);
}
}
示例12: 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);
}
}
}
示例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);
}
}
}
示例14: 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);
}
}
示例15: SmugglerWithoutExcludeExpiredDocumentsShouldWork
public void SmugglerWithoutExcludeExpiredDocumentsShouldWork()
{
var path = Path.GetTempFileName();
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 } }, new SmugglerOptions()).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 } }, new SmugglerOptions()).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);
}
}