コード例 #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
 public void Remove(DMSFolder folder)
 {
     folder.RecordStatus       = RecordStatus.Deleted;
     folder.LastModifyTime     = System.DateTime.Now;
     folder.LastModifyUserName = UserInfo.UserName;
     m_db.Update(m_defaultTableName, m_defaultPrimaryKey, folder.GetTableObject());
 }
コード例 #3
0
 public DMSFolder Update(DMSFolder folder)
 {
     folder.LastModifyTime     = DateTime.Now;
     folder.LastModifyUserName = UserInfo.UserName;
     m_db.Update(m_defaultTableName, m_defaultPrimaryKey, folder.GetTableObject());
     return(folder);
 }
コード例 #4
0
        public DMSFolder Create(DMSFolder folder)
        {
            folder.Guid         = System.Guid.NewGuid().ToString();
            folder.RecordStatus = Models.RecordStatus.Valid;

            var id = Insert(folder.GetTableObject());

            folder.Id = id;
            return(folder);
        }
コード例 #5
0
        public void CheckAddVersionTest()
        {
            using (WebActionExecutor e = new WebActionExecutor())
            {
                var cc = this.getGlobalObject <IGlobalContentCreator>();
                // create a folder
                var folder = cc.getNewContent <DMSFolder>();
                folder.title = "the folder";

                var cd = this.getGlobalObject <IContentDispatcher>();
                cd.Add(folder);

                // create a version inside the folder
                DMSVersion created = cc.getNewContent <DMSVersion>();
                created.title = "Pippo";
                created.parent_folders.Add(folder);
                cd.Add(created);

                // add a new version
                var addNewVersion = new DMSAddVersion(created, null);

                WebActionResult result = e.executeAction(addNewVersion);
                Assert.IsTrue(result.isSuccessfull);

                // reload the original version from the database to get the next version
                Guid version_guid = created.guid;
                created = cd.GetContent <DMSVersion>(version_guid);
                DMSVersion new_version = created.next_version;

                // exist the next version to the original one
                Assert.IsNotNull(new_version);

                // exist a previous version to the new version
                Assert.IsNotNull(new_version.previous_version);

                // created and the previous of the next are the same versions
                Assert.IsTrue(created.samePropertiesValue(new_version.previous_version.value));

                // new version and the next of the previous are the same
                Assert.IsTrue(new_version.samePropertiesValue(created.next_version.value));

                // new version and original are in the same folder
                folder = cd.GetContent <DMSFolder>(folder.guid);
                DMSFolder new_folder = created.parent_folders.FirstOrDefault();

                Assert.IsTrue(folder.samePropertiesValue(new_folder));

                // the new version has version number == 2
                Assert.IsTrue(new_version.version_number == 2);
            }
        }
コード例 #6
0
        public ActionResult CreateFolders(string shortCode, string parentFolderGuid, List <string> folderNames, List <string> folderDescriptions)
        {
            return(ActionUtils.Json(() =>
            {
                ValidateUtils.Name(folderNames, "文件夹名称", 100).FileName();

                CommUtils.AssertEquals(folderNames.Count, folderDescriptions.Count, "传入folderNames和folderDescriptions长度不相等");
                CommUtils.AssertEquals(folderNames.Select(x => x.ToLower()).Distinct().Count(),
                                       folderNames.Count, "传入了重复的文件夹名");

                var dms = GetDMSAndCheckPermission(shortCode, PermissionType.Write);

                var parentFolder = m_dbAdapter.DMSFolder.GetByGuid(parentFolderGuid);
                CommUtils.AssertEquals(parentFolder.DMSId, dms.Instance.Id, "传入projectGuid和folderGuid不在同一个DMS中");

                var sibbingFolders = dms.AllFolders.Where(x => x.ParentFolderId.HasValue &&
                                                          x.ParentFolderId.Value == parentFolder.Id);
                foreach (var folderName in folderNames)
                {
                    CommUtils.Assert(!sibbingFolders.Any(x => x.Name.Equals(folderName, StringComparison.CurrentCultureIgnoreCase)),
                                     "文件夹[{0}]已经存在,请刷新后再试", folderName);
                }

                var folders = new List <DMSFolder>();
                var now = DateTime.Now;
                for (int i = 0; i < folderNames.Count; i++)
                {
                    var folder = new DMSFolder();
                    folder.DMSId = dms.Instance.Id;
                    folder.Name = folderNames[i];
                    folder.Description = folderDescriptions[i];
                    folder.DmsFolderType = DmsFolderType.Normal;
                    folder.ParentFolderId = parentFolder.Id;
                    folder.CreateTime = now;
                    folder.CreateUserName = CurrentUserName;
                    folder.LastModifyTime = now;
                    folder.LastModifyUserName = CurrentUserName;
                    folder = m_dbAdapter.DMSFolder.Create(folder);
                    folders.Add(folder);
                }

                var folderNamesArray = folderNames.ConvertAll(x => "[" + x + "]").ToArray();
                m_dbAdapter.Task.AddTaskLog(shortCode, "创建文件夹" + string.Join(",", folderNamesArray));

                var folderGuids = folders.Select(x => x.Guid);
                return ActionUtils.Success(folderGuids);
            }));
        }