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


C# BusinessException.AddMessages方法代码示例

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


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

示例1: ImportKanBanCard


//.........这里部分代码省略.........
            //IList<FlowDetail> deleteFlowDetailList = new List<FlowDetail>();
            int colCount = 0;

            #region 取所有的路线和路线明细
            //var totalFlowMasterList = genericMgr.FindAll<FlowMaster>("from FlowMaster f where f.Type = ? and f.FlowStrategy = ?", new object[] { (int)type, (int)CodeMaster.FlowStrategy.ANDON });
            var totalFlowDetailList = genericMgr.FindEntityWithNativeSql<FlowDetail>("select d.* from scm_FlowDet d inner join scm_FlowMstr f on f.Code = d.Flow and f.Type = ? and exists(select 1 from SCM_FlowStrategy as fs where fs.Flow=f.Code and fs.Strategy=?)", new object[] { (int)type, (int)CodeMaster.FlowStrategy.ANDON });
            //var totalFlowStrategyList = genericMgr.FindEntityWithNativeSql<FlowStrategy>("select g.* from scm_FlowStrategy g inner join scm_FlowMstr f on f.Code = g.Flow and f.Type = ? and f.FlowStrategy = ?", new object[] { (int)type, (int)CodeMaster.FlowStrategy.ANDON });
            //var totalSupplierList = genericMgr.FindAll<Supplier>();
            //var totalRegionList = genericMgr.FindAll<Region>();
            //var totalLocationList = genericMgr.FindAll<Location>();
            //var totalItemList = genericMgr.FindAll<Item>("from Item where IsActive = ?", true);
            #endregion

            while (rows.MoveNext())
            {
                HSSFRow row = (HSSFRow)rows.Current;
                if (!ImportHelper.CheckValidDataRow(row, 1, 14))
                {
                    break;//边界
                }
                colCount++;

                var rowErrors = new List<Message>();

                string code = string.Empty;
                string item = string.Empty;
                string refItemCode = string.Empty;
                string itemDesc = string.Empty;
                string opRef = string.Empty;
                string opUseQty = string.Empty;
                string itemType = string.Empty;
                string opRefSeq = string.Empty;
                string uc = string.Empty;
                string ucDesc = string.Empty;
                string dock = string.Empty;
                string containerDesc = string.Empty;
                string cardQty = string.Empty;
                string isActive = string.Empty;


                #region 读取数据

                code = ImportHelper.GetCellStringValue(row.GetCell(colCode));
                if (code == null || code.Trim() == string.Empty)
                {
                    rowErrors.Add(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.ErrorMessage.Errors_Import_LineFieldCanNotBeNull, colCount.ToString(), Resources.SCM.FlowMaster.FlowMaster_Code));
                }

                opRef = ImportHelper.GetCellStringValue(row.GetCell(colOpRef));
                if (opRef == null || opRef.Trim() == string.Empty)
                {
                    rowErrors.Add(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.ErrorMessage.Errors_Import_LineFieldCanNotBeNull, colCount.ToString(), "工位"));
                }

                cardQty = ImportHelper.GetCellStringValue(row.GetCell(colCardQty));
                decimal qtyVar = 0;
                if (cardQty == null || cardQty.Trim() == string.Empty || !decimal.TryParse(cardQty,out qtyVar))
                {
                    rowErrors.Add(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.ErrorMessage.Errors_Import_LineFieldCanNotBeNull, colCount.ToString(), "看板张数"));
                }
                
                item = ImportHelper.GetCellStringValue(row.GetCell(colItem));
                if (item == null || item.Trim() == string.Empty)
                {
                    rowErrors.Add(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.ErrorMessage.Errors_Import_LineFieldCanNotBeNull, colCount.ToString(), Resources.SCM.FlowDetail.FlowDetail_Item));
                }
                
                #endregion

                #region 检查路线明细是否都在数据库中
                var flowDet = totalFlowDetailList.FirstOrDefault(f => f.Flow.ToUpper() == code.ToUpper() && f.Item.ToUpper() == item.ToUpper() && f.BinTo.ToUpper() == opRef.ToUpper());
                if (flowDet == null)
                {
                    rowErrors.Add(new Message(com.Sconit.CodeMaster.MessageType.Error, "导入的数据的第{0}行路线明细不存在", colCount.ToString()));
                }
                else
                {
                    flowDet.OrderQty = qtyVar;
                    exactFlowDetailList.Add(flowDet);
                }
                #endregion


                errorMessage.AddMessages(rowErrors);
            }

            if (errorMessage.HasMessage)
            {
                throw errorMessage;
            }

            if (exactFlowDetailList.Count > 0)
            {
                var flowCodes = exactFlowDetailList.Select(f => f.Flow).Distinct();
                foreach (var flow in flowCodes)
                {
                    this.AddManuallyByKanbanFlow(flow, exactFlowDetailList.Where(f => f.Flow == flow).ToList(), DateTime.Now, currUser, true);
                }
            }
        }
开发者ID:Novthirteen,项目名称:sih-les,代码行数:101,代码来源:KanBanCardMgrImpl.cs

示例2: ImportKanBanFlow


//.........这里部分代码省略.........
                            deleteFlowDetailList.Add(sameFlowDet);
                        }

                    }
                    else
                    {
                        //if (exactFlowDetailList.FirstOrDefault(f => f.Flow.ToUpper() == code.ToUpper() && f.BinTo.ToUpper() == opRef.ToUpper() && f.Item.ToUpper() == item.ToUpper()) == null)
                        //{
                        sameFlowDet = new FlowDetail
                        {
                            Flow = code,
                            Item = itemInstance.Code,
                            ItemDescription = itemInstance.Description,
                            BaseUom = itemInstance.Uom,
                            Uom = itemInstance.Uom,
                            ReferenceItemCode = itemInstance.ReferenceCode,
                            UnitCount = itemInstance.UnitCount,
                            MinUnitCount = ucVar,
                            //UnitCountDescription = ucDesc,
                            Container = container,
                            ContainerDescription = containerDesc,
                            //SafeStock = safeStockVal,
                            ItemType = itemType,
                            Dock = dock,
                            OprefSequence = opRefSeq,
                            BinTo = opRef,
                            IsCreate = true,
                            PartyFrom = flowMaster.PartyFrom,
                            LocationTo = flowMaster.LocationTo,
                            FlowMasterStrategy = (int)flowMaster.FlowStrategy,
                            ProductionScan = opRefDesc,
                            //IsRejectInspect = isRejectInspectVal
                        };
                        //sameFlowMaster.AddFlowDetail(sameFlowDet);
                        #region 来源区域 目的库位 物料 不能再不同的策略上出现
                        int checkeSame = this.genericMgr.FindAllWithNativeSql<int>(" select COUNT(*) as countSum  from SCM_FlowDet as d where d.Item=? and exists( select 1 from SCM_FlowMstr as m where m.Code=d.Flow and m.PartyFrom=? and m.LocTo=? and m.Type=2 and exists(select 1 from SCM_FlowStrategy as fs where fs.Flow=m.Code and fs.Strategy<>7)) ", new object[] { item, flowMaster.PartyFrom, flowMaster.LocationTo })[0];
                        if (checkeSame > 0)
                        {
                            rowErrors.Add(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.ErrorMessage.Errors_Import_LineError, colCount.ToString(), (string.Format("来源区域{0}+物料{1}+目的库位{2}+在其他策略中已经存在", flowMaster.PartyFrom, item, flowMaster.LocationTo, sameFlowDet.FlowMasterStrategy))));
                        }
                        if (exactFlowDetailList.Where(ef => ef.PartyFrom == flowMaster.PartyFrom && ef.LocationTo == flowMaster.LocationTo && ef.Item == item && ef.Id != sameFlowDet.Id && ef.FlowMasterStrategy != sameFlowDet.FlowMasterStrategy).Count() > 0)
                        {
                            rowErrors.Add(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.ErrorMessage.Errors_Import_LineError, colCount.ToString(), (string.Format("来源区域{0}+物料{1}+目的库位{2}+策略不同{3}在模板中重复。", flowMaster.PartyFrom, item, flowMaster.LocationTo, sameFlowDet.FlowMasterStrategy))));
                        }
                        #endregion
                        //模板中 路线代码+物料编号+工位 不能重复
                        if (exactFlowDetailList.Where(f => f.Flow.ToUpper() == code.ToUpper() && f.BinTo.ToUpper() == opRef.ToUpper() && f.Item.ToUpper() == item.ToUpper()).Count() > 0
                         || deleteFlowDetailList.Where(f => f.Flow.ToUpper() == code.ToUpper() && f.BinTo.ToUpper() == opRef.ToUpper() && f.Item.ToUpper() == item.ToUpper()).Count() > 0)
                        {
                            rowErrors.Add(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.ErrorMessage.Errors_Import_LineError, colCount.ToString(), string.Format("路线头{0}+工位{1}+物料编号{2}在模板中重复,请确认", code, opRef, item)));
                        }
                        exactFlowDetailList.Add(sameFlowDet);
                        //}

                    }

                }
                else
                {
                    rowErrors.Add(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.ErrorMessage.Errors_Import_LineError, colCount.ToString(), string.Format("第{0}行:物料编号{1}不存在,请确认", code, opRef, item)));

                }
                #endregion

                errorMessage.AddMessages(rowErrors);
            }

            if (errorMessage.HasMessage)
            {
                throw errorMessage;
            }
            if ((exactFlowDetailList == null || exactFlowDetailList.Count == 0) && (deleteFlowDetailList == null || deleteFlowDetailList.Count == 0))
            {
                throw new BusinessException("模板为空,请确认。");
            }
            #region Save Data
            foreach (FlowDetail instance in exactFlowDetailList)
            {
                instance.IsActive = true;
                if (instance.IsCreate)
                {
                    CreateFlowDetail(instance);
                }
                else
                {
                    UpdateFlowDetail(instance);
                    this.genericMgr.UpdateWithNativeQuery("update KB_KanbanCard set Qty=?,Container=? where FlowDetId=?",
                        new object[] { instance.MinUnitCount, instance.Container, instance.Id },
                        new IType[] { NHibernateUtil.Decimal, NHibernateUtil.String, NHibernateUtil.Int32 });
                }
                this.genericMgr.FlushSession();
            }
            foreach (FlowDetail instance in deleteFlowDetailList)
            {
                genericMgr.Delete(instance);
                genericMgr.Delete("from KanbanCard k where k.FlowDetailId = ?", instance.Id, NHibernate.NHibernateUtil.Int32);
            }

            #endregion
        }
开发者ID:Novthirteen,项目名称:sih-les,代码行数:101,代码来源:FlowMgrImpl.cs

示例3: CreateMultiSupplyItemXlsx


//.........这里部分代码省略.........

                    //零件存在性
                    ItemInstance = itemList.FirstOrDefault(i => i.Code.ToUpper() == Item);
                    if (ItemInstance == null)
                    {
                        IList<Item> ItemCount = this.genericMgr.FindAll<Item>("from Item as i where i.Code= ?", Item);
                        if (ItemCount == null || ItemCount.Count() == 0)
                        {
                            rowErrors.Add(new Message(MessageType.Error, Resources.ErrorMessage.Errors_Import_LineFieldValueNotExist, colCount.ToString(), colCount.ToString(), Resources.PRD.MultiSupplyItem.MultiSupplyItem_Item, Item));
                        }
                        else
                        {
                            ItemInstance = ItemCount[0];
                            itemList.Add(ItemCount[0]);
                        }
                    }
                    //数据库重复性验证
                    var items = this.genericMgr.FindAll<MultiSupplyItem>(duiplicateItemVerifyStatement, new object[] { Item });
                    var sameItemInDiffGroup = items.FirstOrDefault(c => c.GroupNo.ToUpper() != GroupNo);
                    if (sameItemInDiffGroup != null)
                    {
                        rowErrors.Add(new Message(MessageType.Error, Resources.PRD.MultiSupplyItem.MultiSupplyItem_Import_ItemOnlyBelongOneGroup, colCount.ToString(), Item, sameItemInDiffGroup.GroupNo));
                    }

                    var sameItemInSameGroupandSupplier = items.FirstOrDefault(c => c.GroupNo.ToUpper() == GroupNo && c.Supplier.ToUpper() == Supplier);
                    if (sameItemInSameGroupandSupplier != null)
                    {
                        rowErrors.Add(new Message(MessageType.Error, Resources.PRD.MultiSupplyItem.MultiSupplyItem_Import_ItemOnlyBelongOneGroupDiffSupplier, colCount.ToString(), Item, sameItemInSameGroupandSupplier.GroupNo, sameItemInSameGroupandSupplier.Supplier));
                    }
                }

                if (rowErrors.Count > 0)
                {
                    errorMessage.AddMessages(rowErrors);
                }
                else
                {
                    var msi = new MultiSupplyItem
                                              {
                                                  GroupNo = GroupNo,
                                                  Supplier = Supplier,
                                                  Item = ItemInstance.Code,
                                                  ItemDescription = ItemInstance.Description,
                                                  SubstituteGroup = substituteGroup,
                                              };
                    exactMultiSupplyItem.Add(msi);

                    if (exactMultiSupplySupplier.FirstOrDefault(m => m.GroupNo.ToUpper() == GroupNo && m.Supplier.ToUpper() == Supplier) == null)
                    {
                        var suppliers = this.genericMgr.FindAll<MultiSupplySupplier>(duiplicateSupplierVerifyStatement,
                                                                                     new object[] { GroupNo, Supplier });
                        if (suppliers == null || suppliers.Count() == 0)
                        {
                            var mss = new MultiSupplySupplier
                                                          {
                                                              GroupNo = GroupNo,
                                                              Supplier = Supplier,
                                                              CycleQty = cy,
                                                              IsActive = true,
                                                              Proportion = proportion
                                                          };
                            exactMultiSupplySupplier.Add(mss);
                        }
                    }

                    if (exactMultiSupplyGroup.FirstOrDefault(m => m.GroupNo.ToUpper() == GroupNo) == null)
开发者ID:Novthirteen,项目名称:sih-les,代码行数:67,代码来源:MultiSupplyGroupMgrImpl.cs


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