This is a migrated thread and some comments may be shown as answers.

Using FileExplorer With A Custom DB Provider

5 Answers 73 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Paul Herzberg
Top achievements
Rank 1
Paul Herzberg asked on 09 Feb 2012, 04:08 PM
Hello,

I'm trying to create "virtual" directories for our file-system and then display them using the fileexplorer from Telerik.

I have a table called FILES that looks something like this:

id int (key)
filename varchar(50)

A table calle VERZEICHNIS that looks like this
id int (key)
directoryname varchar(50)
vorgaengerid int

and a many to many connection between them

FILES_VERZEICHNIS

filesid int  (key)
verzeichnisid int (key)

I've got it to display everything just fine using a custom file provider, but I've run into two problems.

One, because the files come from Internet users we've created a system where the filename displayed can exist more than once in a directory (the id is the key). When the Fileexplorer Itemcommand is fired, it only passes the path. I can probably append an id to some part of the filename, but this is unsightly and exposes information to the user they don't need. Perhaps there's a way I can get at the source node and destination node and the underlying dataitems, but I can't find it.

Two, I've probably set up the page wrong, because when the treeview attempts to refresh the wait indicator never goes away and I get four javascript errors. Three say "a is undefined" and the fourth says "Fehler: $get(this._currentDirectoryInputID) is null
Quelldatei: http://aspnet-scripts.telerikstatic.com/ajaxz/2011.1.315/FileExplorer/RadFileExplorer.js
Zeile: 674 "

Any help with either of these matters would be most appreciated.

5 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 14 Feb 2012, 03:43 PM
Hi Paul,

Straight to the issues:
  1. The grid component of RadFileExplorer is a RadGrid bound on the client, and the dataitems for the displayled items are not available on the server. You can use the Path property of the ItemCommand arguments to get reference of a TreeNode, e.g.:
    protected void RadFileExplorer1_ItemCommand(object sender, RadFileExplorerEventArgs e)
    {
        RadTreeNode node = RadFileExplorer1.TreeView.FindNodeByValue(e.Path);
    }

    However, this approach can be used to provide information for files only in case where the RadFileExplorer's ExplorerMode property is set to FileTree and that is why I do not think this is the best solution for this case. Could you please provide more information regarding the specific scenario so we can try to come up with suitable solution, if possible?
  2.   We are are aware of similar problem with earlier versions of RadFileExplorer, which is already resolved? Could you please try to upgrade your version of RadControls For ASP.NET AJAX to the latest one (currently 2011.3.1305) and see if the problem still occurs?

Regards,
Dobromir
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Paul Herzberg
Top achievements
Rank 1
answered on 14 Feb 2012, 04:16 PM
Hello Dobromir,

Thank you for replying.

For issue one, I want to use the FileExplorer to organize image files that are provided from a database. I have implemented a filehandler that takes an id and returns an image for that id. Eg. getimage.ashx?id=121 returns a picture of me in a hat.

The files are saved with filenames built from a guid and an extension, eg. f70218dd-4e37-43bf-aee2-ca012fb3042f.JPG. The id, the filename and the original filename, eg. paul.jpg (I didn't mention this last time, apologies) are stored to a table ("FILES"). The files are arranged in directories as shown below.

I can get the FileExplorer to display all this information using a Custom Provider based on the one provided in the Knowledge base.

As I mentioned, this setup means that our users can upload various "Paul.jpg"s without them overwriting each other and we can display them all in one folder if needs be. This means that the returned path "News/Paul.jpg" is not unique. What I think I need is some way of getting the underlying URL, "getimage.ashx?id=121", say, or a the fileItem with the Url in it or the id in it.

As the Directories should be unique I can write something like  "private int getDirectoryIdFromPath(string Path)", and to move a file to a directory I have a function "bool moveFile(int FileId, int DirectoryId)" that updates the DB accordingly.

For issue 2 we are currently using dll 2010.2.826.35 I'll see if I can get it updated. By the way, the FileExplorer works as an editor dialog, but not in a page.

Thank you again,

Paul
0
Dobromir
Telerik team
answered on 16 Feb 2012, 10:29 AM
Hi Paul,

Correct me if I am wrong, but as I understand for each file you have a unique name (GUID), alias (name to be displayed with) and an ID. If this is the case, I would recommend you to handle the file naming in the ResolveDirectory() method of the content provider, thus when creating the FileItems use the unique name when generating the value of the Path property, and use the alias for the Name property.


Regards,
Dobromir
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Paul Herzberg
Top achievements
Rank 1
answered on 16 Feb 2012, 12:17 PM
Hello again,

Yes you are correct, sorry if I was not very clear.

At the moment I am using this snippet:

FileItem fileItem = new FileItem(file.OriginalFileName ,
Path.GetExtension(file.FileName),
file.FileSize,
 VirtualPath + file.FileId.ToString(),
 url,
null,
 PathPermissions.Read | PathPermissions.Delete);
And it seems to be what I need, thank you very much.

We aim to get the dlls updated in the next few days, I'll let you know if that works, too.

Cheers

Paul
0
Paul Herzberg
Top achievements
Rank 1
answered on 24 Apr 2012, 04:25 PM
Hello,
Sorry I didn't get back, but the update took a little longer than I expected.

The update works and the problem with the busy wait is gone.

Thank you.
Paul
Tags
FileExplorer
Asked by
Paul Herzberg
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Paul Herzberg
Top achievements
Rank 1
Share this question
or