本文整理汇总了C#中Raven.Client.Indexes.AbstractIndexCreationTask类的典型用法代码示例。如果您正苦于以下问题:C# AbstractIndexCreationTask类的具体用法?C# AbstractIndexCreationTask怎么用?C# AbstractIndexCreationTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractIndexCreationTask类属于Raven.Client.Indexes命名空间,在下文中一共展示了AbstractIndexCreationTask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildIndexAsync
/// <summary>
/// Build a single index asynchronously
/// </summary>
/// <param name="indexInstance">An activated AbstractIndexCreationTask instance</param>
/// <param name="progressCallBack">A callback we can use to report on the progress of a batch job; default is null</param>
/// <returns>A task containing an IndexBuildResult report for this specific index</returns>
public Task<IndexBuildResult> BuildIndexAsync(AbstractIndexCreationTask indexInstance, Action<IndexBuildResult> progressCallBack = null)
{
return Task.Factory.StartNew(() => indexInstance.Execute(_documentStore))
.ContinueWith(result =>
{
var indexBuildResult = new IndexBuildResult()
{IndexName = indexInstance.IndexName, ConnectionString = _documentStore.Identifier};
if (result.IsCompleted && result.Exception == null)
{
indexBuildResult.Result = BuildResult.Created;
}
else if (result.IsCanceled)
{
indexBuildResult.Result = BuildResult.Cancelled;
}
else
{
indexBuildResult.Result = BuildResult.Failed;
indexBuildResult.BuildException = result.Exception != null ? result.Exception.Flatten() : null;
}
if (progressCallBack != null)
{
progressCallBack.Invoke(indexBuildResult);
}
return indexBuildResult;
});
}
示例2: BuildIndex
/// <summary>
/// Build a single index synchronously
/// </summary>
/// <param name="indexInstance">An activated AbstractIndexCreationTask instance</param>
/// <returns>An IndexBuildResult report for this specific index</returns>
public IndexBuildResult BuildIndex(AbstractIndexCreationTask indexInstance)
{
var buildIndexTask = BuildIndexAsync(indexInstance, null);
buildIndexTask.Wait();
return buildIndexTask.Result;
}
示例3: PutIndex
public void PutIndex(AbstractIndexCreationTask index)
{
var response = httpClient
.PutAsync(databaseUrl + "/indexes/" + Uri.EscapeUriString(index.IndexName), new JsonContent(RavenJObject.FromObject(index.CreateIndexDefinition())))
.ResultUnwrap();
if (response.IsSuccessStatusCode == false)
throw new InvalidOperationException(string.Format("PUT failed on '{0}'. Code: {1}.", index.IndexName, response.StatusCode));
}
示例4: SafelyCreateIndex
/// <summary>
/// Safely add the index to the RavenDB database, protect against possible failures caused by documented
/// and undocumented possibilities of failure.
/// Will throw iff index registration failed and index doesn't exist or it exists but with a non-current definition.
/// </summary>
/// <param name="store"></param>
/// <param name="index"></param>
internal static void SafelyCreateIndex(IDocumentStore store, AbstractIndexCreationTask index)
{
try
{
index.Execute(store);
}
catch (Exception) // Apparently ArgumentException can be thrown as well as a WebException; not taking any chances
{
var existingIndex = store.DatabaseCommands.GetIndex(index.IndexName);
if (existingIndex == null || !index.CreateIndexDefinition().Equals(existingIndex))
throw;
}
}
示例5: SideBySideExecuteIndex
public void SideBySideExecuteIndex(AbstractIndexCreationTask indexCreationTask, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
{
Inner.SideBySideExecuteIndex(indexCreationTask, minimumEtagBeforeReplace, replaceTimeUtc);
}
示例6: ExecuteIndexAsync
/// <summary>
/// Executes the index creation.
/// </summary>
/// <param name="indexCreationTask"></param>
public Task ExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask)
{
return server.DocumentStore.ExecuteIndexAsync(indexCreationTask);
}
示例7: ExecuteIndex
/// <summary>
/// Executes the index creation.
/// </summary>
public void ExecuteIndex(AbstractIndexCreationTask indexCreationTask)
{
server.DocumentStore.ExecuteIndex(indexCreationTask);
}
示例8: SideBySideExecuteIndexAsync
public override Task SideBySideExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
{
var list = ShardStrategy.Shards.Values.Select(x => x.AsyncDatabaseCommands).ToList();
return ShardStrategy.ShardAccessStrategy.ApplyAsync(list, new ShardRequestData(), (commands, i) =>
{
var tcs = new TaskCompletionSource<bool>();
try
{
indexCreationTask.SideBySideExecuteAsync(commands, Conventions, minimumEtagBeforeReplace, replaceTimeUtc)
.ContinueWith(t => tcs.SetResult(true));
}
catch (Exception e)
{
tcs.SetException(e);
}
return tcs.Task;
});
}
示例9: ExecuteIndex
public void ExecuteIndex(AbstractIndexCreationTask indexCreationTask)
{
this.ThrowIfNotInitialized();
this.innerStore.ExecuteIndex(indexCreationTask);
}
示例10: ExecuteIndexAsync
public Task ExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask)
{
return Inner.ExecuteIndexAsync(indexCreationTask);
}
示例11: ExecuteIndex
/// <summary>
/// Executes the index creation against each of the shards.
/// </summary>
public override void ExecuteIndex(AbstractIndexCreationTask indexCreationTask)
{
var list = ShardStrategy.Shards.Values.Select(x => x.DatabaseCommands).ToList();
ShardStrategy.ShardAccessStrategy.Apply(list,
new ShardRequestData()
, (commands, i) =>
{
indexCreationTask.Execute(commands, Conventions);
return (object)null;
});
}
示例12: ExecuteIndexAsync
public virtual Task ExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask)
{
return indexCreationTask.ExecuteAsync(AsyncDatabaseCommands, Conventions);
}
示例13: SideBySideExecuteIndexAsync
/// <summary>
/// Executes the index creation in side-by-side mode.
/// </summary>
public virtual Task SideBySideExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
{
return indexCreationTask.SideBySideExecuteAsync(AsyncDatabaseCommands, Conventions, minimumEtagBeforeReplace, replaceTimeUtc);
}
示例14: SideBySideExecuteIndex
/// <summary>
/// Executes the index creation in side-by-side mode.
/// </summary>
public virtual void SideBySideExecuteIndex(AbstractIndexCreationTask indexCreationTask, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
{
indexCreationTask.SideBySideExecute(DatabaseCommands, Conventions, minimumEtagBeforeReplace, replaceTimeUtc);
}
示例15: SideBySideExecuteIndexAsync
public Task SideBySideExecuteIndexAsync(AbstractIndexCreationTask indexCreationTask, Etag minimumEtagBeforeReplace = null, DateTime? replaceTimeUtc = null)
{
return Inner.SideBySideExecuteIndexAsync(indexCreationTask, minimumEtagBeforeReplace, replaceTimeUtc);
}