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


C# DatabaseDataDumper.ExportData方法代码示例

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


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

示例1: CanPerformDump_Dumper

        public async Task CanPerformDump_Dumper()
        {
            var backupPath = NewDataPath("BackupFolder");
            try
            {
                using (var store = NewDocumentStore())
                {
                    InsertUsers(store, 0, 2000);

                    var dumper = new DatabaseDataDumper(store.SystemDatabase) { Options = { Incremental = true } };
                    await dumper.ExportData(
                        new SmugglerExportOptions<RavenConnectionStringOptions>
                        {
                            ToFile = backupPath,
                        });
                }

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

示例2: MaxNumberOfItemsToProcessInSingleBatchShouldBeRespectedByDataDumper

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

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

                dumper.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = path }).ResultUnwrap();

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

                dumper = new DatabaseDataDumper(server.SystemDatabase, options: new SmugglerDatabaseOptions { BatchSize = 4321 });
				Assert.Equal(4321, dumper.Options.BatchSize);

                dumper.ImportData(new SmugglerImportOptions<RavenConnectionStringOptions> { FromFile = path }).Wait();

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

                dumper = new DatabaseDataDumper(server.SystemDatabase, options: new SmugglerDatabaseOptions { BatchSize = 1000 });
				Assert.Equal(1000, dumper.Options.BatchSize);

                dumper.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = path }).ResultUnwrap();

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

示例3: SmugglerTransformShouldRecognizeNumericPropertiesEvenThoughTheyHaveTheSameNames

		public async Task SmugglerTransformShouldRecognizeNumericPropertiesEvenThoughTheyHaveTheSameNames()
		{
			using (var stream = new MemoryStream())
			{
				var testObject = new RavenJObject
				{
					{"Range", new RavenJArray {new RavenJObject {{"Min", 2.4}}}},
					{"Min", 1}
				};

				using (var store = NewDocumentStore())
				{
					store.DatabaseCommands.Put("docs/1", null, testObject, new RavenJObject());

					var smuggler = new DatabaseDataDumper(store.DocumentDatabase, new SmugglerDatabaseOptions
					{
						TransformScript = EmptyTransform
					});

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

				stream.Position = 0;

				using (var store = NewDocumentStore())
				{
					var smuggler = new DatabaseDataDumper(store.DocumentDatabase, new SmugglerDatabaseOptions
					{
						TransformScript = EmptyTransform
					});

					await smuggler.ImportData(new SmugglerImportOptions<RavenConnectionStringOptions>
					{
						FromStream = stream,
						To = new EmbeddedRavenConnectionStringOptions
						{
							DefaultDatabase = store.DefaultDatabase
						}
					});

					var doc = store.DatabaseCommands.Get("docs/1").DataAsJson;
					Assert.NotNull(doc);
					Assert.Equal(testObject["Min"].Type, doc["Min"].Type);
					Assert.Equal(((RavenJObject)((RavenJArray)testObject["Range"])[0])["Min"].Type, ((RavenJObject)((RavenJArray)doc["Range"])[0])["Min"].Type);

					Assert.True(RavenJToken.DeepEquals(testObject, doc));
				}
			}
		}
开发者ID:GorelH,项目名称:ravendb,代码行数:56,代码来源:RavenDB_1733.cs

示例4: TimerCallback

		private void TimerCallback(bool fullBackup)
		{
		    if (currentTask != null)
				return;

            if (Database.Disposed)
            {
                Dispose();
                return;
            }

			// we have shared lock for both incremental and full backup.
			lock (this)
			{
				if (currentTask != null)
					return;
				currentTask = Task.Factory.StartNew(async () =>
				{
					var documentDatabase = Database;
					if (documentDatabase == null)
						return;
					using (LogContext.WithDatabase(documentDatabase.Name))
					{
						try
						{
							var dataDumper = new DatabaseDataDumper(documentDatabase);
							var localBackupConfigs = exportConfigs;
							var localBackupStatus = exportStatus;
							if (localBackupConfigs == null)
								return;

							if (fullBackup == false)
							{
								var currentEtags = dataDumper.Operations.FetchCurrentMaxEtags();
								// No-op if nothing has changed
								if (currentEtags.LastDocsEtag == localBackupStatus.LastDocsEtag &&
									currentEtags.LastAttachmentsEtag == localBackupStatus.LastAttachmentsEtag &&
									currentEtags.LastDocDeleteEtag == localBackupStatus.LastDocsDeletionEtag &&
									currentEtags.LastAttachmentsDeleteEtag == localBackupStatus.LastAttachmentDeletionEtag)
								{
									return;
								}
							}

							var backupPath = localBackupConfigs.LocalFolderName ??
											 Path.Combine(documentDatabase.Configuration.DataDirectory, "PeriodicExport-Temp");
							if (fullBackup)
							{
								// create filename for full dump
								backupPath = Path.Combine(backupPath, SystemTime.UtcNow.ToString("yyyy-MM-dd-HH-mm", CultureInfo.InvariantCulture) + ".ravendb-full-dump");
								if (File.Exists(backupPath))
								{
									var counter = 1;
									while (true)
									{
										backupPath = Path.Combine(Path.GetDirectoryName(backupPath), SystemTime.UtcNow.ToString("yyyy-MM-dd-HH-mm", CultureInfo.InvariantCulture) + " - " + counter + ".ravendb-full-dump");

										if (File.Exists(backupPath) == false)
											break;
										counter++;
									}
								}
							}

                            var smugglerOptions = dataDumper.Options;
							if (fullBackup == false)
							{
								smugglerOptions.StartDocsEtag = localBackupStatus.LastDocsEtag;
								smugglerOptions.StartAttachmentsEtag = localBackupStatus.LastAttachmentsEtag;
								smugglerOptions.StartDocsDeletionEtag = localBackupStatus.LastDocsDeletionEtag;
								smugglerOptions.StartAttachmentsDeletionEtag = localBackupStatus.LastAttachmentDeletionEtag;
								smugglerOptions.Incremental = true;
								smugglerOptions.ExportDeletions = true;
							}
                            var exportResult = await dataDumper.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = backupPath });

							if (fullBackup == false)
							{
								// No-op if nothing has changed
								if (exportResult.LastDocsEtag == localBackupStatus.LastDocsEtag &&
									exportResult.LastAttachmentsEtag == localBackupStatus.LastAttachmentsEtag &&
									exportResult.LastDocDeleteEtag == localBackupStatus.LastDocsDeletionEtag &&
									exportResult.LastAttachmentsDeleteEtag == localBackupStatus.LastAttachmentDeletionEtag)
								{
									logger.Info("Periodic export returned prematurely, nothing has changed since last export");
									return;
								}
							}

							try
							{
								if (!localBackupConfigs.Disabled)
								{
									UploadToServer(exportResult.FilePath, localBackupConfigs, fullBackup);
								}
							}
							finally
							{
								// if user did not specify local folder we delete temporary file.
								if (String.IsNullOrEmpty(localBackupConfigs.LocalFolderName))
//.........这里部分代码省略.........
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:101,代码来源:PeriodicBackupTask.cs

示例5: ExportDatabase

        public Task<HttpResponseMessage> ExportDatabase([FromBody]ExportData smugglerOptionsJson)
		{
            var requestString = smugglerOptionsJson.SmugglerOptions;
            SmugglerDatabaseOptions smugglerOptions;
      
            using (var jsonReader = new RavenJsonTextReader(new StringReader(requestString)))
			{
				var serializer = JsonExtensions.CreateDefaultJsonSerializer();
                smugglerOptions = (SmugglerDatabaseOptions)serializer.Deserialize(jsonReader, typeof(SmugglerDatabaseOptions));
			}

            var result = GetEmptyMessage();
            
            // create PushStreamContent object that will be called when the output stream will be ready.
			result.Content = new PushStreamContent(async (outputStream, content, arg3) =>
			{
			    try
			    {
				    var dataDumper = new DatabaseDataDumper(Database, smugglerOptions);
				    await dataDumper.ExportData(
					    new SmugglerExportOptions<RavenConnectionStringOptions>
					    {
						    ToStream = outputStream
					    }).ConfigureAwait(false);
			    }
			    finally
			    {
			        outputStream.Close();
			    }
			});
		    
            var fileName = String.IsNullOrEmpty(smugglerOptions.NoneDefualtFileName) || (smugglerOptions.NoneDefualtFileName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) ? 
		        string.Format("Dump of {0}, {1}", DatabaseName, DateTime.Now.ToString("yyyy-MM-dd HH-mm", CultureInfo.InvariantCulture)) :
		        smugglerOptions.NoneDefualtFileName;
            result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
            {
                FileName = fileName + ".ravendump"
            };
			
			return new CompletedTask<HttpResponseMessage>(result);
		}
开发者ID:jrusbatch,项目名称:ravendb,代码行数:41,代码来源:StudioTasksController.cs

示例6: SmugglerTransformShouldWorkForDatabaseDataDumper

        public async Task SmugglerTransformShouldWorkForDatabaseDataDumper()
        {
            var path = NewDataPath(forceCreateDir: true);
            var backupPath = Path.Combine(path, "backup.dump");

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

                    session.SaveChanges();
                }
                var smugglerApi = new DatabaseDataDumper(store.DocumentDatabase);
                smugglerApi.Options.TransformScript =
                    @"function(doc) { 
                        var id = doc['@metadata']['@id']; 
                        if(id === 'foos/1')
                            return null;
                        return doc;
                    }";
                await smugglerApi.ExportData(
                    new SmugglerExportOptions<RavenConnectionStringOptions>
                    {
                        ToFile = backupPath,
                        From = new EmbeddedRavenConnectionStringOptions
                        {
                            DefaultDatabase = store.DefaultDatabase
                        }
                    });
            }

            using (var documentStore = NewDocumentStore())
            {
                var smugglerApi = new DatabaseDataDumper(documentStore.DocumentDatabase);
                smugglerApi.Options.TransformScript =
                    @"function(doc) { 
                        var id = doc['@metadata']['@id']; 
                        if(id === 'foos/1')
                            return null;
                        return doc;
                    }";
                await smugglerApi.ImportData(
                    new SmugglerImportOptions<RavenConnectionStringOptions>
                    {
                        FromFile = backupPath,
                        To = new EmbeddedRavenConnectionStringOptions
                        {
                            DefaultDatabase = documentStore.DefaultDatabase
                        }
                    });

                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);

                    Assert.Null(session.Load<Foo>(1));
                }
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:67,代码来源:SmugglerIdentitiesTests.cs

示例7: SmugglerCanStripReplicationInformationDuringImport_Embedded

        public void SmugglerCanStripReplicationInformationDuringImport_Embedded()
        {
            using (var stream = new MemoryStream())
            {
                using (var store = NewDocumentStore(activeBundles: "Replication"))
                {
                    var commands = store.DatabaseCommands;
                    commands.Put("keys/1", null, new RavenJObject(), new RavenJObject());
                    var doc = commands.Get("keys/1");
                    Assert.True(doc.Metadata.ContainsKey(Constants.RavenReplicationSource));
                    Assert.True(doc.Metadata.ContainsKey(Constants.RavenReplicationVersion));

                    commands.PutAttachment("keys/1", null, new MemoryStream(), new RavenJObject());
                    var attachment = commands.GetAttachment("keys/1");
                    Assert.True(attachment.Metadata.ContainsKey(Constants.RavenReplicationSource));
                    Assert.True(attachment.Metadata.ContainsKey(Constants.RavenReplicationVersion));

                    var smuggler = new DatabaseDataDumper(store.DocumentDatabase, new SmugglerDatabaseOptions { StripReplicationInformation = true });
                    smuggler.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToStream = stream, From = new RavenConnectionStringOptions { DefaultDatabase = store.DefaultDatabase } }).Wait(TimeSpan.FromSeconds(15));
                }

                stream.Position = 0;

                using (var store = NewDocumentStore())
                {
                    var smuggler = new DatabaseDataDumper(store.DocumentDatabase, new SmugglerDatabaseOptions { StripReplicationInformation = true });
                    smuggler.ImportData(new SmugglerImportOptions<RavenConnectionStringOptions>
                    {
                        FromStream = stream,
                        To = new RavenConnectionStringOptions
                        {
                            DefaultDatabase = store.DefaultDatabase,
                        }
                    }).Wait(TimeSpan.FromSeconds(15));

                    var commands = store.DatabaseCommands;
                    var doc = commands.Get("keys/1");
                    Assert.False(doc.Metadata.ContainsKey(Constants.RavenReplicationSource));
                    Assert.False(doc.Metadata.ContainsKey(Constants.RavenReplicationVersion));
                    var attachment = commands.GetAttachment("keys/1");
                    Assert.False(attachment.Metadata.ContainsKey(Constants.RavenReplicationSource));
                    Assert.False(attachment.Metadata.ContainsKey(Constants.RavenReplicationVersion));
                }

                stream.Position = 0;

                using (var store = NewDocumentStore(activeBundles: "Replication"))
                {
                    var smuggler = new DatabaseDataDumper(store.DocumentDatabase, new SmugglerDatabaseOptions { StripReplicationInformation = true });
                    smuggler.ImportData(new SmugglerImportOptions<RavenConnectionStringOptions>
                    {
                        FromStream = stream,
                        To = new RavenConnectionStringOptions
                        {
                            DefaultDatabase = store.DefaultDatabase,
                        }
                    }).Wait(TimeSpan.FromSeconds(15));

                    var commands = store.DatabaseCommands;
                    var doc = commands.Get("keys/1");
                    Assert.True(doc.Metadata.ContainsKey(Constants.RavenReplicationSource));
                    Assert.True(doc.Metadata.ContainsKey(Constants.RavenReplicationVersion));
                    var attachment = commands.GetAttachment("keys/1");
                    Assert.True(attachment.Metadata.ContainsKey(Constants.RavenReplicationSource));
                    Assert.True(attachment.Metadata.ContainsKey(Constants.RavenReplicationVersion));
                }
            }

        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:69,代码来源:SmugglerIdentitiesTests.cs

示例8: CanDumpAttachmentsEmpty_Dumper

        public async Task CanDumpAttachmentsEmpty_Dumper()
        {
            var backupPath = NewDataPath("BackupFolder");
            try
            {
                using (var store = NewDocumentStore())
                {
                    var dumper = new DatabaseDataDumper(store.SystemDatabase) { Options = { Incremental = true, BatchSize = 100, Limit = 206 } };
                    await dumper.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = backupPath });
                }

                VerifyDump(backupPath, store => Assert.Equal(0, store.DatabaseCommands.GetAttachmentHeadersStartingWith("user", 0, 500).Count()));
            }
            finally
            {
                IOExtensions.DeleteDirectory(backupPath);
            }            
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:18,代码来源:RavenDB_1603.cs

示例9: CanDumpWhenHiddenDocsWithLimit_Dumper

        public async Task CanDumpWhenHiddenDocsWithLimit_Dumper()
        {
            var backupPath = NewDataPath("BackupFolder");
            using (var server = GetNewServer())
            {
                using (var store = new DocumentStore { Url = "http://localhost:8079" }.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 DatabaseDataDumper(server.SystemDatabase) { Options = { Incremental = true } };
                    await dumper.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = backupPath });
                }
            }

            VerifyDump(backupPath, store =>
            {
                using (var session = store.OpenSession())
                {
                    Assert.Equal(25, session.Query<User>().Customize(x => x.WaitForNonStaleResultsAsOfNow()).Count());
                }
            });

            IOExtensions.DeleteDirectory(backupPath);
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:30,代码来源:RavenDB_1603.cs

示例10: CanDumpEmptyDatabase_Dumper

        public async Task CanDumpEmptyDatabase_Dumper()
        {
            var backupPath = NewDataPath("BackupFolder");
            try
            {
                using (var server = GetNewServer(databaseName: Constants.SystemDatabase))
                {
                    using (new DocumentStore { Url = "http://localhost:8079" }.Initialize())
                    {
                        // now perform full backup
                        var dumper = new DatabaseDataDumper(server.SystemDatabase) { Options = { Incremental = true } };
                        await dumper.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = backupPath });
                    }
                }

                VerifyDump(backupPath, store => Assert.Equal(0, store.SystemDatabase.Documents.GetDocumentsAsJson(0, int.MaxValue, null, CancellationToken.None).Count()));
            }
            finally 
            {
                IOExtensions.DeleteDirectory(backupPath);
            }            
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:22,代码来源:RavenDB_1603.cs

示例11: CanPerformDumpWithLimitAndFilter_Dumper

        public async Task CanPerformDumpWithLimitAndFilter_Dumper()
        {
            var backupPath = NewDataPath("BackupFolder");
            try
            {
                using (var store = NewDocumentStore())
                {
                    var counter = 0;
                    counter = InsertUsers(store, counter, 1000);
                    counter = InsertDevelopers(store, counter, 2);
                    counter = InsertUsers(store, counter, 1000);
                    InsertDevelopers(store, counter, 2);

                    WaitForIndexing(store);

                    var dumper = new DatabaseDataDumper(store.SystemDatabase) { Options = { Limit = 5, Incremental = true } };
                    dumper.Options.Filters.Add(
                        new FilterSetting
                        {
                            Path = "@metadata.Raven-Entity-Name",
                            Values = {"Developers"},
                            ShouldMatch = true,
                        });
                    await dumper.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = backupPath });
                }

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

示例12: can_export_all_documents

        public async Task can_export_all_documents()
        {
            var backupPath = NewDataPath("BackupFolder");
            try
            {
                using (var store = NewDocumentStore())
                {
                    for (var i = 0; i < 1000; i++)
                    {
                        store.DatabaseCommands.Put("users/" + (i + 1), null, new RavenJObject()
                        {
                            { "Name", "test #" + i }
                        }, new RavenJObject()
                        {
                            { Constants.RavenEntityName, "Users"}
                        });
                    }

                    var task1 = Task.Run(async () =>
                    {
                        // now perform full backup
                        var dumper = new DatabaseDataDumper(store.SystemDatabase)
                        {
                            Options =
                            {
                                BatchSize = 10,
                                Incremental = true
                            }
                        };
                        await dumper.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> {ToFile = backupPath});
                    });
                    var task2 = Task.Run(() =>
                    {
                        // change the one document, this document should be exported (any version of it)
                        for (var i = 0; i < 100; i++)
                        {
                            using (var session = store.OpenSession())
                            {
                                var user = session.Load<User>("users/1000");
                                user.Name = "test" + i;
                                session.SaveChanges();
                            }
                        }
                    });

                    await Task.WhenAll(task1, task2);
                }

                using (var embeddableStore = NewDocumentStore())
                {
                    // import all the data
                    var dumper = new DatabaseDataDumper(embeddableStore.SystemDatabase) { Options = { Incremental = true } };
                    dumper.ImportData(new SmugglerImportOptions<RavenConnectionStringOptions> { FromFile = backupPath }).Wait();

                    using (var session = embeddableStore.OpenSession())
                    {
                        var user = session.Load<User>("users/1000");
                        //the document should exist in the export (any version of it)
                        Assert.NotNull(user);

                        var list = session.Query<User>()
                            .Customize(x => x.WaitForNonStaleResultsAsOfNow())
                            .Take(1024)
                            .ToList();
                        Assert.Equal(1000, list.Count);
                    }

                    var stats = embeddableStore.DatabaseCommands.GetStatistics();
                    Assert.Equal(1000, stats.CountOfDocuments);
                }
            }
            finally
            {
                IOExtensions.DeleteDirectory(backupPath);
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:76,代码来源:RavenDB-4085.cs

示例13: can_export_all_attachments

        public async Task can_export_all_attachments()
        {
            var backupPath = NewDataPath("BackupFolder");
            try
            {
                using (var store = NewDocumentStore())
                {
                    for (var i = 0; i < 1000; i++)
                    {
                        store.DatabaseCommands.PutAttachment(
                            "attachments/" + (i + 1),
                            null,
                            new MemoryStream(new[] { (byte)i }),
                            new RavenJObject());
                    }

                    var task1 = Task.Run(async () =>
                    {
                        // now perform full backup
                        var dumper = new DatabaseDataDumper(store.SystemDatabase)
                        {
                            Options =
                            {
                                BatchSize = 10,
                                Incremental = true
                            }
                        };
                        await dumper.ExportData(new SmugglerExportOptions<RavenConnectionStringOptions> { ToFile = backupPath });
                    });
                    var task2 = Task.Run(() =>
                    {
                        // change the one document, this document should be exported (any version of it)
                        for (var i = 0; i < 100; i++)
                        {
                            store.DatabaseCommands.PutAttachment(
                                "attachments/1000", 
                                null,
                                new MemoryStream(new[] { (byte)i }), 
                                new RavenJObject());
                        }
                    });

                    await Task.WhenAll(task1, task2);
                }

                using (var embeddableStore = NewDocumentStore())
                {
                    // import all the data
                    var dumper = new DatabaseDataDumper(embeddableStore.SystemDatabase) { Options = { Incremental = true } };
                    dumper.ImportData(new SmugglerImportOptions<RavenConnectionStringOptions> { FromFile = backupPath }).Wait();

                    var attachemnt = embeddableStore.DatabaseCommands.GetAttachment("attachments/1000");
                    Assert.NotNull(attachemnt);

                    var attachments = embeddableStore.DatabaseCommands.GetAttachments(0, Etag.Empty, 1024).ToList();
                    Assert.Equal(1000, attachments.Count);

                    var stats = embeddableStore.DatabaseCommands.GetStatistics();
                    Assert.Equal(1000, stats.CountOfAttachments);
                }
            }
            finally
            {
                IOExtensions.DeleteDirectory(backupPath);
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:66,代码来源:RavenDB-4085.cs

示例14: CanDisableVersioningDuringImport_Embedded

		public async Task CanDisableVersioningDuringImport_Embedded()
		{
			using (var stream = new MemoryStream())
			{
				long countOfDocuments;
				using (var store = NewDocumentStore())
				{
					using (var session = store.OpenSession())
					{
						for (int i = 0; i < 10; i++)
						{
							session.Store(new User());
							session.Store(new Address());
						}

						session.SaveChanges();
					}

					countOfDocuments = store.DatabaseCommands.GetStatistics().CountOfDocuments;

					var smuggler = new DatabaseDataDumper(store.DocumentDatabase, new SmugglerDatabaseOptions());

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

				stream.Position = 0;

				using (var store = NewDocumentStore(activeBundles: "Versioning"))
				{
					using (var session = store.OpenSession())
					{
						session.Store(new Bundles.Versioning.Data.VersioningConfiguration
						{
							Exclude = false,
							Id = "Raven/Versioning/DefaultConfiguration",
							MaxRevisions = 5
						});

						session.SaveChanges();
					}

					var smuggler = new DatabaseDataDumper(store.DocumentDatabase, new SmugglerDatabaseOptions
					{
						ShouldDisableVersioningBundle = true
					});

					await smuggler.ImportData(new SmugglerImportOptions<RavenConnectionStringOptions>()
					{
						FromStream = stream,
						To = new RavenConnectionStringOptions()
						{
							DefaultDatabase = store.DefaultDatabase
						}
					});

					var countOfDocsAfterImport = store.DatabaseCommands.GetStatistics().CountOfDocuments;

					Assert.Equal(countOfDocuments, countOfDocsAfterImport - 1); // one additional doc for versioning bundle configuration

					var metadata = store.DatabaseCommands.Get("users/1").Metadata;

					Assert.True(metadata.ContainsKey(Constants.RavenIgnoreVersioning) == false, "Metadata contains temporary " + Constants.RavenIgnoreVersioning + " marker");

					// after import versioning should be active
					using (var session = store.OpenSession())
					{
						session.Store(new User(), "users/arek");

						session.SaveChanges();

						var revisionsFor = session.Advanced.GetRevisionsFor<User>("users/arek", 0, 10);

						Assert.Equal(1, revisionsFor.Length);
					}
				}
			}
		}
开发者ID:GorelH,项目名称:ravendb,代码行数:84,代码来源:SmugglerWithDisabledVersioning_RavenDB_3219.cs

示例15: Sample3

		public async void Sample3()
		{
			#region smuggler_api_4
			using (EmbeddableDocumentStore store = new EmbeddableDocumentStore
								   {
									   DefaultDatabase = "Northwind"
								   })
			{
				store.Initialize();

				var dataDumper = new DatabaseDataDumper(
					store.DocumentDatabase,
					new SmugglerDatabaseOptions
					{
						OperateOnTypes = ItemType.Documents | ItemType.Indexes | ItemType.Attachments | ItemType.Transformers,
						Incremental = false
					});

				SmugglerExportOptions<RavenConnectionStringOptions> exportOptions = new SmugglerExportOptions<RavenConnectionStringOptions>
				{
					From = new EmbeddedRavenConnectionStringOptions(),
					ToFile = "dump.raven"
				};

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


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