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


C# IAsyncDatabaseCommands类代码示例

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


IAsyncDatabaseCommands类属于命名空间,在下文中一共展示了IAsyncDatabaseCommands类的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: GenerateDocumentKeyAsync

		public Task<string> GenerateDocumentKeyAsync(IAsyncDatabaseCommands databaseCommands, DocumentConvention conventions, object entity)
		{
			var shardId = shardedDocumentStore.ShardStrategy.ShardResolutionStrategy.MetadataShardIdFor(entity);
			if (shardId == null)
				throw new InvalidOperationException(string.Format(
					"ShardResolutionStrategy.MetadataShardIdFor cannot return null. You must specify where to store the metadata documents for the entity type '{0}'.", entity.GetType().FullName));

			AsyncMultiTypeHiLoKeyGenerator value;
			if (generatorsByShard.TryGetValue(shardId, out value))
				return value.GenerateDocumentKeyAsync(databaseCommands, conventions, entity);

			lock (this)
			{
				if (generatorsByShard.TryGetValue(shardId, out value) == false)
				{
					value = new AsyncMultiTypeHiLoKeyGenerator(capacity);
					generatorsByShard = new Dictionary<string, AsyncMultiTypeHiLoKeyGenerator>(generatorsByShard)
					                    	{
					                    		{shardId, value}
					                    	};
				}
			}

			return value.GenerateDocumentKeyAsync(databaseCommands, conventions, entity);
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:25,代码来源:AsyncShardedHiloKeyGenerator.cs

示例3: DatabaseTask

 public DatabaseTask(IAsyncDatabaseCommands databaseCommands, string taskName, string databaseName)
 {
     this.databaseCommands = databaseCommands;
     this.taskName = taskName;
     this.databaseName = databaseName;
     OutputItems = new ObservableCollection<DatabaseTaskOutput>();
 }
开发者ID:nzaugg,项目名称:ravendb,代码行数:7,代码来源:DatabaseTask.cs

示例4: CreateIndexesAsync

		/// <summary>
		/// Creates the indexes found in the specified catalog
		/// </summary>
		public static Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IAsyncDatabaseCommands asyncDatabaseCommands, DocumentConvention conventions)
		{
			var tasks = catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>();

			Task[] array = tasks.Select(task => task.ExecuteAsync(asyncDatabaseCommands, conventions)).ToArray();
			var indexesAsync = new Task(() => Task.WaitAll(array));
			indexesAsync.Start();
			return indexesAsync;
		}
开发者ID:neiz,项目名称:ravendb,代码行数:12,代码来源:IndexCreation.cs

示例5: DatabaseModel

        public DatabaseModel(string name, IAsyncDatabaseCommands asyncDatabaseCommands)
        {
            Name = name;
            this.asyncDatabaseCommands = asyncDatabaseCommands;

            Statistics = new Observable<DatabaseStatistics>();
            Collections = new DatabaseCollectionsModel(asyncDatabaseCommands);
            RecentDocuments = new BindableCollection<ViewableDocument>(new PrimaryKeyComparer<ViewableDocument>(document => document.Id));
            RecentDocuments = new BindableCollection<ViewableDocument>(new PrimaryKeyComparer<ViewableDocument>(document=>document.Id));
        }
开发者ID:samueldjack,项目名称:studio,代码行数:10,代码来源:DatabaseModel.cs

示例6: ImportImpl

			public ImportImpl(StreamReader reader, string file, TaskModel taskModel, Action<string> output, IAsyncDatabaseCommands databaseCommands)
			{
				this.taskModel = taskModel;
				this.output = output;
				this.databaseCommands = databaseCommands;
				csvReader = new CsvReader(reader);
				header = csvReader.ReadHeaderRecord();
				entity = Path.GetFileNameWithoutExtension(file);
				sw = Stopwatch.StartNew();

				enumerator = csvReader.DataRecords.GetEnumerator();
			}
开发者ID:Trebornide,项目名称:ravendb,代码行数:12,代码来源:CsvImportCommand.cs

示例7: ExportDatabaseTask

 public ExportDatabaseTask(IAsyncDatabaseCommands databaseCommands, string databaseName, bool includeAttachements, bool includeDocuments, bool includeIndexes,
                           bool includeTransformers, bool shouldExcludeExpired, int batchSize, string transformScript, List<FilterSetting> filterSettings) : base(databaseCommands, databaseName, "Export Database")
 {
     this.includeAttachements = includeAttachements;
     this.includeDocuments = includeDocuments;
     this.includeIndexes = includeIndexes;
     this.includeTransformers = includeTransformers;
     this.shouldExcludeExpired = shouldExcludeExpired;
     this.batchSize = batchSize;
     this.transformScript = transformScript;
     this.filterSettings = filterSettings;
 }
开发者ID:nzaugg,项目名称:ravendb,代码行数:12,代码来源:ExportDatabaseTask.cs

示例8: ExecuteAsync

		/// <summary>
		/// Executes the index creation against the specified document store.
		/// </summary>
		public virtual Task ExecuteAsync(IAsyncDatabaseCommands asyncDatabaseCommands, DocumentConvention documentConvention)
		{
			Conventions = documentConvention;
			var transformerDefinition = CreateTransformerDefinition();
			// This code take advantage on the fact that RavenDB will turn an index PUT
			// to a noop of the index already exists and the stored definition matches
			// the new definition.
			return asyncDatabaseCommands.PutTransformerAsync(TransformerName, transformerDefinition)
				.ContinueWith(task => UpdateIndexInReplicationAsync(asyncDatabaseCommands, documentConvention, (client, url) =>
					client.DirectPutTransformerAsync(TransformerName, transformerDefinition, url)))
				.Unwrap();
		}
开发者ID:925coder,项目名称:ravendb,代码行数:15,代码来源:AbstractResultsTransformer.cs

示例9: AfterExecuteAsync

        internal static async Task AfterExecuteAsync(IAsyncDatabaseCommands asyncDatabaseCommands, string indexName, ScriptedIndexResults scripts, CancellationToken token)
        {
            var documentId = GetScriptedIndexResultsDocumentId(indexName);
            scripts.Id = documentId;

            var oldDocument = await asyncDatabaseCommands.GetAsync(documentId, token).ConfigureAwait(false);
            var newDocument = RavenJObject.FromObject(scripts);
            if (oldDocument != null && RavenJToken.DeepEquals(oldDocument.DataAsJson, newDocument))
                return;

            await asyncDatabaseCommands.PutAsync(documentId, null, newDocument, null, token).ConfigureAwait(false);
            await asyncDatabaseCommands.ResetIndexAsync(indexName, token).ConfigureAwait(false);
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:13,代码来源:AbstractScriptedIndexCreationTask.cs

示例10: DatabaseModel

		public DatabaseModel(string name, IAsyncDatabaseCommands asyncDatabaseCommands)
		{
			Name = name;
			this.asyncDatabaseCommands = asyncDatabaseCommands;

			Tasks = new BindableCollection<TaskModel>(x => x.Name)
			{
				new ImportTask(asyncDatabaseCommands),
				new ExportTask(asyncDatabaseCommands)
			};
			SelectedTask = new Observable<TaskModel> {Value = Tasks.FirstOrDefault()};
			Statistics = new Observable<DatabaseStatistics>();
		}
开发者ID:maurodx,项目名称:ravendb,代码行数:13,代码来源:DatabaseModel.cs

示例11: ImportImpl

			public ImportImpl(StreamReader reader, string file, TaskModel taskModel, Action<string> output, IAsyncDatabaseCommands databaseCommands)
			{
				this.taskModel = taskModel;
				this.output = output;
				this.databaseCommands = databaseCommands;
				csvReader = new CsvReader(reader);
				header = csvReader.ReadHeaderRecord();
				entity = Inflector.Pluralize(CSharpClassName.ConvertToValidClassName(Path.GetFileNameWithoutExtension(file)));
				if (entity.Length > 0 &&  char.IsLower(entity[0]))
					entity = char.ToUpper(entity[0]) + entity.Substring(1);
				sw = Stopwatch.StartNew();

				enumerator = csvReader.DataRecords.GetEnumerator();
			}
开发者ID:nberardi,项目名称:ravendb,代码行数:14,代码来源:CsvImportCommand.cs

示例12: NextIdAsync

		///<summary>
		/// Create the next id (numeric)
		///</summary>
		public Task<long> NextIdAsync(IAsyncDatabaseCommands databaseCommands)
		{
			var myRange = Range; // thread safe copy
			long incrementedCurrent = Interlocked.Increment(ref myRange.Current);
			if (incrementedCurrent <= myRange.Max)
			{
				return CompletedTask.With(incrementedCurrent);
			}

			bool lockTaken = false;
			try
			{
				generatorLock.Enter(ref lockTaken);
				if (Range != myRange)
				{
					// Lock was contended, and the max has already been changed. Just get a new id as usual.
					generatorLock.Exit();
					return NextIdAsync(databaseCommands);
				}
				// Get a new max, and use the current value.
				return GetNextRangeAsync(databaseCommands)
					.ContinueWith(task =>
					{
						try
						{
							Range = task.Result;
						}
						finally
						{
							generatorLock.Exit();
						}

						return NextIdAsync(databaseCommands);
					}).Unwrap();
			}
			catch
			{
				// We only unlock in exceptional cases (and not in a finally clause) because non exceptional cases will either have already
				// unlocked or will have started a task that will unlock in the future.
				if (lockTaken)
					generatorLock.Exit();
				throw;
			}
		}
开发者ID:nberardi,项目名称:ravendb,代码行数:47,代码来源:AsyncHiLoKeyGenerator.cs

示例13: CreateIndexesAsync

        /// <summary>
        /// Creates the indexes found in the specified catalog
        /// </summary>
        public static async Task CreateIndexesAsync(ExportProvider catalogToGetnIndexingTasksFrom, IAsyncDatabaseCommands databaseCommands, DocumentConvention conventions)
        {
            var indexCompilationExceptions = new List<IndexCompilationException>();
            var failed = false;
            try
            {
                var tasks = catalogToGetnIndexingTasksFrom
                    .GetExportedValues<AbstractIndexCreationTask>()
                    .ToList();

                var indexesToAdd = CreateIndexesToAdd(tasks, conventions);
                await databaseCommands.PutIndexesAsync(indexesToAdd).ConfigureAwait(false);

                foreach (var task in tasks)
                    await task.AfterExecuteAsync(databaseCommands, conventions).ConfigureAwait(false);
            }
            // For old servers that don't have the new endpoint for executing multiple indexes
            catch (Exception)
            {
                failed = true;
            }
            if (failed)
            {
                foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>())
                {
                    try
                    {
                        await task.ExecuteAsync(databaseCommands, conventions).ConfigureAwait(false);
                    }
                    catch (IndexCompilationException e)
                    {
                        indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e));
                    }
                }
            }

            await CreateTransformersAsync(catalogToGetnIndexingTasksFrom, databaseCommands, conventions).ConfigureAwait(false);

            if (indexCompilationExceptions.Any())
                throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions);
        }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:44,代码来源:IndexCreation.cs

示例14: GenerateDocumentKeyAsync

		public Task<string> GenerateDocumentKeyAsync(IAsyncDatabaseCommands databaseCommands, DocumentConvention conventions, object entity)
		{
		    var typeTagName = conventions.GetTypeTagName(entity.GetType());
			if (string.IsNullOrEmpty(typeTagName)) //ignore empty tags
				return CompletedTask.With<string>(null);
			var tag = conventions.TransformTypeTagNameToDocumentKeyPrefix(typeTagName);
			AsyncHiLoKeyGenerator value;
			if (keyGeneratorsByTag.TryGetValue(tag, out value))
				return value.GenerateDocumentKeyAsync(databaseCommands, conventions, entity);

			lock(generatorLock)
			{
				if (keyGeneratorsByTag.TryGetValue(tag, out value))
					return value.GenerateDocumentKeyAsync(databaseCommands, conventions, entity);

				value = new AsyncHiLoKeyGenerator(tag, capacity);
				keyGeneratorsByTag.TryAdd(tag, value);
			}

			return value.GenerateDocumentKeyAsync(databaseCommands, conventions, entity);
		}
开发者ID:925coder,项目名称:ravendb,代码行数:21,代码来源:AsyncMultiTypeHiLoKeyGenerator.cs

示例15: DatabaseModel

		public DatabaseModel(string name, DocumentStore documentStore)
		{
			this.name = name;
			this.documentStore = documentStore;

			Tasks = new BindableCollection<TaskModel>(x => x.Name)
			{
				new ImportTask(),
				new ExportTask(),
				new StartBackupTask(),
				new IndexingTask(),
				new SampleDataTask()
			};

			SelectedTask = new Observable<TaskModel> { Value = Tasks.FirstOrDefault() };
			Statistics = new Observable<DatabaseStatistics>();
			Status = new Observable<string>
			{
				Value = "Offline"
			};

			asyncDatabaseCommands = name.Equals(Constants.SystemDatabase, StringComparison.OrdinalIgnoreCase)
											? documentStore.AsyncDatabaseCommands.ForDefaultDatabase()
											: documentStore.AsyncDatabaseCommands.ForDatabase(name);

		    DocumentChanges.Select(c => Unit.Default).Merge(IndexChanges.Select(c => Unit.Default))
		        .SampleResponsive(TimeSpan.FromSeconds(2))
		        .Subscribe(_ => RefreshStatistics(), exception => ApplicationModel.Current.Server.Value.IsConnected.Value = false);

			RefreshStatistics();
		}
开发者ID:arelee,项目名称:ravendb,代码行数:31,代码来源:DatabaseModel.cs


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