コード例 #1
0
        /// <summary>
        /// Извлечь разделы ClassSection из pathSections и вставить в структуру
        /// </summary>
        /// <param name="pathSections">XML-раздел, из которого нужно извлечь ClassSections</param>
        /// <param name="parentSection">Секция верхнего уровня (родитель) для извлекаемых секций. Для первого уровня будет null.</param>
        /// <param name="classifierStruct">Структура классификатора</param>
        /// <param name="platform">Платформа (GIS или Autocad)</param>
        private void FillClassSections(XPathNavigator pathSections, ClassifierStruct.Section parentSection,
                                       ClassifierStruct classifierStruct, string platform)
        {
            XPathNodeIterator classSections = pathSections.Select("./ClassSection");                            //select ClassSection

            foreach (XPathNavigator classSection in classSections)
            {
                CurSection++;
                var section = new ClassifierStruct.Section(classSection.GetAttribute("name", string.Empty), parentSection);
                CurSectionName = section.Name;                                                                                                          //can use for show progress
                if (parentSection != null)
                {
                    parentSection.Subsections.Add(section);
                }

                classifierStruct.Sections.Add(section);

                // рекурсивно ищем вложенные секции
                this.FillClassSections(classSection, section, classifierStruct, platform);

                // заполняем ClassItems секции
                FillClassItems(classSection, section, platform);
            }
        }
コード例 #2
0
        /// <summary>
        /// Загрузка классов в секции
        /// </summary>
        /// <param name="classSectionPath">
        /// The class Section Path.
        /// </param>
        /// <param name="section">
        /// The section.
        /// </param>
        /// <param name="platform">
        /// The platform.
        /// </param>
        private void FillClassItems(
            XPathNavigator classSectionPath,
            ClassifierStruct.Section section,
            string platform)
        {
            XPathNodeIterator classItems = classSectionPath.Select("./ClassItem");

            foreach (XPathNavigator classItem in classItems)
            {
                string itemName = classItem.GetAttribute("name", string.Empty);
                string itemId   = classItem.GetAttribute("item_id", string.Empty);
                string code     = classItem.GetAttribute("code", string.Empty);

                string status           = classItem.GetAttribute("status", string.Empty);
                string lineBottomId     = classItem.GetAttribute("line_bottom_id", string.Empty);
                string lineTopId        = classItem.GetAttribute("line_top_id", string.Empty);
                string typeClass        = classItem.GetAttribute("type", string.Empty);
                string cameralDatalayer = classItem.GetAttribute("cameral_datalayer", string.Empty);
                var    item             = section.AddItem(itemName, itemId, code, status, lineBottomId, lineTopId, cameralDatalayer, typeClass);

                XPathNodeIterator representationTemplates;

                if (platform == "AutoCad")
                {
                    representationTemplates =
                        _navigator.Select(
                            "/RNGIS_DataSet/DataStorage/DataLayer/ItemRules[@item_id='" + itemId + "']/RepresentationTemplate");
                }
                else
                {
                    representationTemplates =
                        _navigator.Select(
                            "/RNGIS_DataSet/DataStorage/DataLayer/ItemRules[@item_id='" + itemId + "']/RepresentationTemplate");
                }

                foreach (XPathNavigator representationTemplate in representationTemplates)
                {
                    string templateName = representationTemplate.GetAttribute("name", string.Empty);
                    string templateDesc = representationTemplate.GetAttribute("descriprtion", string.Empty);                     //Bug in classifier
                    if (string.IsNullOrEmpty(templateDesc))
                    {
                        templateDesc = representationTemplate.GetAttribute("description", string.Empty);
                    }

                    List <ClassifierStruct.Subtype> subtypes = FillSubtypes(representationTemplate, item);
                    switch (subtypes[0].DataLayer.Geom_type)
                    {
                    case "point":
                        item.Point.RepresentationTemplates.Add(new ClassifierStruct.RepresentationTemplate(templateName, templateDesc, subtypes, item));
                        break;

                    case "line":
                        item.Line.RepresentationTemplates.Add(new ClassifierStruct.RepresentationTemplate(templateName, templateDesc, subtypes, item));
                        break;

                    case "area":
                        item.Area.RepresentationTemplates.Add(new ClassifierStruct.RepresentationTemplate(templateName, templateDesc, subtypes, item));
                        break;

                    case "nogeometry":
                        item.NoGeometry.RepresentationTemplates.Add(new ClassifierStruct.RepresentationTemplate(templateName, templateDesc, subtypes, item));
                        break;

                    default:
                        if (string.IsNullOrEmpty(subtypes[0].DataLayer.Geom_type))
                        {
                            item.Unknown.RepresentationTemplates.Add(new ClassifierStruct.RepresentationTemplate(templateName, templateDesc, subtypes, item));
                        }
                        else
                        {
                            throw new Exception("Неправильный тип геометрии '" + subtypes[0].DataLayer.Geom_type + "'.");
                        }
                        break;
                    }
                }
            }
        }