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

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

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

ADO.Net Services not showing anything in browser

by Michel 10. November 2008 10:59

Having the problem as well that, when you are testing your ADO.Net Services in Internet Explorer, the browser is not showing anything?

This 'error' occurs when the 'Turn on feed reading view' option is enabled. To disable this, do the following:

Open IE, go to Tools > Internet Options > Content > Feeds (Settings) > Un-tick 'Turn on feed reading view'

Turn on feed reading view enabled Turn on feed reading view Disabled

Turn on feed reading view Enabled

Turn on feed reading view disabled

 

[kickit]

Tags: , , , ,

.Net | C# | Debug

DebuggerStepThroughAttribute

by michel 10. October 2008 16:01

I love to check out somebody else his or her code. I always learn something from it. Just a couple of days ago I had an example from Scott Allen about WWF and ASP.Net.

In his code example I found a class with different small data checks. Each static method was decorated with the ´DebuggerStepThroughAttribute´.

public static class Check
{
    [DebuggerStepThrough]
    public static void IsNotNull(object argument, string message)
    {
        if (argument == null)
        {
            throw new InvalidOperationException(message);
        }
    }
}
Scott Allen, source code example

 

Not exactly knowing what the attribute meant (besides what the name is telling you) triggered me to ask it Google :)

By placing System.Diagnostics.DebuggerStepThrough attribute above a method, you instruct the debugger to step through that method and not into it. With other words this instruction will cause the debugger not to step into method as normal, but you can always place a breakpoint in that method and stop there.

Hmm sweet isn't it :) Hopefully it's useful for you as well.

[kickit] 

Tags: , , ,

C# | Debug

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