private static void MakePrimaryClassCompletion(XmlElement classNode)
        {
            if (!XmlUtils.ContainsAttr((XmlNode)classNode, "data-table"))
            {
                classNode.SetAttribute("data-table", XmlUtils.NeedAttr((XmlNode)classNode, "name").Replace('/', '_'));
            }
            bool flag = false;

            foreach (XmlElement selectNode1 in classNode.SelectNodes("property"))
            {
                string attr = XmlUtils.GetAttr((XmlNode)selectNode1, "purpose", "data");
                ApplicationMetadataXml.CopyAttrIfNotExists(selectNode1, "data-field", "name");
                if (attr == "association" || attr == "aggregation")
                {
                    ApplicationMetadataXml.SetAttrIfNotExists(selectNode1, "data-type", "string");
                    ApplicationMetadataXml.SetAttrIfNotExists(selectNode1, "data-length", "12");
                    if (string.IsNullOrEmpty(selectNode1.GetAttribute("ref-select-case")))
                    {
                        ApplicationMetadataXml.SetAttrIfNotExists(selectNode1, "ref-property", "id");
                    }
                    else
                    {
                        foreach (XmlElement selectNode2 in selectNode1.SelectNodes("case"))
                        {
                            ApplicationMetadataXml.SetAttrIfNotExists(selectNode2, "ref-property", "id");
                        }
                    }
                }
                else if (attr == "id")
                {
                    flag = true;
                }
            }
            if (flag)
            {
                return;
            }
            XmlElement xmlElement = XmlUtils.AppendElement((XmlNode)classNode, "property");

            xmlElement.SetAttribute("purpose", "id");
            xmlElement.SetAttribute("name", "id");
            xmlElement.SetAttribute("caption", "Идентификатор");
            xmlElement.SetAttribute("data-field", "OID");
            xmlElement.SetAttribute("data-type", "string");
            xmlElement.SetAttribute("data-length", "12");
        }
        public XmlDocument GetIncompleteMetadata(
            out Dictionary <string, XmlElement> classElementsByName,
            out List <XmlElement> orderedClassElements)
        {
            string      fileName1       = Path.Combine(this.FolderPath, "Meta\\meta-app.xml");
            double      num             = SysUtils.GetFileVersion(fileName1);
            XmlDocument document        = XmlUtils.CreateDocument("AppMetadata");
            XmlElement  documentElement = document.DocumentElement;

            documentElement.SetAttribute("AppRootFolder", this.FolderPath);
            XmlDocument           xmlDocument1          = XmlUtils.LoadDocument(fileName1, Encoding.GetEncoding(1251));
            MetadataElementLoader metadataElementLoader = new MetadataElementLoader(documentElement);

            if (xmlDocument1.DocumentElement != null)
            {
                foreach (XmlNode selectNode in xmlDocument1.DocumentElement.SelectNodes("meta-data"))
                {
                    string fileName2   = Path.Combine(this.FolderPath, "Meta\\" + XmlUtils.NeedAttr(selectNode, "src"));
                    double fileVersion = SysUtils.GetFileVersion(fileName2);
                    if (fileVersion > num)
                    {
                        num = fileVersion;
                    }
                    XmlDocument xmlDocument2 = XmlUtils.LoadDocument(fileName2, Encoding.GetEncoding(1251));
                    metadataElementLoader.Merge(xmlDocument2.DocumentElement);
                }
            }
            classElementsByName  = new Dictionary <string, XmlElement>();
            orderedClassElements = new List <XmlElement>();
            foreach (XmlElement selectNode in documentElement.SelectNodes("class"))
            {
                orderedClassElements.Add(selectNode);
                classElementsByName[selectNode.GetAttribute("name")] = selectNode;
            }
            documentElement.SetAttribute("Version", XStrUtils.ToXStr(num));
            XmlUtils.SetChildText((XmlNode)documentElement, "meta-version", XStrUtils.ToXStr(num));
            foreach (XmlNode childNode in this.FDbInfo.DocumentElement.ChildNodes)
            {
                documentElement.AppendChild(document.ImportNode(childNode, true));
            }
            foreach (XmlElement selectNode in documentElement.SelectNodes("class"))
            {
                ApplicationMetadataXml.MakePrimaryClassCompletion(selectNode);
            }
            return(document);
        }