• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TransactionInformation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: OnDelete

		public override void OnDelete(string key, TransactionInformation transactionInformation)
		{
			if (key.StartsWith("Raven"))
				return;

			var doc = Database.Get(key, transactionInformation);

			if (doc == null)
				return;

			var metadata = doc.Metadata;

			var entityName = metadata.Value<string>(Constants.RavenEntityName) + "/";

			var uniqueConstraits = metadata.Value<RavenJArray>(Constants.EnsureUniqueConstraints);

			if (uniqueConstraits == null)
				return;

			foreach (var property in uniqueConstraits)
			{
			    var constraint = Util.GetConstraint(property);
                var prefix = "UniqueConstraints/" + entityName + constraint.PropName+ "/"; // UniqueConstraints/EntityNamePropertyName/
                var prop = doc.DataAsJson[constraint.PropName];

			    string[] uniqueValues;
                if (!Util.TryGetUniqueValues(prop, out uniqueValues))
                    continue;

				foreach (var uniqueValue in uniqueValues)
				{
					Database.Delete(prefix + Util.EscapeUniqueValue(uniqueValue, constraint.CaseInsensitive), null, transactionInformation);
				}
			}
		}
开发者ID:925coder,项目名称:ravendb,代码行数:35,代码来源:UniqueConstraintsDeleteTrigger.cs


示例2: CanModifyTxId

		public void CanModifyTxId()
		{
			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));

				var txInfo2 = new TransactionInformation
				{
					Id = Guid.NewGuid(),
					Timeout = TimeSpan.FromDays(1)
				};

                tx.Batch(mutator => mutator.Transactions.ModifyTransactionId(transactionInformation.Id, txInfo2.Id, txInfo2.Timeout));


                tx.Batch(viewer =>
					Assert.NotNull(viewer.Documents.DocumentByKey("Ayende", txInfo2)));
			}
		}
开发者ID:kblooie,项目名称:ravendb,代码行数:26,代码来源:Transactions.cs


示例3: 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:kblooie,项目名称:ravendb,代码行数:27,代码来源:Transactions.cs


示例4: using

        public void Should_save_put_to_tenant_database_if_tenant_database_is_reloaded_in_the_middle_of_the_put_transaction()
        {
			using (var server = GetNewServer(runInMemory: false))
            using (var store = new DocumentStore
            {
                Url = "http://localhost:8079"
            }.Initialize())
            {
                store.DatabaseCommands.CreateDatabase(new DatabaseDocument { Id = TenantName, Settings = { { "Raven/DataDir", @"~\Databases\Mine" } }, });

                var tx1 = new TransactionInformation { Id = Guid.NewGuid().ToString() };
                var tx2 = new TransactionInformation { Id = Guid.NewGuid().ToString() };

                var tenantDatabaseDocument = store.DatabaseCommands.Get("Raven/Databases/" + TenantName);
                server.Database.Put("Raven/Databases/mydb", null, tenantDatabaseDocument.DataAsJson, tenantDatabaseDocument.Metadata, tx1);

                var tenantDb = GetDocumentDatabaseForTenant(server, TenantName);
                tenantDb.Put("Foo/1", null, new RavenJObject { { "Test", "123" } }, new RavenJObject(), tx2);

				server.Database.PrepareTransaction(tx1.Id);
                server.Database.Commit(tx1.Id);

                tenantDb = GetDocumentDatabaseForTenant(server, TenantName);
				tenantDb.PrepareTransaction(tx2.Id);
                tenantDb.Commit(tx2.Id);

                var fooDoc = tenantDb.Get("Foo/1", new TransactionInformation { Id = Guid.NewGuid().ToString() });
                Assert.NotNull(fooDoc);
            }
        }
开发者ID:925coder,项目名称:ravendb,代码行数:30,代码来源:DatabaseReloadingTests.cs


示例5: OnPut

			public virtual void OnPut(
				string key,
				RavenJObject document,
				RavenJObject metadata,
				TransactionInformation transactionInformation)
			{
			}
开发者ID:modulexcite,项目名称:docs-8,代码行数:7,代码来源:Plugins.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:nzdunic,项目名称:ravendb,代码行数:25,代码来源:AncestryPutTrigger.cs


示例7: WhileCreatingDocumentInTransactionTryingToWriteOutsideTransactionFail

		public void WhileCreatingDocumentInTransactionTryingToWriteOutsideTransactionFail()
		{
			var transactionInformation = new TransactionInformation { Id = Guid.NewGuid(), Timeout = TimeSpan.FromMinutes(1) };
			db.Put("ayende", null, RavenJObject.Parse("{ayende:'rahien'}"), new RavenJObject(), transactionInformation);
			Assert.Throws<ConcurrencyException>(
				() => db.Put("ayende", null, RavenJObject.Parse("{ayende:'oren'}"), new RavenJObject(), null));
		}
开发者ID:JPT123,项目名称:ravendb,代码行数:7,代码来源:WriteConflicts.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 JObject { { "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 (DateTime.UtcNow > timeout)
            {
                transactionStorageActions.RollbackTransaction(txId);
                return;
            }

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


示例9: TransactionInformation

		private TransactionInformation (TransactionInformation other)
		{
			local_id = other.local_id;
			dtcId = other.dtcId;
			creation_time = other.creation_time;
			status = other.status;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:TransactionInformation.cs


示例10: SetupReplication

        private void SetupReplication()
        {
            if (RoleEnvironment.CurrentRoleInstance.Role.Instances.Count < 2)
            {
                var tr = new TransactionInformation();
                _database.Put("Debug", null,
                              JObject.Parse(@"{""Url"":""" +
                                            GetEndPointAddress(MyInstanceEndpoint.IPEndpoint) + @"""}"),
                              new JObject(), tr);

                _database.Commit(tr.Id);

            }
            else
            {
                var json = BuildDestinationsString();
                Trace.WriteLine(json);

                var tr = new TransactionInformation();
                _database.Delete("Raven/Replication/Destinations", null, tr);
                _database.Put("Raven/Replication/Destinations", null, JObject.Parse(json),
                              new JObject(), tr);
                _database.Commit(tr.Id);
            }
        }
开发者ID:gatepoet,项目名称:DeiCon.Seznam,代码行数:25,代码来源:WorkerRole.cs


示例11: OnDelete

		public override void OnDelete(string key, TransactionInformation transactionInformation)
		{
			if (key.StartsWith("Raven"))
				return;

			var doc = Database.Get(key, transactionInformation);

			if (doc == null)
				return;

			var metadata = doc.Metadata;

			var entityName = metadata.Value<string>(Constants.RavenEntityName) + "/";

			var uniqueConstraits = metadata.Value<RavenJArray>(Constants.EnsureUniqueConstraints);

			if (uniqueConstraits == null)
				return;

			foreach (var property in uniqueConstraits)
			{
			    var constraint = Util.GetConstraint(property);
                var prefix = "UniqueConstraints/" + entityName + constraint.PropName+ "/"; // UniqueConstraints/EntityNamePropertyName/
                var prop = doc.DataAsJson[constraint.PropName];
				if (prop == null || prop.Type == JTokenType.Null)
					continue;
				var array = prop as RavenJArray;
				var checkKeys = array != null ? array.Select(p => p.Value<string>()) : new[] {prop.Value<string>()};

				foreach (var checkKey in checkKeys)
				{
					Database.Delete(prefix + Util.EscapeUniqueValue(checkKey, constraint.CaseInsensitive), null, transactionInformation);
				}
			}
		}
开发者ID:robashton,项目名称:ravendb,代码行数:35,代码来源:UniqueConstraintsDeleteTrigger.cs


示例12: PutNewDocInTxAndThenGetItBeforeCommitInSameTransactionReturnsNonNull

		public void PutNewDocInTxAndThenGetItBeforeCommitInSameTransactionReturnsNonNull()
		{
			var transactionInformation = new TransactionInformation { Id = Guid.NewGuid(), Timeout = TimeSpan.FromMinutes(1) };
			db.Put("ayende", null, RavenJObject.Parse("{ayende:'rahien'}"), new RavenJObject(), transactionInformation);

			Assert.NotNull(db.Get("ayende", transactionInformation));
		}
开发者ID:JPT123,项目名称:ravendb,代码行数:7,代码来源:Simple.cs


示例13: OnDelete

		public override void OnDelete(string key, TransactionInformation transactionInformation)
		{
			if (key.StartsWith("Raven"))
				return;

			var doc = Database.Get(key, transactionInformation);

			if (doc == null)
				return;

			var metadata = doc.Metadata;

			var entityName = metadata.Value<string>(Constants.RavenEntityName) + "/";

			var uniqueConstraits = metadata.Value<RavenJArray>(Constants.EnsureUniqueConstraints);

			if (uniqueConstraits == null)
				return;

			foreach (var property in uniqueConstraits)
			{
				var checkKey = "UniqueConstraints/" + entityName  + property + "/" + doc.DataAsJson.Value<string>(property.Value<string>());

				Database.Delete(checkKey, null, transactionInformation);
			}
		}
开发者ID:neiz,项目名称:ravendb,代码行数:26,代码来源:UniqueConstraintsDeleteTrigger.cs


示例14: TransactionInformation

 private TransactionInformation(TransactionInformation other)
 {
     this.local_id = other.local_id;
     this.dtcId = other.dtcId;
     this.creation_time = other.creation_time;
     this.status = other.status;
 }
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:7,代码来源:TransactionInformation.cs


示例15: PutNewDocInTxAndThenGetItBeforeCommitReturnsNull

		public void PutNewDocInTxAndThenGetItBeforeCommitReturnsNull()
		{
			var transactionInformation = new TransactionInformation { Id = Guid.NewGuid(), Timeout = TimeSpan.FromMinutes(1) };
			db.Put("ayende", null, RavenJObject.Parse("{ayende:'rahien'}"), new RavenJObject(), transactionInformation);

			Assert.True(db.Get("ayende", null).Metadata.Value<bool>(Constants.RavenDocumentDoesNotExists));
		}
开发者ID:JPT123,项目名称:ravendb,代码行数:7,代码来源:Simple.cs


示例16: 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.Count() <= 0) 
				return;

			var constraintMetaObject = new RavenJObject { { Constants.IsConstraintDocument, true } };
			foreach (var property in properties)
			{
				var propName = ((RavenJValue)property).Value.ToString();
				Database.Put(
					"UniqueConstraints/" + entityName + propName + "/" + document.Value<string>(propName),
					null,
					RavenJObject.FromObject(new { RelatedId = key }),
					constraintMetaObject,
					transactionInformation);
			}
		}
开发者ID:seankearon,项目名称:ravendb,代码行数:26,代码来源:UniqueConstraintsPutTrigger.cs


示例17: OnDelete

		public override void OnDelete(string key, TransactionInformation transactionInformation)
		{
			var document = Database.Get(key, null);
			if (document == null)
				return;
			Database.Delete(document.Metadata.Value<string>("Cascade-Delete"), null, null);
		}
开发者ID:JPT123,项目名称:ravendb,代码行数:7,代码来源:CascadeDeleteTrigger.cs


示例18: OnPut

		public override void OnPut(string key, RavenJObject document, RavenJObject metadata, 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 oldDoc = Database.Get(key, transactionInformation);

			if (oldDoc == null)
			{
				return;
			}

			var oldJson = oldDoc.DataAsJson;

			foreach (var property in metadata.Value<RavenJArray>(Constants.EnsureUniqueConstraints))
			{
				var propName = ((RavenJValue)property).Value.ToString();

				// Handle Updates in the Constraint
				if (!oldJson.Value<string>(propName).Equals(document.Value<string>(propName)))
				{
					Database.Delete("UniqueConstraints/" + entityName + propName + "/" + oldJson.Value<string>(propName), null, transactionInformation);
				}
			}
		}
开发者ID:seankearon,项目名称:ravendb,代码行数:34,代码来源:UniqueConstraintsPutTrigger.cs


示例19: DeletingDocumentInTransactionInNotVisibleBeforeCommit

		public void DeletingDocumentInTransactionInNotVisibleBeforeCommit()
		{
			db.Put("ayende", null, RavenJObject.Parse("{ayende:'oren'}"), new RavenJObject(), null);
			var transactionInformation = new TransactionInformation { Id = Guid.NewGuid(), Timeout = TimeSpan.FromMinutes(1) };
			db.Delete("ayende", null, transactionInformation);
			Assert.NotNull(db.Get("ayende", null));
		}
开发者ID:nhsevidence,项目名称:ravendb,代码行数:7,代码来源:Deletes.cs


示例20: OnDelete

        public override void OnDelete(string key, TransactionInformation transactionInformation)
        {
            if (CascadeDeleteContext.IsInCascadeDeleteContext)
                return;

            var document = Database.Get(key, transactionInformation);
            if (document == null)
                return;

            using (CascadeDeleteContext.Enter())
            {
                var documentsToDelete = document.Metadata.Value<JArray>(MetadataKeys.DocumentsToCascadeDelete);

                if (documentsToDelete != null)
                {
                    foreach (var documentToDelete in documentsToDelete)
                    {
                        var documentId = documentToDelete.Value<string>();
                        if (!CascadeDeleteContext.HasAlreadyDeletedDocument(documentId))
                        {
                            CascadeDeleteContext.AddDeletedDocument(documentId);
                            Database.Delete(documentId, null, transactionInformation);
                        }
                    }
                }

                var attachmentsToDelete = document.Metadata.Value<JArray>(MetadataKeys.AttachmentsToCascadeDelete);

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TransactionManager类代码示例发布时间:2022-05-24
下一篇:
C# Transaction类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap