Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

How To Search A Directory on the webserver + return filenames for possible download?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How To Search A Directory on the webserver + return filenames for possible download?

    I can't quite wrap my head around where to start with this and I was hoping someone here would have a suggestion.

    Here's what I've got right now:

    I have a grid that contains a file location field. Within that field I have a full path and file name. I'm currently using it to download a .pdf drawing via a button and it's working fine for that.

    Besides the .pdf, there are also other files in another directory that are related. These files are the actual CAD files that can only be opened with the proper CAD program. There is always a drawing file in this directory with the same name as the one in the file location field except with the extension being .slddrw instead of .pdf.

    I'm able to get the .slddrw file with a little change to the file download javascript code in alpha 5. The below works:
    Code:
    window['{grid.componentName}_D__UNBOUND_BUTTON_4_1'] = function(rowNum,rowId,objEle) {
    
    if({grid.object}._embeddedMode) {
    	alert('File download is not supported when the Component is running on the Desktop.');
    	return false;
    }
    
    var e = $('{grid.componentName}.__IFRAME1');
    var filename = ({grid.object}.getValue('D','FILE_LOCATION',rowNum));
    var testFilename = filename.split('://')[0];
    var oldn = filename.split('\\').pop();
    var newname = 'P:\\Secured\\Tooling\\' + oldn.substring(0,3) + '\\' + oldn.split('.').shift() + '.sldprt';
    if(testFilename.toLowerCase() == 'http' || testFilename.toLowerCase == 'https') {
    	e.src = filename;
    } else { 
    	filename = urlencode(newname);
    	e.src = '__A5FileDownload.a5w?c=%5fa5filedownload&action=Display%20message&message=File%20%7bfilename%7d%20not%20found%2e&fileToDownload='+filename+'';
    };
    }
    When I use the above (basically to change the file path to the correct one) I can get my drawing file to download to my machine.

    Now, here's my problem.
    The drawing file is no good if I can't get the part and assembly files that may go with it. They may have the same name or they may have the same name plus "-1" or "-03" etc.

    So, what I'd like to do is make some sort of function via xBasic, javascript or a combination of both that searches the directory, returns file names that might match, and then allows the user to pick which ones to download to their machine.

    Let's take this example.

    My file location for the .pdf file is : P:\Secured\ReleasedPDF\Tooling\060\06000.pdf (Currently, I have no problem turning that into : P:\Secured\Tooling\060\06000.slddrw)

    I want to search P:\Secured\Tooling\060\ for files (to use SQL terms just for explaination) LIKE '06000%'
    I want to return the results of that search to the user.
    I want to then allow the user to choose among the results.
    I want to then send the users choices to the users machine via download.

    What do you guys think is the best/easiest way to do this?

    Thanks in advance!

    #2
    Re: How To Search A Directory on the webserver + return filenames for possible downlo

    Come on guys! No bites at all? Maybe I should start posting in the programming puzzles area after I figure these out.

    Anyway; I'M CLOSE!

    I just need a little help with some funky issues.

    Here's what I've got so far.

    A user searches my main grid. When he finds a tool number that the user wants to download the files for he opens the detail view in the grid and there is a button waiting for he/she.

    That button opens up a dialog component.
    In the OnDialogInitialize Event I have this code:

    Code:
    '---------- Simulate a user value passed to the dialog
    dim id as c = "43755"
    
    
    'To edit this action, place insertion point anywhere in the command, then click the 'Action Scripting' button'.
    ExecuteServerSideAction("Populate Dialog from Tables::Populate_a_Dialog_with_data_from_Tooling_Card_Info")
    
    dim filepath as c
    dim filesrc as c
    dim files as c
    
    'filepath = e.rtc._data.file_location
    'below filepath is for testing in working preview.
    filepath = "P:\Secured\ReleasedPDF\Tooling\060\06004.pdf"
    filesrc = word(filepath,-1,chr(92))
    	filesrc = word(filesrc,1,chr(46))
    		filesrc = "P:\Secured\Tooling"+chr(92)+left(filesrc,3)+chr(92)+filesrc+"*.*"
    
    files = filefind.Get(filesrc,0,"N|PN")
    
    '---------- Set up variable to populate the 'UserRoles' radio control
    dim e.rtc.filechoices as c
    
    '---------- populate the variable for my checkbox
    e.rtc.filechoices = files
    'debug(1)
    This populates my dialog correctly and pulls it up in a dropdown window in the grid.
    The dialog consists of a check box populated on the initialize event with the file choices for the user.
    The user may pick multiple files. (still working on a zip function but for now I've got to figure this out.)
    After picking the files there is a download button, and within it is this code:
    Code:
    var e = $('{dialog.componentName}.__IFRAME1');
    var filedl = ({dialog.Object}.getValue('FILES_TO_DOWNLOAD'));
    //alert(filedl);
    var cnt = ''+filedl+'';
    var filedl2 = ''+filedl+'';
    var filestodl = ''+filedl+'';
    var cnt = (cnt.split(",").length);
    //alert(cnt);
    if (cnt>1)
    {
    	
    	for (var i=0; i<cnt; i++)
    		{
    		filedl2 = filestodl.split(",").shift();
    		alert('filedl2 '+filedl2);
    		filestodl = filestodl.replace(filestodl.split(",").shift()+',','');
    		alert('filestodl list '+filestodl);
    		e.src = '__A5FileDownload.a5w?c=%5fa5filedownload&action=Display%20message&message=File%20%7bfilename%7d%20not%20found%2e&fileToDownload='+filedl2+'';
    		}
    
    }
    else
    {
    alert('single file');
    e.src = '__A5FileDownload.a5w?c=%5fa5filedownload&action=Display%20message&message=File%20%7bfilename%7d%20not%20found%2e&fileToDownload='+filedl+'';
    
    }
    It Works!......mostly....

    My problems are:
    When a user clicks on a single file, it appears to work correctly as the file is downloaded; however, as soon as the dialog dropdown is closed it wants do download the file again. Also, after it's closed, if I open the dialog dropdown it will want to download that file again right away

    When a user clicks on multiple files, the problems are the same as the above with the exception that it will only try to download the last file that was clicked on.

    I know the problem has something to do with how I'm most likely; wrongly, using the e.src or the IFRAME.

    Hopefully the solution is simple.

    Comment


      #3
      Re: How To Search A Directory on the webserver + return filenames for possible downlo

      Well, after about 26 hours of messing about I figured it out.....no thanks to you losers.....
      If anyone has interest in doing something like this I can give them a heads up.

      I'd just post it here but maybe this should go in the programming puzzles forum now that I have the answer?...hmmm

      Comment


        #4
        Re: How To Search A Directory on the webserver + return filenames for possible downlo

        Originally posted by -Jinx- View Post
        Well, after about 26 hours of messing about I figured it out.....no thanks to you losers.....
        If anyone has interest in doing something like this I can give them a heads up.

        I'd just post it here but maybe this should go in the programming puzzles forum now that I have the answer?...hmmm
        We had complete confidence that you would solve the problem.....
        Al Buchholz
        Bookwood Systems, LTD
        Weekly QReportBuilder Webinars Thursday 1 pm CST

        Occam's Razor - KISS
        Normalize till it hurts - De-normalize till it works.
        Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
        When we triage a problem it is much easier to read sample systems than to read a mind.
        "Make it as simple as possible, but not simpler."
        Albert Einstein

        http://www.iadn.com/images/media/iadn_member.png

        Comment


          #5
          Re: How To Search A Directory on the webserver + return filenames for possible downlo

          Originally posted by Al Buchholz View Post
          We had complete confidence that you would solve the problem.....
          Likely story...........

          Comment


            #6
            Re: How To Search A Directory on the webserver + return filenames for possible downlo

            Hi -Jinx-
            I am investigating a document management app and would be extremely grateful to see your solution.
            Our files (PDF's, Word, Excel) are stored on a server with a folder for each client. I was planning to use filefind.Get to generate a list in a dialog then use response.sendfile to download the selected file.

            This is an Intranet application so I would like to open the file for editing but from the posts I have read so far this does not seem possible. Is this your understanding also?

            Comment

            Working...
            X