Display remote files through a WCF service - wcf

I don't want to reinvent the wheel, I must display remote files and folders (like SQL Management studio does), should I develop my own interface and logic or there is an alternative? I need multiple selection.
I'm using VS2008 .Net Framework 3.5 SP1
Thanks
EDIT:
I built a multi-ambient music server that is running in the network and i must provide the ability to select which music files or folders should be played. The files resides on the server and are not available to the clients. The clients comunicates to the server trought a WCF service i built.

When you say remote, exactly what do you mean? Do you mean on another server in your intranet, or out on the wide web?
If you just need to view files on another machine in your intranet, the built in file chooser in .net will work. All you need to do is hand it a network address (like: \somemachine\somefilepath).
If you mean more remote than that, then FTP might be an option. You can build yourself basic FTP functionality in your C# application in very little time. Google "C# FTP" and you'll find lots of examples.
A third option would be a simple WCF service that returns a list of file names. But you said you needed "multiple select", so I am assuming you want to do more than just "read" the files, in which case you need to transfer them over the wire, in which case I recommend the FTP route.

Addition to the above - what do you mean by "files", and how would you expect to display them? In a custom application, or by using Windows Explorer?
WCF may not be the most appropriate way to do this, as was said above. There are already file transfer protocols in the world, and if you don't want to reinvent the wheel, then you shouldn't create a file transfer protocol based on WCF. You should use FTP, HTTP or WebDAV.
Otherwise, you should look at those protocols (especially WebDAV) for inspiration on what your service will need to do. It will need to expose a concept of files and folders, and to have a way to get file information and get files.
Just like "the wheel" already does.

Related

How to call VB6 DLL from another machine (DLL as a service)

I have a vb6-mysql client-server desktop application which is distributed as a setup file.
It uses DLL all logical operations as well as database operations. The EXE and the DLL are installed in the server as well as the client machines. When I say server which only means the database resides in that machine no other difference in EXE or DLLs.
As all the database operations are done in the DLL when connected from a client machine, performance would be less. It is not possible now to change all the logic into database.
Is it possible to store the DLL in the server machine only and use the same DLL by the client machine also so that database connection will always be from the server itself?
Is converting the DLL to a windows service the possible solution for this?
How can I to convert it to a service?
And finally, if it is possible to make the DLL act as a service, what would the connection issues be?
You appear to be trying to rediscover n-tier application development.
The usual way this would be done using VB6 within a LAN would be to create an ActiveX EXE instead of a DLL so you can use DCOM. However DCOM isn't something you'd want to expose over the Internet.
For such cases it is more typical to use a commonly-open-port protocol such as HTTP or HTTPS. Almost everyone has firewall settings permitting outbound HTTP and HTTPS connections and most of the major Web servers undergo regular hardening to make them safer to expose to the Internet.
The classic way to do this with VB6 was to use IIS to host the Remote Data Service, which uses a form of Web Service "under the covers" where your program doesn't deal with the gory details. However this is a deprecated approach, and today configuring IIS and the RDS components can be a chore since they are locked down hard by default.
This leaves you with such things as the deprecated SOAP Toolkit or 3rd party tools such as those in the PocketSOAP suite... or you can roll your own.
Doing this from scratch can be a bit of work but is more flexible, allowing REST instead of SOAP which can have advantages in itself. You could use whatever Web server you choose that can work with VB6 (via CGI, etc.).
The hardest approach to justify might seem the simplest on the surface: create your own protocol over TCP and write a Windows Service. This can be the most flexible of all but it can be more work than other options and you are on your own as far as making it and keeping it secure. You'll probably also face firewall issues depending on where your clients are and what the local firewall policies are there.
When we could rely on DCOM the issues were relatively small aside from security configuration headaches. With the Internet in the picture it is an entirely different story.
This really isn't something you undertake casually. Even assuming that your database is safe exposed to the Internet is naive and should be rethought.

WCF Active Directory Helper Service

I've recently started learning the WCF Framework and I have an Active Directory Helper class/library that I've created to house my code for interacting with Active Directory. I'm not sure if I'm reinventing the wheel trying to do this but it seems like it'd be a better implementation to run this Active Directory Helper library as a WCF service within my network and reference that service from any internal application.
My question is, is this something that would be a worthwhile endeavor, is what I'm doing redundant, or is there something else better out there that would already do what I'm looking to implement?
I've found this article in a Google search on this topic:
http://blog.waleedmohamed.net/2009/12/create-active-directory-service-using.html
but it wasn't very intuitive for me to follow along and I don't like the idea of putting domain credentials for something in any config file. Other than that there doesn't seem to be a lot of information on the topic.
Update
The AD Helper library I've developed utilizes the System.DirectoryServices namespace and implements things like:
Instantiate users in ADAM: http://www.koders.com/csharp/fidCD7765F2E9C23683407CEFAFAFB68D3157857BFB.aspx?s=cdef:%22Adam%22#L18
Recursively get all users in a Security Group: http://www.volumeracing.com/blog/?p=129
etc...
My goal is to implement these things as a WCF service over NetTcp so instead of including this AD Helper dll in every project that would want to do these things as well, I can just have my projects call the WCF service. Then if I ever needed to add or update the AD Helper dll, I can do so without having to update all my projects that implement the AD Helper dll.
I would check out these things before proceeding:
What's New in AD DS: Active Directory Web Services
Active Directory Web Services Overview
Active Directory Gateway WebService is available for ‘legacy’ OSes
Introducing the New Active Directory Domain Services in Windows Server 2008 R2
There's a lot going on in this space - however, in most cases, it requires very recent server OS versions (Windows Server 2008 or 2008 R2).
I would take a good close look at these offerings from Microsoft, and then decide whether it's worth doing this on your own - or just use this instead.

Start with remoting or with WCF

I'm just starting with distributed application development. I need to create (all by myself) an enterprise application for document management. That application will run on an intranet (within the firewall, no internet access is required now, BUT is probably that will be later).
The application needs to manage images that will be stored within MySQL Server (as blobs) and those images will be then recovered by the app and eventually one or more of them will be converted to PDF.
Performance is the most important non-functional requirement.
I have a couple of doubts.
What do you suggest to use, .NET Remoting or WCF over TCP-IP (I think second one is the best for the moment I need to expose the business logic over internet, changing the protocol).
Where do you suggest to make the transformation of the images to pdf files, I'm using iText. (I have thought to have the business logic stored within the IIS and exposed via WCF, and that business logic to be responsible of getting the images and transforming them to PDF, that because the IIS and the MySQL Server are the same physical machine). I ask about where to do the transformation because the app must be accessible from multiple devices, and for example, for mobile devices, the pdf maybe is not necessary.
Thank you very much in advance.
WCF, only consider remoting if WCF presents some issue such as performance in your use case. You have many many more scaling and customisation options available under WCF.
Depends. If sending the images over the net presents an issue then it may have to be done locally. However as in (1) your existing suggestion seems ok.
See .Net Remoting vs. WCF for a similar question.
Definitely remoting if this is an option
Transformation - same box that the service is; since the service is going to funnel the images anyway - this is the best place. I would not put it on DB server, to better distribute the load and to separate non-db load from db specific load.
In addition, look into .Net 4.0 RIA services. They allow you best combo of .Net Remoting and WCF

Create a Web Service(WCF) to integrate with QuickBooks

I am in the process of integrating our custom web app with QuickBooks Enterprise 9. My thought is that I could use QuickBooks as my "database" of sorts. When a person creates an invoice, the invoice is actually stored only in QuickBooks. When a person views a list of invoices, they are actually viewing a list of QuickBooks invoices. I want to make sure the data is stored in only one location.
I realize that I could use the QB Web Connector, but the problem with that is I wouldn't have control over when the requests to QB actually get processed (That job is up to the Web Connector).
So I have my web UI to act as the QuickBooks "face," but I don't have any good way to get to and from the QuickBooks file located on an internal server. What I was thinking was that I could create a WCF web service and install it on the QuickBooks server. The web service could then be my integration point. My custom web app could then consume the web service and, viola, I have access to my QuickBooks files.
My question is this: Can a WCF app connect and run QuickBooks? If not, could i create a Windows service to act as my point of integration? If so, can my custom web app "consume" a windows service?
I'll start by warning you that QuickBooks probably isn't your best choice for a reliable back-end database accessible from a remote website. In fact... it's probably a really, really bad choice.
You should have your own application database, and then if you need to also exchange data with QuickBooks, do that outside of the normal lifecycle of your app, as a separate sync process.
QuickBooks generally isn't reliable enough for always-online type of applications due to a number of reasons:
Flaky SDK connections
Updates and single-user mode will
lock you out of accessing QuickBooks
Difficulty in establishing SDK connections from non-GUI processes (Windows Services and IIS processes)
With that said...
Yes, you could create a WCF web service, host it on the QuickBooks machine, and make your WCF web service relay messages to/from QuickBooks.
Yes, you could also create a Windows Service that does the same sort of thing.
Do NOT implement it as a Windows service, and do NOT implement it within IIS - instead implement it as a GUI app that runs alongside QuickBooks.
If you try to implement things as a Windows service or within IIS, the QuickBooks SDK requires you have a GUI available (it users a GUI COM message pump for events dispatching or something like that...) to process requests, so you'll probably need to use something like QBXMLRP2e.exe to straddle the process boundary between QuickBooks and your non-GUI Windows service/IIS. My experience has been that it's a gigantic pain in the butt, and requires mucking with DCOM permissions as well.
I have an example and some documentation on my QuickBooks integration wiki.
The IDN Forums are a good place to ask questions.
My recommendation to you would be to either:
Use the Web Connector and QuickBooks
and give up hope of keeping all of your data in one place. Cache the data in a real database, and update it by querying QuickBooks periodically. I'm almost done building a solution to do exactly this right now, and it works fantastic.
OR
Use a different account system. NetSuite is pretty nice. I'm not sure what else is out there, but if I were you I'd look for something SQL-based or with a strong SOAP/REST API.

Monitoring a Custom Service

I've created a service for one of my apps. How do i create a system tray component in VB.net that can be used to monitor the progress of the service? Is there a way to have this installed via tcpip on multiple client machines such as those that are for our employees?
We do exactly that here, with the server running a really basic HTTP server on a configurable port on a separate thread that returns status in an XML format (nothing else, just that) -- the client just uses a web request to get the XML, before parsing it and displaying it appropriately.
This approach also allows for future extensibility (detailed status, sending service control commands, adding an association to an XSLT file elsewhere for use with a normal web browser, etc.)
You could use WCF for this. Using WCF your service would open up an EndPoint which would expose status information to callers. You could then build a tray icon application that can be deployed to the employees workstations. The tray icon application could periodically poll the WCF service the your Windows Service is hosting and get status information. I know #Johan mentioned Remoting already and this is a similar approach. I'd recommend WCF though as the programming API is more simple, IMHO, and WCF will give you more flexibility with regards to network transports, etc.
I guess your question is not about how to actually do the "traybar"-thing, but how to communicate with the service to get the information you want to show in the monitor/traybar-program?
It can be done in many ways, API is one way, use sendmessage/postmessage/getmessage is one way to make 2 running programs communicate with each other without having to store anything in files or databases first.
DDE is another way. If it needs to do the stuff via net then there is something called NetDDE, but I havent done anything with NetDDE I cant help anything there.
But about the API and DDE, feel free to ask more questions if you want some clarification.
I'll take the second question: Is there a way to remotely install software on client machines?
Yes. However it is very dependent on your environment. For example, if you have an Active Directory domain, you can use group policy to force installation of software on the client boxes.
If you don't like that or if you aren't on active directory, you can buy something like Altiris to push installs down.
Another option would be to use login scripts which would run a custom program to detect if your program is installed and take appropriate action. But then you are probably better off buying Altiris.
For the comunication part, i have used remoting before, and this works very well. With a little bit of configuration, you can even get it working to another machine.