How to add DotNetNuke localization for a country.

I’ve created an SQL to add australian regions and australian currency to DNN Lists table. The task is discussed on DNN Forum.


— =============================================
— Create procedure basic template
— =============================================
— creating the store procedure
IF EXISTS (SELECT name
    FROM   sysobjects
    WHERE  name = N'{databaseOwner}{objectQualifier}Localization_AddAustralia’
    AND    type = ‘P’)
    DROP PROCEDURE {databaseOwner}{objectQualifier}Localization_AddAustralia
GO


CREATE PROCEDURE {databaseOwner}{objectQualifier}Localization_AddAustralia
AS
declare @CountryId integer
SELECT @CountryId=[EntryID] FROM {databaseOwner}[{objectQualifier}Lists]
where  [Text]=’Australia’
INSERT INTO {databaseOwner}[{objectQualifier}Lists]( [ListName], [Value], [Text], [ParentID], [Level]) –, [SortOrder], [DefinitionID], [Description])
 VALUES(‘Region’,’ACT’,’Australian Capital Territory’, @CountryId, 1)
INSERT INTO {databaseOwner}[{objectQualifier}Lists]( [ListName], [Value], [Text], [ParentID], [Level]) –, [SortOrder], [DefinitionID], [Description])
 VALUES(‘Region’,’NSW’,’NEW SOUTH WALES’, @CountryId, 1)
INSERT INTO {databaseOwner}[{objectQualifier}Lists]( [ListName], [Value], [Text], [ParentID], [Level]) –, [SortOrder], [DefinitionID], [Description])
 VALUES(‘Region’,’NT’,’NORTHERN TERRITORY’, @CountryId, 1)
INSERT INTO {databaseOwner}[{objectQualifier}Lists]( [ListName], [Value], [Text], [ParentID], [Level]) –, [SortOrder], [DefinitionID], [Description])
 VALUES(‘Region’,’QLD’,’QUEENSLAND’, @CountryId, 1)
INSERT INTO {databaseOwner}[{objectQualifier}Lists]( [ListName], [Value], [Text], [ParentID], [Level]) –, [SortOrder], [DefinitionID], [Description])
 VALUES(‘Region’,’SA’,’SOUTH AUSTRALIA’, @CountryId, 1)
INSERT INTO {databaseOwner}[{objectQualifier}Lists]( [ListName], [Value], [Text], [ParentID], [Level]) –, [SortOrder], [DefinitionID], [Description])
 VALUES(‘Region’,’TAS’,’TASMANIA’, @CountryId, 1)
INSERT INTO {databaseOwner}[{objectQualifier}Lists]( [ListName], [Value], [Text], [ParentID], [Level]) –, [SortOrder], [DefinitionID], [Description])
 VALUES(‘Region’,’WA’,’WESTERN AUSTRALIA’, @CountryId, 1)
INSERT INTO {databaseOwner}[{objectQualifier}Lists]( [ListName], [Value], [Text], [ParentID], [Level]) –, [SortOrder], [DefinitionID], [Description])
 VALUES(‘Region’,’vic’,’Victoria’, @CountryId, 1)


INSERT INTO {databaseOwner}[{objectQualifier}Lists]( [ListName], [Value], [Text], [ParentID], [Level]) –, [SortOrder], [DefinitionID], [Description])
  VALUES(‘Currency’,’AUD’,’Australian Dollars (AUD)’, 0, 0)



/*– =============================================
— example to execute the store procedure
— =============================================
EXECUTE {databaseOwner}{objectQualifier}Localization_AddAustralia
*/
GO


Update:cathal has a script here with additional regions for DNN3 for about 30 countries.


 

DotNetNuke should cache GetHostSettings calls to database.

I’ve opened SQL profiler and noticed that opening single page in DotNetNuke causes tens of calls to database. In particular opening the Admin Pages List causes more than 50 calls to  GetHostSettings SP.


They should re-design to cache the results.

Suggestions/bugs ranking on MS product feedback site

I’ve recently posted a few suggestings/bugs to MS Product Feedback site.


They have Top Bugs/Suggestions (How we rank?) section, but I found that their way to use average vote is not appropriate.


In the current approach bug with 3 users rated 5 has bigger rank, that the bug with 60 users voted with average 4.96( almost all rated as 5 and a few rated less).
Also if I want to vote for the suggesting/bug, but consider it less than 5, I could reduce average rate and subsequently overall rank, even if I want to say that the issue is important for me.


I beleive that sum of individual rates will be more appropriate. In this case bug with 3 voters will have rank 15, but bug with 60 voters will have rank about 300 and each new voter will increase rank. This approach also do not required extra consideration “bugs with less than two votes are excluded“.


The approach can be extended to provide different weight for each rate.
E.g rate 5 can have  weight 10000, rate 4 -weight 1000,rate 3 -weight 100, rate 2- weight 10, and rate 1 can have weight 1.
Using the weights 3 votes rated 5 will give rank 30000.


56 votes with rate 5 plus 4 voters with rate 4 will give total rank 564000.


This algorithm looks more fair.


I beleive that MS have good programmers to implement this algorithm.

DotNetNuke exceptions when calling GetSupportedLocales

When I running DotNetNuke 4.0.2, I sometimes (not always !?) receive System.NullReferenceException exceptions in the area related to GetSupportedLocales.


1. I’ve changed in DNNLibraryComponentsLocalizationLocalization.vb GetResource(ByVal ResourceFileRoot As String, ByVal objPortalSettings As PortalSettings, ByVal strLanguage As String) function the code to use local variable


Dim locale As Locale = GetSupportedLocales(userLanguage) ‘mnf 17/1/2006 second call returns Nothing
‘If (Not GetSupportedLocales(userLanguage) Is Nothing) AndAlso (GetSupportedLocales(userLanguage).Fallback.ToLower <> “”) Then
If (Not locale Is Nothing) AndAlso (locale.Fallback.ToLower <> “”) Then
               fallbackLanguage = locale.Fallback.ToLower ‘GetSupportedLocales(userLanguage).Fallback.ToLower
End If

2. In  DNNLibraryComponentsSharedPageBase.vb PageCulture function I’ve also added check (Not enabledLocales Is Nothing ) around For Each block


If

Not enabledLocales Is Nothing Then ‘MNF 18/1/2005

            For

Each _localeCode As String In enabledLocales.AllKeys

                     
….


             Next
End If ”MNF 18/1/2005

I found that the similar errors are also posted at DNN Forum here and here.


UPDATE: I was about to post the fix for the DataCache.GetCache pattern when found that it’s already done and fixed in the core code 30/1/2006.

Exception handling in DotNetNuke Container for debugging

I found another useful change in DNN core  to debug exceptions.


Function GetPortalModuleBase in LibraryComponentsSkinsContainer.vb silently catchs exception with comment


‘ module was not loaded correctly


I beleive that exception should not be catched at all, because nothing return after exception causes very unclear message


“MinMax persistance type of cookie requires a ModuleId“


but at least for debugging purposes catch should be replaced with the followning code. (UPDATE 9/6/2006: It seems that the error message fixed in DNN 3.3/4.1)


Catch exc As Exception

    ‘ module was not loaded correctly

   Debug.Assert(

False, exc.ToString)

End Try

It will make redundunt quite useful at the moment DNNDebug.aspx 


Don’t forget to add to the beginning of the file the line




Imports

System.Diagnostics

 


Update: It seems that to show exception in GetPortalModuleBase is too late.


The original exception should be shown where controls are tried to load


i.e in Default.aspx.vb -function LoadSkin() ,


DNNLibraryComponentsSkinsSkin.vb -functions  LoadContainer and InjectModule.


I’ve posted this as a  suggestion to dotnetnuke support.  

Quick Start of Debugger in VS 2005 Tip required manually handle Dependencies.

Because VS 2005 seems much slower compare with VS 2003, I was very excited when read a tip , that suggested to uncheck libraries from Configuration Manager. And it really improves the speed of start up.( I don’t understand why dependency check became so slow in VS 2005)


I have DotNetNuke web site project and a few library projects, both DotNetNuke and my own.


The problem happened when I changed the code in one of the libraries. It was quite obvious that I had to re-build the library which I’ve changed.
But the web application still used the old code. After investigation I undestood that it is required to re-build all libraries in depedencies path.


For example, your Web project depends on libraries A,B,C and D, and also C depends on B and B depends on A.


If you made changes in A, you must rebuild libraries A,B,C  for changes take affect. 


 


 

DotNetNuke NavigateURL() returns FriendlyUrls, which is not always suitable.

My DotNetNuke site  has HostSetting(“UseFriendlyUrls”) = “Y”, which is generally good.

The most popular function used in DNN to generate url is NavigateURL.
However when I want to get Page Url and then add additional query parameters, NavigateURL() is not the best choice.
NavigateURL returns FriendlyUrl, and after adding extra parameters (e.g.
http://localhost/FSDNN/vKnowledgeDataEditing/tabid/59/Default.aspx?List=SubscriptionSearchInterest ) the structure of URL becomes different to what HttpModules.UrlRewrite expects.

HttpModules.UrlRewrite replaces TabId to -1 and appropriate page is not found.

The solution is to use = ApplicationURL(Tabid)

sUrl

instead of NavigateURL and then add QueryString parameters manually.

Overloads of NavigateURL have AdditionalParameters parameter ,that probably was designed by DNN authors to add arbitrary query parameters.
It is possible to parse multiple QueryString parameters into array of string AdditionalParameters and then pass it to appropriate .Sample how to split QueryString into AdditionalParameters array of string is in DNN Default.aspx.vb InitializePage function.

Unfortunautely default FriendlyUrls implementation moves parameters into part of the path ,but default UrlRewrite HttpModule unable to restore them back.
I don’t have enough experience with Rewrite rules to fix it, so using ApplicationURL is a good alternative for me.

 

 

Show exception details during development in DotNetNuke

In DotNetNuke development when exceptions occured, the only short exception message is shown in the web page.
To see full details, you need to open log page, which is required a few mouse click and round-trips.


I found that for development (in Debug mode) it is more convinient to see full exceptions on the page.


The changes can be done in core DotNetNukeLibraryComponentsSharedPageBase.vb file, function Page_Error,


I’ve replaced strURL += IIf(strURL.IndexOf(

“?”) = -1, “?”, “&”).ToString & “error=” & Server.UrlEncode(exc.Message)

to the code


Dim sErrMsg As String = exc.Message
#
If DEBUG Then
               
sErrMsg = exc.ToString
               
sErrMsg = Left(sErrMsg, 1800) ‘limit the length to be less then GET limit 2048 http://support.microsoft.com/default.aspx?scid=KB;en-us;q208427

#
End If

While sErrMsg.IndexOf(“..”) >= 0 ’17/4/2006 added

sErrMsg = sErrMsg.Replace(

“..”, “.”) ‘UrlRewriteModule do not except “..” for security reasons

End While
strURL += IIf(strURL.IndexOf(“?”) = -1, “?”, “&”).ToString & “error=” & Server.UrlEncode(sErrMsg)

Alternatively DEBUG  condition can be changed to check if it is Administrator running.


I’ve posted this as a  suggestion to dotnetnuke support.  

GetTypeFromCLSID changes in .Net Framework 2.0

My application, written for .Net 1.1, used GuidAttribute of Type to uniquely identify classes and then load different classes, based on specified GUID passing to GetTypeFromCLSID.  The classes were not COM classes.


The functionality is broken in .NET 2.0 as documented here.


Now GetTypeFromCLSID returns valid type only if the class is COM object (Type.IsComObject() returns true) and is registered as COM class.


Managed class with matched GuidAttribute will not be returned by GetTypeFromCLSID(guid) .


I have two options- 1. to change identifier to be full class name or make class COM objects and register them in Windows Registry.


 


 

Visual Studio 2005 Web Site Project- “Edit and Continue” is too restrictive.

I have a solution with Start ASP.NET project and several VB and C# library projects. When I stopped in Visual Studio 2005 debugger in the library class code, the file is shown with small “lock”.
It doesn’t allow me to do any changes, but show the message “Edit and Continue”
“Changes are not allowed when the debugger has been attached to an already running process or the code being debugged is optimized”.
None of of these conditions is actually applicable for my case. Library is included in the solution, referred in Web Site project as Project and should allow me to edit it.
I’ve posted this as a suggestion under MS Feedback site , but it’s more a bug, because it makes “Edit and continue” feature  more limited then it was in Visual Studio 2003.

There is a thread in “vsnet.debugging” group, where Jeffrey Tan from MS Online Partner Support  recommends “to stop the debug , change the source code in class library, then re-start the debugging again. This is the behavior of VS.net2003”. This is not correct, because VS.net2003 allowed to do modifications and continue, but changes were not in affect until the next restart.

Update: It seems that restriction is only applicable to VB libraries and C# libraries code can be edited during debugging.

“Workaround”: I found some unconvinient procedure, that allow to continue without stopping debugging.
1. Disable “Edit and Continue“.( If you didn’t apply hotfix 915038 or VS 2005 Service Pack 1, it  should be disabled anyway -see bug FDBK40283 ).

2.When you stopped in debugger on a particular line and want to change a file 

3. Right-mouse click the file name on the tab caption and click “Copy full path“ menu

4.Start another instance of “Visual Studio 2005“ (or any another external editor).

5.Click “Open“ icon and paste file full path. Open the file and make the changes.

6.In the debugger close the file, that is editing in another editor.It is important, otherwise VS IDE will ask to reload the file with changes and can stop debugging anyway.

7. Save the changes in the editing instance of Visual Studio 2005“ (external editor).