Navigation


Upcoming courses:

  • Aarhus, Denmark, March 5 - 9, 2012
  • New York City, USA, March 26 - 30, 2012
Read more on our website

About me

Brian Holmgård Kristensen

Hi, I'm Brian. I'm a Danish guy primarily working with ASP.NET e-commerce solutions using Microsoft Commerce Server.

I'm co-founder and core-member of Aarhus .NET Usergroup (ANUG), which is a offline community for .NET developers in Denmark.

You can visit my View Brian Holmgård Kristensen's profile on LinkedIn or follow me on Twitter @brianh_dk. Also please feel free to contact me via e-mail Send me an e-mail.

Categories

On this page

How to retrieve Category Rank in Commerce Server 2009
Midway impressions on Tech-Ed North America 2009
Installation af Umbraco - step 2
En aften i F#-tegnet
Installation af Umbraco - step 1
Opsætning og installation af prerequisites til Umbraco
Første spadestik med Umbraco...
Nu som deltager i dansk udvikler konkurrence
How to extend Commerce Server Payment Methods and Shipment Methods
Entity Framework Introduction
Microsoft Visual C# Under the Covers: An In-depth Look at C# 3.0
Building Great Web Experience with Silverlight 1.x

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0

Send mail to the author(s) E-mail

Total Posts: 36
This Year: 0
This Month: 0
This Week: 0
Comments: 10

Sign In

Follow me on Twitter @brianh_dk
 Tuesday, 27 April 2010

In Commerce Server the Rank property is used as a sorting discriminator when retrieving categories, products and variants. This property is usually managed using Catalog Manager as shown in the screenshot below:

image

The Rank property could also be managed in your own application which will be the topic of a later blog-post. This blog-post will focus on how to get the actual Rank value when retrieving categories in Commerce Server.

How did we do this in in Commerce Server 2007?

Pretty easy! We just include “Rank” as an item in the PropertiesToReturnArray for child categories (line 12) when requesting a specific category and later retrieve the value from the property-bag of the Category instance (line 24) as shown in the example below:

   1:  public void RequestUsing2007(string catalogName, string categoryName)
   2:  {
   3:      var catalogSystem = CommerceContext.Current.CatalogSystem;
   4:   
   5:      var configuration = new CategoryConfiguration
   6:      {
   7:          LoadChildCategories = true,
   8:          ChildCategories =
   9:          {
  10:              SearchOptions =
  11:              {
  12:                  PropertiesToReturnArray = new[] { "DisplayName", "Rank" }
  13:              }
  14:          }
  15:      };
  16:   
  17:      var category =
  18:          catalogSystem.GetCategory(catalogName, categoryName, "da-DK", configuration);
  19:   
  20:      foreach (var childCategory in category.ChildCategories)
  21:      {
  22:          _writer.WriteLine("Id={0}", childCategory.Name);
  23:          _writer.WriteLine("DisplayName={0}", childCategory.DisplayName);
  24:          _writer.WriteLine("Rank={0}", childCategory["rank"]);
  25:   
  26:          _writer.WriteLine();
  27:      }
  28:  }

And how can I do it in Commerce Server 2009?

In Commerce Server 2009 with the new Foundation API the overall way of retrieving entities in Commerce Server has changed a lot. In the example below I’ve added “Rank” as part of the properties to retrieve when requesting child categories for a specific category (line 10):

   1:  public void RequestUsing2009(string catalogName, string categoryName)
   2:  {
   3:      var categoryQuery = new CommerceQuery<CommerceEntity>("Category");
   4:      categoryQuery.Model.Properties.Add(new[] { "Id", "DisplayName" });
   5:   
   6:      categoryQuery.SearchCriteria.Model.SetPropertyValue("CatalogId", catalogName);
   7:      categoryQuery.SearchCriteria.Model.SetPropertyValue("Id", categoryName);
   8:   
   9:      var childCategoryQuery = new CommerceQueryRelatedItem<CommerceEntity>("ChildCategories", "Category");
  10:      childCategoryQuery.Model.Properties.Add(new[] { "Id", "DisplayName", "Rank" });
  11:      categoryQuery.RelatedOperations.Add(childCategoryQuery);
  12:   
  13:      var operationServiceAgent = new OperationServiceAgent();
  14:   
  15:      var response = 
  16:          operationServiceAgent.ProcessRequest(
  17:              new CommerceRequestContext
  18:              {
  19:                  Channel = "MyChannel",
  20:                  UserLocale = "da-DK",
  21:                  UserUILocale = "da-DK",
  22:                  RequestId = Guid.NewGuid().ToString()
  23:              }, 
  24:              categoryQuery.ToRequest());
  25:   
  26:      var operationResponse = (CommerceQueryOperationResponse)response.OperationResponses.Single();
  27:   
  28:      var entity = operationResponse.CommerceEntities.SingleOrDefault();
  29:   
  30:      foreach (var childCategory in entity.Properties["ChildCategories"] as CommerceRelationshipList)
  31:      {
  32:          foreach (var categoryProperty in childCategory.Target.Properties)
  33:          {
  34:              _writer.WriteLine
  35:                  ("{0}={1} ({2})", 
  36:                  categoryProperty.Key, 
  37:                  categoryProperty.Value, 
  38:                  categoryProperty.Value.GetType().Name);
  39:          }
  40:   
  41:          _writer.WriteLine();
  42:      }
  43:  }

 

One of the Operation Sequence components being executed in this operation is responsible for creating the CategoryConfiguration instance, that we manually created in the Commerce Server 2007 example (CS 2007 example line 5). This Operation Sequence component is named “CategoryConfiguration_Prepare”.

The actual logic for building the CategoryConfiguration instance is implemented in a class named CatalogConfigurationBuilder. This class will look in the MetadataDefinitions.xml file to match up the properties requested by the developer (in our case “Id, DisplayName, Rank”) with the properties registered for the actual entity being requested (“Category”).

If Rank is not registred in the MetadataDefinitions.xml file, it will be ignored by the CatalogConfigurationBuilder (method doing this is called TranslatePropertyName) and will therefore not be part of the “PropertiesToReturnArray” that in the end decides which columns to retrieve from the catalog table in SQL Server.

To make sure that Rank is registred in MetadataDefinitions.xml verify it by follow these steps:

  1. Open MetadataDefinitions.xml
  2. Locate <CommerceEntity name=”Category”>
  3. Make sure that there is a <PropertyMapping> element for property=”Rank” (<PropertyMapping property=”Rank” csProperty=”rank” />)
  4. Make sure that there is a <Property> element for name=”Rank” (<Property name=”Rank” dataType=”String” />)

Step 3 explained:

   1:  <EntityMappings>
   2:    <EntityMapping
   3:          csType="Microsoft.CommerceServer.Catalog.Category"
   4:          csAssembly="Microsoft.CommerceServer.Catalog, Version=6.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
   5:   
   6:      <PropertyMappings>
   7:        <!-- 
   8:              The following mappings are required here to ensure that all
   9:              the product common properties are represented in the Microsoft Multi-Channel Commerce Foundation 
  10:              metadata. These are not returned by the Commerce Server
  11:              metadata automatically as the common properties.
  12:              -->
  13:        <PropertyMapping property="BaseCatalogName" csProperty="BaseCatalogName" />
  14:        <PropertyMapping property="Rank" csProperty="rank" />

 

Step 4 explained:

   1:  <Properties>
   2:    <!-- 
   3:      The following property definitions are required here to ensure that all
   4:      the product common properties are represented in the 
   5:      metadata. These are not returned by the Commerce Server
   6:      metadata automatically as the common properties.
   7:      -->
   8:    <Property name="BaseCatalogName"        dataType="String" >
   9:      <DisplayName value="Base Catalog Name"/>
  10:    </Property>
  11:    <Property name="Rank" dataType="String" />

 

That’s it! The response returned by the Foundation API should now have the actual Rank value returned for each child category entity:

Id=ThirdRankingCategory (String)
Rank=1 (Int32)
DisplayName=ThirdRankingCategory (String)

Id=AnotherRankingCategory (String)
Rank=2 (Int32)
DisplayName=AnotherRankingCategory (String)

Id=SomeRankingCategory (String)
Rank=3 (Int32)
DisplayName=SomeRankingCategory (String)
Posted on Tuesday, 27 April 2010 12:00:00 (Romance Standard Time, UTC+01:00)
# | Comments [0]
 Wednesday, 13 May 2009

This is a brief story of my impressions and experiences with the first couple of days attending TechEd 2009 North America.

So after more than 24 hours of travelling from source (Århus, Denmark) to destination (Los Angeles, CA, USA)  I finally arrived at the hotel Saturday evening. I’m staying at a very nice hotel called Hollywood Roosevelt Hotel, just across Kodak Theatre (the place where the Oscar Academy Award takes place every year) on Hollywood Boulevard.

Pre-Conference

I was signed up to participate in the Pre-Conference part of TechEd, joining in on a whole-day seminar with the topic “The ASP.NET Performance Tuning Cycle”. Stuff I was really looking forward hearing about since we are focusing a lot on performance improvements at Vertica on our projects. The seminar was held by Richard Campbell and Kent Alstad and man those two Canadian guys were really on fire that day. We came around lots of different areas including how to do load-testing with Visual Studio 2008 Team System (Test Edition), load-balancing, how to analyze the response time of a web-site and much more. Generally a whole lot of good advices on how to look at the whole picture of optimizing a given web-site – where to put the energy basically. On advice I would like to highlight here is to use www.webpagetest.org as an external tool to analyze your web-site.

After a great and educational day in company with Richard and Kent I was all psyched about the rest of the conference. I went to see the movie “Wolverine” after getting back to the hotel.

Day 1 – Keynote, ASP.NET 4.0, SharePoint

First day of TechEd started out with the Keynote speech as one would expect. I must admit I wasn’t that enthusiastic about this particular Keynote and as it turned out I wasn’t proved really wrong on that hunch. The Keynote was primarily held by Bill Veghte, Microsoft Senior Vice President on Windows Business. The topics were all about the IT-stuff going on right know with focus on the soon to come operating systems; Windows 7 and Windows Server 2008 R2. Not that I’m not interested in those topics at all, I just wanted to see some developer stuff too – unfortunately there was none.

The first actual session I attended was about ASP.NET 4.0 and what’s coming in that release. It was a pretty good one. Jeff King showed some examples of how you are now able to have more fine-grained control over the markup rendered by the ASP.NET WebForms Framework, some better support for SEO-stuff including new properties on the System.Web.Page class for meta-keywords and –description and generally some new controls to do LINQ-based operations (e.g. Filtering and Sorting) on your LINQ-enabled backend datasource.

The last two sessions I attended that day were both about SharePoint development. The first was focusing on tooling for SharePoint development, especially with focus on using the tool VSeWSS 1.3 (Visual Studio extensions for Windows SharePoint Services). The last session was about how to develop Windows Workflow Foundations to use inside WSS/MOSS applications. This session was held by Ted Pattison, SharePoint MVP and book-writer, and now from my experience a really good presenter. I didn’t get much out of the course technically-wise though since we’ve already been doing a lot of the stuff that he presented.

Next up after first-day sessions was the Partner Expo Reception event which I attended. It can best be described as a circus where all the audience gets magically drawn by all the stuff and weird contests offered by the different vendors. But they had food and beer, and I got a few good talks with some of the different vendors – including a nice demo by a Red Gate Software guy on the soon-to-be-released new version of ANTS Memory Profiler. And yeah of course I got a lot of swag too :-)

Day 2 – More SharePoint, C#, Commerce Server 2009, Parallels, Web Deployment

The second day started out with a morning session by Todd Bleeker on SharePoint Web Part Development Best Practices. Todd had a lot of energy on the stage and that was just really awesome! Even though the session was about Best Practices over half of the audience was rather new to Web Part development which had the impact of Todd having to explain a lot more of the basics taking time from the really interesting stuff. Pretty unfortunate also was that time completely ran out for Todd so he didn’t come around all of his points. All in all I think it was a great session mostly because of Todd’s enthusiasm. And I did get some good advices to take me back home.

I also attended Anders Hejlsberg’s session on “Future of C#”, which I enjoyed a lot – mostly because I think he rocks. To be more specific and professional about it I believe that the future “Compiler As A Service”-feature can really leverage some interesting possibilities to the table, e.g. for an easy way stick-in additional behavior to your code (logging, validation, pre-/post conditions, etc.) to allow cross-cutting concerns to be addressed as secondary concerns.

After having a brief chat with one of the guys at the Commerce Server booth he had me convinced that I should go to their interactive session on Commerce Server 2009 Foundation Services. So I did (later to discover that I thereby missed a Scott Hanselmann session!). Although they had a whole lot of technical problems at this session, I got a pretty good understanding of the upcoming Commerce Server 2009 R2 version including the support of having Commerce Server configured as a true 3-tier environment with Commerce Server as an application server in the middle of this. I’m soon to begin on a new Commerce Server 2009 project which I look really forward to, but seeing that new Foundation API kind of shocks me a little – to me it is extremely verbose compared to the CS 2007 API, and the amount of XML configuration doesn’t seem to have become any less I’m afraid. Perhaps wrapping the new very generic API in a nice fluent and slightly more specific API might just do the trick for me. We’ll see about that.

Next in line was a interesting session on Parallel Computing APIs with .NET 4.0. It gave me a good overview and examples of the possibilities with parallelism that you can get using the new framework that will be baked into .NET 4.0.

Last but not least this I attended a session on Web Application Deployment Packaging and Migration – a look into some new possibilities in IIS about importing and exporting applications and on how to package your solution to allow smooth GUI-enabled installation on IIS. At the session, Faith Allington showed the new Web Platform Installer from Microsoft which I personally think is a awesome tool. Both BlogEngine.NET and Umbraco got some visual attention at this session being on the list of web-applications available on the Web Platform Installer. Faith did really well on this presentation clearly having a lot of knowledge of what she was talking about.

All in all a great day with good sessions by excellent speakers.

Posted on Wednesday, 13 May 2009 05:25:37 (Romance Standard Time, UTC+01:00)
# | Comments [2]
 Monday, 29 September 2008

Jeg fik desværre ikke chancen for at arbejde videre med Umbraco sidst på ugen, forrige uge, pga. F#-arrangement i vores .NET brugergruppe i Århus, samt egen forberedelse til en præsentation og demo af et lille samspil mellem SharePoint 2007, InfoPath Forms og Windows Workflow Foundation.

Derudover kan jeg nævne at jeg i går var til TechTalk hos Microsoft med Anders Hejlsberg, chefarkitekt hos Microsoft på bl.a. C#, samt Steve Ballmer, CEO hos Microsoft. Det var hele køreturen fra Århus til Vedbæk værd, selvom arrangementet kun varede et par timer.

Tilbage til Umbraco. Som nævnt i min forrige post, ramte jeg en lille "mur" i forbindelse med installationen, da jeg ikke havde konfigureret File Permissions for mit Umbraco-website. Jeg Googlede mig vej til en post, som beskriver de foldere og filer som kræver opsætning. Desværre var det ikke helt nok for mig. Jeg måtte sætte Full Control på hele Umbraco-mappen for at få Umbraco til at "æde den". Jeg skal nok vende tilbage med en mere "sikker" løsning, når jeg får tid til at smide lidt tid efter det. Da det her installeres lokalt uden mulighed for at tilgå sitet udefra, kan jeg godt leve med risikoen.

file-permission-error

Som det kan ses havde jeg problemer med ACL på mit Umbraco-website. En hurtig quick-fix var at sætte "Full Control" på hele mappen til kontoen "Network Service", som er den konto som afvikler websitet i IIS'en. Dette anbefales ikke til enhver form for produktionsmiljø.

Videre i installationen kom jeg, men allerede ved næste step kaster Umbraco en Exception i hovedet på mig. Se nedenstående skærmbilleder.

db-installation

Ved klik på "Install", kaster Umbraco følgende Exception:

exception-db-install

Kedeligt. Hvad kan man gøre ved det? Jeg vælger at kigge lidt på den kode som smider den Exception, med anvendelse af mit yndlingstool til decompilering af .NET kode: Lutz Roeders Reflector. Reflector er i øvrigt nu overtaget af softwarehuset Red Gate, som har en væld af yderst interessante tools til .NET og SQL i deres produktportefølje, herunder Ants Profiler og SQL Compare. Et hurtigt kig i koden hjælper imidlertid ingenting - så jeg må overveje andre alternativer. Èt af dem er at prøve igen. Jeg klikker på "Tilbage"-knappen i browseren, og klikker på Install-knappen endnu en gang. Det hjalp :-)

yay-db-install-went-well

Videre i installationen - lækkert. Umbraco tjekker opsætningen af mine filrettigheder, og fortæller mig at det er perfekt sat op, hvilket også er fair nok, på trods af at jeg har sat Full Control på hele mappen. Så helt perfekt er det ikke - men det må jeg kigge på senere.

Igen fortsætter installationen, og nu står jeg på step 5/5 - hvor jeg skal vælge om jeg vil installere Boost. Boost er et nyt begreb i Umbraco 4, og er i følge screencastet af Niels Hartvig, et helt skrabet web-site som overholder en række Umbraco-konventioner (som jeg stadig ikke kender), og som lukker op for en anden feature: Nitros. Igen kan jeg kun trygt læne mig op af Niels Hartvigs definition af Nitros, som dækker over en afgrænset specifik funktionalitet, som f.eks. TopNavigation, standard SiteMap. Jeg har erfaring med WSS/MOSS (SharePoint) udvikling, og umiddelbart minder det rigtig meget om det vi her kender som "Features". Det lyder meget lovende - og mon ikke jeg burde prøve at lave min egen lille Nitro i forbindelse med det her projekt. Jeg følger Niels' guidelines, og installerer Boost med de Nitros som installationen finder.

install-boost

Et klik på "Install Boost"-knappen bekræfter at jeg har brugt for meget tid på at skrive den her post (og i øvrigt lave en masse andet), end at rent faktisk gennemføre selve installationen af Umbraco, for jeg får straks smidt følgende Exception i hovedet:

user-time-out

Min bruger har simpelthen fået et timeout af Umbraco/ASP.NET. Helt forståeligt. Løsningen var ret simpel; jeg besøgte "http://localhost/umbraco" som er adressen til selve administrationsdelen af Umbraco. Her loggede jeg ind med den bruger som blev oprettet i forbindelse med installationen.

Tilbage til installationen, og et klik på "Install Boost", får mig videre til næste side (se nedenstående skærmbillede), hvor jeg kan vælge de Nitros som skal installeres med sitet. Jeg vælger at installere dem alle.

nitros-installation

done-installation

Hermed er Umbraco 4 installeret på Windows Server 2008 med SQL Server 2008. I Rock!

Posted on Monday, 29 September 2008 18:37:57 (Romance Standard Time, UTC+01:00)
# | Comments [0]
 Wednesday, 24 September 2008

I aften var det sidste onsdag i måneden, ergo afholdte vi vores faste månedlige møde i Århus .NET UserGroup (ANUG). Denne gang havde vi inviteret Christian Holm Nielsen til at udgøre den som hovedtaler. Der var lagt på bordet til en gang snak om F#. Et .NET baseret sprog som har været under udvikling i Microsoft Research afdeling, og som nu er udkommet i en CTP-release, og som bl.a. har lagt grund for nogle af de sprog features som vi har fået i C# 3.0 (herunder type inference, og flere eksempler fra denne blog-post om "The Roots of C# 3.0: F# and C-Omega").

Christian gennemgik en langt række eksempler på sprog-features i F#, herunder tupler, sequences, smileys (intern joke), immutable types o.m.a.

Det var super flot at Christian sammen med sin kollega var interesseret i at køre hele vejen fra Odense for at give en præsentation i vores brugergruppe her i Århus. Thumbs up for præsentationen. Klaus Hebsgaard var endda så heldig at vinde en F#-bog for at have stillet aftenens spørgsmål omkring type inference.

Dvs. dagen er 100 % gået med arbejde, og direkte til Usergrup, så jeg har desværre ikke fået arbejdet videre med mit Umbraco-projekt. To be continued...

Posted on Wednesday, 24 September 2008 20:08:25 (Romance Standard Time, UTC+01:00)
# | Comments [0]
 Tuesday, 23 September 2008

Update: Jeg har uploadet nye versioner til de forskellige screen-shots.

Okay, nu er SQL Server 2008 installeret på Windows Server 2008, så nu er jeg endelig klar til at komme igang med at prøve at installere Umbraco 4.

Nedenfor følger de første par trin jeg fulgte for at installere Umbraco (med inspiration fra Niels Hartvigs screencast om netop dette):

  1. Download nyeste version fra http://umbraco.org/v4
  2. Kopiere den udpakkede version til c:\inetpub\wwwroot\
  3. Oprette ny SQL Login bruger i SQL Server 2008 -> UmbracoApp
  4. Oprette ny Database i SQL Server 2008 -> UmbracoApp
  5. Oprette nyt web-site i IIS der peger på c:\inetpub\wwwroot\ - sørg for at AppPool'en anvender "Classic .NET AppPool"
  6. Starte en browser og ind på http://localhost

exception-1-assembly-binding-redirect

Update: exception-1-assembly-binding-redirect-large.gif

Hvorefter jeg ind i første forhindring, som du kan se af ovenstående skærmbillede. Sagen er at Umbraco forventer at jeg har en bestemte versioner af følgende assemblies "System.Web.Extensions" og "System.Web.Extensions.Design" installeret i min GAC (Global Assembly Cache). Det har jeg ikke - tværtimod har jeg en nyere version af netop denne assembly - så der skal lige lidt fodarbejde for at få min Umbraco applikation til at forstå dette. Heldigvis er sådanne scenarier understøttet fuldt ud af .NET runtimen, og kræver blot et par linier af konfiguration i web.config (se nedenstående skærmbillede). Så ingen onde ord om Umbraco på den front.

fix-assembly-binding

Update: fix-assembly-binding-large.gif

Herefter indlæste første side af Umbraco konfigurations-wizarden fint. Lækkert. Videre til step 2/5, hvor det begynder at blive spændende. Her skal jeg opsætte forbindelse til min database. I første forsøg fejler installationen da jeg trykker på "Confirm"-steppet. Men jeg skulle bare lytte videre til Niels Hartvigs screencast, som netop omtaler at det kræver konfiguration af filrettigheder til inetpub-biblioteket og web.config.

En hurtig Google-search leder mig i retning af en side fra Umbracos online dokumentation - som under "Configure IIS for Umbraco" fortæller mig dét jeg skal vide.

Det kigger jeg så videre på i morgen...

Posted on Tuesday, 23 September 2008 21:58:15 (Romance Standard Time, UTC+01:00)
# | Comments [3]
 Monday, 22 September 2008

Okay, som nævnt i min forrige post vil jeg gerne anvende et isoleret, virtuelt miljø til at teste Umbraco. Til det formål har jeg downloadet en evaluation VHD af Windows Server 2008 Enterprise edition hos Microsoft. For at få gang i det miljø, har jeg installeret Virtual Server 2005 R2 SP1 til at hoste VHD'en.

Som default er Windows Server 2008 installeret stortset uden features/serverroller, som potentielt kan åbne systemet for angreb (disclaimer: jeg kan sagtens tage fejl - har sjældent fingrene direkte i konfigurationen af operativsystemer), så derfor har jeg som noget af det første haft gang i at installere og konfigurere serveren til at køre IIS 7.0 (Internet Information Services) til afvikling af Umbraco som er en ASP.NET web-site applikation.

Det næste jeg skal have installeret er SQL Server 2008 Express... Mere herom...

Posted on Monday, 22 September 2008 19:58:55 (Romance Standard Time, UTC+01:00)
# | Comments [0]

Hos Vertica anvender vi SCRUM som procesmodel for vores softwareprojekter, så jeg tænkte det måske ville være et udmærket udgangspunkt for ligesom at få lidt struktur på mit lille projekt her. Jesper har allerede inddelt projektet i faser, så det vil jeg da drage lidt nytte af. Læringsfasen slutter den 12. oktober, så det giver lige præcis tre uger fra og med i dag. Jeg har oprettet et lille regneark inde i Google Docs som jeg vil bruge til at oprette og prioritere opgaver mv. Måske overkill, men det finder vi ud af...

Nå, vi er jo ikke kommet for at snakke, så nu er det på tide at komme igang med Umbraco, så ind på hjemmesiden med mig.... www.umbraco.org.

Ganske ganske kort om Umbraco

Umbraco er i dag et open source CMS (Content Management System). Umbraco blev stiftet af Niels Hartvig i år 2000, og siden da har det oplevet en voldsom vækst og popularitet. Du kan finde alt den information om Umbraco du kan drømme om direkte på Umbraco web-sitet www.umbraco.org, herunder pod- og screencasts.

Jeg har haft chancen for at møde Niels Hartvig personligt, da vi sidste år inviterede ham op til Vertica til en snak om Microsoft Commerce Server og Umbraco. Et rigtig spændende møde.

Valg af version

Da dette projekt ikke skal bruges til noget decideret kundeprojekt, men blot fungere som "Proof-Of-Concept on getting started with Umbraco", har jeg valgt at basere mig på den allernyeste version jeg kan fingrene i (Umbraco 4.0 Beta 1), og dermed ikke spekulere så meget over at denne specifikke version stadig er i beta.

Installation og konfiguration af Umbraco 4.0

Perfekt - Niels Hartvig har lavet en screencast omkring selve installationen af Umbraco 4.0. Så kan det ikke blive meget nemmere - det eneste problem er at jeg skal have stablet et virtuelt miljø på banen, så jeg kan teste og arbejde med Umbraco i et isoleret miljø. Det giver mig samtidig også chancen for at afprøve Windows Server 2008 og SQL Server 2008 - nu må vi se om det spiller godt sammen med Umbraco 4.0.

Posted on Monday, 22 September 2008 16:23:29 (Romance Standard Time, UTC+01:00)
# | Comments [0]

(In English: I've signed up for a contest on a Danish community site for developers, where you have to learn about a new technology and write blogposts about your experience with that. One of the requirements for this contest is that all written material have to be in Danish. Sorry.)

Jeg har været medlem på det danske udviklersite ActiveDeveloper.dk siden det dengang hed Active Server Pages og hvor det var Dennis Knappe som stod i spidsen for sitet. Jeg benytter mig stadig af ActiveDeveloper.dk, dog sjældent til at stille spørgsmål, og desværre sjældent til at besvare på andres spørgsmål. Til gengæld fungerer sitet for mig som en indgangsportal til flere af de danske bloggere som jeg jævnligt følger med i, samt til at opfange de events mv. som der arrangeres fra tid til anden, herunder Geek-Dinners. ActiveDeveloper.dk bliver i dag styret af en gut som jeg ved flere lejligheder har haft chancen for at møde, nemlig Jesper Blad Jensen aka Deldy.

Konkurrencen i korte træk...

Jesper har sammen med Daniel Mellgaard Frost fra Microsoft sat en konkurrence sammen, hvor det gælder om at sætte sig ind i en ny selvvalgt teknologi inden for en given tidshorisont. Alt i mens skal man blogge om sine daglige oplevelser med denne nye teknologi, og i slutperioden af konkurrencen skal man skrive en artikel hvor man sammenfatter hele oplevelsen. Ham/hende som har leveret det bedste arbejde kan vælge mellem en række præmier udlovet af Microsoft.

Kort om mig

Mit navn er Brian Holmgård Kristensen. Jeg blev uddannet datamatiker fra Skive i 2005, og har siden bl.a. arbejdet som ERP-udvikler (Microsoft Dynamics AX) hos en virksomhed i Viborg. Siden maj 2007 har jeg dog arbejdet som .NET udvikler i en virksomhed der hedder Vertica, der ligger inde midt i Århus. Jeg har beskæftiget mig med udvikling i en del år efterhånden, med fokus på web-udvikling. Jeg er medstifter af Århus .NET UserGroup (www.anug.dk), hvor jeg stadig er en aktiv del af kernegruppen, og har også haft æren af at lave en både en præsentation om ASP.NET samt en workshop. Hvis du vil vide lidt mere om hvem jeg er, kan du læse min introduktions-post jeg skrev sidste år da jeg oprettede bloggen, eller besøge min LinkedIn-profil - og du er selvfølgelig også velkommen til at kontakte mig direkte.

Hvad deltager jeg med

Jeg vil gerne i gang med at arbejde med Umbraco. I første omgang bliver det at forstå hele pakken der følger med Umbraco, det være sig installation, konfiguration, maskineriet, plug-ins osv. Det næste for mig vil være hvordan jeg bygger ovenpå Umbraco løsningen – og med at bygge ovenpå mener jeg at anvende de teknologier og værktøjer som jeg normalt sidder med i min arbejdsdag; unit-testing, Inversion of Control, MVP, etc.. – f.eks. sådan at jeg kan integrere mine eCommerce løsninger med Umbraco (med anvendelse af f.eks. Microsoft Commerce Server nedenunder).

Hvorfor jeg deltager...

... fordi jeg synes det er et brand-godt initiativ som jeg gerne vil støtte op omkring, og fordi jeg rigtig gerne vil lære at anvende Umbraco som CMS, da det er et produkt vi overvejer at bruge professionelt på min arbejdsplads, samt i mit fritidsfirma www.yourhost.dk.

Dette er blot min lille introduktionspost til konkurrencen - løbende vil der selvfølgelig komme mange flere post, as we go by.

Posted on Monday, 22 September 2008 14:23:10 (Romance Standard Time, UTC+01:00)
# | Comments [0]
 Sunday, 16 December 2007

By default Microsoft Commerce Server 2007 is highly extensible for example in regards to extending the object model in the Order System (e.g. creating new classes or extending existing ones). Also the Profile System is properly the most extensible subsystem in Commerce Server being a general purpose data repository that allows the developer to define and store any custom data in it. While this is all great and good news, not everything on the Commerce Server platform is possible to extend and this post will focus on one specific lack of extensibility in regards to extending Payment Methods and Shipment Methods.

If you want to read more about Commerce Server 2007 seen from a developer and architect's point of view, I recommend reading my colleague Søren's "Developing with Commerce Server 2007"-series on his blog publicvoid.dk.

Requirements

In Denmark we have a national wide postal service called Post Danmark which we use as our carrier for sending letters, packages etc. This is defined in Commerce Server as one of the Shipment Methods on the specific customer solution I'm currently working on. Post Danmark also offers a service allowing the end-customer to postpone the actual payment of the order until the physical arrival. By having this option, we created a Payment Method in the system called "Post Danmark Efterkrav" ("Post Danmark Cash On Delivery"), so the customer can choose this in the checkout process. To be able to use this payment method we demand that the customer has already chosen Post Danmark as the shipment method. If the customer has chosen another shipment method we will not allow the customer to choose the cash on delivery payment method from Post Danmark, thus having the payment method depending on the chosen shipment method.

Management of Commerce Server Payment Methods and Shipment Methods takes place in the Customer and Orders Manager application. When creating a Payment Method it is possible to specify e.g. Payment Type (Credit Card Payment, Gift Certificate Payment, etc.). It is also possible to specify Name and Description of the Payment Method in the languages you want to support, plus a few more options. Unfortunately this is one of the areas in Commerce Server where you seemed to be locked by this model or behavior and you cannot do any obvious extending. Nonetheless we needed some way to do it, because we wanted to be able to specify a relation or dependency between Payment Methods and Shipment Methods. We wanted to make it possible to specify that a specific Payment Method should only be available when a specific Shipment Method was selected in the checkout process. And of course we wanted to accomplish this using as much Commerce Server standards as possible, so future service pack upgrades would not cause problems among other obvious reasons :-)

The solution

As mentioned earlier the Profile System in Commerce Server is our general purpose data repository where we can model almost anything and leverage from Commerce Server API's to do data access operations and provide security to our data store. The solution we came up with was to create two new profiles in the Profile System; one for payment method extended properties (PaymentMethodExtensionProfile) and another for shipment method extended properties (ShipmentMethodExtensionProfile) and link these profiles to the Shipment Method and the Payment Method types.

Shipped with Commerce Server comes a Software Development Kit, which among other very nice things contains the complete source code to all the business applications (except the Catalog and Inventory Schema Manager). There are two classes in the Customer and Orders Manager project responsible of displaying the dialogs for management of Payment Methods (PaymentMethodEditView) and Shipment Methods (ShippingMethodEditView) respectively. In each of these Windows Forms dialog classes, we added a new button in the toolbar, gave it an icon and named it "Extended Properties". When the user clicks on this button, we execute some code, that depending on whether it is executed from a Payment Method or Shipment Method basically just performs a search for a specific profile (our extended properties profile) specified by the unique id of for instance the Payment Method, and depending on whether the profile exist or not we open the standard profile management dialog in the right state (edit or new). If the profile does not exist, we initialize it with the unique id (our relation-key value). This is all done in a relatively few lines of code, where all we do is basically the same steps as a business user would manually do to either create a new profile or search for an existing one. All the code pieces for this is of course already in the solution, the hard part was just to find these exact pieces and assemble them to suit our requirements.

I have attached some screenshots below that shows how our feature is implemented in the Customer and Orders Manager application.

payment_method_list

The figure above shows the list of payment methods in the system.

payment_method_dialog

The figure above shows the new button we have added to the dialog, that, when the user clicks on the button, executes our custom logic that opens up the profile management dialog (either a new one, or an existing one), related to the payment method.

payment_method_extension_profile_dialog   

The figure above shows the actual profile which we use for extending the properties for a specific payment method in the system.

payment_related_shipping_method 

The figure above shows the actual relation between the payment method and the shipment method. The logical relation is established between the two extension profiles of the "Post Danmark" shipment method and the "Post Danmark Efterkrav" payment method.

Conclusion

The solution I have described here for extending Payment Method and Shipment Methods in Commerce Server 2007 works really good for us and we have added a lot of extended properties to both the Payment Method type (see screenshots supplied) and the Shipment Method type. Some of the functionality this provides is the ability to filter a specific shipment method to a specific country as well as filter a payment method based on the items added to the basket. Really cool and useful features and the best part of it: we are using standard Commerce Server all the way! :-)

Another very cool thing to mention is that when we had Max Akbar at Vertica to provide us some educational days of concentrated Commerce Server training, I gave him a demo of the feature, and his responses to it were really good.

If you have any questions or want me to elaborate more on this subject please don't hesitate to contact me in any way.

Posted on Sunday, 16 December 2007 20:12:41 (Romance Standard Time, UTC+01:00)
# | Comments [0]
 Friday, 09 November 2007

I must admit; I was pretty tired at this point, being very focused on getting most out of the sessions. I write notes from each session I attend and when I get back home to my hotel I polish them up so they can be published on my blog. It is causing me a lot of work and it is a bit slow process but it is useful for me, and hopefully others as well. Even though as mentioned I was a bit beaten up at this last session for Tuesday on TechEd for Developers it really had my attention because it was a topic of huge interest. I am really looking for a proper way of modeling my data access layer in a proper encapsulated way supporting my nTier architecture with the benefits of having an OR mapper in place.

The Entity Framework Introduction session was given by a guy called Carl Perry, who is Senior Program Manager Lead at Microsoft, and Carl was here to talk about Data Access methodologies on specific ADO.NET. Data Access as we know it in ADO.NET 2.0 allows a provider based model for abstracting low level access/interaction with the actual store e.g. SQL Server or Oracle.

With Entity Framework they want to raise the level of abstraction. Raise the abstraction from readers, commands and connections for making it easier to build a data driven application as you work closer to your domain model. Entity Framework lets you to only worry about how your domain is expressed. It introduces a Conceptual Schema which is the model we actually program against which has rich support for inheritance and relations. There is also a model to represent the actual data store given by e.g. the schema of tables, views, stored procedures etc. in the actual database called the Store Model. To map between these models Entity Framework introduces a third model in between known as the Mapping Model.

Entity Framework supports many-to-many relationships - it just removes the link table and creates a many-to-many relation on the related objects.

There are two approaches to access data with Entity Framework: 1) Use LINQ, which will properly give you much higher productivity, and 2) use the newly introduced query language called Entity SQL (eSQL) that is a part of the Entity Framework. Entity SQL looks very SQL like, and has the ability to invoke any server function that the provider has mapped. You query against the Conceptual Model in a string-based manner making e.g. joining tables very implicit.

Carl showed us some demos on using the Entity Framework using both approaches as mentioned above.

The Entity Framework is properly going to be shipped on first half of 2008. All database vendors are already developing managed providers on it. The current version of Entity Framework is on Beta 2 with a Beta 3 just around the corners.

I think it was a good session on introducing the Entity Framework and Carl certainly had a lot of knowledge on that area. I’m going to be attending a specific LINQ To Entities session tomorrow, hopefully to get even more insight on the Entity Framework and how it can be used as an OR mapper to support a data driven application. Looking forward for tomorrow sessions after hopefully a good long nights sleep :-)

Posted on Friday, 09 November 2007 08:31:08 (Romance Standard Time, UTC+01:00)
# | Comments [0]

I really had my doubts on whether I should attend this session, because a colleague of mine, Søren, already had done a presentation about the new language features in C# 3.0, and also I attended a session yesterday by Luca Bolognese on “The .NET Language Integrated Query Framework” where he covered many of the new features as well. However there was a really good reason for me being there; 1) that the session took place in the Auditorium where also my previous session on Silverlight went on, meaning I did not have to move at all, and 2) that I have a lot of interest in C# 3.0 and attending a session with only focusing on that simply could not be a bad thing for me.

This session was by Luke Hoban, Program Manager at Microsoft responsible for the C# compiler. Luke started out by telling about their design themes on this C# 3.0 version, which goes as:

1. Improve C# 2.0 – obvious as many might think.

2. Language Integrated Query (LINQ) - making querying a first class concept in the language. LINQ is really the driving force behind many of the new language features that we'll see as LINQ required making a lot of new capabilities in the language.

3. Being 100% backwards compatible which is always the case.

The rest of the session by Luke was pretty much purely demo-driven to show us the use of the new language features, covering:

Auto-Implemented Properties

The option to introduce a property with an implicit backend data variable. This is very useful for most properties in your classes as they usually always just simple properties without any logic.

Object Initializers

The option to set values on public properties of an object directly in its constructor.

Collection Initializers

Just as with Object Initializers this feature allows to add items to a collection object directly in its constructor.

Local variable type inference

This allows for any local variable inside the code, to just leave out the name of the object type and use the var keyword instead. This is syntactical very convenience and it is completely strong-typed as the compiler already knows which type you operate on given the right side of the assignment expression.

Note that you can't use var as return type or as parameter type. In level of public interface explicit specifying the types is the only way to go.

Query Expressions

The most important thing to understand about Query Expressions is that they are just like any other syntax in C#. It is not some sort of Domain Specific Language, it is just like e.g. a for-loop or a while-loop - a part of the C# language.

Two major reasons why Query Expressions are valuable: 1) they can be used not just over objects but all sorts of data; relational, XML, anything that implements the LINQ Query Provider and 2) it is easy to use as it is a very declarative way of writing queries.

Anonymous Types

The ability to create new shapes that suits the exact needs in your specific logic. Very useful for intermediate results.

The class will be auto generated by the compiler, making sure the type will have the right signature.

Also you can't return it – which means they are for most purposes constrained to a method body.

Lambda Expressions

A way to do anonymous methods but in a more efficient and declarative way. A Lambda Expression is indicated by the => (goes to) keyword. A Lambda Expression starts with a list of all parameters sent to the function.

Extension Methods

The ability to kind of virtually add new methods to existing objects that normally are out of your reach, e.g. sealed classes. It is important to note that this does not in any way break encapsulation. It is purely syntactic sugar. The compiler will go ahead and call the static method on the concrete extension class when it sees an Extension Method.

Expression trees

This is telling the compiler to capture Lambda Expressions not as delegates but as an actual Expression Tree which is a rich object model containing body and parameters exposing the Lambda Expressions thereby allowing the consumer to decide how to process this information, e.g. creating dynamic SQL as with LINQ To SQL.

Partial Methods

Allows you to write code that calls a method that may or not be defined and must be declared within a partial class. A common scenario for partial methods is lightweight event handling and in e.g. LINQ To SQL often used for doing validation in a custom partial class for the generated class.

Implicitly-Typed Arrays

This is a simple but helpful feature allowing you to declare a new array but leave out the name of the type. The compiler then does the type inference for you.

Example: var myArrayOfIntegers = new[] { 1, 2, 3, 4 };

It really was a great session by Luke Hoban and I am glad I attended even though I had my doubts. I feel very lucky having attended only good sessions so far!

Posted on Friday, 09 November 2007 08:25:16 (Romance Standard Time, UTC+01:00)
# | Comments [0]

The speaker of this session, Jesse Liberty actually joined Microsoft because of Silverlight. His work at Microsoft is not about convincing anyone to use Silverlight, his job is more to help developers on how to learn Silverlight and make the best use out of it. There is a tremendous interest in the whole Silverlight technology as he goes, so obviously Microsoft invests in customers wanting to use Silverlight for implementing their applications. Jesse went on a stated his agenda for this session; that we should not expect to see or be impressed by fancy demos of Silverlight in action. That his goal by demo-driven presentation is to show us how easy it is to use the declarative language XAML to build real applications with the .NET Framework and Visual Studio.

Jesse started his demo by creating a new Silverlight project in Visual Studio 2008. What he was about to demo was building a Silverlight application from scratch including a new custom Silverlight control in it. The essence of the demo was to build an application on the Conway´s Game of Life. I don’t want to go into much detail about what Conways Life is, but basically it has something to do with some cells living in a matrix-like world of total 800 cells, where each cell from generation to generation comes to live or dies depending on the state of the cells neighbors.

Among other things in his demo, he showed us how to implement a timer in XAML and make use of this timer for creating a loop control structure. Also and by far more interesting he demoed a new feature of Silverlight 1.x where they have implemented the capability of Silverlight to reference standard HTML that is produced in the page where the Silverlight control is hosted. This makes it possible to reference any HTML elements e.g. changing its display or capturing its events using API’s inside the System.Windows.Browser namespace. The .NET code looked exactly like the DOM most of us are already familiar with from JavaScript:

HtmlPage.Document.GetElementById(“myControlID”)

What Jesse really wanted to illustrate was the only really difficult thing on Silverlight is on how to go around declarative programming. When you are passed that barrier you find yourself back in the well known world of .NET programming and just thinking about implementing the logic using standard .NET. This happens very quickly with Silverlight.

I haven’t done any work in Silverlight at all so coming to this session was really good for me as I got some feeling on how Silverlight fits in – technically speaking that is. I have of course seen a lot of Silverlight demos out there – but for me it is really more interesting to see how it is done. Great session by Jesse Liberty – it was cool to see when his little tiny application came to play. Thumbs up!

IMG_1422

Posted on Friday, 09 November 2007 08:13:50 (Romance Standard Time, UTC+01:00)
# | Comments [0]