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


C# ActiveRecord.TransactionScope类代码示例

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


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

示例1: Create

        public ActionResult Create(TaxpayerRecipient item)
        {
            if (!string.IsNullOrEmpty (item.Id)) {
                var entity = TaxpayerRecipient.TryFind (item.Id);

                if (entity != null) {
                    ModelState.AddModelError ("", Resources.TaxpayerRecipientAlreadyExists);
                }
            }

            if (!item.HasAddress) {
                ModelState.Where (x => x.Key.StartsWith ("Address.")).ToList ().ForEach (x => x.Value.Errors.Clear ());
                item.Address = null;
            }

            if (!ModelState.IsValid) {
                return PartialView ("_Create", item);
            }

            item.Id = item.Id.ToUpper ().Trim ();
            item.Name = item.Name.Trim ();
            item.Email = item.Email.Trim ();

            using (var scope = new TransactionScope ()) {
                if (item.HasAddress) {
                    item.Address.Create ();
                }

                item.CreateAndFlush ();
            }

            return PartialView ("_CreateSuccesful", item);
        }
开发者ID:mictlanix,项目名称:mbe,代码行数:33,代码来源:TaxpayerRecipientsController.cs

示例2: ApplyPayment

        public ActionResult ApplyPayment(SalesOrderPayment item)
        {
            var entity = new SalesOrderPayment {
                SalesOrder = SalesOrder.TryFind (item.SalesOrder.Id),
                Payment = CustomerPayment.TryFind (item.PaymentId),
                Amount = item.Amount
            };
            var balance = entity.SalesOrder.Balance - GetRefunds (entity.SalesOrder.Id);

            if (entity.Amount > entity.Payment.Balance) {
                entity.Amount = entity.Payment.Balance;
            }

            balance -= entity.Amount;

            using (var scope = new TransactionScope ()) {
                if (balance <= 0) {
                    entity.SalesOrder.IsPaid = true;
                    entity.SalesOrder.Update ();
                }

                if (entity.Amount > 0) {
                    entity.Create ();
                }

                scope.Flush ();
            }

            return PartialView ("_ApplyPaymentSuccesful");
        }
开发者ID:mictlanix,项目名称:mbe,代码行数:30,代码来源:AccountsReceivablesController.cs

示例3: AddPurchaseDetail

        public JsonResult AddPurchaseDetail(int movement, int warehouse, int product)
        {
            var p = Product.Find (product);
            var cost = (from x in ProductPrice.Queryable
                    where x.Product.Id == product && x.List.Id == 0
                    select x.Value).SingleOrDefault ();

            var item = new PurchaseOrderDetail {
                Order = PurchaseOrder.Find (movement),
                Warehouse = Warehouse.Find (warehouse),
                Product = p,
                ProductCode = p.Code,
                ProductName = p.Name,
                Quantity = 1,
                TaxRate = p.TaxRate,
                IsTaxIncluded = p.IsTaxIncluded,
                Discount = 0,
                Price = cost,
                ExchangeRate = CashHelpers.GetTodayDefaultExchangeRate (),
                Currency = WebConfig.DefaultCurrency
            };

            using (var scope = new TransactionScope ()) {
                item.CreateAndFlush ();
            }

            return Json (new {
                id = item.Id
            });
        }
开发者ID:mictlanix,项目名称:mbe,代码行数:30,代码来源:PurchasesController.cs

示例4: Create

        public ActionResult Create(Supplier item)
        {
            if (!ModelState.IsValid)
                return PartialView ("_Create", item);

            using (var scope = new TransactionScope ()) {
                item.CreateAndFlush ();
            }

            return PartialView ("_CreateSuccesful", item);

            //if (!ModelState.IsValid)
            //{
            //    if (Request.IsAjaxRequest())
            //        return PartialView("_Create", supplier);

            //    return View(supplier);
            //}

            //supplier.Create ();

            //if (Request.IsAjaxRequest())
            //{
            //    //FIXME: localize string
            //    return PartialView("_Success", "Operation successful!");
            //}

            //return View("Index");
        }
开发者ID:mictlanix,项目名称:mbe,代码行数:29,代码来源:SuppliersController.cs

示例5: Registro

        public static void Registro()
        {
            foreach (var archivo in ActiveRecordBase<ConsumoDto>.FindAllByProperty("Procesado", false))
            {
                var documento = HelperPersona.GetPersona(
                    archivo.Cuit, archivo.TipoCliente,
                    archivo.RazonSocial, archivo.NombrePersona,
                    archivo.NroDocumento, archivo.Empresa);

                    var cliente = HelperCuenta.GetCuenta(
                        archivo.Cuit, archivo.NroDocumento, archivo.Empresa);

                    using (var transac = new TransactionScope())
                        try
                        {
                            var puntos = HelperPuntos.GetPuntos(archivo.Empresa, archivo.FechaHoraComprobante,
                                                            archivo.ImportePesosNetoImpuestos);

                            double acelerador = Double.Parse(archivo.Coeficiente) / 100;
                            puntos = acelerador > 0 ? acelerador * puntos : puntos;

                            var cuenta = new CuentaCorrienteDto
                            {
                                FechaCompra = archivo.FechaHoraComprobante.Date,
                                HoraCompra = DateTime.Now,
                                Key = new KeyCuenta
                                {
                                    CodEmpresa = archivo.Empresa,
                                    NumeroComprobante = archivo.NroComprobante
                                },
                                MontoCompra = archivo.ImportePesosNetoImpuestos,
                                Movimiento = puntos >= 0 ? HelperMovimiento.FindMovimiento("Suma De Puntos") : HelperMovimiento.FindMovimiento("Anulación Carga"),
                                NumeroDocumento = documento,
                                NumeroCuenta = cliente,
                                Puntos = puntos,
                                Sucursal = HelperSucursal.GetSucursal(),
                                Usuario = "web",
                                Programa = archivo.Programa,
                                Secretaria = archivo.Secretaria,
                                Coeficiente = archivo.Coeficiente
                            };
                            cuenta.Save();
                            transac.VoteCommit();
                        }
                        catch (Exception ex)
                        {
                            archivo.Error = ex.Message;
                            Log.Fatal(ex);
                            transac.VoteRollBack();
                        }
                    archivo.Procesado = true;
                    archivo.Save();
                } 
            }
开发者ID:galbarello,项目名称:Importador.Fidecard,代码行数:54,代码来源:WorkflowFidecard.cs

示例6: ActiveRecordUsingTransactionScopeWithRollback

		public void ActiveRecordUsingTransactionScopeWithRollback()
		{
			InitModel();
			using (TransactionScope scope = new TransactionScope())
			{
				new SSAFEntity("example").Save();
				//Assert.AreEqual(1, SSAFEntity.FindAll().Length);
				scope.VoteRollBack();
			}
			Assert.AreEqual(0, SSAFEntity.FindAll().Length);
		}
开发者ID:sheefa,项目名称:Castle.ActiveRecord,代码行数:11,代码来源:SessionScopeAutoflushTestCase.cs

示例7: Create

        public ActionResult Create(Employee item)
        {
            if (!ModelState.IsValid) {
                return PartialView ("_Create", item);
            }

            using (var scope = new TransactionScope ()) {
                item.CreateAndFlush ();
            }

            return PartialView ("_Refresh");
        }
开发者ID:mictlanix,项目名称:mbe,代码行数:12,代码来源:EmployeesController.cs

示例8: CancelReturn

        public ActionResult CancelReturn(int id)
        {
            var item = SupplierReturn.Find (id);

            item.IsCancelled = true;

            using (var scope = new TransactionScope ()) {
                item.UpdateAndFlush ();
            }

            return RedirectToAction ("Index");
        }
开发者ID:mictlanix,项目名称:mbe,代码行数:12,代码来源:SupplierReturnsController.cs

示例9: Create

        public ActionResult Create(TechnicalServiceReceipt item)
        {
            if (!ModelState.IsValid) {
                return PartialView ("_Create", item);
            }

            using (var scope = new TransactionScope ()) {
                item.CreateAndFlush ();
            }

            return PartialView ("_CreateSuccesful", item);
        }
开发者ID:mictlanix,项目名称:mbe,代码行数:12,代码来源:TechnicalServiceReceiptsController.cs

示例10: DisposeScope

 public static void DisposeScope()
 {
     if (TransactionScope != null)
     {
         TransactionScope.Dispose();
         TransactionScope = null;
     }
     if (Scope != null)
     {
         Scope.Dispose();
         Scope = null;
     }
 }
开发者ID:Yavari,项目名称:MyFavourites,代码行数:13,代码来源:ScopeManagement.cs

示例11: Can_execute_SQL

        public void Can_execute_SQL()
        {
            using (var transaction = new TransactionScope())
            {
                var user = repository.Save(new User {Email = "[email protected]", Name = "User1"});
                transaction.Flush();

                repository.ExecuteSql(string.Format("UPDATE User SET Email=\"[email protected]\"", user.Id));
                transaction.Flush();

                repository.Refresh(user);
                Assert.AreEqual("[email protected]", user.Email);
            }
        }
开发者ID:DavidMoore,项目名称:Foundation,代码行数:14,代码来源:ActiveRecordRepositoryFixture.cs

示例12: Create

        public ActionResult Create(Notarization item)
        {
            item.Requester = Employee.TryFind (item.RequesterId);

            if (!ModelState.IsValid) {
                return PartialView ("_Create", item);
            }

            using (var scope = new TransactionScope ()) {
                item.CreateAndFlush ();
            }

            return PartialView ("_CreateSuccesful", item);
        }
开发者ID:mictlanix,项目名称:mbe,代码行数:14,代码来源:NotarizationsController.cs

示例13: Confirm

        public ActionResult Confirm(int id)
        {
            var item = SalesOrder.Find (id);

            item.Updater = CurrentUser.Employee;
            item.ModificationTime = DateTime.Now;
            item.IsDelivered = true;

            using (var scope = new TransactionScope ()) {
                item.UpdateAndFlush ();
            }

            return RedirectToAction ("Index");
        }
开发者ID:mictlanix,项目名称:mbe,代码行数:14,代码来源:ProductionOrdersController.cs

示例14: Edit

 public ActionResult Edit(int id, FormCollection form)
 {
     using (var transaction = new TransactionScope(TransactionMode.Inherits))
     {
         var original = Document.Find(id);
         if (TryUpdateModel(original))
         {
             original.Save();
             return RedirectToAction("Details", new { Id = id });
         }
         transaction.VoteRollBack();
         return View("Edit");
     }
 }
开发者ID:Yavari,项目名称:MyFavourites,代码行数:14,代码来源:DocumentsController.cs

示例15: Create

        public ActionResult Create(TechnicalServiceRequest item)
        {
            item.Customer = Customer.TryFind (item.CustomerId);

            if (!ModelState.IsValid) {
                return PartialView ("_Create", item);
            }

            using (var scope = new TransactionScope ()) {
                item.CreateAndFlush ();
            }

            return PartialView ("_CreateSuccesful", item);
        }
开发者ID:mictlanix,项目名称:mbe,代码行数:14,代码来源:TechnicalServiceRequestsController.cs


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