Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connecting Foxpro to smartphones 1

Status
Not open for further replies.

clipper01

Programmer
Jul 20, 2007
152
IE
Came across a reference recently to Eric Selje session to last years SW Fox, where he showed how to connect Foxpro data to mobiles , using jQuery Mobile to turn it into a modern mobile interface. He used WestWind Connection ( like all on this site, am hugely in awe of what Rick Strahl built with WC )
Decided to take this idea and build something similar using 100% dotNet , specifically ASP.NET MVC4, and would be happy to share information on techniques etc.

The link to this demo is , some of the pages are 'under construction' , the Customers tab is the most complete.

Connect to this with your regular PC browser and you will just see a very plain site , BUT connect with your smartphone ( iPhone , Android , Windows Phone etc ) and the magic of jQuery kicks in , you will see a modern graphical UI , that responds to all the normal smartphone gestures

The platform is
1) standard folder of fox tables ( no dbc ) on local home network, is actually a test data-base of an accounts system
2) web App that links using ASP.Net and jQuery to these tables, site just runs on standard Vista Home Premium PC
3) free service to provide static IP address , the web link then just connects to the standard PC above
4) configure the wireless router and PC firewall to permit HTTP traffic

So in effect we end up with a 'free' way to connect any kind of legacy fox applications to the latest smartphone/tablet devices. Seems to me that from all the " dotNet conversion " threads over the last 12 months here , the general consensus is to just drive existing apps into the ground ( or virtual XP box ) for the next 10 years.

So what will this provide to clients .....

It gives a great way to say to clients that these existing apps ( yes even the oldest FoxBase 2 ) can be modernised/enhanced to provide critical business data to the mobile world, no need to convert to dotNet. And completely kills the anti_Foxpro arguements , this is 100% dotNet that any college undergrad could do before breakfast :)

Let me know if strikes any chords of interest
 
It strikes a chord with me. A big ol' G Maj 7th, in fact. My prob will be learning dotNet abd jQuery. I started using FoxBase+ back in the late 80's but have not educated myself as to dotNet/ASP as I have been able to use VFp or Lotus Notes to satisfy my clients. Time to learn something new!

Giving clients access to VFP data on their smartphones would be a homerun, in my opinion. How would you suggest I proceed to learn what you've done?

Thansk!

Trey
 
In general terms you
a) need to get up to speed on dotNet in general
b) then up to speed on some specific parts of it

Dotnet is VAST , you have to pick the bits you need to use and get familiar with them , so for some specifics , I'd suggest
1) get yourself a copy of Visual Studio Professional , on ebay , education license , prob around 50 US
2) decide on the language , 80% of VFPers use C# ( see LinkedIn survey) , go for this and browse your local book-shop for a good intro
3) google for some tutorials on ADO.NET , this will be your first BIG SHOCK when you see how different data access is from Foxpro
4) google for a few intro "Hello World" apps and then google for a few Northwind apps. Get to the point where you can do a few simple data forms
5) the above will steer you towards ado datasets , which are fine for point&click pages but not much good else. You will need to learn 2 other data access methods . Entity Framework or plain ol' SQL datareaders. For Foxpro tables , the second is your only real option
6) now redo your earlier apps using datareaders
7)at this point start googles on ASP.NET and MVC again , do a few " Hello World " apps
8)you are ready then to start connecting your legacy foxpro data to the mobile/tablet world
give yourself 12 months minimum to get there

As an aside , I had a very interesting discussion with a client to-day and here is a scenario that has MEGA possibilities. Many business situations are very well suited to tablet apps , e.g. Warehouse , Production , external yards etc , where traditional PC , laptops cannot go. Above approach allows you to build webApps that u can then run on your iPad , Samsung etc and talk directly to your legacy Foxpro data tables do very extensive data enquiry apps , and more limited data-entry.

Good luck with this , like it or not , you cannot stop the tablet revolution !

 
Thanks, clipper01. I shall attempt to follow your curriculum. Anything to keep proving that you can't (or shouldn't) kill the Fox.

trey
 
just to clarify, visual studio 2010 is fine , u dont need 2012
 
I would think so, especially as you get to ASP.NET and MVC4 you need a fairly recent version
 
couple of other things ;
1) jQuery is a javascript library that mainly looks after the UI rendering on your web pages, it just works away in the background, you will not need to do any 'learning' there
2) at initial stages while learning dotNet , just use WinForms , not WPF . Way easier to work with and a very similar experience to designing FoxPro forms
 
Of course, you can do this the same way with ActiveVFP (using pure native VFP code and without spending a dime):
(use chrome or firefox for the demo)

All of the server side SQL and any app logic is in pure VFP:

Any of this stuff you can do with .NET you can do with VFP. Using the same principle with VFP as a backend web service, you could write native Windows 8 apps as well!!
 
claude ,
thanks for reply, I've used WestWind in the past and also seen the various threads on ActiveVfp, seems they are the main pure VFP options, both excellent, but it is actually very surprising how succint the code in ASP MVC turns out to be, see the snippets below, using Razor syntax, which corresponds to the same sample code you showed

whatever route to go , we are on the same wavelength , it gives a great new lease of life to the Fox. I could also think of lots of ways where linking legacy Fox data to tablet devices would be very useful, especially in 'intranet' type situations e.g. stock rooms, factory floor etc

with regards , sean m

********** snippets **********
for example , this is all you need to do to read from a VFP table , customer

1) this is the CONTROLLER in the MVC Model View Controller , it then calls the MODEL

public ActionResult CustomerDetails(Models.CustomerKey cust)
{
Models.CustomerDet dets = new Models.CustomerDets(cust.accountno.ToString()).Single;
ViewBag.Message = "CustomerDetails";
return View(dets);

2)this is the MODEL part of MVC, Model View Controller)

public CustomerDets(string custId)
{
string qry = @"sele accountno,title,person,phoneno,address0,address1,address2,address3 from customer where accountno='" + custId + "'";
DataTable dt = Models.Procs.SqlGetTable(qry);

and then the output is passed to render the HTML ( this is the VIEW part )

@model Sybiz.Models.CustomerDet
@{
ViewBag.Title = "Customer Details";
}
<div data-role="content">
<div >

@Model.title, @Model.address0, @Model.address1, @Model.address2, @Model.address3
<br />
@Model.person,@Model.phoneno

</div>
 
Thanks Sean,

I literally replaced the PHP code from this site: with VFP code (which is easier than either PHP or C# and performs much better than PHP btw).
The following is ALL the VFP code you need to do for the jQuery client (I'm not hiding anything):

<% *getemployees.avfp
oJSON=NEWOBJECT('json','json.prg') && Craig Boyd's JSON class

select e.emp_id as id, e.first_Name as firstName, e.last_Name as lastName, e.title as title, [images/Emps/]+e.picture as picture,count(r.emp_id) as reportCount ;
from employee e left join employee r on VAL(r.reports_to) = VAL(e.emp_id) ;
INTO Cursor SearchResults;
group by e.last_Name,e.emp_id, e.first_Name,e.title, e.picture ;
order by e.last_Name,e.first_Name

oJSON.keyforcursors="items"

* send JSON data and properties back
oResponse.ContentType = "application/json;charset=utf-8"
oResponse.Write(oJSON.stringify('SearchResults'))
oResponse.Flush
lcHTMLout=[]
%>
 
claude , agree ActiveVfp is a superb accomplishment on your part mainly

But both options I think are a huge reason why existing VFP apps ( going right back to legacy FoxBase ) can continue to operate for many years to come, if you can just with very minimal code deploy the critical business data via the latest mobile/tablet platforms. The ASP MVC route will appeal to businesses who have internal C# expertise, and need to re-vamp their old legacy Fox apps , so it does play a very valuable role in keeping the Fox alive
sean m
 
True. Another route I've suggested to more than a few with significant Fox code, and are looking to branch out to web and mobile, is to use HTML5, jQuery/jQuery Mobile, CSS for the client and just write a VFP Controller for the Server Side (AVFP now supports an MVC or an RESTful API model just like ASP.NET MVC thanks to Victor Espina). Then, if there is a need for rewrite to C# later, it's a simple controller or business object rewrite while the client code remains the same. And if there is no need to rewrite, you've saved yourself some time and effort and the client is none the wiser but still enjoys a state of the art application!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top