Opening a file from TFS using the full TFS Path, from a web site - visual-studio

So I have a website running that displays full path of a TFS File on the page somewhere, I want the user to be able to click on it, which should then open up that file from TFS inside their Visual Studio.
The command to do this inside Visual Studio is "File.TfsOpenFromSourceControl" (DTE command) - it's basically the user manually going to that file using the Source control explorer and double clicking to open it up.
I am wanting to simulate that action from my web app inside the browser.
Update: The Web app is a pure ASPNet MVC app with Jquery available to it. I am already showing the file's content to the user in the web app. But I want the user to open the same file in Visual studio, by clicking on the file path in the web app. The question is more of Browser to VS integration and how to execute the DTE command in question, from within the web app context of the browser.
Any clues would be helpful

I don't know the answer to Pavel's question, so I'll sketch an outline of both solutions.
If you want to display the file inside the browser, call the Item.DownloadFile() API. NB: in 2008 SP1 there is another overload of this method that allows streaming into a memory buffer instead of writing directly to the filesystem. If you don't already work with Item objects directly, you can retrieve them via the GetItem() / GetItems() APIs.
If you want to make the file open in VS, there are a couple approaches. Perhaps your web app already includes the concept of local workspace(s) for the user, similar to Source Control Explorer. If so, you'd simply call Workspace.GetLocalItemForServerItem() to find the local path of the item, then ShellExecute it. (Or maybe pass it as a command line parameter to devenv.exe, if it's not natively associated with VS.) If not, you can either create a temporary workspace on behalf of the user, or use the same DownloadFile() API shown before; stream the contents to the client over a web service, save to disk, then launch VS as before.
Naturally, the more involved scenarios under option #2 will require deeper OS integration than the DOM / Javascript can provide. Would help to know if this web app is already built on ActiveX, Flash, Silverlight, XBAP, or similar technology...

Related

Display PDF file in LocalState folder in Windows 8 app in Cordova

My application downloads a PDF and stores it in the LocalState folder for my Windows 8 app.
I have a link within the app that I would like to show the PDF when the user clicks it.
I've tried displaying it using ms-appdata:///local/pdfs/filename.pdf in a window.open call and I also tried using the InAppBrowser plugin within cordova with no luck. Additionally, I've tried the following:
var uri = new Windows.Foundation.Uri('ms-appdata:///local/pdfs/filename.pdf');
var file = Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri);
Windows.System.Launcher.launchFileAsync(file).done();
I know the file exists as I'm getting a file result back. Just not sure how to allow the user to view it.
By design, the local appdata folder on Windows is accessible only to that app, or to full-trust desktop applications (and this is probably true of similar sandboxed locations on other platforms). As a result, a Windows Store app that gets launched with Launcher.launchFileAsync won't be able access that location (nor can a webview process, which is also sandboxed). If a desktop application gets launched, on the other hand, it probably can access the file, but you can't tell ahead of time if that's the case. Bottom line is that local appdata isn't a good location for letting other apps get at the file.
You'll need to save the file in another location that is accessible to other apps. There are two approaches here, both of which will require a little user interaction to select a location, so they can place the PDFs anywhere they want:
Have the user select a save folder for your app, which they can do once. You would invoke the FolderPicker for this purpose, and save the selected folder in the FutureAccessList. This way you can have the user select the save folder, which grants you consent to save there, and by saving it in the FutureAccessList you can retrieve it in subsequent sessions without having to ask the user again. Refer to the File Picker Sample and the File Access Sample for more.
Have the user select a save location for each individual file, using the FilePicker (see the same sample), and you can also use the access cache to save permissions to those individual locations if you need them later.
There might be Cordova plugins that work with these APIs too, but I haven't checked. Either way, once the file is in an accessible location, launching the file should work just fine.
As an alternate solution, you could consider rendering the PDFs directly in your app. Windows has an API for this in Windows.Data.Pdf, with an associated sample. There might be a plugin or other JS libraries that could also work for this.

Dynamically changing file lock/access permissions on open file

I have a client application where we try to check files in and out from SharePoint for editing. I am using SharePoint's SOAP interfaces and some FrontPage interfaces to do this. It used to work fine under SharePoint 2007, but with 2010 I can't check out or check in a file if I have the file open for editing. I get a message like "FileXXX is locked for exclusive use by DOMAIN\user" when I examine the returned error message. I also cannot update any of the user defined SharePoint fields for a file/list if the file is open for editing.
My question is this: Is there a way to change the access/lock for an open file to make it non-exclusive temporarily and then restore it?
Note: Some of my data files are opened using windows file handles (flat files) and others are opened using windows structured storage (compound document files).
This may not work for Sharepoint specifically, but the ReOpenFile() API does what you want. I don't know of any other way to do this.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365497(v=vs.85).aspx

Creating a local folder through an url

imagine you want to have a link on a website that creates a local folder and opens it in the Windows Explorer as soon as click on it. Something like Go to new folder
I know there is the file:-protocol, but this only opens a local folder. Is there a way to specify in the url that the browser should also create the folder.
It might be against lot's of security policies. But I'm just curious if there is any way you could achieve that. What ever come in your mind? Don't hold back.
Cheers,
Gerardo
As you mentioned, this is not allowed for web pages from internet. (imagine a rogue script running thousands of these)
You may be able to open an existing folder, in the browser (not via Windows Explorer, unless it's IE and the page is trusted).
If you want to create a folder, try using Offline Storage APIs for HTML5. This may not accomplish the 'opening in Win Explorer' part, but you can store data on user's machine.
Hope this helps.

Open TFS Work Item Attachment in Image Viewer not Web Browser

Is there a way to open an attachment for a TFS work item by double clicking on it (or rather just opening it from the IDE) in your computer's default image viewer, rather than opening it in a web browser? I'd love to be able to change this setting (if it is a setting).
Edit: after reviewing Kate Gregory's response, I looked into this option and realized that the trouble is that VS is launching a url (a handler file to respond with the attachment), which results in the default web browser being launched. A potential work around i'm considering is writing a custom mapper for all web based calls (as in, when going to start->run and enter a URL) that the mapper would determine what kind of call it is (TFS, etc) and use an appropriate program, based on the MIME type responded with, with a second phase to be incorporate this as a VS add-in.
I'm reasonably sure VS just uses your default program. Word for .doc files, IE for .htm files, and (in your case I bet) IE for .jpg files. Try changing the default program you're using in Windows and see what happens.
All files saved in TFS are saved in a path that starts with the following address:
http ://{YourServerName}TFS01:8080/tfs/.../.../...&FileName={YourFileName}.{YourExt}
This means that all files are opened using the default program defined for HTTP protocol, regardless of the extension for your file.
You can probably change the default program for your HTTP protocol (if you have permissions, and usually you wouldn't) but this would also affect opening any regular web page or URL, which is probably not recommended.
I still haven't found a workaround this issue too.
Some kind of preview function in VST/Team Explorer would be nice. Then, only a minor of attachments must be opened in the browser.
http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/6224713-preview-attachments-in-team-explorer

Customizable Windows right-click file uploader?

I'm looking for a "right-click upload" application like RightLoad - an application that can upload media files to a remote FTP server from the Windows Explorer's context menu. I want to customize the application to serve as a customized image uploading tool to a PHP-based CMS.
The user would upload images and other media files to a defined FTP account (I'm also very open for other methods of transport, as long as they are supported by run-off-the-mill web hosting stacks) that they could then use in the CMS they log in to.
For me to be able to do these customizations, the application would have to be Open Source - RightLoad is "only" Freeware. Alternatively, I'm open for closed-source and commercial suggestions as long as they allow "pre-packaged" server settings that can easily be deployed to the user.
Does anybody know such a tool compatible with at least the most current versions of Windows (XP, Vista, 7)?
Bounty
Thanks all for the great input. In the case at hand, I decided it's easiest for me to stick with RightLoad and create a workflow in which the URL presented by RightLoad after the upload is copy+pasted into the CMS. I am putting a bounty on this because I think it's a worthy question for future generations, and I want to be the first one to put up a 500 bounty under the new bounty system :)
You could just use the send to menu using window's My network Places like this http://techie-buzz.com/how-to/right-click-and-send-to-ftp.html
I think WinSCP might have everything you want:
Open Source under GNU GPL
Windows Explorer's 'Send To' Context Menu
Drag 'n Drop Shell Extension
lots of additional features
and it can be scripted and is more secure than FTP due to using SSH
If you insist on open source, why not create a custom context menu handler and send it using some open source FTP client?
I would have to check the details, if it's really viable, but I would start with it.
I just had an idea, tested and working:
use regedit to edit HKEY_CLASSES_ROOT/*/Shell
add a key in shell called FTP to Mysite, in the default value set it to FTP to Mysite.
then add a key to the FTP key you just created called command, in the command default value use:
C:\Program Files (x86)\Internet Explorer\iexplore.exe http://www.mysite.com?file=%1
what this will do is open IE and the address www.mysite.com?file=C:\path\to\file.jpg
now using $_GET you can get the file address, upload it via php to where ever, even add an interface...
now when the user right clicks on any file, they can upload it via your web site by clicking FTP
1) another software is RightLoad , i use it that this moment!
2) The nice software I used over years, was FLING. It adds Right Click menu in windows explorer... However, I have left the software, because till today (version 2.35) fling DOESNT support SFTP (And nowadays on all sites I use SFTP!!)
3) I DONT like SEND-TO menu! (because I think passwords saved in WINDOWS can be easily stolen by virus..)

Resources