当前位置: 首页>>代码示例>>C#>>正文


C# RavenJObject.CreateSnapshot方法代码示例

本文整理汇总了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);
			}
		}
开发者ID:remcoros,项目名称:ravendb,代码行数:31,代码来源:UniqueConstraintsPutTrigger.cs

示例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);
			}
		}
开发者ID:nzaugg,项目名称:ravendb,代码行数:26,代码来源:VersioningPutTrigger.cs

示例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));
              }
        }
开发者ID:SeanFeldman,项目名称:RavenDB-Spikes,代码行数:26,代码来源:PublishedVersioningPutTrigger.cs

示例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);
        }
开发者ID:tzarger,项目名称:contrib,代码行数:21,代码来源:CreatedDateTrigger.cs


注:本文中的RavenJObject.CreateSnapshot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。