Example #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {

            string model1 = (string)CurrentSession.GetValue(Session.SessionKeys.Model1);
            string model2 = (string)CurrentSession.GetValue(Session.SessionKeys.Model2);

            ASTInfo info = (ASTInfo)CurrentSession.GetValue(Session.SessionKeys.ASTInfoList);

            if (model1 != model2)
            {
                IBOMRepository ibomRepository = RepositoryFactory.GetInstance().GetRepository<IMES.FisObject.Common.FisBOM.IBOMRepository>();

                MoBOMInfo cond = new MoBOMInfo();
                cond.material = model2;
                cond.component = info.PartNo;
                cond.flag = 1;
                IList<MoBOMInfo> list = new List<MoBOMInfo>();
                list = ibomRepository.GetModelBomList(cond);
                if (list == null || list.Count == 0)
                {
                    FisException ex;
                    List<string> erpara = new List<string>();
                    ex = new FisException("CHK895", erpara);
                    throw ex;
                }
            }
            
            return base.DoExecute(executionContext);
        }
Example #2
0
        public IList<MoBOMInfo> GetModelBomList(MoBOMInfo condition)
        {
            try
            {
                IList<MoBOMInfo> ret = null;

                //MethodBase mthObj = MethodBase.GetCurrentMethod();
                //int tk = mthObj.MetadataToken;
                mtns::SQLContextNew sqlCtx = null;
                //lock (mthObj)
                //{
                //    if (!SQLCache.PeerTheSQL(tk, out sqlCtx))
                //    {
                mtns::ModelBOM_NEW cond = mtns::FuncNew.SetColumnFromField<mtns::ModelBOM_NEW, MoBOMInfo>(condition);
                sqlCtx = mtns::FuncNew.GetConditionedSelect<mtns::ModelBOM_NEW>(null, null, new mtns::ConditionCollection<mtns::ModelBOM_NEW>(new mtns::EqualCondition<mtns::ModelBOM_NEW>(cond)), mtns::ModelBOM_NEW.fn_id);
                //    }
                //}
                sqlCtx = mtns::FuncNew.SetColumnFromField<mtns::ModelBOM_NEW, MoBOMInfo>(sqlCtx, condition);

                using (SqlDataReader sqlR = _Schema.SqlHelper.ExecuteReader(_Schema.SqlHelper.ConnectionString_BOM, CommandType.Text, sqlCtx.Sentence, sqlCtx.Params))
                {
                    ret = mtns::FuncNew.SetFieldFromColumn<mtns::ModelBOM_NEW, MoBOMInfo, MoBOMInfo>(ret, sqlR, sqlCtx);
                }
                return ret;
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #3
0
        public TreeNodeDef SaveModelBOM(ModelBOMInfoDef item, ChangeNodeInfoDef parent)
        {

            //添加时需要检查是否在part表或在model表及另一个表中存在
            //然后取得该点在树上的信息(返回值)

            TreeNodeDef result = new TreeNodeDef();
            try
            {
                IModelBOMRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IModelBOMRepository, BOMNodeData>();
                //判断是否已经存在此父子关系
                //Select * from ModelBom where Material='" + parentCode + "' and Component='" + oldCode + "'
                IList<BOMNodeData> itemList = itemRepository.findModelBomByMaterialAndComponent(parent.NodeName, item.Component);
                if (itemList.Count > 0 && itemList[0].ID.ToString() != item.ID)
                {
                    List<string> erpara = new List<string>();
                    FisException ex;
                    //!!!need change
                    //数据库中已经存在相同的父子的关系
                    ex = new FisException("DMT017", erpara);
                    throw ex;
                }

                //判断修改的子节点是一个Part
                //SELECT PartNo as Code,Descr from Part where PartNo='code' AND Flag=1  AND AutoDL='Y'
                string partDesc = "";
                DataTable existPartNos = itemRepository.GetExistPartNo(item.Component);
                if (existPartNos == null || existPartNos.Rows.Count == 0)
                {
                    List<string> erpara = new List<string>();
                    FisException ex;
                    //!!!need change
                    //子节点不是一个Part
                    ex = new FisException("DMT018", erpara);
                    throw ex;
                }

                partDesc = Null2String(existPartNos.Rows[0][1]);

                //!!!找父节点的Type(Material_group)!!!还要找part中的type
                //GetMaterialById
                string type = "";
                //SELECT Material AS Code, Material_group AS PartType FROM ModelBOM where Material='code' AND Flag=1
                //UNION SELECT [PartNo] AS Code ,[PartType]  AS PartType    
                //  FROM [IMES_GetData_Datamaintain].[dbo].[Part]
                //where Flag=1 AND [PartNo]='code'

                //父节点的Part信息
                DataTable resultTypeInfo = itemRepository.GetPartTypeInfoByCode(parent.NodeName);
                if (resultTypeInfo.Rows.Count > 0)
                {
                    type = Null2String(resultTypeInfo.Rows[0][1]);
                }

                Hashtable modelIds = new Hashtable();
                Dictionary<string, string> parents = new Dictionary<string, string>();
                GetNeedRefreshModelIncludeCurrentList(parent, modelIds, parents);
                Dictionary<string, string> children = new Dictionary<string, string>();
                GetAllChildren(item.Component, children);
                Boolean isExist = false;
                isExist = JudgeErrorParentChildren(parents, children, isExist);

                //if (isExist == true || parent.NodeName == item.Component)
                if (isExist == true)
                {
                    List<string> erpara = new List<string>();
                    FisException ex;
                    //!!!need change
                    //子节点与直接或间接父节点有嵌套
                    ex = new FisException("DMT019", erpara);
                    throw ex;
                }
                
                UnitOfWork uow = new UnitOfWork();

                foreach (String modelId in modelIds.Keys)
                {
                    //Refreshmodel表
                    //删除原来的modelId
                    //添加新的modelId
                    itemRepository.DeleteRefreshModelByModelDefered(uow, modelId, item.Editor);
                    itemRepository.AddRefreshModelDefered(uow, modelId, item.Editor);
                }

                //需在一个事物中
                //itemRepository.DeleteModelBomByMaterialAndComponentDefered(uow, parent.NodeName, item.Component);
                //空的不是公用料
                IMiscRepository iMiscRepository = RepositoryFactory.GetInstance().GetRepository<IMiscRepository>();
                MoBOMInfo condition = new MoBOMInfo();
                condition.id = Int32.Parse(item.ID);

                IList<MoBOMInfo> itemNew = iMiscRepository.GetData<IMES.Infrastructure.Repository._Metas.ModelBOM_NEW, MoBOMInfo>(condition);

                //BOMNodeData itemNew = itemRepository.GetModelBOM2(Int32.Parse(item.ID));

                Boolean isNeedChangeGroupNo = false;
                //判断有共用料时再做,并且数据有变化时再做
                if (Null2String(itemNew[0].alternative_item_group) != "" && itemNew[0].quantity != item.Quantity)
                {
                    isNeedChangeGroupNo = true;

                }
                itemNew[0].material = parent.NodeName;
                itemNew[0].component = item.Component;
                itemNew[0].quantity = item.Quantity;
                itemNew[0].priority = item.Priority;
                itemNew[0].flag = int.Parse(item.Flag);
                itemNew[0].editor = item.Editor;
                itemNew[0].udt = DateTime.Now;

                iMiscRepository.UpdateDataByIDDefered<IMES.Infrastructure.Repository._Metas.ModelBOM_NEW, MoBOMInfo>(uow, condition, itemNew[0]);
                //itemRepository.UpdateModelBOMDefered(uow, itemNew);


                if (isNeedChangeGroupNo == true)
                {
                    itemRepository.UpdateGroupQuantityDefered(uow, item.Quantity, itemNew[0].alternative_item_group, item.Editor);
                }
                uow.Commit();

                result.id = item.ID.ToString();
                result.curent = itemNew[0].component;
                result.desc = partDesc;
                
            }
            catch (Exception)
            {
                throw;
            }

            return result;
        }
Example #4
0
        private void RecursivelyConstructHierarchicalBOM(IBOMNode node, MoBOMInfo peerInfo, IList<IBOMNode> allNodes, int iDeepLimit)
        {
            IList<MoBOMInfo> rootChildren = GetChildrenInModelBOM(peerInfo.component);
            if (rootChildren != null && rootChildren.Count > 0)
            {
                if (iDeepLimit == 0)
                {
                    throw new FisException("BOML01", new string[] { "", "" }); 
                }

                foreach (MoBOMInfo childItem in rootChildren)
                {
                    IPart nodePart = PrtRepository.Find(childItem.component);
                    if (nodePart != null)
                    {
                        IBOMNode newNode = new BOMNode(nodePart, int.Parse(childItem.quantity), childItem.alternative_item_group);
                        node.AddChild(newNode);
                        allNodes.Add(newNode);
                        RecursivelyConstructHierarchicalBOM(newNode, childItem, allNodes, iDeepLimit - 1);
                    }
                }
            }
        }