示例#1
0
        private void LoadFolders(DMSFolderLogicModel rootLogicModel, List <DMSFolder> allfolders)
        {
            var rootCount = AllFolders.Count(x => x.DmsFolderType == DmsFolderType.Root);

            CommUtils.Assert(rootCount < 2, "根结点数大于2, DMSGuid=[{0}]", m_dms.Guid);

            //初始化根结点文件夹
            DMSFolder rootFolder = null;

            if (rootCount == 0)
            {
                rootFolder                = new DMSFolder();
                rootFolder.DMSId          = m_dms.Id;
                rootFolder.Name           = "root";
                rootFolder.Description    = "root";
                rootFolder.ParentFolderId = null;
                rootFolder.DmsFolderType  = DmsFolderType.Root;
                var now = DateTime.Now;
                rootFolder.CreateUserName     = UserName;
                rootFolder.CreateTime         = now;
                rootFolder.LastModifyUserName = UserName;
                rootFolder.LastModifyTime     = now;
                rootFolder = m_dbAdapter.DMSFolder.Create(rootFolder);
            }
            else
            {
                rootFolder = AllFolders.Single(x => x.DmsFolderType == DmsFolderType.Root);
            }

            rootLogicModel.Instance = rootFolder;
            LoadSubFolders(rootLogicModel, allfolders, 0);
        }
示例#2
0
        private void LoadSubFolders(DMSFolderLogicModel parentFolderLogicModel, List <DMSFolder> allfolders, int folderDepth)
        {
            CommUtils.Assert(folderDepth < DMSLogicModel.MaxFolderDepth, "Load folder failed, folder depth > {0}", DMSLogicModel.MaxFolderDepth);

            var parentFolderId = parentFolderLogicModel.Instance.Id;
            var subFolders     = allfolders.Where(x => x.ParentFolderId == parentFolderId);

            parentFolderLogicModel.SubFolders = new List <DMSFolderLogicModel>();
            foreach (var subFolder in subFolders)
            {
                var subFolderLogicModel = new DMSFolderLogicModel(m_project);
                subFolderLogicModel.Instance     = subFolder;
                subFolderLogicModel.ParentFolder = parentFolderLogicModel;

                LoadSubFolders(subFolderLogicModel, allfolders, folderDepth + 1);
                parentFolderLogicModel.SubFolders.Add(subFolderLogicModel);
            }
        }
示例#3
0
        public DMSFolderLogicModel FindFolder(string folderGuid, DMSFolderLogicModel dmsFolderLogicModel)
        {
            if (dmsFolderLogicModel.Instance.Guid == folderGuid)
            {
                return(dmsFolderLogicModel);
            }

            foreach (var subFolderLoginModel in dmsFolderLogicModel.SubFolders)
            {
                var findFolder = FindFolder(folderGuid, subFolderLoginModel);
                if (findFolder != null)
                {
                    return(findFolder);
                }
            }

            return(null);
        }