transefer file from server to server using web services - c#-2.0

i have to make one .net framework 2.0 web services which took some parameters like source server name destination server name file name then this services will move the file from source to destination.
one solution i found is using asp.net i make two pages one for file download and one for file upload and this pages are available at each server.
web services will send http request to the server and server will send file or save file on server.
but in this i have to place this two pages on all server.
Is ther any way in which i can read and write and create file from the remote server using web services in .net framework 2.0?
if any boduy know about it please help me.
sorry for spelling mistakes and grametical errors.
thanks

If the account your web service runs under has sufficient permissions you could use paths like this:
\\servername\c$\somepath\somefile
Another solution would be to use UNC shares but you won't be able to read and write to arbitrary paths.

Related

Generate a .zip file using Forge Design Automation

I'm working on a web site using Forge Design Automation for AutoCAD, and I'd like to have a .zip file returned. Does the .zip file have to go back to a URL (folder) located in site, or can it be downloaded directly to my view (MVC) through the controller? And, if it can come back to the view, how do provide arguments to my workitem?
Thank you.
The Design Automation will want to PUT/POST the resulting zip file somewhere. So you must supply a resource (URL) that can be operated on by one of those verbs.
Your website then can offer up the same resource to download to your clients. Clients cannot download directly from Design Automation as there's no HTTP resource that they could GET.
We can take advantage of the Forge OSS signed resource with read/write permission, so that Design Automation API will put the file to the Forge OSS bucket, and we can use the sample link to download the file. Please check my sample here. Although it's a Revit sample, the signed resource part can be applied to Design Automation API for AutoCAD, too.
https://github.com/yiskang/forge-revit-fbx-export-bim360/blob/master/routes/da4revit.js#L92
https://github.com/yiskang/forge-revit-fbx-export-bim360/blob/master/routes/da4revit.js#L216
https://github.com/yiskang/forge-revit-fbx-export-bim360/blob/master/public/js/ForgeDesignAutomation.js#L58
https://github.com/yiskang/forge-revit-fbx-export-bim360/blob/master/public/js/ForgeDesignAutomation.js#L220

How to share files between multiple ASP.NET MVC Applications?

I have two web application in my solution. One of them is for managing the system and another is for clients.
I should publish them one by one in separated places (of course on a machine but in separated addresses for Example http://manager.com and http://clients.com)
My question here is that, can clients web application access the files that the other manager web application has (in its physical directory)? If not how can I approach this problem?
see this design to get more details for this problem :
Thanks!
What I usually do in a scenario like this, is store the files in a folder in the application that does the writing. Then I use IIS to create a virtual directory in the other application that points to the folder containing the files in the first application.
So in your case, you could have a folder "Files" in the manager.com website. Let's say the folder has this full path: D:\Websites\manager.com\Files You can then create a virtual directory in the clients.com website pointing to that path.
This has the advantage that you can code everything as if the folder exists in both applications.
If your applications placed on one machine - certainly can.
You should do only one thing - give permission to folder with files (Or permission to DB with files) to user that run your web application on web server (Usually IIS if you use MVC < 5)
It seems from your comment that you want to share uploaded files between multiple web project. You can store them in a common folder outside your web project folder.
For example, create a folder in
"C:\Temp\" say "SharedFiles".
The manager web application that receives the file from user (through upload) can store the files in this folder. The client web application can refer this location for file while reading.
You may have to give permission to the user (IIS_IUSRS) to access this folder.

Maximo 5.2 Can upload attachment to the server but can't view them on client side

Ok I know Maximo 5.2 is horribly outdated but currently I just want to get the attachment working. So here is the situation:
I have an old server (running 2000) with a folder being shared on the network with the name of F$. I have tried that the attachment uploading functionality works fine: users can attach any file to a work order and that file will be copied into a specified folder in the F: drive of the server. But when I try to access to that file from the client side -- that is, click on the link within the work order (from attachment tab in Maximo webapp) in order to view the attachment -- I get a 404 response. So in a way it's like I am able to write to the server but somehow I can't read or download it from the client side.
UPDATE:
I found out that after you've uploaded a file to the server, it can be accessed from the link http://servername:port/doclinks/drawings/filename from any other client side desktop in the browser. However within the Maximo web app, the webpage javascript automatically parse the link as http://servername/f$/MAXIMO/doclinks/drawings/filename -- It returns redundant part and withno port number. Is this returned link configurable through settings or do I have to dig into the JSP?
You need to set up virtual directory mapping on weblogic
http://docs.oracle.com/cd/E11035_01/wls100/webapp/weblogic_xml.html
The files are on the server. You just to correctly map the doclinks root on the file system to make it accessible to the web. You are getting a 404 error because the mapping is wrong.
In c:\maximo\applications\maximo\maximouiweb\webmodule\WEB-INF look for weblogic.xml
Add an entry:
<virtual-directory-mapping>
<local-path>/apps/maximo/</local-path>
<url-pattern>/doclinks/*</url-pattern>
</virtual-directory-mapping>
The entry above sits between <weblogic-web-app> and </weblogic-web-app>
The above example would mean your doclinks directory on the server is /apps/maximo/doclinks/
You would need to edit weblogic.xml, redeploy your maximo.ear along with your doclinks.
Because you are getting http://servername/f$/MAXIMO/doclinks/drawings/filename, particularly the f$/MAXIMO part, it tells me your F<PATH>\\MAXIMO\\doclinks = http://servername:port/doclinks mapping in your doclinks.properties is not correct. If you are on the Maximo host, via remote desktop or whatever, and you open Windows Explorer, what do you need to put in the address bar to access the attached documents folder? You said it's on F$, but F<PATH> in your properties file will translate into F:, not F$. So, you need to change your doclinks.properties
from: F<PATH>\\MAXIMO\\doclinks = http://servername:port/doclinks
to: \\\\servername\\F$\\MAXIMO\\doclinks = http://servername:port/doclinks

how can i know the physical path from selected file (fileupload bootstrap)

I´m making a web application in MVC, I have a view where I select a file from my pc directory (like opendialog form in windows applications), bootstrap´s fileupload gets the file name but I want to know his physical path to. Because I want to save it in my data base (where file come from).
Anybody can help me??
Thank you in advance!
You can't, this information is never sent to the server for obvious security reasons. Only the filename is sent to the server. So you cannot store the physical path where the file originated from the client machine on your server.
When you upload a file via a web browser, the actual file path is not supplied. This is seen as being a security feature.
There is no way to circumvent this using pure HTML. Some people get around it by using a plugin such as Flash or Silverlight to upload the file, but I recommend living with this feature if you can.

How can I make a server log file available via my ASP.NET MVC website?

I have an ASP.NET MVC website that works in tandem with a Windows Service that processes file uploads. For easy maintenance of the site, I'd like the log file for the Windows Service to be accessible (to me, only) via the website, so that I can hit http://myserver/logs/myservice to view the contents of the log file. How can I do that?
At a guess, I could either have the service write its log file in a "Logs" folder at the top level of the site, or I could leave it where it is and set up a virtual directory to point to it. Which of these is better - or is there another, better way?
Wherever the file is stored, I can see that there's going to be another problem. I tried out the first option (Logs folder in my website), but when I try to access the file via HTTP I get an error:
The process cannot access the file 'foo' because it is being used by another process.
Now, I know from experience that my service keeps the file locked for writing while it's running, but that I can still open the file in Notepad to view the current contents. (I'm surprised that IIS insists on write access, if that's what's happening).
How can I get around that? Do I really have to write a handler to read the file and serve it to the browser myself? Or can I fix this with configuration or somesuch?
PS. I'm using IIS7 if that helps.
Unfortunately I'm afraid you'll have to write a handler that will open the file, and return it to the client.
I've written an IIS Manager extension that displays server log files, and what I've noticed that even the simple
System.IO.File.OpenRead("")
can still run in the same problem, and return the same error.. It was kind of confusing.
In the end I used
System.IO.File.Open("", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
and I could easily open the file while the server was writing logs to it :)
I think the virtual directory is an "okay" solution, if you add the directory (application) with READ ONLY rights + perhaps "BROWSE directory" too (so you can see the folder contents rendered by the IIS).
(But once you do that, you should consider that you also anonymous access to that folder - unless you enable authentication, so watch out for "secret" contents of the logfiles that you might expose? just a thought.)
Another approach, I prefer myself, is to make a MVC/ASP.NET page that does the lookup in the folder by normal code, so that you 100% can filter whatever data is shown in the HTML.
You can open the files as TextStream's and in Read Only mode.
If it's a problem to gain access to the logfolder, I would use the virtual directory with READ ONLY access and then program something that renders the logfiles as HTML on my screen and with my detail levels. Perhaps even add some sort of "login" first. But it all depends on your security levels and contents of logfiles.
is this meaningfull to you? if not, please explain more, as I've been through this thought a few times already for similar situations.

Resources