Beispiel #1
0
        public void ReadFromXml(XmlNode xml)
        {
            if (xml?.Attributes == null)
            {
                return;
            }
            _name         = xml.Attributes["Name"].Value;
            _aliasName    = xml.Attributes["AliasName"].Value;
            _visible      = Convert.ToBoolean(xml.Attributes["Visible"].Value);
            _templateName = xml.Attributes["Template"].Value;

            XmlNodeList nodeList = xml.SelectNodes("/LineAssist/Fields/Field");

            if (nodeList != null)
            {
                foreach (XmlNode node in nodeList)
                {
                    IYTField field = new YTField(node);
                    _fields.Add(field);
                }
            }
            _noField       = _fields.FirstOrDefault(c => c.TypeName == "NoField");
            _sPointField   = _fields.FirstOrDefault(c => c.TypeName == "SPointField");
            _ePointField   = _fields.FirstOrDefault(c => c.TypeName == "EPointField");
            _gxlxField     = _fields.FirstOrDefault(c => c.TypeName == "GXLXField");
            _sslxField     = _fields.FirstOrDefault(c => c.TypeName == "SSLXField");
            _lineTypeField = _fields.FirstOrDefault(c => c.TypeName == "LineTypeField");
            _codeField     = _fields.FirstOrDefault(c => c.TypeName == "CodeField");
            _roadCodeField = _fields.FirstOrDefault(c => c.TypeName == "RoadCodeField");
            _dCodeField    = _fields.FirstOrDefault(c => c.TypeName == "DCodeField");
            _dDateField    = _fields.FirstOrDefault(c => c.TypeName == "DDateField");
            _mDateField    = _fields.FirstOrDefault(c => c.TypeName == "MDateField");
            _remarkField   = _fields.FirstOrDefault(c => c.TypeName == "RemarkField");
        }
Beispiel #2
0
        public void ReadFromXml(XmlNode node)
        {
            if (node.Attributes != null)
            {
                _name      = node.Attributes["Name"] == null ? "" : node.Attributes["Name"].Value;
                _aliasName = node.Attributes["AliasName"] == null ? "" : node.Attributes["AliasName"].Value;
                _visible   = node.Attributes["Visible"] == null
                    ? true
                    : (node.Attributes["Visible"].Value.ToUpper().StartsWith("T") ? true : false);
                _dataType = node.Attributes["DataType"] == null
                    ? enumPipelineDataType.Point
                    : EnumHelper.ConvertDataTypeFromString(node.Attributes["DataType"].Value);
                _heightType = node.Attributes["HeightType"] == null
                    ? enumPipelineHeightType.Top
                    : EnumHelper.ConvertHeightTypeFromStr(node.Attributes["HeightType"].Value);
                _validateKeys = node.Attributes["ValidateKeys"] == null ? "" : node.Attributes["ValidateKeys"].Value;
                _templateName = node.Attributes["TemplateName"] == null ? "" : node.Attributes["TemplateName"].Value;
                _autoNames    = node.Attributes["AutoNames"].Value;
            }

            XmlNodeList fieldNodes = node.SelectNodes("Fields/Field");

            foreach (XmlNode fieldNode in fieldNodes)
            {
                IYTField field = new YTField(fieldNode);
                //需要检查已有的字段定义中有没有重名的
                IYTField findField = _fields.FirstOrDefault(c => c.Name == field.Name);
                if (findField != null)
                {
                    _fields.Remove(findField);
                }
                _fields.Add(field);
            }
        }
Beispiel #3
0
        public IYTField Clone(bool keepClass)
        {
            IYTField newField = new YTField(this);

            if (keepClass)
            {
                newField.EsriFieldName = this._esriFieldName;
            }
            return(newField);
        }
Beispiel #4
0
        public void ReadFromXml(XmlNode xml)
        {
            if (xml?.Attributes == null)
            {
                return;
            }
            _name           = xml.Attributes["Name"].Value;
            _aliasName      = xml.Attributes["AliasName"].Value;
            _visible        = Convert.ToBoolean(xml.Attributes["Visible"].Value);
            _heightTypeName = xml.Attributes["HeightType"].Value;
            _heightType     = EnumHelper.ConvertHeightTypeFromStr(_heightTypeName);
            _templateName   = xml.Attributes["Template"].Value;

            XmlNodeList nodeList = xml.SelectNodes("/LineLayer/Fields/Field");

            if (nodeList != null)
            {
                foreach (XmlNode node in nodeList)
                {
                    IYTField field = new YTField(node);
                    _fields.Add(field);
                }
            }
            _noField          = _fields.FirstOrDefault(c => c.TypeName == "NoField");
            _sPointField      = _fields.FirstOrDefault(c => c.TypeName == "SPointField");
            _ePointField      = _fields.FirstOrDefault(c => c.TypeName == "EPointField");
            _sDeepField       = _fields.FirstOrDefault(c => c.TypeName == "SDeepField");
            _eDeepField       = _fields.FirstOrDefault(c => c.TypeName == "EDeepField");
            _shField          = _fields.FirstOrDefault(c => c.TypeName == "SHField");
            _ehField          = _fields.FirstOrDefault(c => c.TypeName == "EHField");
            _codeField        = _fields.FirstOrDefault(c => c.TypeName == "CodeField");
            _materialField    = _fields.FirstOrDefault(c => c.TypeName == "MaterialField");
            _dTypeField       = _fields.FirstOrDefault(c => c.TypeName == "DTypeField");
            _lineStyleField   = _fields.FirstOrDefault(c => c.TypeName == "LineStyleField");
            _dsField          = _fields.FirstOrDefault(c => c.TypeName == "DSField");
            _sectionSizeField = _fields.FirstOrDefault(c => c.TypeName == "SectionSizeField");
            _pdmField         = _fields.FirstOrDefault(c => c.TypeName == "PDMField");
            _pipeNatureField  = _fields.FirstOrDefault(c => c.TypeName == "PipeNatureField");
            _msrqField        = _fields.FirstOrDefault(c => c.TypeName == "MSRQField");
            _mDateField       = _fields.FirstOrDefault(c => c.TypeName == "MDateField");
            _useStatusField   = _fields.FirstOrDefault(c => c.TypeName == "UseStatusField");
            _bCodeField       = _fields.FirstOrDefault(c => c.TypeName == "BCodeField");
            _roadCodeField    = _fields.FirstOrDefault(c => c.TypeName == "RoadCodeField");
            _cabCountField    = _fields.FirstOrDefault(c => c.TypeName == "CabCountField");
            _volPresField     = _fields.FirstOrDefault(c => c.TypeName == "VolPresField");
            _holeCountField   = _fields.FirstOrDefault(c => c.TypeName == "HoleCountField");
            _holeUsedField    = _fields.FirstOrDefault(c => c.TypeName == "HoleUsedField");
            _flowDField       = _fields.FirstOrDefault(c => c.TypeName == "FlowDField");
            _remarkField      = _fields.FirstOrDefault(c => c.TypeName == "RemarkField");
        }
Beispiel #5
0
        public void ReadFromXml(XmlNode xmlNode)
        {
            if (xmlNode.Attributes != null)
            {
                _name     = xmlNode.Attributes["Name"].Value;
                _caption  = xmlNode.Attributes["Caption"].Value;
                _dataType = xmlNode.Attributes["DataType"] == null
                    ? enumPipelineDataType.Point
                    : EnumHelper.ConvertDataTypeFromString(xmlNode.Attributes["DataType"].Value);
            }
            XmlNodeList nodeList =
                xmlNode.SelectNodes($"/PipelineConfig/LayerTemplates/Template[@Name='{_name}']/Fields/Field");

            foreach (XmlNode node in nodeList)
            {
                IYTField field = new YTField(node);
                _fields.Add(field);
            }
        }
Beispiel #6
0
        public void ReadFromXml(XmlNode xml)
        {
            if (xml?.Attributes == null)
            {
                return;
            }
            _name         = xml.Attributes["Name"].Value;
            _aliasName    = xml.Attributes["AliasName"].Value;
            _visible      = Convert.ToBoolean(xml.Attributes["Visible"].Value);
            _templateName = xml.Attributes["Template"].Value;

            XmlNodeList nodeList = xml.SelectNodes("/PointLayer/Fields/Field");

            if (nodeList != null)
            {
                foreach (XmlNode node in nodeList)
                {
                    IYTField field = new YTField(node);
                    _fields.Add(field);
                }
            }

            _noField        = _fields.FirstOrDefault(c => c.TypeName == "NoField");
            _xField         = _fields.FirstOrDefault(c => c.TypeName == "XField");
            _yField         = _fields.FirstOrDefault(c => c.TypeName == "YField");
            _zField         = _fields.FirstOrDefault(c => c.TypeName == "ZField");
            _depthField     = _fields.FirstOrDefault(c => c.TypeName == "DepthField");
            _featureField   = _fields.FirstOrDefault(c => c.TypeName == "FeatureField");
            _subsidField    = _fields.FirstOrDefault(c => c.TypeName == "SubsidField");
            _pStyleField    = _fields.FirstOrDefault(c => c.TypeName == "PStyleField");
            _pdsField       = _fields.FirstOrDefault(c => c.TypeName == "PDSField");
            _codeField      = _fields.FirstOrDefault(c => c.TypeName == "CodeField");
            _mapNoField     = _fields.FirstOrDefault(c => c.TypeName == "MapNoField");
            _useStatusField = _fields.FirstOrDefault(c => c.TypeName == "UseStatusField");
            _bCodeField     = _fields.FirstOrDefault(c => c.TypeName == "BCodeField");
            _rotangField    = _fields.FirstOrDefault(c => c.TypeName == "RotangField");
            _roadCodeField  = _fields.FirstOrDefault(c => c.TypeName == "RoadCodeField");
            _mDateField     = _fields.FirstOrDefault(c => c.TypeName == "MDateField");
            _pcjhField      = _fields.FirstOrDefault(c => c.TypeName == "PCJHField");
            _remarkField    = _fields.FirstOrDefault(c => c.TypeName == "RemarkField");
        }
Beispiel #7
0
        public void ReadFromXml(XmlNode xmlNode)
        {
            if (xmlNode.Attributes != null)
            {
                _name      = xmlNode.Attributes["Name"].Value;
                _aliasName = xmlNode.Attributes["AliasName"] == null ? "" : xmlNode.Attributes["AliasName"].Value;
                _visible   = xmlNode.Attributes["Visible"] == null ||
                             xmlNode.Attributes["Visible"].Value.ToUpper().StartsWith("T");
                _functionType = xmlNode.Attributes["Type"] == null
                    ? enumFunctionLayerType.Other
                    : EnumHelper.ConvertFunctionLayerTypeFromString(xmlNode.Attributes["Type"].Value);
            }
            XmlNodeList nodeList =
                xmlNode.SelectNodes($"/PipelineConfig/FunctionLayers/FunctionLayer[@Name='{_name}']/Fields/Field");

            foreach (XmlNode node in nodeList)
            {
                IYTField field = new YTField(node);
                _fields.Add(field);
            }
        }
Beispiel #8
0
        public List <IPipelineLayer> ReadLayersFromDatabase()
        {
            List <IPipelineLayer> layers = new List <IPipelineLayer>();
            ITable     pCodeTable        = _workspace.OpenTable("YT_PIPE_CODE");
            ITableSort tableSort         = new TableSortClass();

            tableSort.Table  = pCodeTable;
            tableSort.Fields = "Priority";
            tableSort.Sort(null);

            ICursor pCursor  = tableSort.Rows;
            IRow    pRow     = pCursor.NextRow();
            int     codeIdx  = pCursor.FindField("PipeCode");
            int     classIdx = pCursor.FindField("ClassCode");
            int     nameIdx  = pCursor.FindField("PipeName");
            int     autoIdx  = pCursor.FindField("AutoNames");
            int     priIdx   = pCursor.FindField("Priority");

            while (pRow != null)
            {
                IPipelineLayer oneLayer = new PipelineLayer()
                {
                    Code      = pRow.Value[codeIdx].ToString(),
                    Name      = pRow.Value[nameIdx].ToString(),
                    AutoNames = pRow.Value[autoIdx].ToString(),
                    Layers    = new List <IBasicLayerInfo>(),
                    ClassCode = pRow.Value[classIdx].ToString()
                };
                layers.Add(oneLayer);
                pRow = pCursor.NextRow();
            }
            Marshal.ReleaseComObject(pCursor);
            Marshal.ReleaseComObject(tableSort);
            Marshal.ReleaseComObject(pCodeTable);

            List <IYTDomain> domains = new List <IYTDomain>();

            pCodeTable = _workspace.OpenTable("YT_PIPE_DOMAIN");
            pCursor    = pCodeTable.Search(null, false);
            pRow       = pCursor.NextRow();
            nameIdx    = pCursor.FindField("DomainName");
            autoIdx    = pCursor.FindField("DomainValues");

            while (pRow != null)
            {
                string    domainName   = pRow.Value[nameIdx].ToString();
                string    domainValues = pRow.Value[autoIdx].ToString();
                IYTDomain onedomain    = new YTDomain(domainName, domainValues);
                domains.Add(onedomain);
                pRow = pCursor.NextRow();
            }
            Marshal.ReleaseComObject(pCursor);
            Marshal.ReleaseComObject(pCodeTable);

            List <IPipelineTemplate> templates = new List <IPipelineTemplate>();

            //! 先读取模板
            pCodeTable       = _workspace.OpenTable("YT_PIPE_FIELD");
            tableSort        = new TableSortClass();
            tableSort.Table  = pCodeTable;
            tableSort.Fields = "TemplateName";

            tableSort.Sort(null);
            pCursor = tableSort.Rows;
            string oldTemplate = "";

            int[] fieldIndexes = new int[10];
            pRow            = pCursor.NextRow();
            fieldIndexes[0] = pRow.Fields.FindField("TemplateName");
            fieldIndexes[1] = pRow.Fields.FindField("TypeName");
            fieldIndexes[2] = pRow.Fields.FindField("FieldName");
            fieldIndexes[3] = pRow.Fields.FindField("FieldAliasName");
            fieldIndexes[4] = pRow.Fields.FindField("FieldType");
            fieldIndexes[5] = pRow.Fields.FindField("FieldLength");
            fieldIndexes[6] = pRow.Fields.FindField("FieldPrecision");
            fieldIndexes[7] = pRow.Fields.FindField("AllowNull");
            fieldIndexes[8] = pRow.Fields.FindField("AutoValues");
            fieldIndexes[9] = pRow.Fields.FindField("IsKey");
            //  fieldIndexes[10] = pRow.Fields.FindField("Domains");


            IPipelineTemplate oneTemplate = null;

            while (pRow != null)
            {
                string templateName = pRow.Value[fieldIndexes[0]].ToString();
                if (!templateName.Equals(oldTemplate))
                {
                    if (oneTemplate != null)
                    {
                        templates.Add(oneTemplate);
                    }
                    oneTemplate = new PipelineTemplate()
                    {
                        Name = templateName, Fields = new List <IYTField>()
                    };
                    oldTemplate = templateName;
                }
                IYTField field = new YTField()
                {
                    TypeName  = pRow.Value[fieldIndexes[1]].ToString(),
                    Name      = pRow.Value[fieldIndexes[2]].ToString(),
                    AliasName = pRow.Value[fieldIndexes[3]].ToString(),
                    Length    = Convert.ToInt32(pRow.Value[fieldIndexes[5]].ToString()),
                    Precision = Convert.ToInt32(pRow.Value[fieldIndexes[6]].ToString()),
                    AllowNull = Convert.ToInt32(pRow.Value[fieldIndexes[7]].ToString()) == -1 ? true : false,
                    AutoNames = pRow.Value[fieldIndexes[8]].ToString(),
                    FieldType = FieldHelper.ConvertFromString(pRow.Value[fieldIndexes[4]].ToString())
                };
                oneTemplate.Fields.Add(field);
                pRow = pCursor.NextRow();
            }
            if (oneTemplate != null)
            {
                templates.Add(oneTemplate);
            }
            Marshal.ReleaseComObject(pCursor);
            Marshal.ReleaseComObject(tableSort);
            Marshal.ReleaseComObject(pCodeTable);

            List <IBasicLayerInfo> basicInfos = new List <IBasicLayerInfo>();

            pCodeTable       = _workspace.OpenTable("YT_PIPE_LAYER");
            tableSort        = new TableSortClass();
            tableSort.Table  = pCodeTable;
            tableSort.Fields = "Priority,LayerName";
            tableSort.Sort(null);
            pCursor      = tableSort.Rows;
            pRow         = pCursor.NextRow();
            fieldIndexes = new int[8];

            fieldIndexes[0] = pRow.Fields.FindField("PipeCode");
            fieldIndexes[1] = pRow.Fields.FindField("BasicName");
            fieldIndexes[2] = pRow.Fields.FindField("LayerName");
            fieldIndexes[3] = pRow.Fields.FindField("AutoNames");
            fieldIndexes[4] = pRow.Fields.FindField("Priority");
            fieldIndexes[5] = pRow.Fields.FindField("DataType");
            fieldIndexes[6] = pRow.Fields.FindField("Template");
            fieldIndexes[7] = pRow.Fields.FindField("Domains");
            while (pRow != null)
            {
                string         pipeCode = pRow.Value[fieldIndexes[0]].ToString();
                IPipelineLayer oneLayer = layers.Find(c => c.Code == pipeCode);
                if (oneLayer == null)
                {
                    pRow = pCursor.NextRow();
                    continue;
                }
                enumPipelineDataType dataType =
                    Yutai.Pipeline.Config.Helpers.EnumHelper.ConvertDataTypeFromString(
                        pRow.Value[fieldIndexes[5]].ToString().Trim());
                IBasicLayerInfo basicLayer = new BasicLayerInfo()
                {
                    Name         = pRow.Value[fieldIndexes[1]].ToString(),
                    AliasName    = pRow.Value[fieldIndexes[2]].ToString(),
                    AutoNames    = pRow.Value[fieldIndexes[3]].ToString(),
                    DataType     = dataType,
                    TemplateName = pRow.Value[fieldIndexes[6]].ToString(),
                    Fields       = new List <IYTField>()
                };
                if (pRow.Value[fieldIndexes[6]] != null)
                {
                    IPipelineTemplate template = templates.Find(c => c.Name == basicLayer.TemplateName);
                    if (template != null)
                    {
                        foreach (IYTField field in template.Fields)
                        {
                            basicLayer.Fields.Add(new YTField(field));
                        }
                    }
                }

                string domainStr = pRow.Value[fieldIndexes[7]] == DBNull.Value
                    ? string.Empty
                    : pRow.Value[fieldIndexes[7]].ToString();
                if (!string.IsNullOrEmpty(domainStr))
                {
                    //获得Domainzhi值
                    string[] domainPairs = domainStr.Split('/');
                    for (int j = 0; j < domainPairs.Length; j++)
                    {
                        string[]  domainPair = domainPairs[j].Split(':');
                        string    fieldName  = domainPair[0];
                        string    domainName = domainPair[1];
                        IYTDomain findDomain = domains.FirstOrDefault(c => c.DomainName == domainName);
                        if (findDomain != null)
                        {
                            IYTField pField = basicLayer.Fields.FirstOrDefault(c => c.TypeName == fieldName);
                            if (pField != null)
                            {
                                pField.Domain = new YTDomain(findDomain.DomainName, findDomain.DomainValues);
                            }
                        }
                    }
                }

                oneLayer.Layers.Add(basicLayer);
                pRow = pCursor.NextRow();
            }
            Marshal.ReleaseComObject(pCursor);
            Marshal.ReleaseComObject(tableSort);
            Marshal.ReleaseComObject(pCodeTable);
            return(layers);
        }