[DevExpress Support Team: CLONED FROM T291164: ASPxFileManager - File is not selected on the server side on the first page load]
Well, the hotfix fixes the very basic version of the issue: selection of a file from a local file system during page initial load. However, it still does not work for my custom provider. My provider is based on your sample from the following help topic:
https://documentation.devexpress.com/#AspNet/CustomDocument9935
It requires a database, so it would be hard to send it to you. So, could you please check whether the hotfix will work properly for a sample project using the mentioned custom provider? If it will, send me your sample project and I'll see what I can do to make it expose the problem.
Nickolay, Software Architect
ClickHelp - Online Documentation Tool
http://clickhelp.co
ASPxFileManager - It is impossible to select a file on the server side when a custom FileSystemProvider is used
Answers approved by DevExpress Support
We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.
Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.
- v15.2.4Download Official Update
- v15.1.8Download Official Update
This hotfix (15.1.7.15281) has finally resolved the selection problem for me.
Nickolay, Software Architect
ClickHelp - Online Documentation Tool
http://clickhelp.co
Hello Nickolay,
I am happy to hear that the problem has been resolved. Thank you for letting us know of your progress.
Please feel free to contact us if you have any difficulties. We will be happy to assist you.
Hi Nikolay,
This issue is specific for a custom FileSystemProvider. It is reproduced only when setting IDs for the FileManagerFile and FileManagerFolder objects at a custom provider level. I will forward this issue to our R&D team and our developers will continue working on this problem. We will keep you informed of any progress.
For now, it is possible to work around the issue by not setting the FileManagerItem ID in your code. In this case, ID will be equal to the folder/file path. See the modified code from the E2900: ASPxFileManager - How to implement a LINQ to SQL based file system provider code example:
protected void Page_PreRender(object sender, EventArgs e) { ASPxFileManager1.SelectedFile = new FileManagerFile(ASPxFileManager1.CustomFileSystemProvider, "1.jpg"); }
public override IEnumerable<FileManagerFile> GetFiles(FileManagerFolder folder) { DbFileSystemItem dbFolderItem = FindDbFolderItem(folder); // Current code that does not work: //return // from dbItem in DataContext.DbFileSystemItems // where !dbItem.IsFolder && dbItem.ParentId == dbFolderItem.Id // select new FileManagerFile(this, folder, dbItem.Name, dbItem.Id.ToString()); // Code that should work: return from dbItem in DataContext.DbFileSystemItems where !dbItem.IsFolder && dbItem.ParentId == dbFolderItem.Id select new FileManagerFile(this, folder, dbItem.Name); } public override IEnumerable<FileManagerFolder> GetFolders(FileManagerFolder parentFolder) { DbFileSystemItem dbFolderItem = FindDbFolderItem(parentFolder); // Current code that does not work: //return // from dbItem in FolderCache.Values // where dbItem.IsFolder && dbItem.ParentId == dbFolderItem.Id // select new FileManagerFolder(this, parentFolder, dbItem.Name, dbItem.Id.ToString()); // Code that should work: return from dbItem in FolderCache.Values where dbItem.IsFolder && dbItem.ParentId == dbFolderItem.Id select new FileManagerFolder(this, parentFolder, dbItem.Name); }
I think the sample was a bit different back then when I implemented my provider, because I already don't have those IDs set in my code and I bet I did not remove them from the sample intentionally as I have no idea why they should or should not be assigned. Here's how the methods current look like in my code (in which the selection does not work):
public override IEnumerable<FileManagerFile> GetFiles(FileManagerFolder folder)
{
T dbFolderItem = FindDbFolderItem(folder);
return from fileObj in StorageManager<T, DBManager>.getObjectsFromFolder(dbFolderItem.ID, _dbm, true, null, false)
select new FileManagerFile(this, folder, fileObj.name);
}
public override IEnumerable<FileManagerFolder> GetFolders(FileManagerFolder parentFolder)
{
T dbFolderItem = FindDbFolderItem(parentFolder);
return
from dbItem in FoldersCache.Values
where dbItem.IsFolder && dbItem.ParentID == dbFolderItem.ID
select new FileManagerFolder(this, parentFolder, dbItem.name);
}
As you see, the provider class is a generic in my case, because I use it for different tables with the same column names. The class definition is:
public class VirtualFileSystemProvider<T> : FileSystemProviderBase where T : class, IVirtualFileSystemEntry, new()
the "name" property I use here is my own property which simply returns file / folder name without any extra logic. The StorageManager<T, DBManager>.getObjectsFromFolder method is my method for retrieving files / folders from a virtual folder. I can provide you with my entire class source if needed, but as I said it has a lot of dependencies on other classes and besides cannot run without a DB.
Nickolay, Software Architect
ClickHelp - Online Documentation Tool
http://clickhelp.co
Hello Nickolay,
To find the cause of this issue, we need to research implementation details of your scenario. Would you please send me a simplified problematic page and the custom FileProvider class? If the provider requires some external data source, I will appreciate it if you provide it or update the provider so that we can test it without the additional data source.
Sadly, it's not going to be easy and will take some time, but I'll try. Maybe I'll have to defer this to my next release, though. But anyway I promise I'll do that at some point.
Nickolay, Software Architect
ClickHelp - Online Documentation Tool
http://clickhelp.co
I appreciate your cooperation Nickolay and am looking forward to your reply.
Hello Nickolay,
Since the scenario you described does not directly relate to the issue our developers are working on (you aren't using IDs for files/folders), I decided to create a separate ticket for it: T297147: ASPxFileManager - It is impossible to select file on the server side when a custom FileSystemProvider is used in certain cases.
I also suggest that you try downloading the fix from this ticket once it is ready. It is possible that it will be helpful for your case as well.