Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Global App Object
Message
De
21/12/2015 15:07:07
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Global App Object
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Web
Divers
Thread ID:
01629191
Message ID:
01629191
Vues:
96
I'm wanting to get some ideas of properties, methods, features, etc. that would go into making a generic, reusable Application Object. One that would be a good basic App Object that could be used universally in creating common business apps in FoxPro. Ideally, this global App object would have basic properties, and methods that we'd all likely find useful if we were using it in one of our apps.

I assume almost everyone has such an object in their apps, or at least a bunch of hodge-podge functions that simulate such a thing.

So, please share you comments and ideas with me...

For instance, here is what I've started out with as I began to abstract my specific goApp class to a generic one:
Define Class AppObjectBase As Custom

	lExe = .f.
	lDevMode = .f.
	cAppName = ""
	cCurrentModule = ""
	cActiveForm = ""
	cCurrentVersion = ""
	cTempFilesPath = "C:\Temp\"
	
	oConfig = .null.
	oUser   = .null.
	oSql = .null.
	oTracker = .null.
	oBO = .null.

	*---------------------------------------------------------------------------------------
	Procedure Init

		*-- In your override of this method, you'd wire up all the objects and properties
		*-- that are hosted in this class. 
		
		*-- Example setup work displayed below. Every app is different, so do whatever you need to 
		*-- get this global goApp ready for use by your application
		*---------------------------------------------------------------------------------------
		
		* This.oConfig = NewObject("LmConfig", "LmConfig.prg")
		* This.oValues = NewObject("Values", "Values.prg")
		
		* lcRunningFilename = JustFname(_vfp.ServerName)
		* This.cCurrentVersion = lcRunningFilename
		
		* If This.lDevMode and This.lUseTestData
		*	This.oConfig.Connstring = Strtran(This.oConfig.Connstring, "LMDB", "LMDB_TEST",1,99,1)
		* Endif
		
	EndProc
	
	*---------------------------------------------------------------------------------------
	Procedure LogError(tcErrorMessage)
	
		*-- Again, in your override, handle any calls to LogError() however you neede to.
		*-- If you assign This.oBO in the Init() method, then you can use the wwBusinessPro.LogError() method
		*-- as shown below. If not, then override and do whatever magic you need or want to do to handle these calls.
		
		This.oBO.LogError(tcErrorMessage)
	
	Endproc

	*---------------------------------------------------------------------------------------
	Procedure lExe_Access
		
		Local lcApp, llExe

		lcApp = Sys(16,1)
		llExe = '.EXE' $ Upper(lcApp)
		
		Return llExe
	
	Endproc
	
	*---------------------------------------------------------------------------------------
	Procedure lDevMode_Access
	
		Return !This.lExe		
	
	Endproc


	*---------------------------------------------------------------------------------------
	*- This handy method gives you a simple and common way to setup Classlibs and Procedure files
	*-- into your app setup calls.
	Procedure Require(tcAsset)
	
		DO CASE
			CASE ".vcx" $ Lower(tcAsset)	
				Set Classlib To (tcAsset) Additive
				
			Case ".fll" $ Lower(tcAsset)
				Set Library To (tcAsset) Additive
			*-- Assumes .prg or no extension
			Otherwise 
				Set Procedure To (tcAsset) Additive
		ENDCASE

	EndProc
		
	
EndDefine
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform