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


C# Transaction类代码示例

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


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

示例1: Traverse

        public Task Traverse(Transaction tx,
            Func<JObject, bool> searchPredicate,
            Func<bool> shouldStopPredicate,
            Node rootNode = null,
            ushort? edgeTypeFilter = null,
            uint? traverseDepthLimit = null)
        {
	        if (State == AlgorithmState.Running)
                throw new InvalidOperationException("The search already running");

	        return Task.Run(() =>
	        {
		        OnStateChange(AlgorithmState.Running);

		        var visitedNodes = new HashSet<long>();
		        var processingQueue = new Queue<NodeVisitedEventArgs>();
		        rootNode = rootNode ?? GetDefaultRootNode(tx);
		        processingQueue.Enqueue(new NodeVisitedEventArgs(rootNode,null, 1, 0));

		        while (processingQueue.Count > 0)
		        {
			        if (shouldStopPredicate())
			        {
				        OnStateChange(AlgorithmState.Finished);
				        break;
			        }
    
			        AbortExecutionIfNeeded();
    
			        var currentVisitedEventInfo = processingQueue.Dequeue();
			        visitedNodes.Add(currentVisitedEventInfo.VisitedNode.Key);
			        OnNodeVisited(currentVisitedEventInfo);

			        if (searchPredicate(currentVisitedEventInfo.VisitedNode.Data))
			        {
				        OnNodeFound(currentVisitedEventInfo.VisitedNode);
				        if (shouldStopPredicate() ||
                            (traverseDepthLimit.HasValue && currentVisitedEventInfo.TraversedEdgeCount >= traverseDepthLimit.Value))
				        {
					        OnStateChange(AlgorithmState.Finished);
					        break;
				        }
			        }

			        foreach (var childNodeWithWeight in 
                        _graphStorage.Queries.GetAdjacentOf(tx, currentVisitedEventInfo.VisitedNode, edgeTypeFilter ?? 0)
				                             .Where(nodeWithWeight => !visitedNodes.Contains(nodeWithWeight.Node.Key)))
			        {
				        AbortExecutionIfNeeded();
                        processingQueue.Enqueue(new NodeVisitedEventArgs(childNodeWithWeight.Node,
                            currentVisitedEventInfo.VisitedNode, 
                            currentVisitedEventInfo.TraversedEdgeCount + 1,
                            childNodeWithWeight.WeightOfEdgeToNode));
			        }
    
		        }

		        OnStateChange(AlgorithmState.Finished);
	        });
        }
开发者ID:josephi,项目名称:Voron.Graph,代码行数:60,代码来源:BreadthFirstSearch.cs

示例2: Execute

 // Methods
 public void Execute(Customer customer)
 {
     if (customer.CustomerType.Equals("INACTIVE"))
     {
         throw new Exception("INACTIVE ID");
     }
     Boolean decrement = customer.PlanId.ToUpper().StartsWith("BLOCK");
     Transaction transaction = new Transaction();
     if (!decrement)
     {
         transaction.find(string.Concat(new object[] { "([PeopleID]='", customer.PeopleID, "') AND ([DateTime] > '", customer.MealCost.StartTime, "') AND [TTID] = 'MEALCHRG'" }));
         decrement = transaction.PeopleID == null;
     }
     if (decrement)
     {
         if (customer.CurrentMeals <= 0)
         {
             throw new Exception("Zero Meals Left");
         }
         transaction.PeopleID = customer.PeopleID;
         transaction.Amount = 0M;
         transaction.PlanID = customer.PlanId;
         transaction.LocationID = this.location;
         transaction.Ttid = this.ttid;
         transaction.currentMeals();
         customer.CurrentMeals--;
     }
 }
开发者ID:geoffritchey,项目名称:cafeteria,代码行数:29,代码来源:CafeStudentCharge.cs

示例3: WithdrawMoney

 public void WithdrawMoney(double pengar)
 {
     Transaction transact = new Transaction("withdraw", pengar, DateTime.Now);
     transactions.Add(transact);
     double tempMoney = GetCurrentMoney() - pengar;
     SetCurrentMoney(tempMoney);
 }
开发者ID:rikardw,项目名称:Folkbanken,代码行数:7,代码来源:Account.cs

示例4: BroadcastTransaction

		public Transaction BroadcastTransaction(Transaction tx)
		{
			var h = tx.GetHash();
			Mempool.Add(h, tx);
			OnNewTransaction(tx);
			return tx;
		}
开发者ID:vebin,项目名称:NBitcoin,代码行数:7,代码来源:spv_tests.cs

示例5: ContainsNode

	    public bool ContainsNode(Transaction tx, Node node)
        {
	        if (tx == null) throw new ArgumentNullException("tx");
	        if (node == null) throw new ArgumentNullException("node");

	        return ContainsNode(tx, node.Key);
        }
开发者ID:ReginaBricker,项目名称:Voron.Graph,代码行数:7,代码来源:GraphQueries.cs

示例6: ToTransaction

        private static Transaction ToTransaction(ComsecTransactionCsv comsecTransactionCsv)
        {
            var transaction = new Transaction();

            // Detail field has format
            // <B or S> <quanity> <share code> @ <share price>
            // For example
            // B 269 VTS @ 148.620000

            string[] detailComponents = comsecTransactionCsv.Details.Split(new Char[] { ' ' });

            transaction.TransactionDate = comsecTransactionCsv.TransactionDate;
            transaction.ShareCode = detailComponents[2];
            transaction.Quantity = int.Parse(detailComponents[1]);

            if (detailComponents[0] == "S")
            {
                transaction.Amount = comsecTransactionCsv.Credit;
            }
            else
            {
                transaction.Amount = -1 * comsecTransactionCsv.Debit;
            }

            transaction.Reference = comsecTransactionCsv.Reference;

            return transaction;
        }
开发者ID:mperdeck,项目名称:cgtcalculator,代码行数:28,代码来源:Csv.cs

示例7: HasDiscontinuousSpaceFor

		public bool HasDiscontinuousSpaceFor(Transaction tx, long size)
		{
			var sizesFromLargest = _freePagesBySize.Keys.OrderByDescending(x => x).ToList();

			var oldestTransaction = tx.Environment.OldestTransaction;
			long available = 0;

			foreach (var sizeKey in sizesFromLargest)
			{
				var item = _freePagesBySize[sizeKey].Last;

				while (item != null && (oldestTransaction == 0 || item.Value.ValidAfterTransactionId < oldestTransaction))
				{
					available += sizeKey;

					if(available >= size)
						break;

					item = item.Previous;
				}

				if(available >= size)
					break;
			}

			return available >= size;
		}
开发者ID:mdavis,项目名称:ravendb,代码行数:27,代码来源:ScratchBufferFile.cs

示例8: AllocateMorePages

        public override void AllocateMorePages(Transaction tx, long newLength)
        {
            if (newLength < _length)
                throw new ArgumentException("Cannot set the legnth to less than the current length");

            if (newLength == _length)
                return;

            // need to allocate memory again
            NativeFileMethods.SetFileLength(_handle, newLength);

            Debug.Assert(_fileStream.Length == newLength);

            _length = newLength;
            PagerState.Release(); // when the last transaction using this is over, will dispose it
            PagerState newPager = CreateNewPagerState();

            if (tx != null) // we only pass null during startup, and we don't need it there
            {
                newPager.AddRef(); // one for the current transaction
                tx.AddPagerState(newPager);
            }

            PagerState = newPager;
            NumberOfAllocatedPages = newLength/PageSize;
        }
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:26,代码来源:MemoryMappedPager.cs

示例9: SetUp

 public void SetUp()
 {
     _connection = new Mock<Connection>(null);
     _commitCount = 0;
     _rollbackCount = 0;
     _target = new Transaction(_connection.Object, () => ++_commitCount, () => ++_rollbackCount);
 }
开发者ID:gimmi,项目名称:adoutils,代码行数:7,代码来源:TransactionTest.cs

示例10: ListForMatterAndInvoice

 public static List<Common.Models.Billing.InvoiceExpense> ListForMatterAndInvoice(
     Transaction t,
     Guid invoiceId,
     Guid matterId)
 {
     return ListForMatterAndInvoice(invoiceId, matterId, t.Connection, false);
 }
开发者ID:NodineLegal,项目名称:OpenLawOffice.Data,代码行数:7,代码来源:InvoiceExpense.cs

示例11: Get

 public static Common.Models.Billing.InvoiceExpense Get(
     Transaction t,
     Guid invoiceId,
     Guid expenseId)
 {
     return Get(invoiceId, expenseId, t.Connection, false);
 }
开发者ID:NodineLegal,项目名称:OpenLawOffice.Data,代码行数:7,代码来源:InvoiceExpense.cs

示例12: GoofyCreateAndTansferCoin_SouldHaveValidCoin

        public static void GoofyCreateAndTansferCoin_SouldHaveValidCoin()
        {
            //Arrange
            var signature = new Signature(256);
            Global.GoofyPk = signature.PublicKey;

            var coin = new Coin(signature);

            //Act
            var trans = new Transaction(coin, new Signature(256).PublicKey);

            //Assert

            try
            {
                //trans.CheckTransaction();

                if (!coin.isGoofyCoin())
                    throw new Exception("This coin doenst belong to Goofy");
                if (!coin.isValidSignature())
                    throw new Exception("This coin signature is invalid");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
开发者ID:vinils,项目名称:GoofyCoin2015,代码行数:27,代码来源:Tests.cs

示例13: Execute

        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application 
        /// which contains data related to the command, 
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application 
        /// which will be displayed if a failure or cancellation is returned by 
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application 
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command. 
        /// A result of Succeeded means that the API external method functioned as expected. 
        /// Cancelled can be used to signify that the user cancelled the external operation 
        /// at some point. Failure should be returned if the application is unable to proceed with 
        /// the operation.</returns>
        public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
            ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            Transaction newTran = null;
            try
            {
                if (null == commandData)
                {
                    throw new ArgumentNullException("commandData");
                }

                Document doc = commandData.Application.ActiveUIDocument.Document;
                ViewsMgr view = new ViewsMgr(doc);

                newTran = new Transaction(doc);
                newTran.Start("AllViews_Sample");

                AllViewsForm dlg = new AllViewsForm(view);

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    view.GenerateSheet(doc);
                }
                newTran.Commit();

                return Autodesk.Revit.UI.Result.Succeeded;
            }
            catch (Exception e)
            {
                message = e.Message;
                if ((newTran != null) && newTran.HasStarted() && !newTran.HasEnded())
                    newTran.RollBack();
                return Autodesk.Revit.UI.Result.Failed;
            }
        }
开发者ID:AMEE,项目名称:revit,代码行数:51,代码来源:AllViews.cs

示例14: PostTransaction

        public async Task<ByteString> PostTransaction(ByteString rawMutation, IReadOnlyList<SignatureEvidence> authentication)
        {
            Mutation mutation;
            try
            {
                // Verify that the mutation can be deserialized
                mutation = MessageSerializer.DeserializeMutation(rawMutation);
            }
            catch (InvalidProtocolBufferException)
            {
                throw new TransactionInvalidException("InvalidMutation");
            }

            if (!mutation.Namespace.Equals(this.ledgerId))
                throw new TransactionInvalidException("InvalidNamespace");

            if (mutation.Records.Count == 0)
                throw new TransactionInvalidException("InvalidMutation");

            if (mutation.Records.Any(record => record.Key.Value.Count > MaxKeySize))
                throw new TransactionInvalidException("InvalidMutation");

            ValidateAuthentication(authentication, MessageSerializer.ComputeHash(rawMutation.ToByteArray()));

            ParsedMutation parsedMutation = ParsedMutation.Parse(mutation);

            // All assets must have an overall zero balance

            IReadOnlyDictionary<AccountKey, AccountStatus> accounts =
                await this.store.GetAccounts(parsedMutation.AccountMutations.Select(entry => entry.AccountKey));

            var groups = parsedMutation.AccountMutations
                .GroupBy(account => account.AccountKey.Asset.FullPath)
                .Select(group => group.Sum(entry => entry.Balance - accounts[entry.AccountKey].Balance));

            if (groups.Any(group => group != 0))
                throw new TransactionInvalidException("UnbalancedTransaction");

            DateTime date = DateTime.UtcNow;

            await this.validator.Validate(parsedMutation, authentication, accounts);

            TransactionMetadata metadata = new TransactionMetadata(authentication);

            byte[] rawMetadata = SerializeMetadata(metadata);

            Transaction transaction = new Transaction(rawMutation, date, new ByteString(rawMetadata));
            byte[] serializedTransaction = MessageSerializer.SerializeTransaction(transaction);

            try
            {
                await this.store.AddTransactions(new[] { new ByteString(serializedTransaction) });
            }
            catch (ConcurrentMutationException)
            {
                throw new TransactionInvalidException("OptimisticConcurrency");
            }

            return new ByteString(MessageSerializer.ComputeHash(serializedTransaction));
        }
开发者ID:packetlost,项目名称:openchain,代码行数:60,代码来源:TransactionValidator.cs

示例15: AppliesTo

 public override bool AppliesTo(Transaction transaction, BankOperation operation)
 {
     if (transaction.Type == TransactionType.Deposit)
     {
         return false;
     }
     var cardTransaction = transaction as CardTransaction;
     if (cardTransaction == null)
     {
         return false;
     }
     var userCard = _userCardRepository.Find(cardTransaction.Card.Id);
     if (userCard == null)
     {
         return false;
     }
     var query = DbQuery.For<CardTransaction>()
         .FilterBy(Specs.ForCardTransaction.Withdrawals && !Specs.ForCardTransaction.Failed && Specs.ForCardTransaction.ForToday(userCard.Id, _schedule.TimeZone));
     var transactionsForToday = _cardTransactionRepository.Query(query);
     var countForToday = transactionsForToday.Count;
     var amountForToday = transactionsForToday
         .Sum(x => -x.AccountAmount);
     var countLimit = _settings.IsLocalLocation(transaction.Location)
         ? userCard.Settings.Limits.OperationsPerDayLocal
         : userCard.Settings.Limits.OperationsPerDayAbroad;
     var amountLimit = _settings.IsLocalLocation(transaction.Location)
         ? userCard.Settings.Limits.AmountPerDayLocal
         : userCard.Settings.Limits.AmountPerDayAbroad;
     return countForToday > countLimit || amountForToday > amountLimit;
 }
开发者ID:al-main,项目名称:vabank,代码行数:30,代码来源:UserCardLimitsPolicy.cs


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