Dança do Sirí na terra do King’s Crab

O MVP Summit é a chance de MVPs de todo o mundo interagirem entre si mesmos e os times de produto lá em Redmond.

Mas nem só de conteúdo técnico vivem os MVPs. Na terra do King’s Crab, é claro que tinha que ter algum prezepeiro para dançar a dança do sirí – ou como se diz por lá "Crab’s Dance" 🙂

MVP Summit

Na semana passada eu participei do meu primeiro MVP Summit que acontece de tempos em tempos em Seattle e Redmond, WA, USA.

Foi uma boa oportunidade de provar o King’s Crab (pata de carangueijo/siri gigante)…

 

… reunir a galera …

 

… fazer novos amigos …

 

Tinha até umas gatinhas lá…

 

Como não poderia deixar de ser, até rolou a dança do Crew!

 

 

Estas e mais um monte de fotos em http://alfredmyers.spaces.live.com/photos/cns!19D601BD22E34F6E!697/

 

PS.: O The Spoke está fora do ar novamente. Acho que vou voltar a postar algumas coisas em português aqui.

Back to Volta

Today I took the afternoon to take another look at Windows Live Labs Volta.

The idea of deferring the application partitioning to the last minute may be good for some types of projects but translating “X” (IL in this case) into JavaScript was something I’ve been wanting since the ASP + VB6 days!

I always thought that writing code in general and data validation code in particular for the server and then for the client was a tedious and error prone task.

At those days I had to write validation code in VB6 for the server and then rewrite it again in JavaScript for the client. Besides being tedious, it is an error prone task because you had two places to maintain the code as validation logic evolved.

Today I decided to test this with some legacy code I have here. I was thinking on getting some document number validation code I have here, but I stumbled across a function that translates currency amounts into their textual equivalents. Not sure how to say this in English, but the idea is to translate “1,234.56” into “Um mil, duzentos e trinta e quarto Reais e cinquenta e seis centavos”. That is “One thousand, two hundred and thirty four Reais and fifty six cents” in Portuguese.

I got this code originally written in Clipper from a magazine back in 1993.

Sometime later I rewrote it in Access Basic 2.0. A couple of years later ported it to Access 97’s VBA and at last VB 6. I have not touched it since 2000.

I ran the project through Visual Studio 2008 VB project Converter, made a couple of tweaks (really!), and added the project to my Volta test solution configured to run in Debug mode and voila! It worked like a breeze!

The important part is that I converted the project to a normal VB Class Library. Not a Volta Class Library. That implicates that I could theoretically use any any library that does not have dependencies on anything not supported by Volta and have it flow as JavaScript to the client side.

That must be what Erik Meijer means when he says "Volta stretches the .NET platform to cover the Cloud.”!!

It is important to notice however, that when you run the code in Debug mode, you are really running the IL version of it. I’m not yet sure how the magic works. Give me time!

As soon I tried to run it in Release mode, the page started complaining about unsupported features such as the Decimal constructor that accepts a Double or somewhere in the VB string helper functions trying to get a CultureInfo.

This is comprehensible since the technology is in its very early stages.

I tried equivalent BCL types and members without using the Visual Basic helper functions, and they worked so as soon as I find more time, I’ll try to fix it. I could simply try to isolate the helper functions giving me trouble and fix those pieces of code, but I’m more inclined to rewrite it in C# since it is not too much code and I have not been programming seriously in VB since 2005.

Anyway I’ll decide the route another time.

Stay tuned!

Volta

I just watched the Channel 9’s two part video with the Volta team and I have to say that it was mind blowing.

Volta has some really interesting ideas on how to simplify the development of distributed applications.

On the second part they get into the details of some of the obstacles they found translating IL into JavaScript such as JavaScript’s lack of a goto statement and how they got around it: using a while loop and a switch statement – a trick much like what C# does to implement “yield return”.

Other interesting thing was how they used exceptions to simulate multi-threading within the browser.

Really cool stuff worth watching!

The link below points to a post on the Volta Team Blog on Microsoft Live Labs which points to the Channel 9 videos. You also be able to get to the rest of the blog from there.

http://labs.live.com/volta/blog/Volta+On+Channel+9.aspx

Enjoy!

FSRM COM API documentation hits the streets

Back in March I wrote about my findings regarding the API of a feature introduced in Windows Server 2003 R2 called File System Resource Manager (FSRM).

At the time these APIs were not documented, but with the eminent release of Windows Server 2008, Microsoft released the documentation for the COM API at MSDN Library. These aren’t yet the managed libraries I’ve been waiting for, but at least we can safely start doing Interop with the COM version without fear of changes in the API! 🙂

Trip to Redmond

Late last month I took a trip to Redmond to do some consulting for Microsoft Learning.

Together with four other folks, we were responsible for helping designing the Workflow Foundation exam.

Pictures of us can be found in my blog in Portuguese here.

Following are several pictures I took while in Redmond

 

 

The hotel (motel?) where I stayed.

 

Several pictures of the Microsoft Campus

This place is pretty amazing I should say.

Programming FSRM quotas

Introduction

Recently I was evaluating the options I had for implementing disk quotas on a backend system running on a major Internet Service Provider in Brazil.

Windows offers quota management up to some degree since NTFS 5 (Windows 2000) with user/volume quotas. Those were not appropriate for our scenario since we needed to set quotas on a per directory basis and this was not supported natively by Windows until the arrival of Windows Server 2003 R2.

R2 brings us a new feature called File Server Resource Manager a.k.a. FSRM. It is exposed for the system administrator as an MMC 3.0 snap-in.

Unfortunately, as of today Microsoft does not officially support any way for programming against FSRM quotas.  I said “officially support” because if the snap-in can do it, probably we can too! So after some research I found two DLLs called srm.dll and srmlib.dll that happens to do the stuff we want. Srm.dll exposes FSRM functionality through COM and srmlib.dll is a managed code wrapper around srm.dll.

Let’s take a look at some sample code:

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.Storage;

using System.IO;

using System.Runtime.InteropServices;

 

namespace Fsrm {

    class Program {

        static void Main(string[] args) {

            string directoryName = @"c:FsrmTests";

 

            // Creates a directory for testing if necessary

            if (!Directory.Exists(directoryName)) {

                Directory.CreateDirectory(directoryName);

            }

           

            ISrmQuotaManager quotaManager = new SrmQuotaManagerClass();

            ISrmQuota quota = null;

            try {

                // Try to get quota info

                quota = quotaManager.GetQuota(directoryName);

                quota.QuotaLimit *= 2;

            }

            catch (COMException ex) {

                unchecked {

                    if (ex.ErrorCode == (int)0x80045301) {

                        // Quota doesn’t exist for this directory. Create it.

                        Console.WriteLine("No quota defined for ‘{0}’. Creating quota.", directoryName);

                        quota = quotaManager.CreateQuota(directoryName);

                        quota.QuotaLimit = 1024 * 1024;

                    }

                    else {

                        Console.WriteLine(ex);

                        return;

                    }

                }

            }

 

            // Update quota info

            quota.Commit();

 

            // Add new file to the diretory to see QuotaUsed getting updated

            File.WriteAllText(directoryName + @"" + Path.GetRandomFileName() + ".txt", "Testing FSRM directory quotas");

            Console.WriteLine("New file added. Quota doubledrn{0} of {1} used.", quota.QuotaUsed, quota.QuotaLimit);

        }

    }

}

 

This sample doubles the size of the directory’s quota and puts a file in it every time it is run.

There are a bunch of other classes and methods available. Have fun!