Google analytics

I have to admit that WordPress is a great blog engine, today I activated google analytics, and after a 10 seconds search I found a plugin to insert automatically the analytics code in the blog. I must admit that even if I’m a .NET programmer php blogs such WordPress are still superior.

Alk.

How to format code blogging with word 2007

Today I was trying to blog with word 2007 and I found some difficulties with code. First of all I suggest you to install a Visual Studio Plugin that enable a “copy source as HTML” option that permits you to copy the code as HTML and this makes the life easier. The problem is that simply pasting the code into word will produce some strange results

    3 ”’ <summary>

    4 ”’ classe base per la definizione di proprietà comuni

    5 ”’ </summary>

    6 ”’ <remarks></remarks>

    7 <TypeConverter(GetType(ExpandableObjectConverter))> _

    8 Public
Class BaseDefinition

    9 
   17    <NotifyParentProperty(True)> _

   18   Public
Property CssClass() As
String

   19      Get

   20         Return mCssClass

   21      End
Get

   22      Set(ByVal value As
String)

   23          mCssClass = value

   24      End
Set

   25   End
Property

The code above has two problems, the first is that spacing between lines is too big, and then in HTML there are some <BR/> tags that completely makes code unreadable. After some investigation I found that it is possible to force word to generate better HTML making two substitutions. The first is substitute ^p character with ^l, the ^l character does not generate <P> tags but a simple <BR/> and this makes lines spacing smaller.

    3 ”’ <summary>
    4 ”’ classe base per la definizione di proprietà comuni
    5 ”’ </summary>
    6 ”’ <remarks></remarks>
    7 <TypeConverter(GetType(ExpandableObjectConverter))> _
    8 Public
Class BaseDefinition
    9 
   17    <NotifyParentProperty(True)> _
   18   Public
Property CssClass() As
String
   19      Get
   20         Return mCssClass
   21      End
Get
   22      Set(ByVal value As
String)
   23          mCssClass = value
   24      End
Set
   25   End
Property

Now you need to substitute also the space character with ^s (unifying space) this (do not ask me why) makes word not to generate the weird <BR /> tag.

    3 ”’ <summary>
    4 ”’ classe base per la definizione di proprietà comuni
    5 ”’ </summary>
    6 ”’ <remarks></remarks>
    7 <TypeConverter(GetType(ExpandableObjectConverter))> _
    8 Public Class BaseDefinition
    9 
   10    ”’ <summary>
   11    ”’ è necessario questo attributo per far siche il designer si accorga del 
   12    ”’ cambiamento della proprietà e fare in modo che venga serializzata
   13    ”’ </summary>
   14    ”’ <value></value>
   15    ”’ <returns></returns>
   16    ”’ <remarks></remarks>
   17    <NotifyParentProperty(True)> _
   18    Public Property CssClass() As String
   19       Get
   20          Return mCssClass
   21       End Get
   22       Set(ByVal value As String)
   23          mCssClass = value
   24       End Set
   25    End Property

Now the code looks really better but a last problem remains, the code with line numbering cannot be copied and pasted from the blog into visual studio. Even if you remove the numbering, word substitutes all occurrence of double ‘ chars with ” character, so the resulting VB.Code is not valid. At this time I really do not understand how to tell word to leave the ‘ code unchanged.

Alk.

Error synchronizing database with red gate SQL compare

Today I was synchronizing two database with red gate sql compare, newer database has 6 more additional view, but the sync script failed with some errors. One of the view is called MatterKnowledges and the script return error “matterknowledges” already exists, even if the destination database has no such view. The problem originates from the fact that the view (SQL2000) was create with a different name and then renamed to MatterKnowledges. The solution to the problem was dropping and then recreate the view on the original database, now all works ok.

Alk.

Reassociated object has dirty collection

Today I Hitted this exception working with NHibernate, after consulting some posts on the net I discovered that this exception is raised when a detached object is reattached to a session with lock and the object has a one-to-many relation that was changed. The strange thing is that the same code works perfectly on a test web site and throw this error in production site. Moreover I’m sure that the whole object graph is unchanged and that the collections is not changed

After a couple of minutes I realized that a control store a detatched object in asp.net session and reattach with session.lock…the problem is that in production code session state is managed in sql server, so the object graph is serialized, then deserialized at the next request and reattached with session.lock(). It seems that the operations of serialization and deserialization make nhibernate think that the collection of objects is somewhat changed.

Alk.

Test of blog publishing with Microsoft word 2007

This post is created using Microsoft word 2007. Let’s see if this makes blogging simpler. First of all some formatting bold
italic.

This is indented with tab.

  1. Some ordered item
  2. Another ordered item
  • A bullet list
  • Another element of the bullet list

Some weird code in VB.NET

    1 <AspNetHostingPermission(SecurityAction.LinkDemand, Level:=AspNetHostingPermissionLevel.Minimal), _
    2  AspNetHostingPermission(SecurityAction.InheritanceDemand, Level:=AspNetHostingPermissionLevel.Minimal), _
    3  ToolboxData(“<{0}:MultipleFieldsValidator runat=server></{0}:MultipleFieldsValidator>”)> _
    4 Public Class MultipleControlsValidator
    5    Inherits BaseValidator
    6 
    7    <Browsable(False), _
    8    EditorBrowsable(EditorBrowsableState.Never)> _
    9    Private Shadows Property SetFocusOnError() As Boolean
   10       Get
   11          Return False
   12       End Get
   13       Set(ByVal value As Boolean)
   14          Throw New NotSupportedException(“Cannot focus if we have more than one control to validate.”)
   15       End Set
   16    End Property

Some in C#


   38         Section section, Int32 linkId) {

   39 
   40         IUnitOfWork UoW = DataAccessProviderFactory.GetConversationUnitOfWork();
   41         Query Q = Query.CreateQuery(“Field.OwnerSection.mId”, section.Id, CriteriaOperator.Equal);
   42          Q.AddCriteria(“LinkId”, linkId, CriteriaOperator.Equal);
   43          Q.Operator = QueryOperator.And;
   44         IList<FieldData> result = UoW.GetByCriteria<FieldData>(Q);
   45         foreach (FieldData f in result) {
   46             UoW.Detach(f);
   47          }

And at last one image, this is the place where I work, my home…quite messy isn’t it?? :D

Now let’s see if word can publish all this post in my new wordpress blog. :D :D :D

The result for the code was quite messy, to have a good result I need to install a plugin for Visual Studio that gives me the option to “Copy as HTML” the code, and then once pasted in word 2007 I need to make some manual substitution for space and paragraph sign to have a good result. L

Alk.