예제 #1
0
파일: File.cs 프로젝트: radtek/EMIP
        public bool ISBPAFileWritable(IYZDbProvider provider, IDbConnection cn, BPMConnection bpmcn)
        {
            Folder parentFolder = DirectoryManager.GetFolderByID(provider, cn, this.FolderID);
            Folder rootFolder   = DirectoryManager.GetFolderByID(provider, cn, parentFolder.RootID);

            if (NameCompare.EquName(rootFolder.FolderType, "BPALibrary"))
            {
                if (SecurityManager.CheckPermision(bpmcn, parentFolder.RSID, BPMPermision.Write))
                {
                    return(true);
                }
            }

            if (NameCompare.EquName(rootFolder.FolderType, "BPAGroup"))
            {
                if (bpmcn.Token.ContainsSID(WellKnownSID.Administrators))
                {
                    return(true);
                }

                YZSoft.Group.Group  group  = YZSoft.Group.GroupManager.GetGroupFromFolderID(provider, cn, rootFolder.FolderID);
                YZSoft.Group.Member member = YZSoft.Group.GroupManager.TryGetGroupMember(provider, cn, group.GroupID, YZAuthHelper.LoginUserAccount);
                if (member != null)
                {
                    if ((member.GroupPerm & Group.GroupPerm.Edit) == Group.GroupPerm.Edit || (member.GroupPerm & Group.GroupPerm.Auth) == Group.GroupPerm.Auth)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #2
0
        public static void MoveFolders(IYZDbProvider provider, IDbConnection cn, int[] folderids, int targetfolderid, MovePosition position)
        {
            Folder           targetFolder = DirectoryManager.GetFolderByID(provider, cn, targetfolderid);
            FolderCollection folders;
            int parentFolderId;

            if (position == MovePosition.Append)
            {
                parentFolderId = targetFolder.FolderID;
            }
            else
            {
                parentFolderId = targetFolder.ParentID;
            }

            foreach (int folderid in folderids)
            {
                Folder folder = new Folder();
                folder.FolderID = folderid;
                folder.ParentID = parentFolderId;
                folder.RootID   = targetFolder.RootID;
                DirectoryManager.UpdateParent(provider, cn, folder);
            }

            folders = DirectoryManager.GetFolders(provider, cn, parentFolderId, null, null);

            folders.Move <int>("FolderID", folderids, targetfolderid, position);

            for (int i = 0; i < folders.Count; i++)
            {
                Folder folder = folders[i];
                folder.OrderIndex = i;
                DirectoryManager.UpdateOrderIndex(provider, cn, folder);
            }
        }
예제 #3
0
        public static void MoveFiles(IYZDbProvider provider, IDbConnection cn, int folderid, int[] fileids, int targetfileid, MovePosition position)
        {
            FileCollection files = GetFiles(provider, cn, folderid, null, null, -1);

            files.Move <int>("ID", fileids, targetfileid, position);

            for (int i = 0; i < files.Count; i++)
            {
                File file = files[i];
                file.OrderIndex = i;
                DirectoryManager.UpdateOrderIndex(provider, cn, file);
            }
        }
예제 #4
0
        public static void MoveFilesToFolder(IYZDbProvider provider, IDbConnection cn, int[] fileids, int targetfolderid)
        {
            foreach (int fileid in fileids)
            {
                File file = DirectoryManager.TryGetFileByID(provider, cn, fileid);
                if (file == null)
                {
                    continue;
                }

                file.FolderID = targetfolderid;
                DirectoryManager.Update(provider, cn, file);
            }
        }
예제 #5
0
        public static string GetNewFileName(IYZDbProvider provider, IDbConnection cn, int folderid, string oldName)
        {
            string                   perfix      = Path.GetFileNameWithoutExtension(oldName);
            string                   ext         = Path.GetExtension(oldName);
            FileCollection           files       = DirectoryManager.GetFiles(provider, cn, folderid, null, null, -1);
            AttachmentInfoCollection attachments = files.GetAllAttachmentInfo(provider, cn);
            BPMObjectNameCollection  fileNames   = attachments.Names;

            for (int i = 1; true; i++)
            {
                string newFileName = perfix + "(" + i.ToString() + ")" + ext;

                if (fileNames.Contains(newFileName))
                {
                    continue;
                }

                return(newFileName);
            }
        }
예제 #6
0
 static DirectoryManager()
 {
     DirectoryManager._instance = new DirectoryManager();
 }