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


C# UnitOfWork.RollbackTransaction方法代码示例

本文整理汇总了C#中UnitOfWork.RollbackTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# UnitOfWork.RollbackTransaction方法的具体用法?C# UnitOfWork.RollbackTransaction怎么用?C# UnitOfWork.RollbackTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnitOfWork的用法示例。


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

示例1: RollbackTransaction_calls_DbContext_RollbackTransaction

        public void RollbackTransaction_calls_DbContext_RollbackTransaction()
        {
            var uow = new UnitOfWork(_dbContextFactoryMock.Object);

            uow.RollbackTransaction();

            _dbContextMock.Verify(x => x.RollbackTransaction(), Times.Once);
        }
开发者ID:qstream-inactive,项目名称:ENTech-Store,代码行数:8,代码来源:UnitOfWorkTest.cs

示例2: CalculateProdOrder

 private void CalculateProdOrder(ProdOrder pOrder)
 {
     UnitOfWork uow = new UnitOfWork(); //  (UnitOfWork)((ObjectSpace)View.ObjectSpace).Session;
     ProdOrder prodOrder = ProdOrder.Find(uow, pOrder.OrderNo);
     try
     {
         uow.BeginTransaction();
         prodOrder.CalculateOrder(uow);
         uow.CommitChanges();
         View.ObjectSpace.Refresh();
     }
     catch (Exception e)
     {
         DevExpress.XtraEditors.XtraMessageBox.Show(e.Message, string.Format("錯誤 - 生产单 {0} 不能计算", prodOrder.OrderNo));
         uow.RollbackTransaction();
     }
 }
开发者ID:kamchung322,项目名称:Namwah,代码行数:17,代码来源:ProdOrder_Update.cs

示例3: DeductByShipmentNo

        void DeductByShipmentNo(string sNo)
        {
            UnitOfWork uow = new UnitOfWork();
            uow.BeginTransaction();

            Shipment shipment = uow.FindObject<Shipment>(CriteriaOperator.Parse(string.Format("PackingListNo == '{0}'", sNo)));

            if (shipment == null)
            {
                txtMessage.Text = string.Format("错误!!  找不到这单号 {0}! 请查清楚 !!", sNo);
                uow.RollbackTransaction();
                PlayErrorSound();
                return;
            }

            if (shipment.Status != Shipment.PackStatus.Ready)
            {
                txtMessage.Text = string.Format("错误!!  这单号 {0} 的状态不是 '{1}'", sNo, Shipment.PackStatus.Ready);
                uow.RollbackTransaction();
                PlayErrorSound();
                return;
            }

            try
            {
                shipment.AddPackedQty(shipment.UnPackedQty);
                shipment.AddCartonNo(txtCartonNo.Text);
                uow.CommitTransaction();
                PlayOKSound();
                txtMessage.Text = "OK";
            }
            catch (Exception ex)
            {
                PlayErrorSound();
                txtMessage.Text = ex.Message;
                uow.RollbackTransaction();
            }
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:38,代码来源:frmShipmentConfirmActive.cs

示例4: CompleteProdOrder

        private void CompleteProdOrder(ProdOrder pOrder)
        {
            UnitOfWork uow = new UnitOfWork(); // (UnitOfWork)((ObjectSpace)View.ObjectSpace).Session;
            ProdOrder prodOrder = uow.GetObjectByKey<ProdOrder>(pOrder.Oid);

            try
            {
                uow.BeginTransaction();
                prodOrder.CompleteOrder(uow);
                uow.CommitChanges();
                View.ObjectSpace.Refresh();
            }
            catch (Exception ex)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message, string.Format("錯誤 - 生产单 {0} 不能结单", prodOrder.OrderNo));
                uow.RollbackTransaction();
            }
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:18,代码来源:ProdOrder_Update.cs

示例5: IssueQCProdOrder


//.........这里部分代码省略.........
            sortProps.Add(new SortProperty("PurchOrderLineType", SortingDirection.Descending ));
            sortProps.Add(new SortProperty("NeedDate", SortingDirection.Ascending));
            sortProps.Add(new SortProperty("SubItem", SortingDirection.Ascending));
            poLines.Criteria = CriteriaOperator.Parse(string.Format("OrderStatus == '{0}'AND SubItem.ItemType == '{1}' ", SubPurchOrderLine.PurchOrderStatus.Active, SubItem.SubItemType.QC));
            poLines.Sorting = sortProps;

            foreach (SubPurchOrderLine poLine in poLines)
            {
                float deductQty = 0;
                string key = poLine.SubItem.ItemNo + "_" + poLine.PurchOrderLineType.ToString();

                if (dictDeductQty.ContainsKey(key) == false)
                {
                    SubItemSummary itemSummary = SubItemSummary.Find(uow, poLine.SubItem.ItemNo, poLine.PurchOrderLineType);
                    deductQty = itemSummary.ProdOrderBalQty + itemSummary.CanShipQty + itemSummary.CanShipDefectQty + itemSummary.CanShipNWDefectQty;
                    dictDeductQty.Add(key, deductQty);
                }

                if (dictIssueQty.ContainsKey(key))
                    dictIssueQty[key] = dictIssueQty[key] + poLine.BalQty ;
                else
                    dictIssueQty.Add(key, poLine.BalQty);

            }

            #endregion

            #region ��������
            try
            {
                uow.BeginTransaction();
                float balQty = 0;
                float balSht = shtQty;

                foreach (KeyValuePair<string, float> issue in dictIssueQty)
                {
                    if (balSht == 0)
                        break;

                    string[] key = issue.Key.Split('_');
                    string itemNo = key[0];
                    string orderType = key[1];
                    SubItem subItem = SubItem.Find(uow, itemNo);
                    float issueQty = issue.Value;

                    if (dictDeductQty.ContainsKey(issue.Key))
                    {
                        issueQty = issueQty - dictDeductQty[issue.Key];

                        if (issueQty < 0)
                            issueQty = 0;
                    }

                    if (issueQty > 0)
                    {
                        int issueSht = (int)(issueQty / prodQty);
                        // �ȳ�������.
                        for (int i = 0; i <= issueSht; i++)
                        {
                            if (balSht > 0 && issueQty > 0)
                            {
                                SubProdOrder prodOrder = new SubProdOrder(uow);
                                prodOrder.SubItem = subItem;

                                if (orderType == "Return")
                                    prodOrder.ProdOrderType = SubPurchOrderLine.OrderType.Return;
                                else
                                    prodOrder.ProdOrderType = SubPurchOrderLine.OrderType.Normal;

                                if (issueQty > prodQty)
                                {
                                    prodOrder.Qty = prodQty;
                                    issueQty = issueQty - prodQty;
                                }
                                else
                                {
                                    prodOrder.Qty = issueQty;
                                    issueQty = 0;
                                }

                                prodOrder.Save();

                                balSht--;
                            }
                        }
                    }
                }

                uow.CommitChanges();
                View.ObjectSpace.Refresh();
            }
            catch
            {
                uow.RollbackTransaction();
                View.ObjectSpace.Refresh();
                XtraMessageBox.Show("ϵͳ���ⲻ�ܷ���, ���˳����� !!!");
            }

            #endregion
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:101,代码来源:SubProdOrder_View.cs

示例6: PostPurchOrderReceive_Execute

        private void PostPurchOrderReceive_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            if (View.CurrentObject == null)
                return;

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("请确认是否把以下采购单过帐 !!");

            foreach (PurchOrderReceive poReceive in View.SelectedObjects)
                sb.AppendLine(string.Format("采购单号 : {0}, 产品编码 ; {1}, 数量 ; {2}", poReceive.PurchOrderLine.PurchOrderNo, poReceive.Item.ItemNo, poReceive.Qty));

            DialogResult dr = XtraMessageBox.Show(sb.ToString(), "确认过帐", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                foreach (PurchOrderReceive oReceive in e.SelectedObjects)
                {
                    // 这样过帐才可避免扣多数
                    using (UnitOfWork uow = new UnitOfWork())
                    {
                        uow.BeginTransaction();
                        try
                        {
                            PurchOrderReceive orderReceive = uow.GetObjectByKey<PurchOrderReceive>(oReceive.Oid);
                            orderReceive.Post();
                            uow.CommitTransaction();
                        }
                        catch (Exception ex)
                        {
                            DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message, "錯誤", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                            uow.RollbackTransaction();
                        }
                    }
                }
                View.ObjectSpace.Refresh();
            }
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:38,代码来源:PurchOrderReceive_View.cs

示例7: RunReport

        public void RunReport()
        {
            Logger.For(this).Info("开始");
            wipTable = new WIPTable(Session);
            wipTable.WIPReportType = this.WIPReportType;
            wipTable.Save();

            dictPoLine = new Dictionary<string, XPCollection<WIPPurchOrderLine>>();
            dictProdRoute = new Dictionary<string, XPCollection<WIPProdRoute>>();
            dictWHTotal = new Dictionary<string, XPCollection<WIPWHTotal>>();
            dictProdBom = new Dictionary<string, XPCollection<WIPProdBom>>();
            dictWIPRouteLine = new Dictionary<string, WIPRouteLine>();

            uow = (UnitOfWork)Session;
            try
            {
                cacheData();
                initWIPItemNeed();
                uow.CommitChanges();
                calcWIP();
                uow.CommitChanges();
                calcReadyQty();
                uow.CommitChanges();
            }
            catch (Exception ex)
            {
                Logger.For(this).Error(string.Format("不能计算WIP.  出现以下错误.\n{0}", ex.Message));
                uow.RollbackTransaction();
            }
            Logger.For(this).Info("结束");
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:31,代码来源:mpWIPAll.cs

示例8: createUnitOfWork

        /// <summary>
        /// Creates the unit of work for package data.
        /// </summary>
        /// <returns>Unit of work</returns>
        private UnitOfWork createUnitOfWork()
        {
            tempFileName = Path.GetTempFileName();
            if (PackageData != null)
                File.WriteAllBytes(tempFileName, PackageData);
            else if (File.Exists(tempFileName))
                File.Delete(tempFileName);

            var connStr = AccessConnectionProvider.GetConnectionString(tempFileName);

            // create unit of work based on temporary ms access database
            IDisposable[] disposables;
            var dataStore = XpoDefault.GetConnectionProvider(connStr, AutoCreateOption.DatabaseAndSchema,
                out disposables);
            var dataLayer = new SimpleDataLayer(XafTypesInfo.XpoTypeInfoSource.XPDictionary, dataStore);
            var result = new UnitOfWork(dataLayer, disposables);

            string errorText;
            if(!verifyMarker(result, out errorText))
            {
                result.RollbackTransaction();
                result.Dispose();
                throw new InvalidPackageDataException(errorText);
            }
            // mark object changed
            if (PackageData == null)
                OnChanged();
            return result;
        }
开发者ID:xafdelta,项目名称:xafdelta,代码行数:33,代码来源:Package.cs

示例9: IssuePOReceive

        public static void IssuePOReceive(SubItem subItem, SubPurchOrderLine.OrderType poType, SubSalesOrderLine soLine,
                                                     ref float Qty, ref float DefectQty, ref float NWDefectQty)
        {
            UnitOfWork uow = new UnitOfWork();
            uow.BeginTransaction();
            List<SubPurchOrderLine> PoLines = SubPurchOrderLine.LoadOpenBalance(uow, subItem, poType);

            try
            {
                for (int i = 0; i < PoLines.Count; i++)
                {
                    if (Qty == 0 && DefectQty == 0 && NWDefectQty == 0)
                        break;

                    SubPurchOrderLine poLine = PoLines[i];
                    SubPurchOrderReceive poReceive = new SubPurchOrderReceive(uow);
                    poReceive.PurchOrderLine = poLine;

                    if (soLine != null)
                    {
                        poReceive.SalesOrderLine = uow.FindObject<SubSalesOrderLine>(new BinaryOperator("Oid", soLine.Oid));
                    }

                    float poBal = poLine.BalQty;
                    poReceive.Qty = UDFunction.AssignSmallQty(ref poBal, ref Qty);
                    poReceive.DefectQty = UDFunction.AssignSmallQty(ref poBal, ref DefectQty);
                    poReceive.NWDefectQty = UDFunction.AssignSmallQty(ref poBal, ref NWDefectQty);

                    poReceive.Save();
                    poReceive.Post();

                }

                uow.CommitTransaction();
            }
            catch (Exception ex)
            {
                uow.RollbackTransaction();
                throw ex;
            }
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:41,代码来源:SubPurchOrderReceive.cs


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