Exemplo n.º 1
0
        public void Update(FondInfo Fond)
        {
            var key = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}", _BusinessKey, Fond.Number);

            var nameConfig = _IBaseConfig.GetConfig(key);

            if (!nameConfig.Value.Equals(Fond.Name))
            {
                nameConfig.Value = Fond.Name;

                _IBaseConfig.Update(nameConfig);
            }

            var keyNote = string.Format("{0}.note", key, Fond.Number);

            var noteConfig = _IBaseConfig.GetConfig(keyNote);

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

                _IBaseConfig.Update(noteConfig);
            }
        }
Exemplo n.º 2
0
        public void Add(FondInfo Fond)
        {
            var key = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}", _BusinessKey, Fond.Number);

            if (Check(Fond.Number))
            {
                throw new Exception("全宗号重复");
            }

            _IBaseConfig.Add(new ConfigEntity()
            {
                Key       = key,
                Value     = Fond.Name,
                IsDeleted = false,
                Tag       = null,
                Type      = "1"
            });

            if (!string.IsNullOrEmpty(Fond.Note))
            {
                _IBaseConfig.Add(new ConfigEntity()
                {
                    Key       = string.Format("{0}.note", key),
                    Value     = Fond.Note,
                    IsDeleted = false,
                    Tag       = null,
                    Type      = "1"
                });
            }
        }
Exemplo n.º 3
0
        public List <FondInfo> GetAll(bool WithField = false, bool WithCategory = false)
        {
            var key = string.Format("BusinessSystem.{0}.Structure.Fonds", _BusinessKey);

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

            var result = new List <FondInfo>();

            nodes.ForEach(n =>
            {
                var fond = new FondInfo()
                {
                    Name     = n.NodeValue,
                    Number   = n.NodeName,
                    Archives = new List <ArchiveInfo>()
                };

                var archives = n.ChildNodes.SingleOrDefault(c => c.NodeName == "Archive");
                if (archives != null)
                {
                    foreach (var archive in archives.ChildNodes)
                    {
                        var archiveInfo = new ArchiveInfo()
                        {
                            Key  = archive.NodeName,
                            Name = archive.NodeValue,
                        };

                        var proj    = archive.ChildNodes.SingleOrDefault(c => c.NodeName == "Project");
                        var vol     = archive.ChildNodes.SingleOrDefault(c => c.NodeName == "Volume");
                        var catey   = archive.ChildNodes.SingleOrDefault(c => c.NodeName == "Category");
                        var note    = archive.ChildNodes.SingleOrDefault(c => c.NodeName == "Note");
                        var disable = archive.ChildNodes.SingleOrDefault(c => c.NodeName == "Disable");

                        archiveInfo.HasProject  = proj == null ? false : proj.NodeValue == "1";
                        archiveInfo.HasVolume   = vol == null ? false : vol.NodeValue == "1";
                        archiveInfo.HasCategory = catey == null ? false : catey.NodeValue == "1";
                        archiveInfo.Note        = note == null ? "" : note.NodeValue;
                        archiveInfo.Disabled    = disable != null;

                        if (WithCategory && archiveInfo.HasCategory)
                        {
                            archiveInfo.Categorys = GetCategorys(catey.ChildNodes);
                        }

                        if (WithField)
                        {
                            var k = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.Archive.{2}.File.Field.", ConstValue.BusinessKey, fond.Number, archiveInfo.Key);
                            archiveInfo.FileFields = _IFieldService.GetFields(k, "File");

                            if (archiveInfo.HasVolume)
                            {
                                k = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.Archive.{2}.Volume.Field.", ConstValue.BusinessKey, fond.Number, archiveInfo.Key);
                                archiveInfo.VolumeFields = _IFieldService.GetFields(k, "Volume");
                            }
                            else
                            {
                                k = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.Archive.{2}.Box.Field.", ConstValue.BusinessKey, fond.Number, archiveInfo.Key);
                                archiveInfo.BoxFields = _IFieldService.GetFields(k, "Box");
                            }

                            if (archiveInfo.HasProject)
                            {
                                k = string.Format("BusinessSystem.{0}.Field.Project", ConstValue.BusinessKey);
                                archiveInfo.ProjectFields = _IFieldService.GetFields(k, "Project");
                            }
                        }

                        fond.Archives.Add(archiveInfo);
                    }
                }


                result.Add(fond);
            });

            return(result);
        }