I'm in the initial phase of designing an application that will have a backend implemented in C# that will provide data for other platforms using WCF web services hosted on IIS. One of the platforms will the the iPhone.
Since it's a personal project, I want to use it to learn MongoDB. I already know that there are community developed drivers for MongoDB and C#, so I could handle the persistence on the server side using MongoDB.
Without even knowing the replications models offered by MongoDB, I was thinking about some kind of simple synchronization model to keep data local if the iPhone is not connected or has a poor connection.
Here's the question: Can MongoDB be used in the iPhone using the MongoDB C drivers? Has anybody already tried that?
The typical iPhone architecture is to have your application call out to a web service. Even if it is possible to use a MongoDB driver directly from a mobile client I would not recommend it. For a few reasons.
You are basically talking about doing client server architecture where your client application talks directly to the datastore (MongoDB.) What about security? When any authenticated client talks directly to the datastore all sorts of bad things can happen.
Tightly coupling your client application directly to any given data access technology is dangerous in that it would require you to rewrite your client if for some reason you needed to change your data access solution.
It is more common these days to have your client applications go through a data access tier and when the Internet is involved this tier often involves a web service of some sort unless you want to get elbows deep writing server code.
Think about writing a RESTful api exposing your datastore to your iPhone client. I've heard good things about Open Rasta (C# REST library)
Edit - More about hosting MongoDB on the iPhone
Sorry I didn't understand that you wish to run MongoDB locally on iPhone. MongoDB is a server. I do not believe that it is embeddable as an in-process datastore. And it is not possible to run more than one process on the iPhone.
If you are familiar with C# you might want to check out MonoTouch. It allows you to run C# applications on iPhone. There is a nice library for using SqlLite which is supported by iPhone.
Related
I've been developing an application that interfaces with PowerShell for Windows. So far, everything has worked great. However, it connects to MySQL directly (I guess that's not good practice?) and also connects directly to the local PowerShell instance. My goal for the future, however is to make it cross platform. I currently purchased a book on cross platform development (mono based I believe) to get a handle on have a best practice common services layer for some basic things. However, I can't get my head around how I'll do that with PowerShell.
My question is, is there a way to host a server somewhere that accepts Powershell connections remotely via web requests from multiple connections at once? Otherwise, I don't see how I can port such an application to Android and the likes.
Also, I wouldn't be opposed to some basic links for best practices on web requests and the likes.
Have a look at PowerShell Web Access.
I am writing a plugin for an application in C#. The plugin allows me full access to the internal information model for the application.
I would like to create a mechanism to allow external applications to be able to connect to the information so they can report on it etc.
In days of old this used to be achieved via ODBC links - is that still the way to go.
I assume it's a significant task to create an ODBC driver for this, are there any easier recommendations or example C# code for cresting a driver.
Looking back I was not very clear in the original question. The requirement is to allow two applications on the same PC to share data. The "host" application use a proprietary storage format and as such access to the data cannot be achieved without using the "Host" application. The "host" applications allows the development of plugins (using C#) and the plugins have access to all of the data within the application. On that basis I was exploring whether a plugin could therefore expose an interface to an other external application and as such could act as a "Data Access Layer"
My reference to ODBC is probably a "red herring" - just shows how out of touch I am in this area.
Probably you are looking for something like Remoting and\or Web Services and\or the more modern WCF (windows communication foundation).
You can write your own services and access to that services from every language you want.
C# support for WCF and Remoting and WebServices is very good and allow you to write your server-client infrastructure in a very clean, object oriented and easy way.
Use HTTP: each services is handled in a serialized object sent in XML through an HTTP server, for example, IIS.
Clients can be written in every kind of language you want, from PHP to C# to C++ to JAVA to wathever, they need only to connect through HTTP and parse\deserialize\serialize XML.
You can choose your architecture. If both clients and servers are written in C# all is transparent to you, serialization and deserialization of XML, remote procedure call and IIS integration are all ready for you to use. You need only to write your applications.
You can export services instead of tables like a relational DBMS does, in this way you can divide the logic of your system from the data layer and the presentation layer.
In this way you can obtain scalability, multiplatform and multisystem support.
Some links to read:
http://en.wikipedia.org/wiki/Windows_Communication_Foundation
http://www.codeproject.com/KB/webservices/myservice.aspx
http://msdn.microsoft.com/en-us/library/aa730857(v=vs.80).aspx
http://msdn.microsoft.com/en-us/library/kwdt6w2k(v=vs.71).aspx
http://blogs.microsoft.co.il/blogs/bursteg/archive/2008/02/10/how-to-build-an-n-tier-application-with-wcf-and-datasets-in-visual-studio-2008.aspx
http://msmvps.com/blogs/williamryan/archive/2008/05/16/doing-tiers-with-wcf.aspx
Instead, if you are in an intranet, for example, or a single computer and you want just to share a DB service, you can just use SQLServer or MySql or PostgreSql and connect to it via TCP/IP.
Is not safe\secure however to expose a DB service on internet or in an intranet where security can be a problem.
Note also that SQLServer Express is free and may be suitable for you if you don't have much users\connections or a DB not greater than 4gb.
MySql and PostgreSql are free and open source.
I have some backend functionality which need to be written in C# (for political, not technical reasons).
The C# 'module' is to provide functionality for a website, which is written in PHP.
The hosting environment for the completed solution will be as follows:
Operating system: Linux
Web server: Apache
Backend db: mySQl and/or PostgreSQL.
The C# 'module' will be business logic only, (i.e. no GUI).
This is my proposed solution so far, I would like to know if I am going down the correct path and/or if my proposed solution may be improved:
I am guessing that I will have to write and deploy the C# module as a stand alone executable
Add a RESTful API to the C# executable or communicate directly to the C# executable using TCP/IP from the web app. I prefer the RESTful API since it is higher level, but there may be performance considerations - I'd like to hear of pros and cons on choosing one over the other - to help me to decide whether to use a RESTful API or TCP/IP to communicate with the web app.
What is the "best" way to bind C++ to C# (I will be making use of C++ libraries in my C# application).
I will have mono installed on the server, to host the C# application.
Since I don't often use C#, I wonder if a "C# expert" can tell me if I am going about this the right way, and/or if this approach can be improved?
Yes. My guess is you would want it to be an executable communicating with WCF or a Web Service hosted with IIS communicating with WCF.
Depending on your requirements, I would investigate the HTTP Long Polling technique.
C# can use PInvoke through DllImport to use any available C++ library calls.
I am looking at writing a WinForms app and getting stumped over what seems to be simple issue.
There is a server and database (SQL Server) Open ports are HTTP, HTTPS
There is a WinForms client. It needs to connect a TCP/IP stream (possibly HTTP, SOAP, REST) to the server.
Sometimes the WinForms client goes off-line and then the WinForms client stores its data in a database.
When the WinForms client goes on-line to server, it synchronizes data to the server, gets all the latest data from the server and updates local database.
How do I do that?
Newbie question
As you've conceded, this question shows you might not know where to begin looking for how to architect this kind of application.
I'd start here: http://msdn.microsoft.com/en-us/library/ms973279.aspx
The offline architecture you've described is a little tougher for a newbie than not supporting this, consider making the application only work online first, then add offline functionality.
Also, if you have a web server you will almost always use HTTP, SOAP and REST are strategies that sit on top of HTTP. I cannot recommend that a new developer look at any server communication using direct TCP/IP.
Edit: Answer to related question - there are tons of ORMs and service builders, not a lot of them have built in support for offline workflow but ODX does, but it might be a bit out of date. NHibernate and any of the projects in the Castle Project are very popular components for what you're looking to do also.
No idea how actively this is still being supported by Microsoft, but you might check out the Smart Client Software Factory, it seems to support offline mode and smart reconnecting like you need.
http://msdn.microsoft.com/en-us/library/ff709809.aspx
You could approach this with a 'Service' mindset - Write a WebService (preferably a WCF service) - that forms the synchronization tier between your Winforms app. and remote database.
So, you would have your
1. Local WinformsApp. with a local database (as functional/lightweight as you want it to be)
2. WebService
3. Remote app./DB
Here are some links to tutorials/resources:
http://www.codeproject.com/KB/architecture/three_tier_architecture.aspx
http://services.community.microsoft.com/feeds/feed/query/tag/n-tier/eq/tag/visual%20basic/eq/and/locale/en-us/eq/and
http://msdn.microsoft.com/en-us/library/bb384570.aspx
http://msdn.microsoft.com/en-us/library/bb384398.aspx
IMHO this isn't usually as simple as it may sound
If you were able to go DB to DB, then SQL replication could be the simplest mechanism for synchronisation.
However, since it sounds like you are using a SOA approach, you might need to look at frameworks which have offline support built in, such as the Ent Lib Composite Application Block and Smart Client Software Factory
You might also look at using Queues (e.g. MSMQ) to accomodate network connectivity problems.
Microsoft Sync Framework (http://code.msdn.microsoft.com/sync) + WCF solution here:
http://code.msdn.microsoft.com/sync/Release/ProjectReleases.aspx?ReleaseId=3762
Database synchronisation is not an easy task to get started with, by any means. Good luck.
Generally, you need a local database, or at least a local cache.
I'm looking for some input on my current project architecture. There are three components: Server, Desktop, and Mobile Device.
I have 2 goals:
1) Send data (Approx. no more than 100 KB of text) from the Desktop (multi platform client application running on windows XP/Vista/7, and Mac OS X) to a server (Windows Server 2008, IIS 7, WCF RESTful service) to save in a database (Sql Server). The services need to be scalable because the number of desktop devices and frequency they send data is unknown.
2) A service to retrieve data from the database (Sql Server) and send to a mobile device(Iphone and Android application. Message size no more than 100 KB of text). Service needs to be scalable because number of mobile devices and frequency they connect is unknown.
My proposed solution:
Server Side (Sql Server and Windows Server 2008):
I'm looking at a WCF RESTful JSON services to communicate with Desktop App(s) and Mobile App(s). I like WCF because I am most proficient in C#, have some experience implementing WCF, after doing some research it appears all technologies used for the platforms(Windows XP/Vista/7 and Mac OS X) can easily communicate with the WCF RESTful service.
Any high level fundamental issues with the WCF service in this scenario?
I have only implemented WCF on a Windows Server 2003 machine with ~800 devices connecting every 15 minutes. The server was a physical in house server running on a private network. I need this solution to be hosted and scalable. Any recommendations for hosting a Windows Server 2008? Is there a better technology to host the service? (I'm not very familiar with how the cloud stuff works)
The services will be saving and retrieving data from a SQL server. I would like to use LINQ to SQL as my data access layer. It's my understanding there are large licensing fees tied to SQL server so I may need to go with SQL Server Express for now.
I'd prefer to keep the WCF services and database hosted separately (2 diff machines). Any recommendations for hosting sql server(or express)? Is there a hosting service that can scale better for my database? Does it make sense to keep these on 2 diff machines?
Desktop (Client Side)
I am required to develop for Windows XP/Vista/7 and Mac OS X. I plan to write a .net application to run on the windows machine(s). I"m still up in the air if i'm going to write (and learn :P) XCode or try mono. Any cross-platform ideas?
Should I expect to have any fundamental problems getting the desktop applications to talk to my WCF RESTful services?
Mobile Applicaitons
I am required to developer for the IPhone and Android. There are many examples of making WCF RESTful service calls using Objective C and the Android SDK. I'm considering trying a cross platform (ie. Appcelerator). From a high level it appears these mobile cross platforms have built a Java script layer that works with both IPhone and Android!
Any thoughts on using the cross platform technology to write ONE mobile app to run on IPhone and Android?
Any fundamental issues calling the WCF RESTful service in javascript?
Sorry for the somewhat long post. I have never designed a solution of this size. All feedback is appreciated.
Thank you!
As you are clearly wanting to use Microsoft technologies - the suggestions about Mono probably make sense to you and will certainly make things easier.
However I think you may find that you compromise elements of the user experience for Mac and iPhone users which is not ideal as these users tend to have the highest expectations for great user experiences.
I understand that we don't live in an ideal world but if we did you would develop a separate client for each platform - optimised to the needs of each platform. Unless you application is doing a lot of data manipulation the data layer is now abstracted to the server viw your JSON interface so you will not gain much from sharing the data objects across implementations.
As it seems you are implementing the project in a small team (yourself?) then I would suggest that you look at implementing a web solution with the HTML javascript communicating with the server over JSON.
The other option is that you use a flex/air client on windows and mac and flash on the android and Adobe's solution to compile flex/air into iPhone code.
Good luck though.
For your client side you may consider using Appclerator because it will run on all of the platforms that you need with little to no extra code, and it is designed to be used for web app type applications
You should consider MonoTouch for the iphone. You'll be able to share much of the desktop code. I would use Mono on the Mac for the same reason. Android is the odd man out. Eventually someone might create something like MonoTouch for Android but not soon enough to help you out.