本文整理汇总了C#中RavenJObject.CreateSnapshot方法的典型用法代码示例。如果您正苦于以下问题:C# RavenJObject.CreateSnapshot方法的具体用法?C# RavenJObject.CreateSnapshot怎么用?C# RavenJObject.CreateSnapshot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RavenJObject
的用法示例。
在下文中一共展示了RavenJObject.CreateSnapshot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AfterPut
public override void AfterPut(string key, RavenJObject document, RavenJObject metadata, System.Guid etag, TransactionInformation transactionInformation)
{
if (key.StartsWith("Raven/"))
{
return;
}
var entityName = metadata.Value<string>(Constants.RavenEntityName) + "/";
var properties = metadata.Value<RavenJArray>(Constants.EnsureUniqueConstraints);
if (properties == null || properties.Length <= 0)
return;
var constraintMetaObject = new RavenJObject { { Constants.IsConstraintDocument, true } };
constraintMetaObject.EnsureSnapshot();
foreach (var property in properties)
{
var propName = ((RavenJValue)property).Value.ToString();
var uniqueValue = document.Value<string>(propName);
if(uniqueValue == null)
continue;
string documentName = "UniqueConstraints/" + entityName + propName + "/" +Util.EscapeUniqueValue(uniqueValue);
Database.Put(
documentName,
null,
RavenJObject.FromObject(new { RelatedId = key }),
(RavenJObject)constraintMetaObject.CreateSnapshot(),
transactionInformation);
}
}
示例2: AfterPut
public override void AfterPut(string key, RavenJObject document, RavenJObject metadata, Etag etag, TransactionInformation transactionInformation)
{
VersioningConfiguration versioningConfiguration;
if (TryGetVersioningConfiguration(key, metadata, out versioningConfiguration) == false)
return;
using (Database.DisableAllTriggersForCurrentThread())
{
var copyMetadata = new RavenJObject(metadata);
copyMetadata[VersioningUtil.RavenDocumentRevisionStatus] = RavenJToken.FromObject("Historical");
copyMetadata[Constants.RavenReadOnly] = true;
copyMetadata.Remove(VersioningUtil.RavenDocumentRevision);
object parentRevision;
metadata.__ExternalState.TryGetValue("Parent-Revision", out parentRevision);
if (parentRevision != null)
{
copyMetadata[VersioningUtil.RavenDocumentParentRevision] = key + "/revisions/" + parentRevision;
copyMetadata[VersioningUtil.RavenDocumentParentRevision] = key + "/revisions/" + parentRevision;
}
object value;
metadata.__ExternalState.TryGetValue("Next-Revision", out value);
Database.Put(key + "/revisions/" + value, null, (RavenJObject)document.CreateSnapshot(), copyMetadata,
transactionInformation);
}
}
示例3: AfterPut
public override void AfterPut(string key, RavenJObject document, RavenJObject metadata, Etag etag, TransactionInformation transactionInformation)
{
if (key.StartsWith("Raven/", StringComparison.InvariantCultureIgnoreCase))
return;
var status = document.Value<string>("Status");
if (string.IsNullOrWhiteSpace(status) || !status.Equals("Published", StringComparison.InvariantCultureIgnoreCase))
return;
if (metadata.Value<string>(PublishedVersioningConstants.AtisDocumentRevisionStatus) == "Historical")
return;
using (Database.DisableAllTriggersForCurrentThread())
{
var copyMetadata = new RavenJObject(metadata);
copyMetadata[PublishedVersioningConstants.AtisDocumentRevisionStatus] = RavenJToken.FromObject("Historical");
copyMetadata[Constants.RavenReadOnly] = true;
copyMetadata.Remove(PublishedVersioningConstants.AtisDocumentRevision);
object value;
metadata.__ExternalState.TryGetValue("Next-Revision", out value);
var revisionKey = string.Format("{0}/PublishedRevisions/{1}", key, value);
Database.Put(revisionKey, null, (RavenJObject)document.CreateSnapshot(), copyMetadata, transactionInformation);
log.Debug(() => string.Format("Created published revision with key [{0}]", revisionKey));
}
}
示例4: AfterPut
public override void AfterPut(string key, RavenJObject document, RavenJObject metadata, Guid etag, TransactionInformation transactionInformation)
{
// leave raven system docs alone
if (key.StartsWith("Raven/"))
return;
// when there's already a Created date written, this is not the original insert
if (metadata.ContainsKey("Created"))
return;
// get the timestamp set for the last-modified date
var timestamp = metadata.Value<DateTime>(Constants.LastModified);
// copy the metadata and add the timestamp
var newMetadata = (RavenJObject)metadata.CreateSnapshot();
newMetadata.Add("Created", timestamp);
// update the metadata in the document
using (Database.DisableAllTriggersForCurrentThread())
Database.PutDocumentMetadata(key, newMetadata);
}