BAT File
BAT File
Summary== If you are anything like me then you change your Schema's alot while your developing it, and maybe work on different projects at the same time. Wouldn't it be nice to have a batch file which will build your DAL files for you and keep all your build options in one place? To use just change the setting to where-ever you have installed subsonic, and specify the path where you want the generated files to be output to. It's pretty simple so you should be able to modify this to suit your needs. Just copy all this into a new .bat file and then run the file from the command prompt. To run an option just start the file like this "c:\yourfile.bat TEST1", if you omit the parameter then the help text defined under :MissingParam will be displayed instead.:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::Start this batch file, Set which directories & programs we will be using. ::Delete any previously generated files before we begin. ::BuildPath is where the generated files will be created. @ECHO OFF CLS SET BuildPath=c:\Batch\DAL SET Sonic=c:\progra~1\SubSonic\SubSon~1.1\sonic.exe SET Generate=generate /override /spStartsWith SP_ /viewStartsWith View /out %BuildPath% /lang vb SET ODS=generateODS /override /out %BuildPath% /lang vb SET VIEWS=generateviews /override /out %BuildPath% /lang vb /viewStartsWith View IF EXIST %BuildPath% RD %BuildPath% /S /Q IF EXIST %BuildPath% GOTO FailedDelete MD %BuildPath% GOTO BuildProviderOptions :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::See if the user specified a valid option from the command line, if so ::Setup the connection string for the database, if not display warning message. :BuildProviderOptions IF [%1]==[TEST1] GOTO BuildTest1 IF [%1]
[TEST2] GOTO BuildTest2 GOTO MissingParam :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :BuildTest1 SET DATABASE=/server localhost /db test1 /userid Joe /password Bloggs /generatedNamespace Test1 GOTO GenerateDatabase :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :BuildTest2 SET DATABASE=/server localhost /db test2 /userid Joe /password Blogs /generatedNamespace Test2 GOTO GenerateDatabase :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::Start generating your DAL files :GenerateDatabase CLS ECHO Generate using connection string : %DATABASE% ECHO. %Sonic% %Generate% %DATABASE% %Sonic% %ODS% %DATABASE% %Sonic% %VIEWS% %DATABASE% GOTO End :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::Display help menu when a user doesn't enter a valid option :MissingParam ECHO SubSonic Builder ECHO -------------------------------------------------- ECHO. ECHO Usage: ECHO. ECHO SubSonicBuilder {BuildProvider} ECHO. ECHO Valid BuildProvider Selections: ECHO. ECHO TEST1 ECHO TEST2 GOTO End :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :FailedDelete CLS ECHO SubSonic Builder ECHO -------------------------------------------------- ECHO Error: ECHO. ECHO The BuildPath directory could not be deleted, one or more files may be open in another application. GOTO End :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::End of the batch file :End ECHO. ECHO Sub Sonic Builder... Done. ECHO.