Friday, December 22, 2006

N-Tier and Globalization Issues

Initially, I was facing a minor globalization issue. A glitch, I thought, and nothing more. Someone from Turkey (or somebody with a tr-TR culture installed in his or her machine or set in his or her web browser’s language setting) must have tried to visit www.covalentia.net but to no avail. The person was probably feeling frustrated and forwarded me the errors (you don’t actually have to do that because all errors are automatically logged and sent to me at errorlog@covalentia.net). After a careful inspection, I found out that it’s not really a minor issue, but a major one. I had everything wrong. The culture configuration in the web.config file is not supposed to be set to auto:en-US. This will cause everything – I mean everything – from the database connection string to date and time to follow the CultureInfo.CurrentCulture information. If your database, MySQL database for example, is an English version (mine is), it will give the following error (note the date is Turkish as well as the word "uid"):

The following error/exception has occured in the Covalentia.Net Portal - FREE C#.Net Code Generator on 16 Aralık 2006 Cumartesi 23:33:32. Please response immediately. Thank you.
GUID: 11c2ae5b-8c14-4bb3-80e5-ee837f263e27
Type: Unhandled Exception
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Keyword not supported.
Parameter name: uıd
Source: MySql.Data
Stack Trace: at MySql.Data.MySqlClient.MySqlConnectionString.ConnectionParameterParsed(Hashtable hash, String key, String value)
at MySql.Data.Common.DBConnectionString.Parse(String newConnectString)
at MySql.Data.MySqlClient.MySqlConnection.set_ConnectionString(String value)
at MySql.Data.MySqlClient.MySqlConnection..ctor(String connectionString)
at Covalentia.Core.Data.SqlDataProvider.ExecuteReader(String connectionString, Int32 databaseTypeId, String query)
at Covalentia.Core.Data.SqlDataProvider.ExecuteReader(String connectionString, Int32 databaseTypeId, String tableName, String queryExpression, Boolean executeScalar)
at Covalentia.Core.Objects.GetObject(String connectionString, Int32 databaseTypeId, Type type, String queryExpression)
at Covalentia.Core.Objects.GetObject(Type type, String queryExpression)
at Covalentia.CRUD.Read(Type type, String queryExpression)
at Covalentia.Controls.Portal.Default.InitializeSkin(Control skin)
at Covalentia.Controls.SkinControl.CreateChildControls()
at System.Web.UI.Control.EnsureChildControls()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
IP Address: 85.105.17.21
Raw Url: /Default.aspx
Date: 16 Aralık 2006 Cumartesi 23:33:32

And so, I have to fix a lot of things. I can’t use the CultureInfo.CurrentCulture to display data according to the user’s culture installed (or web browser’s language setting). Instead, I have to use the following:

CultureInfo ci = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]);

For the rest, I have to use the third type of culture that is culture-insensitive – CultureInfo.InvariantCulture. So, my bad. My deepest apology goes to the Turkish person or whoever he or she might be. I had replaced the auto:en-US value with just en-US. Feel free to browse the portal. We're the FOC bunch. Covalentia is for charity ;)

That’s not all.

After the recent launch of Windows Foundation, I realized that I couldn’t create a Windows Application (WPF) using Covalentia. Covalentia is very much focusing on generating web applications on the fly – and my plan is to make Covalentia a robust platform or code generator that can support other types of applications as well, not just web application.

My mistake is just like any other programmers’ mistakes. We tend to follow examples on the net every now and then, and those examples do not necessarily follow the supposedly correct rules of programming N-Tier or enterprise level applications. And so, I have Windows.Web.UI and Windows.Web.UI.WebControls in the Business Object or Logic Layer. Oooops :|

As a result, the new release of RC 2 mentioned earlier will not happen so soon. I’m working 24/7 to restructure both the presentation and business layers. Perhaps, next year? In the meantime, enjoy your holidays ;)

Tuesday, December 19, 2006

Microsoft AJAX RC

It took me 3 to 4 hours to migrate the old Atlas codes to AJAX RC. There were some issues with the Menu and Tabs, but I managed to fix them. The CollapsiblePanel doesn’t seem to work properly with FireFox if the direction property is set to horizontal. I’ve posted this problem at the CodePlex’s issue tracker. A few other important things to note:
  • AjaxToolkit extender and its target control must be located under the same update panel
  • JavaScript: Type.registerSealedClass is no longer supported and has been changed to Type.registerClass
  • JavaScript: Sys.TypeDescriptor.addType is no longer needed
  • Timer.tick has been changed to Timer.Tick
  • JavaScript: $(‘’) has been changed to $get(‘’)
  • Web Service: The following attribute must be added to any web service class so that it can be called by AJAX:
    [System.Web.Script.Services.ScriptService()]
  • For the rest, follow this guide
I hope I’ve not missed anything. I should have jotted down everything.

After migrating the codes, I did some changes to the Sub-Tabs to make use of the AJAX DropDownList. I will upload a new Release Candidate soon (RC 2). It will include supports for the PostgreSQL database as well. So stay tuned ;)

Friday, December 1, 2006

Covalentia Version 2.1 Release Candidate 1

As promised, I’ve uploaded a new release candidate, Covalentia Version 2.1 RC 1 to both Covalentia Community Portal and CodePlex site. This release includes:
  • Covalentia.Core project source codes
  • Removal of un-used methods and classes in both Covalentia and Covalentia.Core projects
  • Upgrading Table and TableColumn Attributes and Attribute Handler classes, and Table Schema generation especially for foreign key support, maximum data length, default value and supports for all possible data type
  • New database support for PostgreSQL 8.1 and Oracle 10g (Partial)
  • Optimizing and bug-fixing Query Generator class
  • Microsoft SQL/MySQL database structure optimizations which include the following:
    • Making data as small as possible for example using smallint and mediumint integer types
    • Declaring columns to be not null
    • Declaring Foreign Keys, Constraints and Indexes
      It is important to note here that since the InnoDB in MySQL database rejects any INSERT or UPDATE operation that attempts to create a foreign key value in a child table without a matching candidate key value in the parent table, only non-zero (or not null) columns may be declared as Foreign Keys.
  • Renaming classes and methods to follow Microsoft’s Naming Covention
  • Placing C# codes in separate files (for Web Form & Web User Control files) to increase readability
  • Using UpdateProgress (Microsoft AJAX) to avoid pages from freezing upon post-back, especially during switching Tabs and Sub-Tabs back and forth
  • Applying styles, themes and skins – small changes in the GUI
  • Upgrading Tabs and Sub-Tabs for better performance and look
  • Better documentations for codes, tooltips and help (partial – this is a lot of work)
  • Discontinuation of Covalentia Template files (Covalentia.vsi) – with the release of Covalentia.Core project, it’s easier to copy and paste the whole solution folder when creating a new application
If you encounter any problems, don’t hesitate to e-mail me.
Enjoy ;)