This is a showcase review for our sponsors at The Code Project. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers.
Introduction
In this article I am going to show you how to generate your favorite routines in every application you create with Iron Speed Designer. This technique applies to all Version 4.X releases, and you may want to repeat these instructions across all of your versions, if like me you have projects in several different versions.
Iron Speed Designer Version 5.0 now Released
PDF report generation and Excel exporting features enhance database applications.
Download Free Trial
Getting Started
Open My Computer and traverse to:
C:\Program Files\Iron Speed\Designer v4.2.1\ProjectTemplates\vs2005\vb
I use Visual Studio 2005 and Visual Basic .NET for most of my applications, so that is where I am headed. You can navigate to your favorite combination of .NET and language as it suits you.
Next, click on the App_Code folder.
Any extra classes that you want to have automatically included in all of your new applications need to be placed here. If any of these routines reference specific tables or views common across applications you will have to remember to include those in your database or your application will not compile.
I have a Support.vb file that contains a number of common routines that I use regularly in most of my applications.
One of the first things that I did with every application (before now) was to open Web.config and make some adjustments local to my environment. This includes changing the email server reference. As you can see from the picture below, the default is localhost. However, my mail server is located on another server, so I have to change the email server setting to point toward my server. You will see below where I highlighted the setting to change your email server.
Reminder
I am opening the default Web.config file in my Iron Speed installation directory and NOT the Web.config with my application. You can use either Visual Studio or Notepad to open this file. If you are not sure how to do this, click on the file and right-click. You should see an option that says "Open" or "Open With." Select the choice that works for you.
I also change the default EmailFrom setting as well, so that this is tailored to my environment.
Another consistency in my environment is debugging. I always seem to be writing custom routines or Code Customizations that require that extra testing effort. Visual Studio has a wonderful debugging environment and I couldn't do my job nearly as well without it.
There is a setting in our Web.config that has to be turned on for Visual Studio to allow us to step through each line of code. Looking at the picture below, you can see that the default is "false" or off.
Look for the line <compilation debug="false">
Now change the value "false" to be "true". Although Visual Studio 2005 will ask us to turn this on when we first request debugging in our new applications, this is just another way to reduce the number of prompts (like traffic lights) that we face every day.
Save Web.config and close the file.
OK, that was fairly straightforward. Let's take it up a notch. Suppose I want to have custom code included with every record control that is created by Iron Speed Designer. An ideal example is the record auditing code inserted when running the Code Customization Wizard example called 'Set Audit fields on Update.' Instead inserting the code using the Code Customization Wizard every time, let's find out how to have Iron Speed Designer do it for us.
In order to accomplish this task, we first execute that code customization for any table in an application.
Open up windows Explorer and navigate to either:
C:\Program Files\Iron Speed\Designer v4.2.2\Designer\CodeGenerator\Templates\vs2005\DataAccess\PhysicalRecord.safe.vb.txt
Or
C:\Program Files\Iron Speed\Designer v4.2.2\Designer\CodeGenerator\Templates\vs2005\DataAccess\PhysicalRecord.safe.cs.txt
Depending on whether you are using Visual Basic .NET or C#.
Open this file in Visual Studio or Notepad and insert the code from the Code Customization Wizard's Audit example.
The purpose of putting code here is so that it is included when Iron Speed Designer generates the safe class in the business layer for the table we are adding to our application. This saves us the trouble of rerunning the Code Customization Wizard for every table. A real time-saver for sure!
Note: I am making a presumption that the fields 'CreatedOn' and 'CreatedBy' are present in every table! If these fields are not present in a table you will get a compile error when you bring it into your Iron Speed Designer application.
If this happens, you can either add the fields to your database or comment out the offending lines. You could also comment out the lines in the template file and then uncomment them as required.
Important Note: When you upgrade to another version of Iron Speed Designer you will have to reapply these changes to the new version. Also, when you uninstall a version of Iron Speed, those changes will be lost, so remember to back up!
Conclusion
What I have shown you in this article is just the tip of the iceberg for extending and configuring Iron Speed Designer for your environment. With a little imagination we have added general functionality to all of our applications. Download the Free Trial.