本文整理汇总了C#中IDatabaseCommands.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IDatabaseCommands.Get方法的具体用法?C# IDatabaseCommands.Get怎么用?C# IDatabaseCommands.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabaseCommands
的用法示例。
在下文中一共展示了IDatabaseCommands.Get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWindowsAuthDocument
static WindowsAuthDocument GetWindowsAuthDocument(IDatabaseCommands systemCommands)
{
var existing = systemCommands.Get("Raven/Authorization/WindowsSettings");
if (existing == null)
{
return new WindowsAuthDocument();
}
return existing
.DataAsJson
.JsonDeserialization<WindowsAuthDocument>();
}
示例2: AfterExecute
internal static void AfterExecute(IDatabaseCommands databaseCommands, string indexName, ScriptedIndexResults scripts)
{
var documentId = GetScriptedIndexResultsDocumentId(indexName);
scripts.Id = documentId;
var oldDocument = databaseCommands.Get(documentId);
var newDocument = RavenJObject.FromObject(scripts);
if (oldDocument != null && RavenJToken.DeepEquals(oldDocument.DataAsJson, newDocument))
return;
databaseCommands.Put(documentId, null, newDocument, null);
databaseCommands.ResetIndex(indexName);
}
示例3: WaitForDocument
protected virtual void WaitForDocument(IDatabaseCommands databaseCommands, string id)
{
var done = SpinWait.SpinUntil(() =>
{
// We expect to get the doc from the <system> database
var doc = databaseCommands.Get(id);
return doc != null;
}, TimeSpan.FromMinutes(5));
if (!done) throw new Exception("WaitForDocument failed");
}
示例4: GetNextRange
private RangeValue GetNextRange(IDatabaseCommands databaseCommands)
{
#if !NETFX_CORE
using (new TransactionScope(TransactionScopeOption.Suppress))
{
#endif
ModifyCapacityIfRequired();
while (true)
{
try
{
var minNextMax = Range.Max;
JsonDocument document;
try
{
document = GetDocument(databaseCommands);
}
catch (ConflictException e)
{
// resolving the conflict by selecting the highest number
var highestMax = e.ConflictedVersionIds
.Select(conflictedVersionId => GetMaxFromDocument(databaseCommands.Get(conflictedVersionId), minNextMax))
.Max();
PutDocument(databaseCommands, new JsonDocument
{
Etag = e.Etag,
Metadata = new RavenJObject(),
DataAsJson = RavenJObject.FromObject(new { Max = highestMax }),
Key = HiLoDocumentKey
});
continue;
}
long min, max;
if (document == null)
{
min = minNextMax + 1;
max = minNextMax + capacity;
document = new JsonDocument
{
Etag = Etag.Empty,
// sending empty etag means - ensure the that the document does NOT exists
Metadata = new RavenJObject(),
DataAsJson = RavenJObject.FromObject(new { Max = max }),
Key = HiLoDocumentKey
};
}
else
{
var oldMax = GetMaxFromDocument(document, minNextMax);
min = oldMax + 1;
max = oldMax + capacity;
document.DataAsJson["Max"] = max;
}
PutDocument(databaseCommands, document);
return new RangeValue(min, max);
}
catch (ConcurrencyException)
{
// expected, we need to retry
}
}
#if !NETFX_CORE
}
#endif
}
示例5: GetDocument
private JsonDocument GetDocument(IDatabaseCommands databaseCommands)
{
var documents = databaseCommands.Get(new[] { HiLoDocumentKey, RavenKeyServerPrefix }, new string[0]);
return HandleGetDocumentResult(documents);
}
示例6: WaitForDocument
protected void WaitForDocument(IDatabaseCommands databaseCommands, string id)
{
var done = SpinWait.SpinUntil(() =>
{
// We expect to get the doc from the <system> database
var doc = databaseCommands.Get(id);
return doc != null;
}, TimeSpan.FromMinutes(5));
Assert.True(done);
}
示例7: WaitForRestore
protected void WaitForRestore(IDatabaseCommands databaseCommands)
{
var done = SpinWait.SpinUntil(() =>
{
// We expect to get the doc from the <system> database
var doc = databaseCommands.Get(RestoreStatus.RavenRestoreStatusDocumentKey);
if (doc == null)
return false;
var status = doc.DataAsJson["restoreStatus"].Values().Select(token => token.ToString()).ToList();
var restoreFinishMessages = new[]
{
"The new database was created",
"Esent Restore: Restore Complete",
"Restore ended but could not create the datebase document, in order to access the data create a database with the appropriate name",
};
return restoreFinishMessages.Any(status.Last().Contains);
}, TimeSpan.FromMinutes(5));
Assert.True(done);
}