01.Blogs :
SvenH  
How To? Host Web Services on CE devices.
Tuesday, February 28, 2006 8:07 PM

"Noone wants to create a server farm on CE devices." That's what Frank Prengel said. But I did! So I had to begin from the scratch. First of all: requirements. I needed to host Web Services on a Windows CE device to update and retrieve data of a SQL CE database. The client should be able to retrieve a DataSet and send changes to the database. You might imagine that this is not a trivial task. I had to face many problems, e.g. Compact Framework 1.0 does not support all feature of DataSet serialization. But let me start with the CE web server. I found an interesting project with help of Christian Weyer.

It's a web server for Windows CE based on Compact Framework 1.0 (More information available here). But there were some bugs in it. Thus, I needed to do some modifications. Mobile Web Server is a bit oversized for use with Web Service Purposes only, because it contains an HTML engine as well as the required SOAP engine. Perhaps one could also slenderize it a bit, by doing some optimizations - the version I used exclusively required 4 MB of memory to run the server.

But let's go on with the more interesting issues of this article. The Web Service itself. Because there are some unsupported serialization features in Compact Framework 1.0, I had to find some workarounds...

To be continued...

3 Comments | Post a Comment |

posted  by  SvenH  with 

Version 0.6 of WSCF VS AddIn released!
Tuesday, February 28, 2006 9:16 AM
There's a new release of Christian Weyer's amazing tool for creating contract-first Web Services. It allows you to design your Web Service Interface by defining a XSD schema. Unlike the oridinary approach through Web References and method calls in Visual Studio, this tool gives you the ability to send and receive real data. To get more details, visit http://www.thinktecture.com/WSCF.

0 Comments | Post a Comment |

posted  by  SvenH  with 

How To? Convert RFC 822 date-time to System.DateTime
Friday, February 24, 2006 8:46 AM

If you have to work with emails, you''ll soon come to a point, where you want to get time information out of those mails. Date-time information according to RFC 822 are like the following:

  • Thu, 17 Jul 2003 12:35:18 CET
  • Thu, 17 Jul 2003 12:35:18 +0100

The .Net Framework provides a special pattern for these purposes, the DateTimeFormat.RFC1123Pattern. But there seem to be some problems with Datetimes containing special TimeZones (e.g. "CET", "AWST"etc.). I found a function that handles these cases and returns the adequate DateTime.

using System.Globalization;

private static string[][] TimeZones = new string[][] {
    new string[] {"ACDT", "+1030", "Australian Central Daylight"},
    new string[] {"ACST", "+0930", "Australian Central Standard"},
    new string[] {"ADT", "-0300", "(US) Atlantic Daylight"},
    new string[] {"AEDT", "+1100", "Australian East Daylight"},
    new string[] {"AEST", "+1000", "Australian East Standard"},
    new string[] {"AHDT", "-0900", "AHDT"},
    new string[] {"AHST", "-1000", "AHST"},
    new string[] {"AST", "-0400", "(US) Atlantic Standard"},
    new string[] {"AT", "-0200", "Azores"},
    new string[] {"AWDT", "+0900", "Australian West Daylight"},
    new string[] {"AWST", "+0800", "Australian West Standard"},
    new string[] {"BAT", "+0300", "Bhagdad"},
    new string[] {"BDST", "+0200", "British Double Summer"},
    new string[] {"BET", "-1100", "Bering Standard"},
    new string[] {"BST", "-0300", "Brazil Standard"},
    new string[] {"BT", "+0300", "Baghdad"},
    new string[] {"BZT2", "-0300", "Brazil Zone 2"},
    new string[] {"CADT", "+1030", "Central Australian Daylight"},
    new string[] {"CAST", "+0930", "Central Australian Standard"},
    new string[] {"CAT", "-1000", "Central Alaska"},
    new string[] {"CCT", "+0800", "China Coast"},
    new string[] {"CDT", "-0500", "(US) Central Daylight"},
    new string[] {"CED", "+0200", "Central European Daylight"},
    new string[] {"CET", "+0100", "Central European"},
    new string[] {"CST", "-0600", "(US) Central Standard"},
    new string[] {"EAST", "+1000", "Eastern Australian Standard"},
    new string[] {"EDT", "-0400", "(US) Eastern Daylight"},
    new string[] {"EED", "+0300", "Eastern European Daylight"},
    new string[] {"EET", "+0200", "Eastern Europe"},
    new string[] {"EEST", "+0300", "Eastern Europe Summer"},
    new string[] {"EST", "-0500", "(US) Eastern Standard"},
    new string[] {"FST", "+0200", "French Summer"},
    new string[] {"FWT", "+0100", "French Winter"},
    new string[] {"GMT", "-0000", "Greenwich Mean"},
    new string[] {"GST", "+1000", "Guam Standard"},
    new string[] {"HDT", "-0900", "Hawaii Daylight"},
    new string[] {"HST", "-1000", "Hawaii Standard"},
    new string[] {"IDLE", "+1200", "Internation Date Line East"},
    new string[] {"IDLW", "-1200", "Internation Date Line West"},
    new string[] {"IST", "+0530", "Indian Standard"},
    new string[] {"IT", "+0330", "Iran"},
    new string[] {"JST", "+0900", "Japan Standard"},
    new string[] {"JT", "+0700", "Java"},
    new string[] {"MDT", "-0600", "(US) Mountain Daylight"},
    new string[] {"MED", "+0200", "Middle European Daylight"},
    new string[] {"MET", "+0100", "Middle European"},
    new string[] {"MEST", "+0200", "Middle European Summer"},
    new string[] {"MEWT", "+0100", "Middle European Winter"},
    new string[] {"MST", "-0700", "(US) Mountain Standard"},
    new string[] {"MT", "+0800", "Moluccas"},
    new string[] {"NDT", "-0230", "Newfoundland Daylight"},
    new string[] {"NFT", "-0330", "Newfoundland"},
    new string[] {"NT", "-1100", "Nome"},
    new string[] {"NST", "+0630", "North Sumatra"},
    new string[] {"NZ", "+1100", "New Zealand "},
    new string[] {"NZST", "+1200", "New Zealand Standard"},
    new string[] {"NZDT", "+1300", "New Zealand Daylight"},
    new string[] {"NZT", "+1200", "New Zealand"},
    new string[] {"PDT", "-0700", "(US) Pacific Daylight"},
    new string[] {"PST", "-0800", "(US) Pacific Standard"},
    new string[] {"ROK", "+0900", "Republic of Korea"},
    new string[] {"SAD", "+1000", "South Australia Daylight"},
    new string[] {"SAST", "+0900", "South Australia Standard"},
    new string[] {"SAT", "+0900", "South Australia Standard"},
    new string[] {"SDT", "+1000", "South Australia Daylight"},
    new string[] {"SST", "+0200", "Swedish Summer"},
    new string[] {"SWT", "+0100", "Swedish Winter"},
    new string[] {"USZ3", "+0400", "USSR Zone 3"},
    new string[] {"USZ4", "+0500", "USSR Zone 4"},
    new string[] {"USZ5", "+0600", "USSR Zone 5"},
    new string[] {"USZ6", "+0700", "USSR Zone 6"},
    new string[] {"UT", "-0000", "Universal Coordinated"},
    new string[] {"UTC", "-0000", "Universal Coordinated"},
    new string[] {"UZ10", "+1100", "USSR Zone 10"},
    new string[] {"WAT", "-0100", "West Africa"},
    new string[] {"WET", "-0000", "West European"},
    new string[] {"WST", "+0800", "West Australian Standard"},
    new string[] {"YDT", "-0800", "Yukon Daylight"},
    new string[] {"YST", "-0900", "Yukon Standard"},
    new string[] {"ZP4", "+0400", "USSR Zone 3"},
    new string[] {"ZP5", "+0500", "USSR Zone 4"},
    new string[] {"ZP6", "+0600", "USSR Zone 5"}
    };

private static DateTime ParseDateTime(string dateTime)
{
    CultureInfo ci = 
    CultureInfo.InvariantCulture;
    try
    {
        return DateTime.Parse(dateTime, ci, 
        DateTimeStyles.AllowWhiteSpaces);
    }
    catch (FormatException)
    {
        try
        {
            return DateTime.ParseExact(dateTime, 
        new string[] 
        { ci.DateTimeFormat.SortableDateTimePattern, 
          ci.DateTimeFormat.RFC1123Pattern }, 
        ci, DateTimeStyles.AllowWhiteSpaces);
        }
        catch (FormatException)
        {
            string dateFormat = 
        ci.DateTimeFormat.RFC1123Pattern.Replace("'GMT'", "zzz");

            foreach (string[] entry in TimeZones)
            {
                if (dateTime.EndsWith(entry[0]))
                {
                    dateTime = String.Format("{0}{1}", 
            dateTime.Substring(0, 
            dateTime.Length - entry[0].Length), 
            entry[1]);
                    break;
                }
            }
            try
            {
                return DateTime.ParseExact(dateTime, dateFormat, ci, 
            DateTimeStyles.AllowWhiteSpaces);
            }
            catch (FormatException)
            {
                return DateTime.Now;
            }
        }
    }
}

Many thanks to Ed Courtenay, [MCP, MCSD], http://www.edcourtenay.co.uk.

0 Comments | Post a Comment |

posted  by  SvenH  with 

How To? Easily handle huge amounts of Constants
Friday, February 17, 2006 10:20 AM

Many solutions contain several projects which need to access the same constant values. Think about table and column names of the underlying datasource or common keys of key-value-collections such as IDictionary. The first approach would be creating a class in a common project, referenced by all projects that use these constants, and provide public const values.

But what about hierarchical constants? Let's say I want to file my constants into several levels, such as Common.Constants.DataSource.TableNames.Table1. This can be easily done using .Net Framework 2.0. You only have to write a static class, named Constants. This class itself defines constants and additional static subclasses.

The next step is to integrate more complex constants. Sometimes you need a readonly instance of a complex class. Const members can not be instantiated. But C# provides another useful keyword - readonly. So you just need to define a public static readonly member and instantiate it, e.g. with the operator new, in the static constructor.

namespace Common
{
    public static class Constants
    {
        public const int IntValue = 1;
        public const string StringValue = "level 1";

        public static class Level2
        {
            public const int IntValue = 2;
            public const string StringValue = "level 2";

            public static class Level3
            {
                public const int IntValue = 3;
                public const string StringValue = "level 3";
            }
        }
        public static readonly ComplexClass InstantiatedConstant;
        
        static Constants()
        {
            InstantiatedConstant = new Complexlass(1);
        }
    }
}

0 Comments | Post a Comment |

posted  by  SvenH  with 

Das MVP Pattern
Tuesday, February 14, 2006 7:31 PM

Wer des öfteren mit SoftwareDesign zu tun hat, wird nicht an ihnen vorbeikommen - den Patterns. Die GoF - die Gang of Four - hat ja einige grundlegende Patterns begründet. Im Laufe der Zeit haben sich aber noch weitere Patterns herausgebildet. So zum Beispiel das MVC-Pattern. Als eine Weiterentwicklung versteht sich das MVP Pattern - das Model View Presenter Pattern, welches die vielbeschworene Trennung der View vom Model nun endlich in real world applications ermöglichen soll.

Eine gute Übersicht über die altbewährten GoF Pattern gibt es unter dofactory.com.

0 Comments | Post a Comment |

posted  by  SvenH  with 

Manchmal laufen die Dinge aus dem Ruder
Tuesday, February 14, 2006 7:24 PM

Mit Projekten - im Speziellen wohl Softwareprojekten - ist das so eine Sache. Selbst erfahrene Projektleiter können da schonmal an ihre Grenze stoßen. Die Mitarbeiter einfach mal machen lassen iss nich. Besonders wenn diese weit weg sitzen (z.B. im Ausland). Da kann es schonmal passieren, dass man nach 3 Anfragen und 2 Wochen sinnlos verstrichener Zeit den selben SourceCode zugeschickt bekommt, wie vor eben diesen 14 Tagen - mit den selben Bugs. Und wenn man dann zu spät einen CodeReview macht und mal genauer hinschaut, sitzt man auf dem Trockenen. Dann bleibt einem wohl nichts mehr anderes übrig, als das ganze Projekt neu zu starten.

Daher immer kleine Ergebnisse in kurzen Zeitintervalen anfordern, bzw. ausliefern. Das sollte man schon für sich selbst tun. Denn wie oft hat man schon vor einem Problem gesessen, was das ganze Projekt zum Stillstand brachte. Da hilft dann nur die Politik der kleinen Schritte... ;-)

0 Comments | Post a Comment |

posted  by  SvenH  with 


 
03.UPDATE CALENDAR :
<December 2008>
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

05.MY LINKS :

06.Archives :
07.Subscriptions :

Subscriptions


© Copyright 2005 Microsoft Corporation. All Rights Reserved.
Terms of Use | Privacy Statement | Code of Conduct | Hosted by MaximumASP for Microsoft
WHO-BAR