Beispiel #1
0
        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);
        }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #6
0
 static DirectoryManager()
 {
     DirectoryManager._instance = new DirectoryManager();
 }