Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# or VB.NET ??
Message
From
12/04/2007 16:22:25
 
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Title:
Miscellaneous
Thread ID:
01215050
Message ID:
01215225
Views:
19
Thank you very much for sharing it. I wouldn't dare pick it apart! (Actually, I really wouldn't)


>"Thanks for sharing your view on it Woodie. I agree with you, but I have read a lot of posts on the web during the last year advocating the opposite (which I don't agree with). I'm assuming all your wrappers belong to your employer? In other words, not anything you can share or sell?"
>
>Unfortunately I am my employer, lol. Talk a about a "putz" for a boss! I am in a relationship (bordering on abusive! i kid) with Methods Workshop but I have complete control over the software. My intellectual property is mine. I have written a lot of wrappers and custom classes in our framework. I have never really thought of them being terribly useful for anyone else. Well, some of them are pretty nifty. My SQL classes are done wellk I think and I also came up with a tool for internationalizing my Apps that I liked better than Steven Black's INTL system. It is a bit easier to employ and works with SQL Server. It also makes the language changes Global for all user of the the system rather than to the local machine only.
>
>I don't mind sharing my solutions or code that doesn't contain proprietary business logic (which 90% of my classes and wrappers do not) but I have always been hesitant. Mainly because there are so many incredible coders around here and I'd hate to get picked apart, lol.
>
>
>Here is an example of a Wrapper (a work in progress) for the My.Settings.Add() Method. I really dig the my class and the ease of using a xml.config file
>
>The wrapper is a method of my AppManager "master" class for my applications. Since getting into C# I have made all my wrappers in VFP Class methods rather than functions to try and maintain similar paradigms between the two languages. As a result very little procedural fox code is left in my apps.
>
>*****************************************************************************************
>*  AddSetting() : Add a Configuration Setting							*  Wrapper for the My.Settings.Add() Method
>*****************************************************************************************
>PROCEDURE AddSetting
>	LPARAMETERS SettingType, SettingName, SettingValue
>	**  SettingType denotes local or global
>	LOCAL My as My
>	My = this.oConfig
>				
>	** Return False and exit the method is any parameter is null
>	DO CASE
>		CASE EMPTY(SettingType) = .t.
>		 	RETURN .f.
>		CASE EMPTY(SettingName) = .t.
>		 	RETURN .f.
>		 CASE EMPTY(SettingValue) = .t.
>		 	RETURN .f.
>	ENDCASE
>		
>	**  Execute for local Settings
>	IF ALLTRIM(UPPER(SettingType)) == "LOCAL"
>		LOCAL AddedSetting
>		AddedSetting = My.Settings.Add((SettingName), (SettingValue))
>		my.Settings.Save(this.ConfigFile)
>		RETURN AddedSetting
>	ELSE
>		**  Execute for Global Settings (Settings table of the back end Database)
>		
>	ENDIF
>ENDPROC
>
>
>Some simple Sql type wrappers:
>
>	*****************************************************************************************
>*  DbConnect() :  Connects to the remote database						*
>*****************************************************************************************
>PROCEDURE DbConnect
>	this.DbConnectionHandle = SQLSTRINGCONNECT(this.oConfig.Settings.ConnectionString1)
>		
>	** Check for for success (> -1)
>	IF this.DbConnectionHandle < 0
>		RETURN .f.
>	ELSE
>		RETURN .t.
>	ENDIF
>ENDPROC
>	
>	
>		
>	*****************************************************************************************
>* DbDisconnect() : Disconnects from the remote database						*
>*****************************************************************************************
>PROCEDURE DbDisconnect
>	LOCAL DbDiscon
>		
>	DbDiscon = SQLDISCONNECT(This.DbConnectionHandle)
>		
>		
>	**  Check for Disconnection Errors
>	DO CASE
>		CASE DbDiscon = 1  	&&  Success
>			this.DbConnectionHandle = -1
>                        && set the oApp.DbConnectionHandle property to -1 indicating no active connection
>			RETURN .t.
>				
>		CASE DbDiscon = -1 	&& 	Connection Level Error
>			**  Add Code to handle a failed Disconnect!!!
>			**  !!!
>			**  !!!
>			RETURN .f.
>				
>		CASE DbDiscon = -2	&&  Environmental Level Error
>			**  Add Code to handle a failed Disconnect!!!
>			**  !!!
>			**  !!!
>			RETURN .f.
>		ENDCASE
>ENDPROC
>
>
>	*****************************************************************************************
>*  DbExec() : Executes a SQL Command against the remote Database.				*							
>*****************************************************************************************
>PROCEDURE DbExec
>	LPARAMETERS DbCommand, CursorName
>		
>	**  Return False (error) for a missing parameter
>	IF EMPTY(DbCommand) = .t.
>		
>		**  Paramteter failure message  **
>		IF _Vfp.StartMode = 0 &&  dev environment
>			WAIT WINDOW "Sql Parameter Failure"
>		ELSE
>			**!!!!  Run time Error
>		ENDIF
>			
>		RETURN .f.
>	ENDIF
>		
>	IF EMPTY(CursorName)
>		CursorName = "SqlResult"
>	ENDIF
>	
>	** Execute the command against the remote database
>	LOCAL DbExecValue, ReturnValue
>	IF this.DbConnect() = .t.
>		DbExecValue =  SQLEXEC(this.DbConnectionHandle, DbCommand, Cursorname)
>	ELSE
>		**  Sql Connection Error  **
>		IF _Vfp.StartMode = 0 &&  dev environment
>			WAIT WINDOW "Connection Level Error"
>		ELSE
>			**  Run time Error
>		ENDIF
>			
>		RETURN .f.  && failed database connection
>	ENDIF
>		
>	IF DbExecValue = -1
>		ReturnValue = .f.
>	ELSE
>		ReturnValue = .t.
>	ENDIF
>		
>	This.DbDisconnect()
>		
>	RETURN ReturnValue			
>ENDPROC
>	
>
>
>No making fun of me.
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform