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

C# Transaction类代码示例

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

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



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


示例16: Get

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


示例17: SendAsync

        public static async Task<Transaction> SendAsync(this TestServer server, string uri, string cookieHeader = null)
        {
            var request = new HttpRequestMessage(HttpMethod.Get, uri);
            if (!string.IsNullOrEmpty(cookieHeader))
            {
                request.Headers.Add("Cookie", cookieHeader);
            }
            var transaction = new Transaction
            {
                Request = request,
                Response = await server.CreateClient().SendAsync(request),
            };
            if (transaction.Response.Headers.Contains("Set-Cookie"))
            {
                transaction.SetCookie = transaction.Response.Headers.GetValues("Set-Cookie").ToList();
            }
            transaction.ResponseText = await transaction.Response.Content.ReadAsStringAsync();

            if (transaction.Response.Content != null &&
                transaction.Response.Content.Headers.ContentType != null &&
                transaction.Response.Content.Headers.ContentType.MediaType == "text/xml")
            {
                transaction.ResponseElement = XElement.Parse(transaction.ResponseText);
            }
            return transaction;
        }
开发者ID:rosslyn-cuongle,项目名称:Security,代码行数:26,代码来源:TestExtensions.cs


示例18: KinectSwitchJig

        private bool _drawing;     // Drawing mode active

        public KinectSwitchJig(
          Document doc, Transaction tr, double profSide, double factor
        )
        {
            // Initialise the various members

            _doc = doc;
            _tr = tr;
            _vertices = new Point3dCollection();
            _lastDrawnVertex = -1;
            _resizing = false;
            _drawing = false;
            _created = new DBObjectCollection();
            _profSide = profSide;
            _segFactor = factor;
            switchm = 0;

            Words.Add("red");
            Words.Add("green");
            Words.Add("blue");
            Words.Add("yellow");
            Words.Add("pink");
            Words.Add("magenta");
            Words.Add("cyan");
        }
开发者ID:prateek777,项目名称:Skulpturous,代码行数:27,代码来源:switch.cs


示例19: Run

        public void Run()
        {
            var a = new Transaction[4];
            a[0] = new Transaction("Turing   6/17/1990  644.08");
            a[1] = new Transaction("Tarjan   3/26/2002 4121.85");
            a[2] = new Transaction("Knuth    6/14/1999  288.34");
            a[3] = new Transaction("Dijkstra 8/22/2007 2678.40");

            Console.WriteLine("Unsorted");
            foreach (var transaction in a)
                Console.WriteLine(transaction);
            Console.WriteLine();

            Console.WriteLine("Sort by date");
            Insertion<Transaction>.Sort(a, new WhenOrderComparer());
            Insertion<Transaction>.Show(a);
            Console.WriteLine();

            Console.WriteLine("Sort by customer");
            Insertion<Transaction>.Sort(a, new WhoOrderComparer());
            Insertion<Transaction>.Show(a);
            Console.WriteLine();

            Console.WriteLine("Sort by amount");
            Insertion<Transaction>.Sort(a, new HowMuchOrderComparer());
            Insertion<Transaction>.Show(a);
            Console.WriteLine();

            Console.ReadLine();
        }
开发者ID:vladdnc,项目名称:Algorithms-NET,代码行数:30,代码来源:TransactionWorker.cs


示例20: Execute

        public Result Execute(
          ExternalCommandData commandData,
          ref string message,
          ElementSet elements)
        {
            // Get application and document objects
            UIApplication uiApp = commandData.Application;
            Document doc = uiApp.ActiveUIDocument.Document;
            UIDocument uidoc = uiApp.ActiveUIDocument;

            try
            {
                if (!doc.IsWorkshared)
                {
                    TaskDialog.Show("Workset 3D View", "Project doesn't have any Worksets.");
                }
                else
                {
                    ViewFamilyType vft = new FilteredElementCollector(doc)
                    .OfClass(typeof(ViewFamilyType))
                    .Cast<ViewFamilyType>()
                    .FirstOrDefault(q => q.ViewFamily == ViewFamily.ThreeDimensional);

                    using (Transaction t = new Transaction(doc, "Workset View Creation"))
                    {
                        t.Start();
                        int i = 0;
                        // Loop through all User Worksets only
                        foreach (Workset wst in new FilteredWorksetCollector(doc)
                            .WherePasses(new WorksetKindFilter(WorksetKind.UserWorkset)))
                        {
                            // Create a 3D View
                            View3D view = View3D.CreateIsometric(doc, vft.Id);

                            // Set the name of the view to match workset
                            view.Name = "WORKSET - " + wst.Name;

                            // Isolate elements in the view using a filter to find elements only in this workset
                            view.IsolateElementsTemporary(new FilteredElementCollector(doc)
                                .WherePasses(new ElementWorksetFilter(wst.Id))
                                .Select(q => q.Id)
                                .ToList());
                            i++;
                        }
                        t.Commit();
                        TaskDialog.Show("Workset 3D View", i.ToString() + " Views Created Successfully!");
                    }
                }
                return Result.Succeeded;
            }
            catch (Autodesk.Revit.Exceptions.OperationCanceledException)
            {
                return Result.Cancelled;
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return Result.Failed;
            }
        }
开发者ID:mjkkirschner,项目名称:GrimshawTools,代码行数:60,代码来源:Workset3dView.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# TransactionInformation类代码示例发布时间:2022-05-24
下一篇:
C# TraitCollector类代码示例发布时间: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