Exemplo n.º 1
0
        public override bool Validate(ValidateContext context)
        {
            BOMStruct bOMStruct = context.ValidateList as BOMStruct;

            if (bOMStruct != null)
            {
                this.SupportMultiConfig = context.ExtendProperty.GetValue(_.MultiConfiguration, false);

                foreach (DocStruct doc in bOMStruct.BOMView.Cast <DocView>().Where(p => !((DocStruct)p).STD_IsStandardParts))
                {
                    IList     dbRelation = this.dvManager.SearchObjectRelationByParent(doc.RealityVerId);
                    ArrayList arrayList  = new ArrayList(5);
                    IEnumerable <ChildStruct> children =
                        from p in doc.DataView.ChildRelation
                        where p.ChildNode != null && p.ParentNode != null
                        select p;
                    if (!this.ValidateRelation(dbRelation, (ObjectRelation DBR) => this.ObjectRelationExists(DBR, doc, children), doc, arrayList))
                    {
                        return(false);
                    }
                    if (!BOMHelp.IsNullOrEmpty(arrayList))
                    {
                        BOMHelp.Add <string, ArrayList>(this.dicDeleteSTDRelation, doc.RealityVerId, arrayList, (ArrayList il) => true);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 设置序号
        /// </summary>
        /// <param name="vm"></param>
        /// <param name="bom"></param>
        protected override void PreShowData(ViewMode vm, BOMStruct bom)
        {
            base.PreShowData(vm, bom);

            foreach (var doc in bom)
            {
                int index = 1;
                foreach (var item in doc.Child)
                {
                    item.OrderId = (index++).ToString();
                }
            }
        }
Exemplo n.º 3
0
        public override bool Validate(ValidateContext context)
        {
            DocStruct docStruct = context.ValidateObject as DocStruct;
            BOMStruct bOMStruct = context.ValidateList as BOMStruct;

            if (docStruct != null && bOMStruct != null)
            {
                List <string> list = new List <string>();
                if (docStruct.IsConfigPart && !docStruct.ContainsKey(_.DELETE_CONFIG) &&
                    ValidateCreoConfig.IsZuBiao(docStruct) &&//不是族表实例的时候。判断不了实例的添加与删除
                    !comp_arr.Contains(docStruct.FileName))    //每一个文件只比较一次
                {
                    comp_arr.Add(docStruct.FileName);
                    var Configs = docStruct.GetString(ZuBiaoNames).Trim().Split(';');
                    Configs = Configs.Concat(new string[] { GetFileWithoutExt(docStruct.FileName) }).ToArray();

                    foreach (DocConfig cfg in
                             from p in this.docconfigManager.GetStandardPartsConfigByDVerId(docStruct.RealityVerId)
                             where !string.IsNullOrEmpty(p.ConfigName)
                             select p)
                    {
                        if (!Configs.Any((string p) => BOMHelp.IsEquals(p, cfg.ConfigName, true)))
                        {
                            if (docStruct.IsBorrow || BOMHelp.Contains(docStruct.OperateType, EntityOperateType.NotCheckOut))
                            {
                                string msg = string.Format("{0}:不允许修改文档族表实例", docStruct.IsBorrow ? "借用" : "未检出");
                                this.DealDocStruct(docStruct, delegate(DocStruct p)
                                {
                                    p.SetDocStateL(false, "red", msg);
                                });
                                return(false);
                            }
                            if (!list.Contains(cfg.ConfigID))
                            {
                                list.Add(cfg.ConfigID);
                            }
                        }
                    }
                    if (list.Count > 0)
                    {
                        docStruct.WriteValue(_.DELETE_CONFIG, string.Join(",", list.ToArray()));
                    }
                }
                if (context.CurIndex == bOMStruct.Count && !this.ValidateConfigUse(bOMStruct))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 4
0
        private bool ValidateConfigUse(BOMStruct bom)
        {
            foreach (DocStruct current in bom)
            {
                if (current.GetString(_.DELETE_CONFIG).Length != 0)
                {
                    string[] delconfigs = current.GetString(_.DELETE_CONFIG).Split(new char[] { ',' });

                    IEnumerable <ObjectRelation> source = this.objrelatda.SearchObjectRelationByVerId(current.RealityVerId).Cast <ObjectRelation>();

                    IEnumerable <ObjectRelation> dbParents  = source.Where(p => delconfigs.Any((string c) => BOMHelp.IsEquals(c, p.ConfigID)));
                    IEnumerable <ObjectRelation> dbChildren = source.Where(p => delconfigs.Any((string c) => BOMHelp.IsEquals(c, p.ParentConfigID)));

                    if (dbParents.Any() || dbChildren.Any())
                    {
                        this.DealDocStruct(current, (DocStruct p) => p.SetDocStateL(false, "red", "配置已经被使用,不能删除配置"));
                        return(false);
                    }
                }
            }
            return(true);
        }