本文整理汇总了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>();
}
示例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);
}
示例3: DatabaseTask
public DatabaseTask(IAsyncDatabaseCommands databaseCommands, string taskName, string databaseName)
{
this.databaseCommands = databaseCommands;
this.taskName = taskName;
this.databaseName = databaseName;
OutputItems = new ObservableCollection<DatabaseTaskOutput>();
}
示例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;
}
示例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));
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
示例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>();
}
示例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();
}
示例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;
}
}
示例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);
}
示例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);
}
示例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();
}