Ejemplo n.º 1
0
        private List <FileLibraryInfo> getChildren(string fondNumber, string parentID, IEnumerable <ConfigNode> nodes)
        {
            var result = new List <FileLibraryInfo>();

            foreach (var node in nodes)
            {
                var archive = new FileLibraryInfo()
                {
                    ID          = parentID == "" ? node.NodeName : string.Format("{0}.{1}", parentID, node.NodeName),
                    Number      = node.NodeName,
                    Name        = node.NodeValue,
                    FondsNumber = fondNumber,
                    NodeType    = string.IsNullOrEmpty(parentID) ? 1 : 2
                };

                var noteNode = node.ChildNodes.SingleOrDefault(n => n.NodeName == "Note");

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

                var childNode = node.ChildNodes.FirstOrDefault(n => n.NodeName == "Node");
                if (childNode != null && childNode.ChildNodes != null)
                {
                    archive.Children = getChildren(fondNumber, archive.ID, childNode.ChildNodes);
                }

                result.Add(archive);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public List <FileLibraryInfo> GetAll()
        {
            var key = string.Format("BusinessSystem.{0}.Structure.Fonds", ConstValue.BusinessKey);

            var nodes = _IBaseConfig.GetConfigNodes(c => c.Key.StartsWith(key) && !c.IsDeleted, key);

            var result = new List <FileLibraryInfo>();

            nodes.ForEach(n =>
            {
                var fond = new FileLibraryInfo()
                {
                    ID          = n.NodeName,
                    Name        = n.NodeValue,
                    Number      = n.NodeName,
                    FondsNumber = n.NodeName,
                    NodeType    = 0
                };

                var fileLibrary = n.ChildNodes.FirstOrDefault(c => c.NodeName == "FileLibrary");

                fond.Children = getChildren(fond.Number, "", fileLibrary.ChildNodes);

                result.Add(fond);
            });

            return(result);
        }
Ejemplo n.º 3
0
        public int Create(FileLibraryInfo FileLibrary)
        {
            var key = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.FileLibrary.{2}",
                                    ConstValue.BusinessKey, FileLibrary.FondsNumber, FileLibrary.ParentFullKey);

            if (string.IsNullOrEmpty(FileLibrary.Name))
            {
                throw new Exception("文件库名称不能为空");
            }

            if (CheckName(FileLibrary))
            {
                throw new Exception("文件库名称重复");
            }

            var nodes = _IBaseConfig.GetConfigNodes(c => c.Key.StartsWith(key) && !c.IsDeleted, key, true, 1);
            var index = 1;

            if (nodes.Count > 0)
            {
                index = nodes.Max(n => int.Parse(n.NodeName)) + 1;
            }
            FileLibrary.Number = index.ToString();

            _IBaseConfig.Add(new ConfigEntity()
            {
                Key       = string.Format("{0}{1}", key, index),
                Value     = FileLibrary.Name,
                IsDeleted = false,
                Tag       = null,
                Type      = "1"
            });

            if (!string.IsNullOrEmpty(FileLibrary.Note))
            {
                _IBaseConfig.Add(new ConfigEntity()
                {
                    Key       = string.Format("{0}{1}.Note", key, index),
                    Value     = FileLibrary.Note,
                    IsDeleted = false,
                    Tag       = null,
                    Type      = "1"
                });
            }

            return(index);
        }
Ejemplo n.º 4
0
        public void Update(FileLibraryInfo FileLibrary)
        {
            var key = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.FileLibrary.{2}", ConstValue.BusinessKey, FileLibrary.FondsNumber, FileLibrary.Number);

            if (!string.IsNullOrEmpty(FileLibrary.ParentFullKey))
            {
                key = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.FileLibrary.{2}{3}", ConstValue.BusinessKey, FileLibrary.FondsNumber, FileLibrary.ParentFullKey, FileLibrary.Number);
            }

            var configEntity = _IBaseConfig.GetConfig(key);

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

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

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

            if (note != null)
            {
                note.Value = FileLibrary.Note;
                _IBaseConfig.Update(note);
            }
        }
Ejemplo n.º 5
0
        public bool CheckName(FileLibraryInfo FileLibrary)
        {
            var key = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.FileLibrary.{2}.", ConstValue.BusinessKey, FileLibrary.FondsNumber, FileLibrary.ParentFullKey);

            return(_IBaseConfig.Exists(c => c.Key.StartsWith(key) && c.Value == FileLibrary.Name));
        }