Exemplo n.º 1
0
        public List <ArchiveNodeInfo> GetList()
        {
            var result = new List <ArchiveNodeInfo>();

            var fonds = _IFondService.GetAll();

            foreach (var fond in fonds)
            {
                var fondNode = new ArchiveNodeInfo()
                {
                    FondsNumber = fond.Number,
                    Name        = fond.Name,
                    Note        = fond.Note,
                    NodeType    = ArchiveNodeType.Fonds,
                };

                var key = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.Node.", ConstValue.BusinessKey, fond.Number);

                var nodes = _IBaseConfig.GetConfigNodes(c => c.Key.StartsWith(key), key);
                fondNode.Children = getChildren(fond.Number, "", nodes);

                result.Add(fondNode);
            }

            return(result);
        }
Exemplo n.º 2
0
        public void AddNode(ArchiveNodeInfo Node)
        {
            var key = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.Node.{2}{3}",
                                    ConstValue.BusinessKey, Node.FondsNumber, string.IsNullOrEmpty(Node.ParentFullKey) ? "" : Node.ParentFullKey.TrimStart('.'), Node.Number);

            if (string.IsNullOrEmpty(Node.Name))
            {
                throw new Exception("节点名称不能为空");
            }

            if (_IBaseConfig.Exists(c => c.Key == key))
            {
                throw new Exception("节点编号重复");
            }

            var type = ((int)Node.NodeType).ToString();

            _IBaseConfig.Add(new ConfigEntity()
            {
                Key       = key,
                Value     = Node.Name,
                IsDeleted = false,
                Tag       = Node.ArchiveType,
                Type      = type
            });

            if (!string.IsNullOrEmpty(Node.Note))
            {
                _IBaseConfig.Add(new ConfigEntity()
                {
                    Key       = string.Format("{0}.Note", key),
                    Value     = Node.Note,
                    IsDeleted = false,
                    Tag       = Node.ArchiveType,
                    Type      = type
                });
            }

            if (Node.NodeType == ArchiveNodeType.DataFilter)
            {
                _IBaseConfig.Add(new ConfigEntity()
                {
                    Key       = string.Format("{0}.Condition", key),
                    Value     = Node.Conditions.ToQuerySql(),
                    IsDeleted = false,
                    Tag       = Node.ArchiveType,
                    Type      = type
                });
            }
        }
Exemplo n.º 3
0
        public void UpdateNode(ArchiveNodeInfo Node)
        {
            var key = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.Node.{2}{3}",
                                    ConstValue.BusinessKey, Node.FondsNumber, string.IsNullOrEmpty(Node.ParentFullKey) ? "" : Node.ParentFullKey.Trim('.') + ".", Node.Number);

            if (string.IsNullOrEmpty(Node.Name))
            {
                throw new Exception("节点名称不能为空");
            }

            var configEntity = _IBaseConfig.GetConfig(key);

            if (configEntity != null)
            {
                if (configEntity.Value != Node.Name)
                {
                    configEntity.Value = Node.Name;
                    _IBaseConfig.Update(configEntity);
                }

                var noteConfigEntity = _IBaseConfig.GetConfig(string.Format("{0}.Note", key));

                if (noteConfigEntity == null && !string.IsNullOrEmpty(Node.Note))
                {
                    _IBaseConfig.Add(new ConfigEntity()
                    {
                        Key       = string.Format("{0}.Note", configEntity.Key),
                        Value     = Node.Note,
                        IsDeleted = false,
                        Tag       = configEntity.Tag,
                        Type      = configEntity.Type
                    });
                }

                if (noteConfigEntity != null && noteConfigEntity.Value != Node.Note)
                {
                    noteConfigEntity.Value = Node.Note;
                    _IBaseConfig.Update(noteConfigEntity);
                }
            }
        }
Exemplo n.º 4
0
        private List <ArchiveNodeInfo> getChildren(string fondNumber, string parentKey, IEnumerable <ConfigNode> nodes)
        {
            var result = new List <ArchiveNodeInfo>();

            foreach (var node in nodes)
            {
                var archive = new ArchiveNodeInfo()
                {
                    Number        = node.NodeName,
                    Name          = node.NodeValue,
                    ArchiveType   = node.Tag.Trim(),
                    NodeType      = (ArchiveNodeType)Enum.Parse(typeof(ArchiveNodeType), node.Type),
                    ParentFullKey = parentKey,
                    FondsNumber   = fondNumber,
                };

                var volumeKey   = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.Archive.{2}.Volume", ConstValue.BusinessKey, fondNumber, archive.ArchiveType);
                var projKey     = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.Archive.{2}.Project", ConstValue.BusinessKey, fondNumber, archive.ArchiveType);
                var categoryKey = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.Archive.{2}.Category", ConstValue.BusinessKey, fondNumber, archive.ArchiveType);

                archive.HasVolume   = _IBaseConfig.Exists(c => c.Key == volumeKey);
                archive.HasProject  = _IBaseConfig.Exists(c => c.Key == projKey);
                archive.HasCategory = _IBaseConfig.Exists(c => c.Key == categoryKey);

                var noteNode      = node.ChildNodes.SingleOrDefault(n => n.NodeName == "Note");
                var disableNode   = node.ChildNodes.SingleOrDefault(n => n.NodeName == "Disable");
                var conditionNode = node.ChildNodes.SingleOrDefault(n => n.NodeName == "Condition");

                if (noteNode != null)
                {
                    archive.Note = noteNode.NodeValue;
                }

                if (conditionNode != null)
                {
                    archive.ConditionsSqlStr = conditionNode.NodeValue;
                }

                if (disableNode != null)
                {
                    archive.Disabled = true;
                }
                else
                {
                    var childNode = node.ChildNodes.FirstOrDefault(n => n.NodeName == "Node");
                    if (childNode != null && childNode.ChildNodes != null)
                    {
                        var pk = archive.ParentFullKey + ".Node." + archive.Number;

                        if (string.IsNullOrEmpty(archive.ParentFullKey))
                        {
                            pk = archive.Number;
                        }

                        archive.Children = getChildren(fondNumber, pk, childNode.ChildNodes);
                    }
                }

                result.Add(archive);
            }

            return(result);
        }