Solved

Copy table as needed over the internet

Posted on 2011-09-15
6
450 Views
Last Modified: 2012-05-12
Hi experts,

I have an application that some users are running on the field. The application is a quote application. What I would like to acomplish is that when the application starts, it could check a table over the internet and if this table is newer that the one in the laptop it will replace it. The table is small table, it can even compressed and have it as a zip file.

Thanks,

0
Comment
Question by:falvarad
  • 3
  • 3
6 Comments
 
LVL 4

Expert Comment

by:wcsoctu
ID: 36545424
* in my opening prg (http://www.west-wind.com/wwipstuff.zip)
SET PROCEDURE TO wwUtils.prg
SET CLASSLIB TO wwIPStuff


* my internet function
FUNCTION Internet
DECLARE SHORT InternetGetConnectedState IN wininet.Dll;
   INTEGER @lpdwFlags, INTEGER dwReserved
LOCAL lConnected
lConnected = .F.
lpdwFlags = 0
IF InternetGetConnectedState (@lpdwFlags, 0) = 1
   MyFTP=CREATE('wwFTP')
   ConnectResult=MyFTP.FTPConnect('myftpsite',"myftpuser","myftppassword")
   FTPFound=(ConnectResult=0)
   lConnected = .T.
ENDIF
RETURN lConnected


* my code to check for update

IF Internet()
   * get remote file details, if not there no need to go further
   RemoteFileFound=.F.
   DIMENSION RemoteArray(1,4)
   ADIRResult=MyFTP.aFTPDIR(@RemoteArray,"ftpfolder/ftpfile.dbf")
   IF ADIRResult>0
      RemoteFileFound=.T.
      RemoteFileSize=RemoteArray(1,2)
      RemoteFileDate=TTOD(RemoteArray(1,4))
   ENDIF

   IF RemoteFileFound
      UpdateTheFile=.F.
      CompareCount=ADIR(LocalArray,'c:\localfolder\localfile.dbf')
      IF CompareCount=1
         LocalFileSize=LocalArray(1,2)
         LocalFileDate=LocalArray(1,3)
         IF RemoteFileSize<>LocalFileSize OR RemoteFileDate>LocalFileDate
            UpdateTheFile=.T.
         ENDIF
   ELSE
      UpdateTheFile=.T.
   ENDIF
   IF UpdateTheFile
      MyFTP.FTPGetFileEx("ftpfolder/ftpfile.dbf","c:\localfolder\localfile.dbf")
   ENDIF
ENDIF
0
 

Author Comment

by:falvarad
ID: 36545548
It looks good but the zip file is not there.

Thanks
0
 
LVL 4

Expert Comment

by:wcsoctu
ID: 36545566
localfile.dbf was just an example.  Use any folder/filenames you want.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:falvarad
ID: 36545659
I'm sorry I'm talking about the zip file that contain wwUtIPStuff and wwUtils.prg
SET PROCEDURE TO wwUtils.prg
SET CLASSLIB TO wwIPStuff
0
 
LVL 4

Accepted Solution

by:
wcsoctu earned 500 total points
ID: 36545683
0
 

Author Closing Comment

by:falvarad
ID: 36545707
Thank you, i will test this but it seems exactly what I need.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now