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


C# Data.TransactionInformation类代码示例

本文整理汇总了C#中Raven.Abstractions.Data.TransactionInformation的典型用法代码示例。如果您正苦于以下问题:C# TransactionInformation类的具体用法?C# TransactionInformation怎么用?C# TransactionInformation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TransactionInformation类属于Raven.Abstractions.Data命名空间,在下文中一共展示了TransactionInformation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DatabaseBulkOperations

		public DatabaseBulkOperations(DocumentDatabase database, TransactionInformation transactionInformation, CancellationTokenSource tokenSource, CancellationTimeout timeout)
		{
			this.database = database;
			this.transactionInformation = transactionInformation;
			this.tokenSource = tokenSource;
			this.timeout = timeout;
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:7,代码来源:DatabaseBulkOperations.cs

示例2: 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

示例3: OnPut

        /// <summary>
        /// Called when [put].
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="document">The document.</param>
        /// <param name="metadata">The metadata.</param>
        /// <param name="transactionInformation">The transaction information.</param>
        public override void OnPut(string key, RavenJObject document, RavenJObject metadata, TransactionInformation transactionInformation)
        {
            if (key.StartsWith("Raven/",true,CultureInfo.InvariantCulture)) // we don't deal with system documents
                return;

            if (TriggerContext.IsInTriggerContext)
                return;

            using (TriggerContext.Enter()) {
                var meta = document["MetaData"] as RavenJObject;
                if(meta != null) {
                    var slug = meta.Value<string>("Slug");
                    RavenJToken parent;
                    if (document.TryGetValue("Parent", out parent) && parent.Type != JTokenType.Null) {
                        var parentId = parent.Value<string>("Id");
                        var parentDocument = Database.Get(parentId, transactionInformation);
                        var parentUrl = parentDocument.DataAsJson.Value<JObject>("Metadata").Value<string>("Url");
                        if (parentUrl != null) {
                            meta["Url"] = string.Format("{0}/{1}", parentUrl, slug);
                            base.OnPut(key, document, metadata, transactionInformation);
                            return;
                        }
                    }
                    meta["Url"] = slug;
                }
            }
            base.OnPut(key, document, metadata, transactionInformation);
        }
开发者ID:stemyers,项目名称:BrickPile,代码行数:35,代码来源:UpdateTrigger.cs

示例4: RecursiveDelete

        private void RecursiveDelete(string key, TransactionInformation transactionInformation)
        {
            var document = Database.Documents.Get(key, transactionInformation);
            if (document == null)
                return;

            var documentsToDelete = document.Metadata.Value<RavenJArray>(MetadataKeys.DocumentsToCascadeDelete);
            if (documentsToDelete != null)
            {
                foreach (var documentToDelete in documentsToDelete)
                {
                    var documentId = documentToDelete.Value<string>();
                    if (!CascadeDeleteContext.HasAlreadyDeletedDocument(documentId))
                    {
                        CascadeDeleteContext.AddDeletedDocument(documentId);
                        RecursiveDelete(documentId, transactionInformation);
                        Database.Documents.Delete(documentId, null, transactionInformation);
                    }
                }
            }
            var attachmentsToDelete = document.Metadata.Value<RavenJArray>(MetadataKeys.AttachmentsToCascadeDelete);

            if (attachmentsToDelete != null)
                foreach (var attachmentToDelete in attachmentsToDelete)
                    Database.Attachments.DeleteStatic(attachmentToDelete.Value<string>(), null);
            return;
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:27,代码来源:CascadeDeleteTrigger.cs

示例5: HandleConflictedDocument

        private void HandleConflictedDocument(JsonDocument document, TransactionInformation transactionInformation)
        {
            var conflicts = document.DataAsJson.Value<RavenJArray>("Conflicts");
            var currentSource = Database.TransactionalStorage.Id.ToString();
            var historySet = false;

            foreach (var c in conflicts)
            {
                RavenJObject conflict;
                if (Database.Documents.Delete(c.Value<string>(), null, transactionInformation, out conflict) == false)
                    continue;

                if (historySet)
                    continue;

                var conflictSource = conflict.Value<RavenJValue>(Constants.RavenReplicationSource).Value<string>();

                if (conflictSource != currentSource)
                    continue;

                deletedHistory.Value = new RavenJArray
                {
                    new RavenJObject
                    {
                        { Constants.RavenReplicationVersion, conflict[Constants.RavenReplicationVersion] },
                        { Constants.RavenReplicationSource, conflict[Constants.RavenReplicationSource] }
                    }
                };

                historySet = true;
            }
        }
开发者ID:knives-out,项目名称:ravendb,代码行数:32,代码来源:VirtualDeleteAndRemoveConflictsTrigger.cs

示例6: OnPut

		public override void OnPut(string key, RavenJObject document, RavenJObject metadata, TransactionInformation transactionInformation)
		{
			if (key.StartsWith("Raven/")) // we don't deal with system documents
				return;
			var doc = Database.Get(key, null);
			if (doc != null)
			{
				var history = doc.Metadata.Value<RavenJArray>(ReplicationConstants.RavenReplicationHistory) ?? new RavenJArray();
				metadata[ReplicationConstants.RavenReplicationHistory] = history;

				history.Add(new RavenJObject
				{
					{ReplicationConstants.RavenReplicationVersion, doc.Metadata[ReplicationConstants.RavenReplicationVersion]},
					{ReplicationConstants.RavenReplicationSource, doc.Metadata[ReplicationConstants.RavenReplicationSource]}

				});

				if (history.Length > ReplicationConstants.ChangeHistoryLength)
				{
					history.RemoveAt(0);
				}
			}
			metadata[ReplicationConstants.RavenReplicationVersion] = RavenJToken.FromObject(hiLo.NextId());
			metadata[ReplicationConstants.RavenReplicationSource] = RavenJToken.FromObject(Database.TransactionalStorage.Id);
		}
开发者ID:nhsevidence,项目名称:ravendb,代码行数:25,代码来源:AncestryPutTrigger.cs

示例7: AllowPut

        public override VetoResult AllowPut(string key, Raven.Json.Linq.RavenJObject document, Raven.Json.Linq.RavenJObject metadata, TransactionInformation transactionInformation)
        {
            if (key == "Raven/Authorization/WindowsSettings" && Authentication.IsEnabled == false)
                return VetoResult.Deny("Cannot setup Windows Authentication without a valid commercial license.");

            return VetoResult.Allowed;
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:7,代码来源:WindowsAuthPutTrigger.cs

示例8: AssertNotModifiedByAnotherTransaction

		public static void AssertNotModifiedByAnotherTransaction(TableStorage storage, ITransactionStorageActions transactionStorageActions, string key, Table.ReadResult readResult, TransactionInformation transactionInformation)
		{
			if (readResult == null)
				return;
			var txIdAsBytes = readResult.Key.Value<byte[]>("txId");
			if (txIdAsBytes == null)
				return;

			var txId = new Guid(txIdAsBytes);
			if (transactionInformation != null && transactionInformation.Id == txId)
			{
				return;
			}

			var existingTx = storage.Transactions.Read(new RavenJObject { { "txId", txId.ToByteArray() } });
			if (existingTx == null)//probably a bug, ignoring this as not a real tx
				return;

			var timeout = existingTx.Key.Value<DateTime>("timeout");
			if (SystemTime.UtcNow > timeout)
			{
				transactionStorageActions.RollbackTransaction(txId);
				return;
			}

			throw new ConcurrencyException("Document '" + key + "' is locked by transacton: " + txId);
		}
开发者ID:jtmueller,项目名称:ravendb,代码行数:27,代码来源:StorageHelper.cs

示例9: OnPut

		public override void OnPut(string key, RavenJObject document, RavenJObject metadata, TransactionInformation transactionInformation)
		{
			if (key.StartsWith("Raven/", StringComparison.InvariantCultureIgnoreCase) && // we don't deal with system documents
				key.StartsWith("Raven/Hilo/", StringComparison.InvariantCultureIgnoreCase) == false) // except for hilos
				return;
			using (Database.DisableAllTriggersForCurrentThread())
			{
				var doc = Database.Get(key, null);
				if (doc != null)
				{
					var history = doc.Metadata.Value<RavenJArray>(ReplicationConstants.RavenReplicationHistory) ?? new RavenJArray();
					metadata[ReplicationConstants.RavenReplicationHistory] = history;

					if (doc.Metadata.ContainsKey(ReplicationConstants.RavenReplicationVersion) && 
						doc.Metadata.ContainsKey(ReplicationConstants.RavenReplicationSource))
					{
						history.Add(new RavenJObject
						{
							{ReplicationConstants.RavenReplicationVersion, doc.Metadata[ReplicationConstants.RavenReplicationVersion]},
							{ReplicationConstants.RavenReplicationSource, doc.Metadata[ReplicationConstants.RavenReplicationSource]}
						});
					}

					if (history.Length > ReplicationConstants.ChangeHistoryLength)
					{
						history.RemoveAt(0);
					}
				}
				metadata[ReplicationConstants.RavenReplicationVersion] = RavenJToken.FromObject(HiLo.NextId());
				metadata[ReplicationConstants.RavenReplicationSource] = RavenJToken.FromObject(Database.TransactionalStorage.Id);
			}
		}
开发者ID:royra,项目名称:ravendb,代码行数:32,代码来源:AncestryPutTrigger.cs

示例10: AllowDelete

        public override VetoResult AllowDelete(string key, TransactionInformation transactionInformation)
        {
            if (key == Constants.InResourceKeyVerificationDocumentName)
                return VetoResult.Deny("Cannot delete the encryption verification document.");

            return base.AllowDelete(key, transactionInformation);
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:7,代码来源:EncryptionSettingsDeleteTrigger.cs

示例11: AllowRead

        public override ReadVetoResult AllowRead(string key, RavenJObject metadata, ReadOperation operation, TransactionInformation transactionInformation)
        {
            // This trigger is only for simple query operations
            if (key == null || operation != ReadOperation.Query)
                return ReadVetoResult.Allowed;

            // Don't do anything if temporal versioning is inactive for this document type
            if (!Database.IsTemporalVersioningEnabled(key, metadata))
                return ReadVetoResult.Allowed;

            // If an effective date was passed in, then use it.
            DateTimeOffset effective;
            var headerValue = CurrentOperationContext.Headers.Value[TemporalMetadata.RavenTemporalEffective];
            if (headerValue == null || !DateTimeOffset.TryParse(headerValue, null, DateTimeStyles.RoundtripKind, out effective))
            {
                // If no effective data passed, return as stored.
                return ReadVetoResult.Allowed;
            }

            // Return the requested effective date in the metadata.
            var temporal = metadata.GetTemporalMetadata();
            temporal.Effective = effective;

            // Return the result if it's the active revision, or skip it otherwise.
            return temporal.Status == TemporalStatus.Revision &&
                   temporal.EffectiveStart <= effective && effective < temporal.EffectiveUntil &&
                   !temporal.Deleted
                       ? ReadVetoResult.Allowed
                       : ReadVetoResult.Ignore;
        }
开发者ID:jggutierrez,项目名称:RavenDB-TemporalVersioning,代码行数:30,代码来源:TemporalVersioningQueryTrigger.cs

示例12: OnPut

		public override void OnPut(string key, RavenJObject document, RavenJObject metadata, TransactionInformation transactionInformation)
		{
			if (key.StartsWith("Raven/", StringComparison.InvariantCultureIgnoreCase))
				return;

			if (metadata.Value<string>(VersioningUtil.RavenDocumentRevisionStatus) == "Historical")
				return;

			var versioningConfiguration = Database.GetDocumentVersioningConfiguration(metadata);
			if (versioningConfiguration == null || versioningConfiguration.Exclude)
				return;

			using (Database.DisableAllTriggersForCurrentThread())
			{
				var copyMetadata = new RavenJObject(metadata);
				copyMetadata[VersioningUtil.RavenDocumentRevisionStatus] = RavenJToken.FromObject("Historical");
				copyMetadata[Constants.RavenReadOnly] = true;
				copyMetadata.Remove(VersioningUtil.RavenDocumentRevision);
				var parentRevision = metadata.Value<string>(VersioningUtil.RavenDocumentRevision);
				if (parentRevision != null)
				{
					copyMetadata[VersioningUtil.RavenDocumentParentRevision] = key + "/revisions/" + parentRevision;
					metadata[VersioningUtil.RavenDocumentParentRevision] = key + "/revisions/" + parentRevision;
				}

				PutResult newDoc = Database.Put(key + "/revisions/", null, document, copyMetadata,
				                                transactionInformation);
				int revision = int.Parse(newDoc.Key.Split('/').Last());

				RemoveOldRevisions(key, revision, versioningConfiguration, transactionInformation);

				metadata[VersioningUtil.RavenDocumentRevisionStatus] = RavenJToken.FromObject("Current");
				metadata[VersioningUtil.RavenDocumentRevision] = RavenJToken.FromObject(revision);
			}
		}
开发者ID:arelee,项目名称:ravendb,代码行数:35,代码来源:VersioningPutTrigger.cs

示例13: OnDelete

        /// <summary>
        /// Called when [delete].
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="transactionInformation">The transaction information.</param>
        public override void OnDelete(string key, TransactionInformation transactionInformation)
        {
            if (key.StartsWith("Raven/")) // we don't deal with system documents
                return;

            var childrenQuery = new IndexQuery
            {
                Query = "Id:" + key
            };

            var queryResult = Database.Query("Documents/ByParent", childrenQuery);

            if (queryResult.Results.Count > 0) {
                foreach (var result in queryResult.Results) {

                    var metadataJObject = result.Value<RavenJObject>("@metadata");

                    if (metadataJObject != null)
                    {
                        var childId = metadataJObject.Value<string>("@id");

                        var childEtag = metadataJObject.Value<string>("@etag");
                        Database.Delete(childId, Guid.Parse(childEtag), transactionInformation);
                    }
                }
            }

            base.OnDelete(key, transactionInformation);
        }
开发者ID:dasheddot,项目名称:BrickPile,代码行数:34,代码来源:DeleteTrigger.cs

示例14: AfterCommittingCanSeeChangesWithoutTx

		public void AfterCommittingCanSeeChangesWithoutTx()
		{
			var transactionInformation = new TransactionInformation
			{
				Id = Guid.NewGuid(),
				Timeout = TimeSpan.FromDays(7)
			};

			using (var tx = NewTransactionalStorage())
			{
				tx.Batch(mutator => mutator.Transactions.AddDocumentInTransaction("Ayende", null, RavenJObject.FromObject(new { Name = "Rahien" }), new RavenJObject(),
					transactionInformation));

				tx.Batch(mutator => mutator.Transactions.CompleteTransaction(transactionInformation.Id, data =>
				{
					if (data.Delete)
					{
						RavenJObject metadata;
						mutator.Documents.DeleteDocument(data.Key, null, out metadata);
					}
					else
						mutator.Documents.AddDocument(data.Key, null, data.Data, data.Metadata);
				}));
				tx.Batch(viewer =>
					Assert.NotNull(viewer.Documents.DocumentByKey("Ayende", null)));
			}
		}
开发者ID:nhsevidence,项目名称:ravendb,代码行数:27,代码来源:Transactions.cs

示例15: GetNextIdentityValueWithoutOverwritingOnExistingDocuments

     public long GetNextIdentityValueWithoutOverwritingOnExistingDocuments(string key,
 IStorageActionsAccessor actions,
 TransactionInformation transactionInformation)
     {
         int tries;
         return GetNextIdentityValueWithoutOverwritingOnExistingDocuments(key, actions, transactionInformation, out tries);
     }
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:7,代码来源:DocumentActions.cs


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