Download all PDC content with OData

by michel 3. November 2010 22:23

Did you know that the Microsoft PDC had a OData feed which showed all sessions, speakers, locations & downloadable content? NO??!! Then you know now…. Uri: http://odata.microsoftpdc.com/ODataSchedule.svc/

Do you want all the PDC content offline available but don’t you feel like browsing the site frequently, keep track of which files got added and download all the files one by one?

Then I think I have a solution for you Smile As an available download I’ll publish the PDCDownloader console application (Using .Net 4.0) including source code. The application will search for available content via the provided OData feed and download what you need.

The application has the following command line parameters:

/type: Do you want to download PPTX, MP4 High bitrate/low bitrate or WMV high/low resolution.
/location: destination directory
/forceredownload: if set to true all files will be redownloaded again, even if they are already on disk available.

Usage PDCDownloader.exe  /type:[PPTX | MP4HIGH | MP4LOW | WMVHIGH | WMVLOW] /location:<valid dir> [/forceredownload: [true | false] (default: false)

Example PDCDownloader /type:PPTX /location:c:\downloads

works-on-my-machine-starburst[2]Because new content gets added daily it is advisable to start the command line app every day for the next 1 or 2 weeks, with the /forceredownload switch set to false. In this scenario the application will only download the new available content!

Software is only tested on my own machine, in case of errors please leave a comment.

Downloads:

Tags:

C# | Microsoft | .Net

Adding QR Code functionality to BlogEngine

by Michel 20. October 2010 15:28

What is a QR code?

First QR stands for Quick Response meaning that the contents can be decoded at a very high speed.  Secondly it’s a two-dimensional bar code.  Not one-dimensional like the bar codes we all are familiar with when a cashier scans something we want to buy.

There are three big advantages to using QR codes.

  1.  
    1. They can hold a ridiculous amount of information compared to their one-dimensional cousin.
    2. Most mobile phones/devices can automatically decode the information stored in a QR code.
    3. You can generate your own very easily.

The guys from Tech Boy Fresh did a very neat blog post about QR Codes, I would strongly recommended you to check it out!

After playing with QR, I decided it was time to create my very first BlogEngine plugin which adds QR code functionality to every page.

How to use this plugin?

  • Download the plugin
  • unpack it
  • upload the unpacked (GoogleQR.cs) file to your own BlogEngine website, under App_Code/Extensions folder.
  • Login to your BlogEngine blog and verify if the extension is enabled, if not enable it!
  • Go to a blogpost, where you would like to add the QR code, and insert to following snippet:

    [ GoogleQR ]

  • You properly have to to this in HTML view, but sometimes it will work out in the preview modus.

Little side note: The QRcode being created has a div tag around it, so via CSS (css class = ‘qrImage’) styling  to can position the image wherever you want.

Please contact me for suggestions, comments, bug reports etc….

Download the plugin:

 

 

Tags:

Using the PRiSM EventAggregator in non WPF / SilverLight applications

by michel 13. October 2010 15:41

While working with SilverLight, I frequently use the PRiSM library to support MVVM & modularity. One of the key component is supporting modularity is the Event Aggregator.

As per Martin Fowler “An Event Aggregator acts as a single source of events for many objects. It registers for all the events of the many objects allowing clients to register with just the aggregator.”

According to the PRiSM documentation:

“The EventAggregator service is primarily a container for events that allow decoupling of publishers and subscribers so they can evolve independently.”

IC269586

Because the PRiSM library is released under the MS-PL, I can copy and modify it according to my need. The PRiSM Event Aggregator is used for WPF & SilverLight applications and some of the references are specific for those platforms.

To use the Event Aggregator in non WPF / SilverLight applications I isolated the required code, removed the WPF / SilverLight dependencies and built a separate assembly which can be downloaded below.

Included in the download, is a small console demo application which will be explained below.

PersonClass The demo application we will have multiple Person instances which will communicate via the Event Aggregator. The Person object will consist of a property ‘Name’ to identify the current person instance and two public methods ‘Shout’ & ‘Whisper’. Both methods will publish the conversation via the Event Aggregator, only the Whisper methods will include an destination person for which the message meant.

In the constructor of Person, the name and the Event Aggregator will be injected to make the conversation possible. 

 

conversationFor the two different types of communication (shout and whisper) we have to different classes (the LoudConversation and WhisperConversation class)which both inherit from the base class Conversation.

The base class Conversation contains the source person which communicated, and the text which got sent. The whisperConversation also contains an destination Person for which person instance the message is meant.

 

 

Besides getting the Event Aggregator injected, the person is subscribing to two different events ‘LoudConversationEvent’ and ‘WhisperConversationEvent’, both inherit from CompositePresentationEvent which defines the class that manages publication and subscription to events.

   1: public Person(String name, IEventAggregator eventAggregator)
   2: {
   3:     Name = name;
   4:     _eventAggregator = eventAggregator;
   5:     _eventAggregator.GetEvent<LoudConversationEvent>().Subscribe(Listen, ThreadOption.BackgroundThread, true, p => !p.Source.Equals(this));
   6:     _eventAggregator.GetEvent<WhisperConversationEvent>().Subscribe(Listen, ThreadOption.BackgroundThread, true, p => !p.Source.Equals(this) && p.Destination.Equals(this));
   7: }
   8:  
   9: private void Listen(Conversation conversation)
  10: {
  11:     Console.WriteLine("{0}: Listened to '{1}': {2} ", this.Name, conversation.Source.Name, conversation.Text);
  12: }

The CompositePresentationEvent is a generic class which encapsulates the LoudConversation and WhisperConversation class.

   1: public class LoudConversationEvent  : CompositePresentationEvent<LoudConversation>{}
   2: public class WhisperConversationEvent : CompositePresentationEvent<WhisperConversation> { }

This subscription setup in the constructor of Person .will tell the event aggregator that the specific instance is interested in an certain type of event and that when the event arrives it should be delegated to the private method ‘Listen’. When subscribing to the an specific event you can optionally tell the Event Aggregator on which thread the delegated event should be handled by setting the ThreadOption (in my example, it should be handled on the background thread). The second parameter you can specify if the subscription should stay alive after a event has been received (in my case is is set to true, which is the default setting). The last optional parameter is a predicate where you can filter out certain type of events in which you are not interested in.

In the above example, I am only interested in the LoudConversationEvent when  I am not the source of the message. That is pretty logical because why would I want to listen to something which I am broadcasting.

In the WhisperConversationEvent I am only interested when I am not the sender and where I am receiver specified by the Destination property of the WhisperConversation class. This doesn’t guarantee you that other instances which also subscribe to the above events will implement the exact same predicates!!

For a short demo what we described above we will execute the code below. We are first creating a single event aggregators, create a amount of Person instances which will have a conversation.

   1: var eventAggregator = new EventAggregator();
   2: var Marc = new Person("Marc", eventAggregator);
   3: var Will = new Person("Will", eventAggregator);
   4: var John = new Person("John", eventAggregator);
   5: var Scott = new Person("Scott", eventAggregator);
   6:  
   7: Console.WriteLine("******** Shout ********");
   8: Marc.Shout("Hello, my name is Marc");
   9:  
  10:  
  11: Console.WriteLine("******** Whisper ********");
  12: Scott.Whisper("http://www.MichelTol.nl is a cool website :)", Will);
  13: Console.ReadLine();

The result will be: 
 output

The order in which the ‘Listen’ delegates will be handled is unknown because of the fact that we specified at subscription time that the delegate will be handled at the background thread.

Download the Event Aggregator and demo here:

External sources:

Tags:

The service '/Sample/SampleService.svc' cannot be activated due to an exception during compilation. The exception message is: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.

by Michel 17. September 2009 13:55

Getting the error below in your eventlog and do you have multiple identities for your website (i.e: sample.domain.tld & localhost)?

Event Type:        Error
Event Source:     System.ServiceModel 3.0.0.0
Event Category: WebHost
Event ID:           3
Date:                 16-9-2009
Time:                 8:46:15
User:                  NT AUTHORITY\NETWORK SERVICE
Computer:          COMPUTERNAME
Description:
WebHost failed to process a request.
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/40535505
Exception: System.ServiceModel.ServiceActivationException: The service '/Sample/SampleService.svc' cannot be activated due to an exception during compilation.  The exception message is: This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection.

You could solve this issue by adding the following config section to your web.config:

    <system.serviceModel>
        ...
        <serviceHostingEnvironment>
            <baseAddressPrefixFilters>
                <add prefix="http://sample.domain.tld/Sample/"/>
            </baseAddressPrefixFilters>
        </serviceHostingEnvironment>
        ...
    </system.serviceModel>

Tags:

C# | Debug | .Net | WCF

Performance testing of Dictionary, List and HashSet in the rebound.

by Michel 1. June 2009 16:52

After reading the following blog post I became curious if I could reproduce the same behavior on the HashSet.

So what did I do. I tested an List, Dictionary and a HashSet.

For all types I ran the test five times. Every run I added 10.000 items. Besides adding items to the collection I checked if the collection contained the item. This test I did 5 times with 10.000 items in the collection to check.

The figure show the result for adding the items to the different collections, and checking if the collection contained the item.

image

The horizontal line shows the amount of milliseconds to Add or check if the item contains in the collection. Without having a look at the numbers it is obvious that the Contains method on the List collections is slower than the Contains method on the HashSet or the Containskey on a Dictionary. The difference can be explained because the HashSet collection as well as the Dictionary collection uses a hashing algorithm to quickly retrieve data from it’s collection.

To get an better view on the time it takes to add an item to the different collection and see which collection is faster for retrieving the data, I removed the data duration data from the List Contains method is the graph below.

image

The graph shows that the HashSet is slower to do an lookup than the Dictionary. To be precise, it took the double amount of time to check every single item if it was in the collection. For adding stuff the List collection was the absolute winner. If we compare both structures who uses the a hashing table, the HashSet was the absolute winner. It took the Dictionary object 37,5% longer to add 10.000 items.

Even Stian Sveen got a lot of complains about his post. I got exactly the same result as he did. Until somebody else proven otherwise I believe that a Dictionary collection is faster for retrieving items than a HashSet when the collection contains 10.000 items.

 

 

 

download the test project here! DictionaryPerformance.rar

Tags:

Error Logging Modules and Handlers for ASP.NET (elmah)

by michel 18. May 2009 20:37

A while ago a friend a my promoted ELMAH via Live messenger, since then I am a FAN! ELMAH (Error Logging Modules and Handlers) is an application-wide error logging facility that is completely pluggable. It can be dynamically added to a running ASP.NET web application, or even all ASP.NET web applications on a machine, without any need for re-compilation or re-deployment.

Exceptions caught by ELMAH can be stored in memory, loose xml, VistaDb, Access, SQLLite, Oracle, MS Sql, or directly send by email. Storage- & mail configuration is done via the web.config.

The source of ELMAH is available and under the Apache License 2.0.
More info @: http://code.google.com/p/elmah/

In this post I’ll do an new implementation of the ELMAH Errorlog class to facilitate the MS SQL error logging with MOSS elevated privileges to solve the following problem.

The RunWithElevatedPrivilegesmethod will executes the specified code with Full Control rights even if the user does not otherwise have Full Control. In the MOSS environment it will execute the code under control of the the Application Pool Identity User. Implementing this method is really easy:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
   // put your code in here :)
});

The first step is to setup a class in Visual Studio (my example SqlErrorLogWEP (Sql ErrorLog With Elevated Privileges) and implement the abstract Errorlog class.

namespace Elmah
{
    using System;

    class SqlErrorLogWEP : ErrorLog
    {
        public override string Log(Error error)
        {
            throw new NotImplementedException();
        }

        public override ErrorLogEntry GetError(string id)
        {
            throw new NotImplementedException();
        }

        public override int GetErrors(int pageIndex, int pageSize, IList errorEntryList)
        {
            throw new NotImplementedException();
        }
    }
}

Because our SqlErrorLogWEP looks really for 99,9% like the classic SqlErrorLog class. In fact our class will act as a wrapper to implement the MOSS elevated privileges functionality for the SqlErrorLog class. To do this our constructor will initialize the (classic) SqlError log class and use the private sqlErrror object to perform the database logging. The above methods which still need to be implemented will use the sqlError object to do the work.

Our new class will look like this:

namespace Elmah
{
    using System;
    using System.Text;
    using System.Collections;
    using Microsoft.SharePoint;
    

    class SqlErrorLogWEP : ErrorLog
    {
        SqlErrorLog sqlErrorLog;

        public SqlErrorLogWEP(IDictionary config)
        {
            sqlErrorLog = new SqlErrorLog(config);
        }

        public SqlErrorLogWEP(string connectionString)
        {
            sqlErrorLog = new SqlErrorLog(connectionString);
        }

        public override string Log(Error error)
        {
            string retVal = String.Empty;
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                retVal = sqlErrorLog.Log(error);
            });

            return retVal;
        }

        public override ErrorLogEntry GetError(string id)
        {
            ErrorLogEntry retVal = default(ErrorLogEntry);

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                retVal = sqlErrorLog.GetError(id);
            });

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
               // put your code in here :)
            });
            return retVal;
        }

        public override int GetErrors(int pageIndex, int pageSize, System.Collections.IList errorEntryList)
        {
            int retVal = -1;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                // put your code overhere 
            });

            return retVal;
        }
    }
}

Pro’s  / Con’s
Pro’s: Implementation in 2 minutes, completely ELMAH proof, extendable.
Con’s: Instead of only deploying the ELMAH assembly you will have an extra reference to the Microosoft.SharePoint assembly.

Tags: , , ,

.Net | C# | Microsoft | SharePoint | Tooling

New version Ajax Control Toolkit (.NET 3.5)

by michel 18. May 2009 19:12

asp.net Ajax The AJAX Control Toolkit is a joint project between the community and Microsoft. Built upon the ASP.NET 3.5 AJAX Extensions, the Toolkit aims to be the biggest and best collection of web-client components available.
The Toolkit addresses three needs. First it gives website developers a place to get components to make their web applications spring to life, second it gives a set of great examples for those wishing to write client-side code, and third it is a place for the best script developers to get their work highlighted.

Version number: 3.0.30512

info: here!

Tags: , , ,

Microsoft | .Net

BizTalk 2009 Deep Dive Training

by Michel 10. May 2009 09:43

As with every new release of Microsoft BizTalk, InfoSupport is setting up a DeepDive training track with a trainer coming from Redmond. I bet it is Robert or John Callaway from Quicklearn. For everybody who is interested in BizTalk these DeepDives are the place to be. 

Info: 
BizTalk 2009 Developer Deep Dive (5 dagen)
After five extended-hour days of training and intensive labs, Deep Dive attendees will leave prepared with the advanced skills required to build complete enterprise-level SOA and integration solutions using BizTalk 2009. Deep Dive attendees are guaranteed to be challenged as they use advanced BizTalk techniques to build a complex integration solution.
You can choose to complete labs using BizTalk 2006 R2, or use the latest features of BizTalk 2009, including updates for Hyper-V, improved clustering capabilities, and the enhanced BAM, EDI, and ESB Guidance 2.0!
Inschrijven en meer informatie:

Tags:

Microsoft

1234567890 Day

by Michel 13. February 2009 12:13

More info: here!

Tags: ,

Fun

This version of the Enterprise Library cannot be installed side-by-side with version 4.0. Please uninstall Enterprise Library v4.0 and try again

by michel 3. February 2009 17:21

Getting the following error after uninstalling version 4.0?

This version of the Enterprise Library cannot be installed side-by-side with version 4.0. Please uninstall Enterprise Library v4.0 and try again

Try to remove the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Enterprise Library v4

Tags:

About the author

Michel TolMy name is Michel Tol. I'm a developer specialized in .NET technologies. Mainly focussing on SharePoint Technologies and web development. I am Certified Technology Specialist for MOSS 2007 -  Configuration, .Net Framework 2.0 - Web applications and Biztalk Server 2006 - Custom Applications.

View Michel Tol's profile on LinkedIn

  

E-mail me Send mail

Page List