コード例 #1
0
ファイル: PipelineConfig.cs プロジェクト: secondii/Yutai
        public void LoadFromXml(string fileName)
        {
            _templates.Clear();
            _layers.Clear();
            _styleFiles.Clear();
            _xmlFile = fileName;
            //首先读取Template
            XmlDocument doc = new XmlDocument();

            doc.Load(_xmlFile);

            _configDatabaseName = doc.SelectSingleNode("/PipelineConfig/ConfigDatabase").InnerText;
            InitStyleFiles(doc);
            InitCommonConfig(doc);
            string fullPath = FileHelper.GetFullPath(_configDatabaseName);

            _workspace = Yutai.ArcGIS.Common.Helpers.WorkspaceHelper.GetAccessWorkspace(fullPath) as IFeatureWorkspace;
            XmlNodeList nodes = doc.SelectNodes("/PipelineConfig/LayerTemplates/Template");

            if (nodes != null)
            {
                foreach (XmlNode node in nodes)
                {
                    IPipelineTemplate template = new PipelineTemplate(node);
                    _templates.Add(template);
                }
            }
            nodes = doc.SelectNodes("/PipelineConfig/PipelineLayers/PipelineLayer");
            if (nodes != null)
            {
                foreach (XmlNode node in nodes)
                {
                    IPipelineLayer layer = new PipelineLayer(node, _templates);
                    _layers.Add(layer);
                }
            }

            nodes = doc.SelectNodes("/PipelineConfig/FunctionLayers/FunctionLayer");
            if (nodes != null)
            {
                foreach (XmlNode node in nodes)
                {
                    IFunctionLayer layer = new FunctionLayer(node);
                    _functionLayers.Add(layer);
                }
            }
        }
コード例 #2
0
ファイル: PipelineLayer.cs プロジェクト: frankerlee/Yutai
        public IPipelineLayer NewOrganizeFeatureClass(IFeatureClass featureClass)
        {
            string          ownerName      = ConfigHelper.GetClassOwnerName(((IDataset)featureClass).Name);
            string          baseName       = ConfigHelper.GetClassShortName(featureClass);
            string          classAliasName = featureClass.AliasName;
            string          autoStr        = "/" + _autoNames + "/";
            IBasicLayerInfo layerInfo      =
                _layers.FirstOrDefault(
                    c => c.Name.ToUpper() == baseName.ToUpper() || c.AliasName.ToUpper() == baseName.ToUpper() || autoStr.Contains("/" + baseName + "/") || c.AutoNames.ToUpper().Replace("_", "").Contains(baseName.ToUpper().Replace("_", "")));

            if (layerInfo != null)
            {
                IPipelineLayer pipeLayer = new PipelineLayer(this, false);
                layerInfo =
                    pipeLayer.Layers.FirstOrDefault(
                        c => c.Name == baseName || c.AliasName == baseName || autoStr.Contains("/" + baseName + "/") || c.AutoNames.ToUpper().Replace("_", "").Contains(baseName.ToUpper().Replace("_", "")));
                layerInfo.FeatureClass = featureClass;
                return(pipeLayer);
            }
            return(null);
        }
コード例 #3
0
ファイル: PipelineLayer.cs プロジェクト: frankerlee/Yutai
        public IPipelineLayer Clone(bool keepClass)
        {
            IPipelineLayer pClone = new PipelineLayer(this, keepClass);

            return(pClone);
        }
コード例 #4
0
ファイル: PipelineConfig.cs プロジェクト: secondii/Yutai
        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);
        }