Beispiel #1
0
        private static void AddAttributes(XPathNavigator dataLayerPath, ClassifierStruct.DataLayer dataLayer, string itemId)
        {
            // Получение атрибутов и правил атрибутов
            XPathNodeIterator attributesLayerPaths = dataLayerPath.Select("./Attribute");

            foreach (XPathNavigator attributeLayerPath in attributesLayerPaths)
            {
                var attribute =
                    new ClassifierStruct.Attribute(
                        attributeLayerPath.GetAttribute("name", string.Empty),
                        attributeLayerPath.GetAttribute("field_name", string.Empty),
                        attributeLayerPath.GetAttribute("field_type", string.Empty),
                        attributeLayerPath.GetAttribute("comment", string.Empty),
                        attributeLayerPath.GetAttribute("status", string.Empty));

                // Получение правил атрибутов
                XPathNodeIterator attributesRulesPaths =
                    dataLayerPath.Select(
                        "./ItemRules[@item_id='" + itemId + "']/AttributeRule[@field_name='" + attribute.Field_name + "']");
                foreach (XPathNavigator attributeRulePath in attributesRulesPaths)
                {
                    if (attributeRulePath.GetAttribute("required", string.Empty) != string.Empty)
                    {
                        attribute.AttributeRules.Requried = attributeRulePath.GetAttribute("required", string.Empty);
                    }

                    //Проверка домена
                    XPathNodeIterator codeDefsPaths = attributeRulePath.Select("./CodedDomain/CodeDef");
                    foreach (XPathNavigator codeDefPath in codeDefsPaths)
                    {
                        attribute.AttributeRules.CodedDomain.Add(
                            new ClassifierStruct.DomainCodeDef(
                                codeDefPath.GetAttribute("code", string.Empty), codeDefPath.GetAttribute("name", string.Empty)));
                    }
                }

                // Добавление атрибута в DataLayer
                dataLayer.Attributes.Add(attribute);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Дополнительные члены класса классификатора
        /// </summary>
        /// <param name="classifier">
        /// The classifier.
        /// </param>
        private void UpdateDataLayers(ClassifierStruct classifier)
        {
            XPathNodeIterator datalayersPaths = _navigator.Select("/RNGIS_DataSet/DataStorage/DataLayer");

            foreach (XPathNavigator datalayerPath in datalayersPaths)
            {
                var dataLayer = new ClassifierStruct.DataLayer(
                    datalayerPath.GetAttribute("layer_id", string.Empty),
                    datalayerPath.GetAttribute("name", string.Empty),
                    datalayerPath.GetAttribute("table_name", string.Empty),
                    datalayerPath.GetAttribute("description", string.Empty),
                    datalayerPath.GetAttribute("geom_type", string.Empty),
                    datalayerPath.GetAttribute("z_order", string.Empty),
                    datalayerPath.GetAttribute("comment", string.Empty),
                    datalayerPath.GetAttribute("status", string.Empty));

                // Получение атрибутов.
                XPathNodeIterator appearancesPaths = datalayerPath.Select("./Appearance");
                foreach (XPathNavigator appearancePath in appearancesPaths)
                {
                    try
                    {
                        dataLayer.AutoCadAppearance = new ClassifierStruct.DataLayer.AutoCadAppearanceDef();
                        string appereanceColor = appearancePath.GetAttribute("color", string.Empty);

                        if (!int.TryParse(appereanceColor, out dataLayer.AutoCadAppearance.Color))
                        {
                            dataLayer.AutoCadAppearance.Color = int.MinValue;
                        }

                        dataLayer.AutoCadAppearance.Pattern = appearancePath.GetAttribute("pattern", string.Empty);
                        string appereanceLineWeight = appearancePath.GetAttribute("line_weight", string.Empty);
                        if (string.IsNullOrEmpty(appereanceLineWeight) || string.Equals(appereanceLineWeight, "none", StringComparison.OrdinalIgnoreCase))
                        {
                            dataLayer.AutoCadAppearance.LineWeight = double.MinValue;
                        }
                        else
                        {
                            dataLayer.AutoCadAppearance.LineWeight = double.Parse(
                                appereanceLineWeight, System.Globalization.CultureInfo.InvariantCulture);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Не правильные аттрибуты для AutoCad Appearance.", ex);
                    }
                }

                XPathNodeIterator annotationsPaths = datalayerPath.Select("./Annotation");
                foreach (XPathNavigator annotationPath in annotationsPaths)
                {
                    dataLayer.AutoCadAnnotation = new ClassifierStruct.DataLayer.AutoCadAnnotationDef();
                    string textHeight = annotationPath.GetAttribute("text_height", string.Empty);
                    if (string.IsNullOrEmpty(textHeight))
                    {
                        dataLayer.AutoCadAnnotation.TextHeight = double.MinValue;
                    }
                    else
                    {
                        dataLayer.AutoCadAnnotation.TextHeight = double.Parse(
                            annotationPath.GetAttribute("text_height", string.Empty), System.Globalization.CultureInfo.InvariantCulture);
                    }
                }

                // Мы не получаем правила для атрибутов для вспомогательного члена структуры
                XPathNodeIterator attributesLayerPaths = datalayerPath.Select("./Attribute");
                foreach (XPathNavigator attributeLayerPath in attributesLayerPaths)
                {
                    var attribute =
                        new ClassifierStruct.Attribute(
                            attributeLayerPath.GetAttribute("name", string.Empty),
                            attributeLayerPath.GetAttribute("field_name", string.Empty),
                            attributeLayerPath.GetAttribute("field_type", string.Empty),
                            attributeLayerPath.GetAttribute("comment", string.Empty),
                            attributeLayerPath.GetAttribute("status", string.Empty));

                    // Добавление атрибута в DataLayer
                    dataLayer.Attributes.Add(attribute);
                }

                // Добавление DataLayer в спомогательную стуктуру
                classifier.DataLayers.Add(dataLayer);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Дополнительные члены класса классификатора AutoCad
        /// </summary>
        /// <param name="classifier">
        /// The classifier.
        /// </param>
        private void UpdateAutocadAttributes(ClassifierStruct classifier)
        {
            XmlNodeList xmlAttributeGroups = _xmlDocument.SelectNodes("//AttributeGroup");

            if (xmlAttributeGroups == null)
            {
                return;
            }

            foreach (XmlNode xmlAttributeGroup in xmlAttributeGroups)
            {
                var attributeGroup = new ClassifierStruct.AttributeGroup();

                var dataLayerAttributes = new List <ClassifierStruct.Attribute>();

                // Записываем аттрибуты
                XmlNodeList xmlAttributes = xmlAttributeGroup.SelectNodes("./Attribute");
                if (xmlAttributes != null)
                {
                    foreach (XmlNode xmlAttr in xmlAttributes)
                    {
                        var attribute = new ClassifierStruct.Attribute(
                            GetAttrNode(xmlAttr, "name"),
                            GetAttrNode(xmlAttr, "field_name"),
                            GetAttrNode(xmlAttr, "field_type"),
                            GetAttrNode(xmlAttr, "comment"),
                            GetAttrNode(xmlAttr, "status"));
                        //string fieldName = this.GetAttrNode(xmlAttr, "field_name");
                        dataLayerAttributes.Add(attribute);
                    }
                }

                // Записываем все классы
                XmlNodeList xmlClassItems = xmlAttributeGroup.SelectNodes(".//ClassItem");
                if (xmlClassItems != null)
                {
                    foreach (XmlNode xmlClassItem in xmlClassItems)
                    {
                        var itemAttrs = new List <ClassifierStruct.Attribute>();

                        var classItem = new ClassifierStruct.AttributeClassItem(
                            GetAttrNode(xmlClassItem, "code"), GetAttrNode(xmlClassItem, "geom_type"));

                        foreach (ClassifierStruct.Attribute attribute in dataLayerAttributes)
                        {
                            var newAttr = new ClassifierStruct.Attribute(
                                attribute.Name, attribute.Field_name, attribute.Field_type.Text, attribute.Comment, attribute.Status);

                            XmlNode attrRule = xmlClassItem.SelectSingleNode("./AttributeRule[@field_name='" + attribute.Field_name + "']");
                            if (attrRule != null && attrRule.Attributes != null)
                            {
                                if (attrRule.Attributes["required"] != null)
                                {
                                    newAttr.AttributeRules.Requried = attrRule.Attributes["required"].Value;
                                }

                                // Проверка домена
                                XmlNodeList codeDefsPaths = attrRule.SelectNodes("./CodedDomain/CodeDef");
                                if (codeDefsPaths != null)
                                {
                                    foreach (XmlNode codeDefPath in codeDefsPaths)
                                    {
                                        newAttr.AttributeRules.CodedDomain.Add(
                                            new ClassifierStruct.DomainCodeDef(
                                                GetAttrNode(codeDefPath, "code"), GetAttrNode(codeDefPath, "name")));
                                    }
                                }
                            }

                            itemAttrs.Add(newAttr);
                        }

                        classItem.Attributes = itemAttrs;
                        attributeGroup.Items.Add(classItem);
                    }
                }

                classifier.AttributeGroups.Add(attributeGroup);
            }
        }