本文整理汇总了C#中Raven.Client.Indexes.AbstractIndexCreationTask.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# AbstractIndexCreationTask.Execute方法的具体用法?C# AbstractIndexCreationTask.Execute怎么用?C# AbstractIndexCreationTask.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Raven.Client.Indexes.AbstractIndexCreationTask
的用法示例。
在下文中一共展示了AbstractIndexCreationTask.Execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
}
示例3: ExecuteIndex
/// <summary>
/// Executes the index creation.
/// </summary>
public virtual void ExecuteIndex(AbstractIndexCreationTask indexCreationTask)
{
indexCreationTask.Execute(DatabaseCommands, Conventions);
}
示例4: 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;
});
}