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

C# ActiveRecord.TransactionScope类代码示例

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

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



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


示例16: btnSalvar_Click1

        /// <summary>
        /// evento disparado pelo botão salvar
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSalvar_Click1(object sender, EventArgs e)
        {
            //bisca a lista de moradores selecionados
            List<int> lista = (List<int>)ViewState["moradores"];

            
            if (lista.Count > 0)
            {
                //abre a transação
                using (TransactionScope trans = new TransactionScope())
                {
                    try
                    {
                        //cria o template da mensagem
                        Domain.Model.Mensagem mensagem = new Domain.Model.Mensagem();
                        mensagem.Usuario = txtUsuario.Text;
                        mensagem.Detalhe = txtMensagem.Text;
                        mensagem.CreateAndFlush();


                        Usuario user = new Usuario();
                        MensagensDosUsuarios mensagemRelacionada;
                        //envia a mensagem para casa usuário selecionado
                        foreach (var item in lista)
                        {
                            user.Id = item;
                            mensagemRelacionada = new MensagensDosUsuarios();
                            mensagemRelacionada.Mensagem = mensagem;
                            mensagemRelacionada.Usuario = user;
                            mensagemRelacionada.CreateAndFlush();
                        }
                        //commit da transação
                        trans.VoteCommit();
                    }
                    catch (Exception ex)
                    {
                        //rollback da transação
                        trans.VoteRollBack();
                        //grava o erro em um log
                        Logger.Error(ex.Message);
                        base.ExibirMensagemErro();
                    }
                }
                base.ExibirMensagemSucesso(Funcionalidade.Mensagem, Operacao.Inclusao);
            }
            else
            {
                pnlMensagem.ExibirMensagem("Selecione os usuários para quem você vai enviar a mensagem");
            }
        }
开发者ID:felipealbuquerq,项目名称:Condominio,代码行数:55,代码来源:CadastroMensagem.aspx.cs


示例17: Cancel

        public ActionResult Cancel(int id)
        {
            var entity = CustomerRefund.Find (id);

            entity.Updater = CurrentUser.Employee;
            entity.ModificationTime = DateTime.Now;
            entity.Date = DateTime.Now;
            entity.IsCancelled = true;

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

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


示例18: Confirm

        public ActionResult Confirm(int id)
        {
            var dt = DateTime.Now;
            bool changed = false;
            var entity = CustomerRefund.Find (id);

            using (var scope = new TransactionScope ()) {
                foreach (var item in entity.Details) {
                    var qty = GetRefundableQuantity (item.SalesOrderDetail.Id);

                    if (qty < item.Quantity) {
                        changed = true;

                        if (qty > 0) {
                            item.Quantity = qty;
                            item.Update ();
                        } else {
                            item.Delete ();
                        }
                    }
                }

                if (changed) {
                    entity.Updater = CurrentUser.Employee;
                    entity.ModificationTime = dt;
                    entity.UpdateAndFlush ();

                    return RedirectToAction ("Edit", new { id = entity.Id, notify = true });
                }
            }

            using (var scope = new TransactionScope ()) {

                foreach (var x in entity.Details) {
                    InventoryHelpers.ChangeNotification (TransactionType.CustomerRefund, entity.Id, dt,
                        x.SalesOrderDetail.Warehouse, null, x.Product, x.Quantity);
                }

                entity.Updater = CurrentUser.Employee;
                entity.ModificationTime = dt;
                entity.Date = dt;
                entity.IsCompleted = true;
                entity.UpdateAndFlush ();
            }

            return RedirectToAction ("View", new { id = entity.Id });
        }
开发者ID:mictlanix,项目名称:mbe,代码行数:47,代码来源:CustomerRefundsController.cs


示例19: ConfirmReturn

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

            var qry = from x in item.Details
                  where x.Order.Id == id
                  group x by x.Warehouse into g
                  select new { Warehouse = g.Key, Details = g.ToList () };

            var dt = DateTime.Now;
            var employee = CurrentUser.Employee;

            using (var scope = new TransactionScope ()) {
                foreach (var x in qry) {
                    var master = new InventoryIssue {
                        Return = item,
                        Warehouse = x.Warehouse,
                        CreationTime = dt,
                        ModificationTime = dt,
                        Creator = employee,
                        Updater = employee,
                        Comment = string.Format (Resources.Message_SupplierReturn, item.Supplier.Name, item.PurchaseOrder.Id, item.Id)
                    };

                    master.Create ();

                    foreach (var y in x.Details) {
                        var detail = new InventoryIssueDetail {
                            Issue = master,
                            Product = y.Product,
                            Quantity = y.Quantity,
                            ProductCode = y.ProductCode,
                            ProductName = y.ProductName
                        };

                        detail.Create ();
                    }
                }

                item.IsCompleted = true;
                item.UpdateAndFlush ();
            }

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


示例20: AddIssueDetail

        public JsonResult AddIssueDetail(int movement, int product)
        {
            var p = Product.Find (product);

            var item = new InventoryIssueDetail {
                Issue = InventoryIssue.Find (movement),
                Product = p,
                ProductCode = p.Code,
                ProductName = p.Name,
                Quantity = 1
            };

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

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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