private FileManagerAccessRuleBase CreateCompoundRoleRule(FileManagerAccessRuleBase source)
    {
        FileManagerAccessRuleBase rule;

        if (source is FileManagerFolderAccessRule)
        {
            rule = new FileManagerFolderAccessRule();
        }
        else
        {
            rule = new FileManagerFileAccessRule();
        }

        rule.Assign(source);
        rule.Role = CompoundUserRole;
        return(rule);
    }
        void ApplyRules(FileManagerFolder folder)
        {
            FileManagerFolder[] folders = folder.GetFolders();

            for (int i = 0; i < folders.Length; i++)
            {
                FileManagerFolderAccessRule folderEditingRule = new FileManagerFolderAccessRule(folders[i].RelativeName);
                folderEditingRule.Edit = Rights.Deny;
                FileManagerFolderAccessRule folderContentEditingRule = new FileManagerFolderAccessRule(folders[i].RelativeName);
                folderContentEditingRule.EditContents = Rights.Allow;

                ASPxFileManager1.SettingsPermissions.AccessRules.Add(folderEditingRule);
                ASPxFileManager1.SettingsPermissions.AccessRules.Add(folderContentEditingRule);

                ApplyRules(folders[i]);
            }
        }
        public static void ApplyRules(FileManagerFolder folder)
        {
            int fileId = 0;
            //set for my own files
            //var myFolder = ProcessBlueprintDataProvider.GetAll().FindAll(x => x.CreatedBy == sessionData.UserId).ToList();
            var fs = ProcessBlueprintFileSystemProvider.GetFolder(folder);

            if (fs == null)
            {
                return;
            }
            fileId = fs.FileId;
            var myFolder = ProcessBlueprintDataProvider.service.GetPrivileges(new Services.Requests.ProcessBlueprint.GetProcessBlueprintPrivilegeRequest {
                FileId = fileId, RoleGroupId = sessionData.RoleId
            });

            if (myFolder.TotalRecords > 0)
            {
                foreach (var item in myFolder.FileManagerRolePrivileges)
                {
                    var file = item.ProcessBlueprint.MapTo <FileSystemItem>();
                    if (string.IsNullOrEmpty(file.Name))
                    {
                        continue;
                    }
                    var folderItem = ProcessBlueprintFileSystemProvider.GetRelativeName(file);
                    FileManagerAccessRuleBase rule = null;
                    if (item.ProcessBlueprint.IsFolder)
                    {
                        rule = new FileManagerFolderAccessRule();
                    }
                    else
                    {
                        rule = new FileManagerFileAccessRule();
                    }
                    rule.Path   = folderItem;
                    rule.Browse = item.AllowBrowse ? Rights.Allow : Rights.Deny;
                    rule.Edit   = item.AllowRename == item.AllowCreate == item.AllowCopy == item.AllowDelete == item.AllowMove ? Rights.Allow : Rights.Deny;
                    settings.AccessRules.Add(rule);
                }
            }
            else
            {
                var folderItem = ProcessBlueprintFileSystemProvider.GetRelativeName(fs);
                FileManagerAccessRuleBase rule = null;

                if (fs.IsFolder)
                {
                    rule = new FileManagerFolderAccessRule();
                }
                else
                {
                    rule = new FileManagerFileAccessRule();
                }
                rule.Path   = folderItem;
                rule.Browse = Rights.Default;
                rule.Edit   = Rights.Default;
                settings.AccessRules.Add(rule);
            }
            //foreach (var item in myFolder.FileManagerRolePrivileges)
            //{
            //    FileManagerAccessRuleBase rule = null;
            //    // get folderitem
            //    var folderItem = ProcessBlueprintFileSystemProvider.GetRelativeName(item);
            //    if (item.IsFolder)
            //    {
            //        rule = new FileManagerFolderAccessRule();
            //        //settings.AccessRules.Add(new FileManagerFolderAccessRule(folderItem) { Edit = Rights.Allow, Browse = Rights.Allow, Role = sessionData.RoleName });
            //        //settings.AccessRules.Add(new FileManagerFolderAccessRule(folderItem) { EditContents = Rights.Allow, Role = sessionData.RoleName });
            //    }
            //    else
            //    {
            //        rule = new FileManagerFileAccessRule();
            //        //settings.AccessRules.Add(new FileManagerFileAccessRule(folderItem) { Edit = Rights.Allow, Role = sessionData.RoleName });
            //    }
            //    rule.Path = folderItem;
            //    rule.Browse = Rights.Allow;
            //    rule.Edit = Rights.Allow;
            //    settings.AccessRules.Add(rule);
            //}
        }
示例#4
0
        public static void ApplyRules(FileManagerFolder folder)
        {
            int fileId = 0;
            //set for my own files
            //var myFolder = ProcessBlueprintDataProvider.GetAll().FindAll(x => x.CreatedBy == sessionData.UserId).ToList();
            var fs = ProcessBlueprintFileSystemProvider.GetFolder(folder);
            if(fs == null) return;
            fileId = fs.FileId;
            var myFolder = ProcessBlueprintDataProvider.service.GetPrivileges(new Services.Requests.ProcessBlueprint.GetProcessBlueprintPrivilegeRequest { FileId=fileId, RoleGroupId = sessionData.RoleId  });
            if (myFolder.TotalRecords > 0)
            {
                foreach (var item in myFolder.FileManagerRolePrivileges)
                {
                    var file = item.ProcessBlueprint.MapTo<FileSystemItem>();
                    if (string.IsNullOrEmpty(file.Name)) continue;
                    var folderItem = ProcessBlueprintFileSystemProvider.GetRelativeName(file);
                    FileManagerAccessRuleBase rule = null;
                    if (item.ProcessBlueprint.IsFolder)
                    {
                        rule = new FileManagerFolderAccessRule();
                    }
                    else
                    {
                        rule = new FileManagerFileAccessRule();
                    }
                    rule.Path = folderItem;
                    rule.Browse = item.AllowBrowse ? Rights.Allow : Rights.Deny;
                    rule.Edit = item.AllowRename == item.AllowCreate == item.AllowCopy == item.AllowDelete == item.AllowMove ? Rights.Allow : Rights.Deny;
                    settings.AccessRules.Add(rule);
                }
            }
            else
            {
                var folderItem = ProcessBlueprintFileSystemProvider.GetRelativeName(fs);
                FileManagerAccessRuleBase rule = null;

                if (fs.IsFolder)
                {
                    rule = new FileManagerFolderAccessRule();
                }
                else
                {
                    rule = new FileManagerFileAccessRule();
                }
                rule.Path = folderItem;
                rule.Browse = Rights.Default;
                rule.Edit = Rights.Default;
                settings.AccessRules.Add(rule);
            }
            //foreach (var item in myFolder.FileManagerRolePrivileges)
            //{
            //    FileManagerAccessRuleBase rule = null;
            //    // get folderitem
            //    var folderItem = ProcessBlueprintFileSystemProvider.GetRelativeName(item);
            //    if (item.IsFolder)
            //    {
            //        rule = new FileManagerFolderAccessRule();
            //        //settings.AccessRules.Add(new FileManagerFolderAccessRule(folderItem) { Edit = Rights.Allow, Browse = Rights.Allow, Role = sessionData.RoleName });
            //        //settings.AccessRules.Add(new FileManagerFolderAccessRule(folderItem) { EditContents = Rights.Allow, Role = sessionData.RoleName });
            //    }
            //    else
            //    {
            //        rule = new FileManagerFileAccessRule();
            //        //settings.AccessRules.Add(new FileManagerFileAccessRule(folderItem) { Edit = Rights.Allow, Role = sessionData.RoleName });
            //    }
            //    rule.Path = folderItem;
            //    rule.Browse = Rights.Allow;
            //    rule.Edit = Rights.Allow;
            //    settings.AccessRules.Add(rule);
            //}
        }