Пример #1
0
        public ArchiveInfo GetArchiveInfo(string Fonds, string Key, bool WithField = false, bool WithCategory = false, bool WithMapping = false)
        {
            var key = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.Archive.{2}", _BusinessKey, Fonds, Key);

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

            if (nodes == null || nodes.Count == 0)
            {
                return(null);
            }

            var result = new ArchiveInfo();

            result.Name        = nodes[0].NodeValue;
            result.FondsNumber = Fonds;
            result.Key         = Key;

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

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

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

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

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

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

            return(result);
        }
Пример #2
0
        private string getArchiveMainName(ArchiveInfo aInfo, Dictionary <string, object> data)
        {
            var fields = aInfo.HasVolume ? aInfo.VolumeFields : aInfo.BoxFields;

            var fs = fields.Where(f => f.Main).Select(f => data[string.Format("_f{0}", f.ID)].ToString());

            return(string.Join("_", fs));
        }
Пример #3
0
        private void addFields(ArchiveInfo archive, string key)
        {
            var k = string.Format("BusinessSystem.{0}.Field.{1}", ConstValue.BusinessKey, key);

            var fields = _IFieldService.GetFields(k, key);

            foreach (var item in fields)
            {
                item.ParentKey = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.Archive.{2}.{3}.Field.", ConstValue.BusinessKey, archive.FondsNumber, archive.Key, key);
                _IFieldService.AddField(item);
            }
        }
Пример #4
0
        public List <MyArchiveBorrowInfo> GetMyBorrowedArchive(int UserID)
        {
            var borrowInfos = _DBArchive.GetList(a => a.BorrowUser == UserID).ToList();

            var myBorrowIDs = _DBArchive.GetQuery(a => a.BorrowUser == UserID).Select(a => a.ID);

            //var status = (int)BorrowStatus.归还;
            var borrowItems = _DBArchiveItem.GetQuery(i => myBorrowIDs.Contains(i.BorrowID)).OrderBy(a => a.Status).ThenBy(a => a.BorrowID);

            var archiveTypeDic = new Dictionary <string, ArchiveInfo>();


            var result = new List <MyArchiveBorrowInfo>();

            foreach (var item in borrowItems)
            {
                var key = string.Format("{0}_{1}", item.Fonds, item.ArchiveType);

                ArchiveInfo ainfo = null;

                if (archiveTypeDic.ContainsKey(key))
                {
                    ainfo = archiveTypeDic[key];
                }
                else
                {
                    ainfo = _IArchiveLibraryService.GetArchiveInfo(item.Fonds, item.ArchiveType, true);

                    archiveTypeDic.Add(key, ainfo);
                }

                var data = _IArchiveDataService.GetArchiveData(item.ArchiveID, item.Fonds, item.ArchiveType, ainfo.HasVolume ? EnumArchiveName.Volume : EnumArchiveName.Box);


                var myBorrowInfo = new MyArchiveBorrowInfo();
                myBorrowInfo.BorrowID        = item.ID;
                myBorrowInfo.Fonds           = item.Fonds;
                myBorrowInfo.ArchiveType     = item.ArchiveType;
                myBorrowInfo.ArchiveID       = item.ArchiveID;
                myBorrowInfo.ArchiveTypeName = ainfo.Name;
                myBorrowInfo.Name            = getArchiveMainName(ainfo, data);
                myBorrowInfo.Status          = item.Status;
                myBorrowInfo.BorrowCount     = item.Count;
                myBorrowInfo.BorrowInfo      = borrowInfos.Find(b => b.ID == item.BorrowID);
                myBorrowInfo.Copies          = (int)data["Copies"];
                myBorrowInfo.AccessLevel     = (int)data["AccessLevel"];
                myBorrowInfo.ArchiveInfo     = ainfo;

                result.Add(myBorrowInfo);
            }

            return(result);
        }
Пример #5
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);
        }
Пример #6
0
        public void Update(ArchiveInfo Archive)
        {
            var key = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.Archive.{2}", _BusinessKey, Archive.FondsNumber, Archive.Key);

            var configEntity = _IBaseConfig.GetConfig(key);

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

            var hasProject  = _IBaseConfig.GetConfig(string.Format("{0}.Project", key));
            var hasVolume   = _IBaseConfig.GetConfig(string.Format("{0}.Volume", key));
            var hasCategory = _IBaseConfig.GetConfig(string.Format("{0}.Category", key));
            var note        = _IBaseConfig.GetConfig(string.Format("{0}.Note", key));

            if (hasProject == null && Archive.HasProject)
            {
                _IBaseConfig.Add(new ConfigEntity()
                {
                    Key       = string.Format("{0}.Project", key),
                    Value     = "1",
                    IsDeleted = false,
                    Tag       = null,
                    Type      = "1"
                });
            }
            if (hasVolume == null && Archive.HasVolume)
            {
                _IBaseConfig.Add(new ConfigEntity()
                {
                    Key       = string.Format("{0}.Volume", key),
                    Value     = "1",
                    IsDeleted = false,
                    Tag       = null,
                    Type      = "1"
                });
            }
            if (hasCategory == null && Archive.HasCategory)
            {
                _IBaseConfig.Add(new ConfigEntity()
                {
                    Key       = string.Format("{0}.Category", key),
                    Value     = "1",
                    IsDeleted = false,
                    Tag       = null,
                    Type      = "1"
                });
            }
            if (note == null && !string.IsNullOrEmpty(Archive.Note))
            {
                _IBaseConfig.Add(new ConfigEntity()
                {
                    Key       = string.Format("{0}.Note", key),
                    Value     = Archive.Note,
                    IsDeleted = false,
                    Tag       = null,
                    Type      = "1"
                });
            }

            if (hasProject != null)
            {
                hasProject.Value = Archive.HasProject ? "1" : "0";
                _IBaseConfig.Update(hasProject);
            }
            if (hasVolume != null)
            {
                hasVolume.Value = Archive.HasVolume ? "1" : "0";
                _IBaseConfig.Update(hasVolume);
            }
            if (hasCategory != null)
            {
                hasCategory.Value = Archive.HasCategory ? "1" : "0";
                _IBaseConfig.Update(hasCategory);
            }
            if (note != null)
            {
                note.Value = Archive.Note;
                _IBaseConfig.Update(note);
            }

            // 更新档案类型也同时更新对应的档案节点信息
            _IArchiveNodeService.UpdateNode(new ArchiveNodeInfo()
            {
                FondsNumber = Archive.FondsNumber,
                Number      = "N" + Archive.Key,
                Name        = Archive.Name,
                Note        = Archive.Note,
                NodeType    = ArchiveNodeType.Archive,
                ArchiveType = Archive.Key,
            });
        }
Пример #7
0
        public int Create(ArchiveInfo Archive)
        {
            var key = string.Format("BusinessSystem.{0}.Structure.Fonds.{1}.Archive.", _BusinessKey, Archive.FondsNumber);

            if (string.IsNullOrEmpty(Archive.Name))
            {
                throw new Exception("档案馆名称不能为空");
            }

            if (CheckName(Archive.FondsNumber, Archive.Name))
            {
                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;
            }
            Archive.Key = index.ToString();

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

            if (Archive.HasVolume)
            {
                // 案卷
                _IBaseConfig.Add(new ConfigEntity()
                {
                    Key       = string.Format("{0}{1}.Volume", key, index),
                    Value     = "1",
                    IsDeleted = false,
                    Tag       = null,
                    Type      = "1"
                });

                addFields(Archive, "Volume");

                // 项目,有案卷才会有项目
                if (Archive.HasProject)
                {
                    _IBaseConfig.Add(new ConfigEntity()
                    {
                        Key       = string.Format("{0}{1}.Project", key, index),
                        Value     = "1",
                        IsDeleted = false,
                        Tag       = null,
                        Type      = "1"
                    });

                    addFields(Archive, "Project");
                }
            }
            else
            {
                // 没有案卷,则生成盒
                _IBaseConfig.Add(new ConfigEntity()
                {
                    Key       = string.Format("{0}{1}.Box", key, index),
                    Value     = "1",
                    IsDeleted = false,
                    Tag       = null,
                    Type      = "1"
                });

                addFields(Archive, "Box");
            }

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

            addFields(Archive, "File");

            if (Archive.HasCategory)
            {
                // 分类表
                _IBaseConfig.Add(new ConfigEntity()
                {
                    Key       = string.Format("{0}{1}.Category", key, index),
                    Value     = "1",
                    IsDeleted = false,
                    Tag       = null,
                    Type      = "1"
                });
            }
            if (!string.IsNullOrEmpty(Archive.Note))
            {
                _IBaseConfig.Add(new ConfigEntity()
                {
                    Key       = string.Format("{0}{1}.Note", key, index),
                    Value     = Archive.Note,
                    IsDeleted = false,
                    Tag       = null,
                    Type      = "1"
                });
            }

            // 新建档案类型的时候自动生成一个对应的档案节点
            _IArchiveNodeService.AddNode(new ArchiveNodeInfo()
            {
                FondsNumber = Archive.FondsNumber,
                Number      = "N" + Archive.Key,
                Name        = Archive.Name,
                Note        = Archive.Note,
                NodeType    = ArchiveNodeType.Archive,
                ArchiveType = index.ToString(),
            });

            return(index);
        }