Пример #1
0
        public override bool Validate(ValidateContext context)
        {
            DocStruct doc = context.ValidateObject as DocStruct;

            if (doc != null && doc.IsConfigPart)
            {
                string text = "借用";
                if (BOMHelp.Contains(doc.OperateType, EntityOperateType.NotCheckOut))
                {
                    text = "未检出";
                }
                DocumentVersion documentVersion = BOMHelp.GetOValueFromDictionary(context.CurScopeProperty, _.CURVALIDATEDOCUMENT) as DocumentVersion;
                DocumentCopy    documentCopy    = BOMHelp.GetOValueFromDictionary(context.CurScopeProperty, _.CURVALIDATEDOCCOPY) as DocumentCopy;
                if (documentVersion != null) //文档已经存在
                {
                    List <DocStruct>  list  = doc.DataView.DocList.ToList <DocStruct>();
                    IList <DocConfig> list2 = BOMHelp.GetOValueFromDictionary(context.ExtendProperty, documentVersion.VerId) as IList <DocConfig>;
                    if (list2 == null)
                    {
                        list2 = this.docconfigManager.GetStandardPartsConfigByDVerId(documentVersion.VerId);
                        BOMHelp.Write(context.ExtendProperty, documentVersion.VerId, list2);
                    }
                    if (doc.IsBorrow || BOMHelp.Contains(doc.OperateType, EntityOperateType.NotCheckOut))
                    {
                        DocConfig docConfig = list2.FirstOrDefault((DocConfig p) => p.ConfigName == doc.ConfigName);
                        if (docConfig == null) //查找索引相同的配置
                        {
                            if (list2.All((DocConfig p) => string.IsNullOrEmpty(p.ConfigName)))
                            {
                                docConfig = list2.FirstOrDefault((DocConfig p) => BOMHelp.IndexIsEqualsG <DocConfig>(p, doc, this.IndexFields));
                            }
                        }
                        if (docConfig == null) //未找到的配置
                        {
                            if (IsZuBiao(doc))
                            {
                                doc.CFG_OperateType = EntityOperateType.CreateNewVer;
                                ValidatorHelp.SetSelfRelationType(doc, RelationOperateType.AddRelation);
                            }
                            else
                            {
                                if (list2.Count < list.Count)
                                {
                                    doc.SetDocStateL(false, "red", "{0}:文档配置不允许新增", text);
                                }
                                else
                                {
                                    doc.SetDocStateL(false, "red", "{0}:文档配置名称被修改", text);
                                }
                                return(false);
                            }
                        }
                        else
                        {
                            ValidatorHelp.ValiedateDocChanage <DocConfig>(doc, doc, docConfig, this.IndexFields, documentCopy.FileMD5, text, false);
                            if (string.IsNullOrEmpty(docConfig.ConfigName))
                            {
                                doc.CFG_OperateType = EntityOperateType.UpdateVer;
                            }
                        }
                    }
                    else
                    {
                        DocConfig docConfig2 = list2.FirstOrDefault((DocConfig p) => p.ConfigName == doc.ConfigName);
                        if (docConfig2 == null)
                        {
                            if (list2.All((DocConfig p) => string.IsNullOrEmpty(p.ConfigName)))
                            {
                                docConfig2 = list2.FirstOrDefault((DocConfig p) => BOMHelp.IndexIsEqualsG <DocConfig>(p, doc, this.IndexFields));
                            }
                        }
                        if (docConfig2 != null)
                        {
                            DocStruct currentData = doc.DataView.GetCurrentData();
                            if (BOMHelp.PropertyIsEqualsG <DocConfig>(docConfig2, doc, this.IndexFields, false))
                            {
                                doc.CFG_OperateType = (string.IsNullOrEmpty(docConfig2.ConfigName) ? EntityOperateType.UpdateVer : EntityOperateType.JustCheckIn);
                                doc.OperateType     = EntityOperateType.JustCheckIn;
                                if (BOMHelp.Contains(currentData.OperateType, EntityOperateType.None))
                                {
                                    currentData.OperateType = EntityOperateType.JustCheckIn;
                                }
                            }
                            else
                            {
                                if (!BOMHelp.IndexIsEqualsG <DocConfig>(docConfig2, doc, this.IndexFields))
                                {
                                    doc.SetDocStateL(false, "red", "文档的索引已经修改");
                                    return(false);
                                }
                                doc.OperateType     = EntityOperateType.UpdateVer;
                                doc.CFG_OperateType = EntityOperateType.UpdateVer;
                                if (!BOMHelp.Contains(currentData.OperateType, EntityOperateType.UpdateVer))
                                {
                                    currentData.OperateType = EntityOperateType.UpdateVer;
                                }
                            }
                        }
                        else
                        {
                            doc.CFG_OperateType = EntityOperateType.CreateNewVer;
                            ValidatorHelp.SetSelfRelationType(doc, RelationOperateType.AddRelation);
                        }
                    }
                }
                else
                {
                    doc.CFG_OperateType = doc.OperateType;
                }
            }
            return(true);
        }
Пример #2
0
        public override bool Validate(ValidateContext context)
        {
            DocStruct docStruct = context.ValidateObject as DocStruct;

            if (docStruct != null && !BOMHelp.IsNullOrEmptyG <Associatefield>(this.IndexFields))
            {
                string          valueFromDictionary  = BOMHelp.GetValueFromDictionary(context.ExtendProperty, "__DocCategoryId");
                string          valueFromDictionary2 = BOMHelp.GetValueFromDictionary(context.ExtendProperty, "__FileTypeId");
                DocumentVersion docversion           = this.docversionManager.GetDocumentVersionByFileName(BOMHelp.GetFileNameNoVersion(docStruct.FileName));
                if (docversion == null)
                {
                    if (docStruct.STD_IsStandardParts)
                    {
                        docStruct.OperateType = EntityOperateType.CreateNewVer;
                        ValidatorHelp.SetSelfRelationType(docStruct, RelationOperateType.AddRelation);
                    }
                    else
                    {
                        if (docStruct.DrawingType != IntegrationDrawingType.Engineering)
                        {
                            if (this.FileImportManager.GetDocVerByIndex(this.IndexFields, docStruct, valueFromDictionary, valueFromDictionary2) != null)
                            {
                                docStruct.SetDocStateL(false, "red", "文档库中存在相同索引的文档");
                                return(false);
                            }
                            if (!this.ValidateGeneralWithoutDB(docStruct))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            if (!this.ValidateEngineeringWithoutDB(docStruct, docStruct.OperateDocStrcut))
                            {
                                return(false);
                            }
                        }
                    }
                }
                else
                {
                    BOMHelp.Add(context.CurScopeProperty, "__CurValidateDocument", docversion);
                    if (docversion.StateId == 3)
                    {
                        string @string = docStruct.GetString("phydocvercode");
                        if (docversion.PhyDocVerCode == null)
                        {
                            docversion.PhyDocVerCode = string.Empty;
                        }
                        bool flag = this.ComparePhyDocVerCode(docversion.PhyDocVerCode, @string);
                        if (flag)
                        {
                            docStruct.OperateType = EntityOperateType.CreateNewVer;
                            ValidatorHelp.SetSelfRelationType(docStruct, RelationOperateType.AddRelation);
                            return(true);
                        }
                    }
                    docStruct.SetVerId(docversion.VerId);
                    docStruct.DocBaseId   = docversion.DocId;
                    docStruct.OperateType = EntityOperateType.None;
                    docStruct.IsBorrow    = true;
                    DocumentCopy currentCopyByVerId = this.doccopyManager.GetCurrentCopyByVerId(docversion.VerId);
                    if (currentCopyByVerId != null)
                    {
                        BOMHelp.Add(context.CurScopeProperty, "__CurValidateDocumentCopy", currentCopyByVerId);
                        if (docStruct.STD_IsStandardParts || docStruct.IsConfigPart)
                        {
                            return(ValidateConfigParts(docStruct, context, ValidatorHelp.CheckDocConfig(this.STDManager.GetStandardPartsConfigByDVerIdAndName(docStruct.RealityVerId, docStruct.ConfigName, true), docStruct, this.IndexFields), (ChildStruct p) => this.objrelatda.GetObjectRelations(p.ParentNode.RealityVerId, p.ChildNode.RealityVerId)));
                        }
                        if (docStruct.DrawingType == IntegrationDrawingType.Engineering)
                        {
                            docStruct.SetDocStateL(false, "借用");
                            if (!this.ValidateEngineering(docStruct))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            if (!this.ValidateGeneral(docStruct))
                            {
                                return(false);
                            }
                            ValidatorHelp.ValiedateDocChanage <DocumentVersion>(docStruct, docStruct, docversion, this.IndexFields, currentCopyByVerId.FileMD5, "借用", false);
                        }
                    }
                }
            }
            return(true);
        }