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


C# Smuggler.SmugglerOptions类代码示例

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


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

示例1: SmugglerApi

		public SmugglerApi(SmugglerOptions smugglerOptions, IAsyncDatabaseCommands commands, Action<string> output)
			: base(smugglerOptions)
		{
			this.commands = commands;
			this.output = output;
			batch = new List<RavenJObject>();
		}
开发者ID:robashton,项目名称:ravendb,代码行数:7,代码来源:SmugglerApi.cs

示例2: RunImplementation

        protected async override Task<DatabaseTaskOutcome> RunImplementation()
        {
            var statistics = await DatabaseCommands.GetStatisticsAsync();
            if (statistics.CountOfDocuments > 0)
            {
                ReportError("Database already contains documents");
                return DatabaseTaskOutcome.Error;
            }

            Report("Creating Sample Data, Please wait...");

            // this code assumes a small enough dataset, and doesn't do any sort
            // of paging or batching whatsoever.

            using (var sampleData = typeof(CreateSampleDataTask).Assembly.GetManifestResourceStream("Raven.Studio.Assets.EmbeddedData.Northwind.dump"))
            {
                Report("Reading documents");

                var smugglerOptions = new SmugglerOptions
                {
                    OperateOnTypes = ItemType.Documents | ItemType.Indexes | ItemType.Transformers,
                    ShouldExcludeExpired = false,
                };
                var smuggler = new SmugglerApi(smugglerOptions, DatabaseCommands, s => Report(s));

                await smuggler.ImportData(sampleData, smugglerOptions);
            }

            return DatabaseTaskOutcome.Succesful;
        }
开发者ID:925coder,项目名称:ravendb,代码行数:30,代码来源:CreateSampleDataTask.cs

示例3: CanSaveImplicitChangesToDocumentsFromAQuery_UsingDunpFile

        public void CanSaveImplicitChangesToDocumentsFromAQuery_UsingDunpFile()
        {
            using (var store = NewDocumentStore())
            {
                store.Conventions.FindTypeTagName = FindTypeByTagName;

                var options = new SmugglerOptions
                {
                    BackupPath = @"Dump of test-concurrency-exception2, 21 May 2013 14-36.ravendump"
                };

                var dumper = new DataDumper(store.DocumentDatabase, options);
                dumper.ImportData(options);

                using (var session = store.OpenSession())
                {
                    session.Advanced.UseOptimisticConcurrency = true;
                    var foos =
                        session.Query<SectionData>()
                               .Customize(x => x.WaitForNonStaleResults())
                               .Take(1024)
                               .ToList();

                    Assert.True(foos.Count > 200);
                    session.SaveChanges();
                }
            }
        }
开发者ID:kijanawoodard,项目名称:RavenTests,代码行数:28,代码来源:ConcurrencyTests.cs

示例4: CanGetCorrectResult

		public void CanGetCorrectResult()
		{
			using (var store = NewDocumentStore())
			{
				var smugglerOptions = new SmugglerOptions();
				var dataDumper = new DataDumper(store.DocumentDatabase, smugglerOptions);
				using (var stream = typeof(TroyMapReduceImport).Assembly.GetManifestResourceStream("Raven.Tests.Patching.failingdump11.ravendump"))
				{
					dataDumper.ImportData(stream, smugglerOptions).Wait(TimeSpan.FromSeconds(15));
				}

				
				using (var s = store.OpenSession())
				{
					s.Advanced.LuceneQuery<object>("Raven/DocumentsByEntityName").WaitForNonStaleResults().ToList();

					store.DatabaseCommands.UpdateByIndex("Raven/DocumentsByEntityName", new IndexQuery {Query = "Tag:Regions"},
					                                     new ScriptedPatchRequest
					                                     {
						                                     Script = @"this.Test = 'test';"
					                                     }
					                                     , true);
				}
			}
		}
开发者ID:925coder,项目名称:ravendb,代码行数:25,代码来源:BigDoc.cs

示例5: ExportDeletions

        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonWriter"></param>
        /// <param name="options"></param>
        /// <param name="result"></param>
        /// <param name="maxEtags">Max etags are inclusive</param>
        protected async override void ExportDeletions(JsonTextWriter jsonWriter, SmugglerOptions options, ExportDataResult result, LastEtagsInfo maxEtags)
        {
            jsonWriter.WritePropertyName("DocsDeletions");
            jsonWriter.WriteStartArray();
            result.LastDocDeleteEtag = await ExportDocumentsDeletion(options, jsonWriter, result.LastDocDeleteEtag, maxEtags.LastDocDeleteEtag.IncrementBy(1));
            jsonWriter.WriteEndArray();

            jsonWriter.WritePropertyName("AttachmentsDeletions");
            jsonWriter.WriteStartArray();
            result.LastAttachmentsDeleteEtag = await ExportAttachmentsDeletion(options, jsonWriter, result.LastAttachmentsDeleteEtag, maxEtags.LastAttachmentsDeleteEtag.IncrementBy(1));
            jsonWriter.WriteEndArray();
        }
开发者ID:randacc,项目名称:ravendb,代码行数:19,代码来源:DataDumper.cs

示例6: Initialize

		public void Initialize(SmugglerOptions options)
		{
			if (options == null || string.IsNullOrEmpty(options.TransformScript))
				return;

			jint = new Engine(cfg =>
			{
				cfg.AllowDebuggerStatement(false);
				cfg.MaxStatements(options.MaxStepsForTransformScript);
			});

			jint.Execute(string.Format(@"
					function Transform(docInner){{
						return ({0}).apply(this, [docInner]);
					}};", options.TransformScript));
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:16,代码来源:SmugglerJintHelper.cs

示例7: Initialize

		public void Initialize(SmugglerOptions options)
		{
		    if (options == null || string.IsNullOrEmpty(options.TransformScript))
		        return;

		    jint = new JintEngine()
		        .AllowClr(false)
		        .SetDebugMode(false)
		        .SetMaxRecursions(50)
		        .SetMaxSteps(options.MaxStepsForTransformScript);

		    jint.Run(string.Format(@"
					function Transform(docInner){{
						return ({0}).apply(this, [docInner]);
					}};", options.TransformScript));
		}
开发者ID:Nakro,项目名称:ravendb,代码行数:16,代码来源:SmugglerJintHelper.cs

示例8: Initialize

		public static void Initialize(SmugglerOptions options)
		{
			if (options != null && !string.IsNullOrEmpty(options.TransformScript))
			{
				jint = new JintEngine()
					.AllowClr(false)
					.SetDebugMode(false)
					.SetMaxRecursions(50)
					.SetMaxSteps(options.MaxStepsForTransformScript);

				jint.Run(string.Format(@"
					function Transform(docInner){{
						return ({0}).apply(this, [docInner]);
					}};", options.TransformScript));
			}

			propertiesTypeByName = new Dictionary<string, JTokenType>();
		}
开发者ID:KyleGobel,项目名称:ravendb,代码行数:18,代码来源:SmugglerJintHelper.cs

示例9: ImportDatabase

		public async Task<HttpResponseMessage> ImportDatabase(int batchSize, bool includeExpiredDocuments, ItemType operateOnTypes, string filtersPipeDelimited, string transformScript)
		{
            if (!this.Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            var streamProvider = new MultipartMemoryStreamProvider();
            await Request.Content.ReadAsMultipartAsync(streamProvider);
            var fileStream = await streamProvider.Contents
                .First(c => c.Headers.ContentDisposition.Name == "\"file\"")
                .ReadAsStreamAsync();

            var dataDumper = new DataDumper(Database);
            var importOptions = new SmugglerImportOptions
            {
                FromStream = fileStream
            };
            var options = new SmugglerOptions
            {
                BatchSize = batchSize,
                ShouldExcludeExpired = includeExpiredDocuments,
                OperateOnTypes = operateOnTypes,
                TransformScript = transformScript
            };

            // Filters are passed in without the aid of the model binder. Instead, we pass in a list of FilterSettings using a string like this: pathHere;;;valueHere;;;true|||againPathHere;;;anotherValue;;;false
            // Why? Because I don't see a way to pass a list of a values to a WebAPI method that accepts a file upload, outside of passing in a simple string value and parsing it ourselves.
            if (filtersPipeDelimited != null)
            {
                options.Filters.AddRange(filtersPipeDelimited
                    .Split(new string[] { "|||" }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(f => f.Split(new string[] { ";;;" }, StringSplitOptions.RemoveEmptyEntries))
                    .Select(o => new FilterSetting
                    {
                        Path = o[0],
                        Values = new List<string> { o[1] },
                        ShouldMatch = bool.Parse(o[2])
                    }));
            }

            await dataDumper.ImportData(importOptions, options);
            return GetEmptyMessage();
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:44,代码来源:StudioTasksController.cs

示例10: ImportDatabase

		public async Task<HttpResponseMessage> ImportDatabase()
		{
            if (!this.Request.Content.IsMimeMultipartContent()) 
            { 
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); 
            }

            var streamProvider = new MultipartMemoryStreamProvider();
            await Request.Content.ReadAsMultipartAsync(streamProvider);
            var fileStream = await streamProvider.Contents.First().ReadAsStreamAsync();
			var dataDumper = new DataDumper(Database);
            var importOptions = new SmugglerImportOptions
			{
                FromStream = fileStream
			};
            var options = new SmugglerOptions();
			await dataDumper.ImportData(importOptions, options);
            return GetEmptyMessage();
		}
开发者ID:paulcbetts,项目名称:ravendb,代码行数:19,代码来源:StudioTasksController.cs

示例11: ExportDatabase

		public async Task<HttpResponseMessage> ExportDatabase(SmugglerOptionsDto dto)
		{
			var smugglerOptions = new SmugglerOptions();
			// smugglerOptions.OperateOnTypes = ;

			var result = GetEmptyMessage();
			result.Content = new PushStreamContent(async (outputStream, content, arg3) =>
			{
				{
					
				};
				await new DataDumper(Database).ExportData(new SmugglerExportOptions
				{
					ToStream = outputStream
				}, smugglerOptions);
			});
			
			return result;
		}
开发者ID:randacc,项目名称:ravendb,代码行数:19,代码来源:StudioTasksController.cs

示例12: ShouldTakeUnder30Minutes

		public void ShouldTakeUnder30Minutes()
		{
			var sw = Stopwatch.StartNew();
			var smugglerOptions = new SmugglerOptions();

			using (var store = NewDocumentStore())
			{
				using (var stream = typeof(LoadBigFile).Assembly.GetManifestResourceStream("Raven.StressTests.Load.LoadBigFile.dump"))
				{
					var dataDumper = new DataDumper(store.DocumentDatabase, smugglerOptions)
					{
						Progress = Console.WriteLine
					};
					dataDumper.ImportData(stream, smugglerOptions);
				}
			}
			sw.Stop();

			Assert.True(sw.Elapsed < TimeSpan.FromMinutes(30), string.Format("Test should run under 30 minutes, but run {0} minutes.", sw.Elapsed.TotalMinutes));
		}
开发者ID:925coder,项目名称:ravendb,代码行数:20,代码来源:LoadBigFile.cs

示例13: CanGetCorrectResult

		public void CanGetCorrectResult()
		{
			using (var store = NewDocumentStore())
			{
				var smugglerOptions = new SmugglerOptions();
				var dataDumper = new DataDumper(store.DocumentDatabase, smugglerOptions);
				using (var stream = typeof(TroyMapReduceImport).Assembly.GetManifestResourceStream("Raven.Tests.MailingList.Sandbox.ravendump"))
				{
					dataDumper.ImportData(stream, smugglerOptions).Wait();
				}

				using(var s = store.OpenSession())
				{
					var objects = s.Query<object>("LogEntry/CountByDate")
						.Customize(x => x.WaitForNonStaleResults())
						.ToList();
					Assert.Equal(4, objects.Count);
				}
			}
		}
开发者ID:925coder,项目名称:ravendb,代码行数:20,代码来源:TroyMapReduceImport.cs

示例14: CanBackupToDirectory

		public void CanBackupToDirectory()
		{
			var backupPath = GetPath("BackupFolder");
			using (var store = NewDocumentStore())
			{
				Etag etagForBackups;
				using (var session = store.OpenSession())
				{
					session.Store(new User { Name = "oren" });
					var periodicBackupSetup = new PeriodicBackupSetup
					{
						LocalFolderName = backupPath,
						IntervalMilliseconds = 25
					};
					session.Store(periodicBackupSetup, PeriodicBackupSetup.RavenDocumentKey);

					session.SaveChanges();

					etagForBackups = session.Advanced.GetEtagFor(periodicBackupSetup);
				}
				SpinWait.SpinUntil(() =>
					 store.DatabaseCommands.Get(PeriodicBackupSetup.RavenDocumentKey).Etag != etagForBackups);

			}

			using (var store = NewDocumentStore())
			{
				var smugglerOptions = new SmugglerOptions
				{
					BackupPath = backupPath
				};
				var dataDumper = new DataDumper(store.DocumentDatabase, smugglerOptions);
				dataDumper.ImportData(smugglerOptions, true);

				using (var session = store.OpenSession())
				{
					Assert.Equal("oren", session.Load<User>(1).Name);
				}
			}
			IOExtensions.DeleteDirectory(backupPath);
		}
开发者ID:samueldjack,项目名称:ravendb,代码行数:41,代码来源:PeriodicBackupTests.cs

示例15: CreateSampleData

		public async Task<HttpResponseMessage> CreateSampleData()
		{
			var results = Database.Queries.Query(Constants.DocumentsByEntityNameIndex, new IndexQuery(), CancellationToken.None);
			if (results.Results.Count > 0)
			{
				return GetMessageWithString("You cannot create sample data in a database that already contains documents", HttpStatusCode.BadRequest);
			}

			using (var sampleData = typeof(StudioTasksController).Assembly.GetManifestResourceStream("Raven.Database.Server.Assets.EmbeddedData.Northwind.dump"))
			{
				var smugglerOptions = new SmugglerOptions
				{
					OperateOnTypes = ItemType.Documents | ItemType.Indexes | ItemType.Transformers,
					ShouldExcludeExpired = false,
				};
				var dataDumper = new DataDumper(Database);
				await dataDumper.ImportData(new SmugglerImportOptions {FromStream = sampleData}, smugglerOptions);
			}

			return GetEmptyMessage();
		}
开发者ID:randacc,项目名称:ravendb,代码行数:21,代码来源:StudioTasksController.cs


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