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


C# Transactions.TransactionOptions类代码示例

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


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

示例1: GuardarAsignaciones

        public void GuardarAsignaciones(IList<int> ordenesVenta, IList<Usuario> asistentes)
        {
            try
            {
                var transactionOptions = new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted };

                using (var transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
                {
                    foreach (var idOrdenVenta in ordenesVenta)
                    {
                        var ordenVenta = _orderVentaDA.ObtenerPorID(idOrdenVenta);

                        var asistenteConMenorCarga = asistentes.OrderBy(p => p.CantidadOV).FirstOrDefault();

                        if (asistenteConMenorCarga != null)
                        {
                            asistenteConMenorCarga.CantidadOV++;

                            ordenVenta.Estado = Constantes.EstadoOrdenVenta.Asignado;
                            ordenVenta.AsistentePlaneamiento = asistenteConMenorCarga;

                            _orderVentaDA.AsignarAsistentePlaneamiento(ordenVenta);
                        }
                    }

                    transactionScope.Complete();
                }
            }
            catch (Exception ex)
            {
                throw ThrowException(ex, MethodBase.GetCurrentMethod().Name);
            }
        }
开发者ID:steel-framing,项目名称:metal-forming,代码行数:33,代码来源:OrdenVentaBL.cs

示例2: JobEntity

 private static WaitCallback JobEntity(TransactionOptions options)
 {
     return state =>
         {
             try
             {
                 using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, options))
                 {
                     using (var context = new ProjectTemplate_DevEntities())
                     {
                         var element = context.Element.First(d => d.Id == "d0530ea7-639f-4d5e-91fb-1a4fed1debfe");
                         var intInternalName = Int32.Parse(element.InternalName);
                         PrintMessage("ReadValue=" + intInternalName.ToString());
                         element.InternalName = (intInternalName + 1).ToString();
                         PrintMessage("Incrementing to" + element.InternalName);
                         Thread.Sleep(2000);
                         context.SaveChanges(); // Save changes to DB
                         PrintMessage("Saving");
                         Thread.Sleep(2000);
                     }
                     scope.Complete(); // Commit transaction
                     PrintMessage("Commit");
                 }
             }
             catch (Exception e)
             {
                 PrintMessage( e.Message);
             }finally
             {
                 ((ManualResetEvent)state).Set();
             }
         };
 }
开发者ID:rodrijp,项目名称:TransactionOptions,代码行数:33,代码来源:Program.cs

示例3: MsmqScopeOptions

        public MsmqScopeOptions(TimeSpan? requestedTimeout = null, IsolationLevel? requestedIsolationLevel = null)
        {
            var timeout = TransactionManager.DefaultTimeout;
            var isolationLevel = IsolationLevel.ReadCommitted;
            if (requestedTimeout.HasValue)
            {
                var maxTimeout = GetMaxTimeout();

                if (requestedTimeout.Value > maxTimeout)
                {
                    throw new ConfigurationErrorsException(
                        "Timeout requested is longer than the maximum value for this machine. Override using the maxTimeout setting of the system.transactions section in machine.config");
                }

                timeout = requestedTimeout.Value;
            }

            if (requestedIsolationLevel.HasValue)
            {
                isolationLevel = requestedIsolationLevel.Value;
            }

            TransactionOptions = new TransactionOptions
            {
                IsolationLevel = isolationLevel,
                Timeout = timeout
            };
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:28,代码来源:MsmqScopeOptions.cs

示例4: Abandon

        public void Abandon(int masterSysNo, int userSysNo)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {

                //�����dz�ʼ״̬
                POInfo dbInfo = LoadPO(masterSysNo);
                if ( dbInfo == null )
                    throw new BizException("does not exist this po sysno");
                if ( dbInfo.Status != (int)AppEnum.POStatus.Origin )
                    throw new BizException("status is not origin now, abandon failed");

                //���� ���š�״̬�������
                Hashtable ht = new Hashtable(4);

                ht.Add("SysNo", masterSysNo);
                ht.Add("Status", (int)AppEnum.POStatus.Abandon);
                if ( 1!=new PODac().UpdateMaster(ht))
                    throw new BizException("expected one-row update failed, verify failed ");

                ProductIDManager.GetInstance().AbandonProductIDsByPO(masterSysNo);

                scope.Complete();
            }
        }
开发者ID:ue96,项目名称:ue96,代码行数:29,代码来源:PurchaseManager.cs

示例5: TransactionScope

		public TransactionScope (TransactionScopeOption scopeOption,
			TransactionOptions options,
			DTCOption opt)
		{
			Initialize (scopeOption, null, options, opt,
				TransactionManager.DefaultTimeout);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:7,代码来源:TransactionScope.cs

示例6: AddRMA

        /// <summary>
        /// ����rma��
        /// </summary>
        /// <param name="rmaInfo"></param>
        public void AddRMA(RMAInfo rmaInfo)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                if(!this.IfExistOpenedRMA(rmaInfo.SOSysNo))
                {
                    Hashtable leftHash = this.GetLeftRMAQty(rmaInfo.SOSysNo);
                    foreach(RMAItemInfo item in rmaInfo.ItemHash.Values)
                    {
                        if(item.RMAQty>(int)leftHash[item.ProductSysNo])
                            throw new BizException("����д�ı�����Ʒ�����������۵���ʵ�ʹ�����������ȷ���豣�޵���Ʒ��Ϊ�˵�����");
                    }
                    rmaInfo.SysNo = SequenceDac.GetInstance().Create("RMA_Sequence");
                    rmaInfo.RMAID = this.BuildRMAID(rmaInfo.SysNo);
                    rmaInfo.SubmitInfo = this.GetRMASnapShot(rmaInfo);
                    rmaInfo.Status = (int)AppEnum.RMAStatus.Origin;
                    this.InsertMaster(rmaInfo);
                    foreach(RMAItemInfo rmaItem in rmaInfo.ItemHash.Values)
                    {
                        rmaItem.RMASysNo = rmaInfo.SysNo;
                        this.InsertItem(rmaItem);
                    }
                }
                else
                    throw new BizException("�����۵��Ѿ�����һ�ű��޵��ڴ����У�������������ύ�µı������룬����ϵORS�̳ǿͷ�");
                scope.Complete();
            }
        }
开发者ID:ue96,项目名称:ue96,代码行数:36,代码来源:RMAManager.cs

示例7: Execute

        /// Execute action
        public override object Execute()
        {
            TransactionOptions options = new TransactionOptions
                                             {
                                                 IsolationLevel = IsolationLevel,
                                                 Timeout = (Utils.ToTimeSpan(Context.TransformStr(Timeout, Transform)) ?? TimeSpan.FromSeconds(60))
                                             };

            VerboseMessage(" -- Starting transaction {0} (Isolation: {1}) --",Option,IsolationLevel);

            object ret;
            using (TransactionScope scope=new TransactionScope(Option,options))
            {
                try
                {
                    ret = base.Execute();
                    scope.Complete();
                    VerboseMessage(" -- Transaction commit --");
                }
                catch
                {
                    VerboseMessage(" -- Transaction rollback --");
                    throw;
                }
            }

            return ret;
        }
开发者ID:xsharper,项目名称:xsharper,代码行数:29,代码来源:Transaction.cs

示例8: CreateTransactionScope

 public static TransactionScope CreateTransactionScope()
 {
     var transactionOptions = new TransactionOptions();
     transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted;
     transactionOptions.Timeout = TimeSpan.MaxValue;
     return new TransactionScope(TransactionScopeOption.Required, transactionOptions);
 }
开发者ID:Newbourne,项目名称:CAPITAL,代码行数:7,代码来源:TransactionUtil.cs

示例9: CreateTransactionScope

 public static TransactionScope CreateTransactionScope()
 {
     var transactionOptions = new TransactionOptions();
     transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted;
     transactionOptions.Timeout = TransactionManager.MaximumTimeout;
     return new TransactionScope(TransactionScopeOption.Required, transactionOptions);
 }
开发者ID:gbsens,项目名称:Community,代码行数:7,代码来源:TransactionUtils.cs

示例10: GetTransactionOptions

 /// <summary>
 /// 获取事务隔离级别
 /// </summary>
 /// <returns></returns>
 public static TransactionOptions GetTransactionOptions()
 {
     TransactionOptions transactionOptions = new TransactionOptions();
         switch (ConfigurationManager.AppSettings["IsolationLevel"].ToString())
         {
             case "Chaos":
                 transactionOptions.IsolationLevel = IsolationLevel.Chaos;
                 break;
             case "ReadCommitted":
                 transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted;
                 break;
             case "ReadUncommitted":
                 transactionOptions.IsolationLevel = IsolationLevel.ReadUncommitted;
                 break;
             case "RepeatableRead":
                 transactionOptions.IsolationLevel = IsolationLevel.RepeatableRead;
                 break;
             case "Serializable":
                 transactionOptions.IsolationLevel = IsolationLevel.Serializable;
                 break;
             case "Snapshot":
                 transactionOptions.IsolationLevel = IsolationLevel.Snapshot;
                 break;
             case "Unspecified":
                 transactionOptions.IsolationLevel = IsolationLevel.Unspecified;
                 break;
             default:
                 transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted;
                 break;
         }
     return transactionOptions;
 }
开发者ID:loozhang,项目名称:WebApplication3---copy,代码行数:36,代码来源:PublicMethod.cs

示例11: CommendCustomerEmailVerified

        public void CommendCustomerEmailVerified(int CustomerSysNo,string CommendEmail)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                CustomerCommendInfo oInfo = LoadCustomerCommend(CommendEmail);
                if(oInfo == null)
                    throw new BizException("");
                decimal increment = 5; //�Ƽ��ĺ���ͨ��Email��֤����5���˷�
                int rowsAffected = new FreeShipFeeDac().SetFreeShipFee(CustomerSysNo, increment);
                if (rowsAffected != 1)
                    throw new BizException("�ͻ��˷�������ʧ�ܣ�������Ϊ�˷����㡣");

                UpdateCustomerCommendStatus(CommendEmail, (int) AppEnum.CommendStatus.Registered); //�����Ƽ�״̬

                if (increment != 0)
                {
                    int freeShipFeeLogType = (int)AppEnum.FreeShipFeeLogType.CustomerRegister;
                    string freeShipFeeLogMemo = "�Ƽ��ͻ�ע�����˷� - " + CommendEmail;
                    CustomerFreeShipFeeLogInfo oLog = new CustomerFreeShipFeeLogInfo(CustomerSysNo, freeShipFeeLogType, increment, freeShipFeeLogMemo);
                    oLog.LogCheck = oLog.CalcLogCheck();

                    if (1 != new FreeShipFeeDac().Insert(oLog))
                        throw new BizException("�����˷����ʧ��");
                }

                scope.Complete();
            }
        }
开发者ID:ue96,项目名称:ue96,代码行数:32,代码来源:FreeShipFeeManager.cs

示例12: CommendCustomerEmailList

        public void CommendCustomerEmailList(int CustomerSysNo,decimal FreeShipFee,Hashtable ht,string EmailBody)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                if (!VerifyValidEmailList(ht))
                    throw new BizException("�����ظ��Ƽ�!");

                CustomerInfo cInfo = CustomerManager.GetInstance().Load(CustomerSysNo);
                string CustomerName = cInfo.CustomerName;
                string mailSubject = CustomerName + " �����Ƽ�ORS�̳���";
                foreach (string email in ht.Keys)
                {
                    UpdateCustomerCommendStatus(email, (int) AppEnum.CommendStatus.Origin);

                    string mailBody = "@FriendName<br>" + EmailBody + "<br>@CustomerName<br>" + DateTime.Now.ToString(AppConst.DateFormat);
                    mailBody = mailBody.Replace("@FriendName", ht[email].ToString());
                    mailBody = mailBody.Replace("@CustomerName", CustomerName);

                    EmailInfo oEmail = new EmailInfo(email, mailSubject, mailBody);
                    EmailManager.GetInstance().InsertEmail(oEmail);
                }

                SetFreeShipFee(CustomerSysNo, FreeShipFee, (int)AppEnum.FreeShipFeeLogType.CommendCustomer, "�Ƽ�����Email");

                scope.Complete();
            }
        }
开发者ID:ue96,项目名称:ue96,代码行数:31,代码来源:FreeShipFeeManager.cs

示例13: AddItem

        public int AddItem(RMARevertInfo oParam)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                foreach (int registerSysNo in oParam.ItemHash.Keys)
                {
                    RMARevertItemInfo oRevertItem = new RMARevertItemInfo();
                    oRevertItem.RegisterSysNo = registerSysNo;
                    oRevertItem.RevertSysNo = oParam.SysNo;
                    //��Register�ֿ��д��RMA_Revert_Item
                    int revertStockSysNo = AppConst.IntNull;
                    DataRow regdr = RMARegisterManager.GetInstance().GetRegisterRow(registerSysNo);
                    revertStockSysNo = Util.TrimIntNull(regdr["RevertStockSysNo"]);

                    oRevertItem.StockSysNo = Util.TrimIntNull(revertStockSysNo);

                    this.InsertRevertItem(oRevertItem);
                }

                scope.Complete();
                return oParam.SysNo;
            }
        }
开发者ID:ue96,项目名称:ue96,代码行数:27,代码来源:RMARevertManager.cs

示例14: Init

        /// <summary>
        /// Initializes the <see cref="IDequeueMessages" />.
        /// </summary>
        /// <param name="address">The address to listen on.</param>
        /// <param name="transactionSettings">The <see cref="TransactionSettings" /> to be used by <see cref="IDequeueMessages" />.</param>
        /// <param name="tryProcessMessage">Called when a message has been dequeued and is ready for processing.</param>
        /// <param name="endProcessMessage">Needs to be called by <see cref="IDequeueMessages" /> after the message has been processed regardless if the outcome was successful or not.</param>
        public void Init(Address address, TransactionSettings transactionSettings, Func<TransportMessage, bool> tryProcessMessage, Action<TransportMessage, Exception> endProcessMessage)
        {
            this.tryProcessMessage = tryProcessMessage;
            this.endProcessMessage = endProcessMessage;
            this.workQueue = this.NamePolicy.GetQueueName(address);
            this.clientInfo = string.Format("OracleAQDequeueStrategy for {0}", this.workQueue);

            this.transactionOptions = new TransactionOptions
            {
                IsolationLevel = transactionSettings.IsolationLevel,
                Timeout = transactionSettings.TransactionTimeout,
            };

            this.dequeueOptions = new OracleAQDequeueOptions
            {
                DequeueMode = OracleAQDequeueMode.Remove,
                ProviderSpecificType = true,
                Wait = 0,
            };

            if (this.PurgeOnStartup)
            {
                this.Purger.Purge(this.workQueue);
            }
        }
开发者ID:rosieks,项目名称:NServiceBus.OracleAQ,代码行数:32,代码来源:OracleAQDequeueStrategy.cs

示例15: GetSalesHistory

        public static List<SalesHistoryData> GetSalesHistory()
        {
            List<SalesHistoryData> result = new List<SalesHistoryData>();
            try
            {
                // The encrypted list will timeout for slightly large lists (in the hundreds), so the list is
                // being grabbed in smaller chunks.  Transaction logic is used to lock the list while the list is being
                // grabbed.
                TransactionOptions transactionOptions = new TransactionOptions();
                transactionOptions.IsolationLevel = IsolationLevel.RepeatableRead;
                transactionOptions.Timeout = new TimeSpan(0, 2, 0);
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew, transactionOptions))
                {
                    Console.WriteLine("Test 1: List all Sales Orders");
                    int take = 5;
                    int count = UserSession.Current.Client.GetSalesOrderListCount();
                    for (int skip = 0; skip < count; skip = skip + take)
                    {
                        List<SalesHistoryData> salesOrders = UserSession.Current.Client.GetSalesHistory(take, skip).ToList();
                        result = result.Union(salesOrders).ToList();
                    }
                    result = result.OrderByDescending(so => so.SalesOrderNumber).ThenBy(so => so.SortOrder).ToList();
                    //No scope.Complete here as no write tasks are being scoped.

                    scope.Dispose();
                }
            }
            catch (Exception) { throw; }
            return result;
        }
开发者ID:JamieMellway,项目名称:BicycleWorldWCFAssignment,代码行数:30,代码来源:SalesHistoryClient.cs


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