foxteach 2001 building server services with visual foxpro session v17 rainer becker dfpug, germany
TRANSCRIPT
![Page 1: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/1.jpg)
FoxTeach 2001
Building Server Services with Visual FoxPro
Session V17
Rainer BeckerdFPUG, Germany
![Page 2: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/2.jpg)
FoxTeach 2001
Who Am I?
• German FoxPro User Grouphttp://www.dfpug.de/forum
– German VFP DevCon– FoxX Professional (4x200 pages)
• Wizards & Builders GmbHhttp://www.wizards-builders.com
• MVP, MCSD, speaker/writer– But I am not bilingual !
![Page 3: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/3.jpg)
FoxTeach 2001
Defining the problem
What is the problem we solve with a remote server service ?
![Page 4: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/4.jpg)
FoxTeach 2001
Services on a Server
Multiply performance by direct table access instead of network traffic for (examples):– Database reorg/reindex– Structure modification/update– Data synchronization– Data import (host)/export– Complex queries/reports– Long-running process (e.g. re-booking)
![Page 5: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/5.jpg)
FoxTeach 2001
How to call a Server App
• CREATEOBJECT– only local registration with /REGSERVER
or REGSRV32.EXE
• CREATEOBJECTX– remote registration with CLIREG32.EXE– But still no asynchronous connection...
But: Server Application must run independent from Client App!
![Page 6: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/6.jpg)
FoxTeach 2001
Automatic Start on a Server
• AUTOEXEC.BAT– Only for DOS Command
• AUTOSTART folder– Only for active user
• SCHEDULER– Configuration problem
• SERVICE– Currently the most suitable solution
![Page 7: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/7.jpg)
FoxTeach 2001
Installing a “Service“
How to define a VFP server service on Windows NT ?
![Page 8: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/8.jpg)
FoxTeach 2001
Installation of a “Service“
• Configuration / System Management / Services– Only allows changing of existing services
(e.g. execution type, used account)– “Allow Interactive Relation to Desktop“
• Wizard “SRVINSTW.EXE“ allows interactive installation of a service
• Interface for a service cannot be supplied with VFP -> SRVANY.EXE
![Page 9: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/9.jpg)
FoxTeach 2001
Using the Install Wizard
• P1: [x] Install a service• P2: [x] Local Machine• P3: Service Name „Remote Server“• P4: Executable File „SRVANY.EXE“• P5: [x] Service is its own process• P6: [x] System account
– [x] Allow Service to interact with Desktop
• P7: [x] Automatic• P8: Finish
![Page 10: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/10.jpg)
FoxTeach 2001
Configure SRVANY.EXE
• Call REGEDIT.EXE• Navigate to “HKEY_LOCAL_MACHINE \
SYSTEM\CurrentControlSet\Services\” • Navigate to your “Remote Service“• Right mouse: Option “New“, Sub-option
“Key“, Value “Parameters“ • “New”, “Char”, “Application“, Value “
“<Drive>:<path>\<vgremote>.exe“ • “New”, “Char”, “AppDirectory“, Value
“<Drive>:\<path>“ • Optional “AppParameters“, Value “NONE“
![Page 11: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/11.jpg)
FoxTeach 2001
How to start a Service
• Various Options to start/stop:– Interactive with system configuration– NET START/STOP “service name“– SC START via SC commandline utility of
Windows NT
• Problem: Applet does not see VFP-status but only SRVANY-status (even “ “QUIT“ still allows to start/stop/restart the service) – confusing for admins!
![Page 12: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/12.jpg)
FoxTeach 2001
Unattended Installation
• INSTSRV.EXE parameters– Service name– Exe location– (-a account name)– (-p account password)– REMOVE
![Page 13: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/13.jpg)
FoxTeach 2001
Implementing Remote Server
How to implement a remote server application ?
![Page 14: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/14.jpg)
FoxTeach 2001
Parameter Passing
• No access via object reference
• Parameter table instead– User, Password (encrypted)– Module, Object, Method, Parameter
Or – Script-Memo (Single/Multi-Line)– ErrorRetry
![Page 15: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/15.jpg)
FoxTeach 2001
Setup Methods
• Settings• SetVars / Properties• Set OnShutDown / Shutdown• Set OnError+ErrorHandler /
ErrorMethod• OpenTable• Endless Loop / Timer (snp)
![Page 16: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/16.jpg)
FoxTeach 2001
Problems with Endless Loops
• Normally you get an endless loop by accident with no work at all, but– A typical endless loop produces 100%
workload in the Task Manager– Additionally, it creates a GUI error with
SYS(2335,0) (unattended servermode)
• Solution: Use READ EVENTS with a timer which fires CLEAR EVENTS– (still you get problems with sys(2335,0)...)
![Page 17: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/17.jpg)
FoxTeach 2001
Job Execution Methods
• Scan Job-Table• JobLock• JobProcess
– Macro execution– Script-compiling– COM-Server creation/call (snp)
• Repositioning• JobUnlock
![Page 18: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/18.jpg)
FoxTeach 2001
Call COM Servers
• CREATEOBJECT– Call an .EXE instead of .DLL to survive
execution failure
• LOGIN– encryption for security
• Method-Call– COMRETURNERROR if exclusive access
is needed but not available
• Return Value
![Page 19: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/19.jpg)
FoxTeach 2001
Configuration with Constants
• Name, Title, Caption• Table, Path• Retry on Error• Timer: Break between jobs• Master-User / -Password• Exclusive Access ComReturnError• For Discussion of constants see
session V18 Dynamic Constants
![Page 20: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/20.jpg)
FoxTeach 2001
Logfile / Activity
• Low-Level Text File for Job-Log– Datetime start/end, result/failure
• NT Eventlog not implemented yet– WinAPI-problems occured
• Monitor activity from Client(snp)
• Restart via Starter Application– CreateObjectX for Starter not Server
![Page 21: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/21.jpg)
FoxTeach 2001
Connect the Client
How to connect the client to the remote server application ?
![Page 22: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/22.jpg)
FoxTeach 2001
Client Implementation
• Implementation as a service class– Reusability needed
• Data access to job-table needed– Place in a different class for later change
of table format or parameter passing type
• Read/Write Job-Table– Read status information (see below)– Timer for status information
• „Call once“ or „Call many“ jobs
![Page 23: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/23.jpg)
FoxTeach 2001
Client Methods
• IsServerActive
• ServerStart
• JobCreate
• JobStatusGet
• JobTimerCreate (Thermometer)
![Page 24: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/24.jpg)
FoxTeach 2001
Thermometer Update
• Status information is wanted for long-running remote jobs, but– Server application cannot update
Job-Table as it is locked by the remote server service
• Solution: 1:1-related table for status information OR pass THIS for a callback mechanism– Use a wrapper object reference
![Page 25: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/25.jpg)
FoxTeach 2001
The “exclusive client“ Problem
• Some useful server jobs need exclusive database access(e.g. reorg, reindex, pack, backup)
• Client application can insert a job into job-table, but that‘s it– Server application will terminate again and
again as long as user is logged into app
• Depends on your implementation of semaphores and locking
![Page 26: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/26.jpg)
FoxTeach 2001
Special Tricks
How can we extend the potential power of remote server services ?
![Page 27: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/27.jpg)
FoxTeach 2001
Multiple Server Services
• Even on a single processor server, more than one instance might be useful to shorten processing time– See example in VFPSP3.CHM– Just place a RUN-Task in job-table...
• Memory consumption problems might be reduced by Multi-Threaded VFP-Runtime (see SP3)
![Page 28: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/28.jpg)
FoxTeach 2001
MQ / MSTS
• Parameter table can be replaced by Message Queue Server– No current experience
• Instantiation time might be reduced by use of MS Transaction Server– No current experience
![Page 29: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/29.jpg)
FoxTeach 2001
Service as “WebService“
• Remote Server Service built as COM Server convertable to Web service– with Toolkit in Visual Studio 6.0 or VFP 7.0
• Build a table-interface-Webservice– Send Job-Table entry as XML-record– Implement Client functions for COM-server
• See Session V19 “Creating and Using SOAP Web Services with Visual FoxPro“ by Rick Strahl
![Page 30: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/30.jpg)
FoxTeach 2001
Additional Material
Where to go from here ? Where to find additional information ?
![Page 31: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/31.jpg)
FoxTeach 2001
Visit other Sessions
• V14 “Building World-Class Visual FoxPro COM Servers“– Kevin McNeish
• V19 “Creating and Using SOAP Web Services with Visual FoxPro“– Rick Strahl
![Page 32: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/32.jpg)
FoxTeach 2001
Tools/Docs on Companion CD
• SRVINSTW.EXE (install wizard)
• INSTSRV.EXE (install tool)
• SRVANY.EXE (service interface)
• SRVANY.WRI (documentation)
• W2RKTOOL.CHM (NT Resource Kit)
![Page 33: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/33.jpg)
FoxTeach 2001
FoxTeach Web Update Page
www.dbcentral.com
This session will NOT have web updates.
![Page 34: FoxTeach 2001 Building Server Services with Visual FoxPro Session V17 Rainer Becker dFPUG, Germany](https://reader035.vdocument.in/reader035/viewer/2022070306/5518cbcc55034638098b4e05/html5/thumbnails/34.jpg)
FoxTeach 2001
Thank you!
Please remember to fill out your evaluation.