Tuesday, October 17, 2006

3084.aspx

Microsoft Italy Innovation Tour

Microsoft Italy is hitting the road this winter with the Starting Innovation Tour:



  • Tuesday: dedicated to partners

  • Wednesday: dedicate to developers, IT professionals, OEMs/System builders

  • Thursday: dedicated to companies, professionals,  schools and public offices.




Each day is split in multiple tracks. The developer day, for example, has three parallel tracks:



  • TechNet track for IT professionals

  • MSDN track for developers

  • OEM/System Builder track

The show hits Milano in late November and I will attend the MSDN developer track. See you there?

3080.aspx

Free automatic contact dialer for the Pocket PC

I have just made the poDialer available in the download section.


poDialer is a very simple application that I wrote for some colleagues a while back. It lets you call many contacts after another. It integrates with the contacts in Pocket Outlook using the POOM .NET CF library to display the list of contacts with at least one phone number:


The POOM library makes it a snap to get the contacts:


const int LOAD_STEPS = 10;  // Number of updates/steps on the progress bar            
// Log in to Pocket Outlook
_pocketOutlook = new PocketOutlook.Application();
_pocketOutlook.Logon();

PocketOutlook.Contact contact;
lbAllContacts.Items.Clear();
PocketOutlook.ItemCollection allContacts = _pocketOutlook.GetDefaultFolder(
(int) FolderType.olFolderContacts).Items;
// Show progress bar
// Setting the progress for each contact is expensive if we have many contacts
//
so we only show LOAD_STEPS steps on the entire progressbar
progressLoad.Visible = true;
progressLoad.Minimum = 0;
progressLoad.Maximum = LOAD_STEPS ;
int loadFactor = allContacts.Count / LOAD_STEPS;
_contacts = new Contact[allContacts.Count];
int contactsWithNumber = 0;
for (int i = 0; i < allContacts.Count; i++)
{
    if (i % loadFactor == (LOAD_STEPS -1 )) progressLoad.Value++;               
    contact = (PocketOutlook.Contact) allContacts.Item(i + 1);    // 1 based
    // We add contacts with at least one phone number
    if (contact.BusinessTelephoneNumber.Length > 0 ||
        contact.MobileTelephoneNumber.Length > 0)
    {
        lbAllContacts.Items.Add(contact.FileAs);
        _contacts[contactsWithNumber++] = contact;
    }
}
// Log off from Pocket Outlook
_pocketOutlook.Logoff();

The details of each contact is displayed and it lets you choose the number to dial (business or mobile).


Very basic with big buttons. It may be ugly but it is handy as you can control it with a finger instead of having to use a stylus. No need to install; just copy the .EXE and .DLL to the device or a SD Card.

3077.aspx

poDialer

poDialer is a very simple application that I wrote for some colleagues a while back. It lets you call many contacts after another. It integrates with the contacts in Pocket Outlook using the POOM .NET CF library to display the list of contacts with at least one phone number:


The POOM library makes it a snap to get the contacts:


const int LOAD_STEPS = 10;  // Number of updates/steps on the progress bar            
// Log in to Pocket Outlook
_pocketOutlook = new PocketOutlook.Application();
_pocketOutlook.Logon();

PocketOutlook.Contact contact;
lbAllContacts.Items.Clear();
PocketOutlook.ItemCollection allContacts = _pocketOutlook.GetDefaultFolder((int) FolderType.olFolderContacts).Items;
// Show progress bar
// Setting the progress for each contact is expensive if we have many contacts so we only show
// LOAD_STEPS steps on the entire progressbar
progressLoad.Visible = true;
progressLoad.Minimum = 0;
progressLoad.Maximum = LOAD_STEPS ;
int loadFactor = allContacts.Count / LOAD_STEPS;
_contacts = new Contact[allContacts.Count];
int contactsWithNumber = 0;
for (int i = 0; i < allContacts.Count; i++)
{
    if (i % loadFactor == (LOAD_STEPS -1 )) progressLoad.Value++;               
    contact = (PocketOutlook.Contact) allContacts.Item(i + 1);    // 1 based
    // We add contacts with at least one phone number
    if (contact.BusinessTelephoneNumber.Length > 0 ||
        contact.MobileTelephoneNumber.Length > 0)
    {
        lbAllContacts.Items.Add(contact.FileAs);
        _contacts[contactsWithNumber++] = contact;
    }
}
// Log off from Pocket Outlook
_pocketOutlook.Logoff();

The details of each contact is displayed and it lets you choose the number to dial (business or mobile).


Very basic with big buttons. It may be ugly but it is handy as you can control it with a finger instead of having to use a stylus. No need to install; just copy the .EXE and .DLL to the device or a SD Card.

Monday, October 16, 2006

3075.aspx

Everyone wants our code

I have lost of how many sites wants to host our code;



Looks like the next battleground will be code search.


Google is catching up with others like Koders and CodeKeep that have been around for a while. But once again Google does what it does best; Google Code Search delivers relevant search results fast. Krugle, on the other hand, has a lot richer interface for viewing the code. Great if you are looking for information on how to use a particular API in context but I still prefer the speed and accuracy of Google. The results page are a bit spartan as you can only see a three lines of code which is pretty useless when you results like this;



//
// System.Net.CookieCollection
//


I found the result above while searching "CookieCollection" on the various code search engines as I am looking for Cookie and CookieCollection implementations for .NET Compact Framework. I have considered implementing a Gmail notifier for the Pocket PC  for a while but the lack of cookie support by .NET CF makes it a pain. I know, cookies are only HTTP headers, but the Gmail API makes heavy uses of the cookies so I have to make significant changes to the API. I tried the usual resources like OpenNetCF.org which has come to the rescue several times in the past. But, but this time, the winner is Google Code Search as it found the Mono source code for System.Net.Cookie in the Gentoo distribution.


I also found the documentation I need on MSDN for writing Today Screens plugins in .NET CF so now the only thing I need is time.
Please let me know if you have any to sell :-)

3073.aspx

Free event: workshop on Microsoft SQL Server 27/10 in Milano

Microsoft organizes a free workshop 27/10 on SQL Server in Milano that covers;



  • The Storage Engine

  • Index design

  • Stored procedures

  • Data modeling and DB design

Thanks for the tip Michele


See you there?

Monday, October 2, 2006

3062.aspx

How to implement a JavaScript eval function in c#

I recently needed a javascript like eval() function for a .NET project. I didn't feel like porting JPLite so I googled a bit until I found this gem that saved my day: An Eval Function for C# using JScript.NET (JavaScript)


It shows how to use the out of the box .NET libraries to implement a eval() function using JScript.NET. The code works but it is not thread safe. With some minor adjustments you get this neat boolean evaluator function (comments and error management removed to save space):



using System;
using System.CodeDom.Compiler;
using System.Reflection;
using Microsoft.JScript;
 
namespace  JavaScript
{    public class Evaluator
    {
        private static Type _evaluatorType = null;
        private static readonly string _jscriptSource = 
            @"package Evaluator
                {
                    class Evaluator
                    {
                        public function Eval(expr : String) : String 
                        { 
                            return eval(expr); 
                        }
                    }
                }";
 
        static Evaluator()
        {
            ICodeCompiler compiler;
            compiler = new JScriptCodeProvider().CreateCompiler();
 
            CompilerParameters parameters;
            parameters = new CompilerParameters();
            parameters.GenerateInMemory = true;
 
            CompilerResults results;
            results = compiler.CompileAssemblyFromSource(parameters, 
                                 _jscriptSource);
 
            Assembly assembly = results.CompiledAssembly;
            _evaluatorType = assembly.GetType("Evaluator.Evaluator");
 
        }
 
        // ...
        public static bool EvalToBoolean(string statement)
        {
            string s = EvalToString(statement);
            return bool.Parse(s);
        }
 
        public static string EvalToString(string statement)
        {
            object o = EvalToObject(statement);
            return o.ToString();
        }
 
        public static object EvalToObject(string statement)
        {
            object evaluator = Activator.CreateInstance(_evaluatorType);
            return _evaluatorType.InvokeMember("Eval", 
                    BindingFlags.InvokeMethod, null, evaluator, new object[] 
                                                          { statement } );                
        }
    }
}




Example usage:


System.Console.Out.WriteLine("1==1 : {0}", 
        JavaScript.Evaluator.EvalToBoolean("1==1"));
System.Console.Out.WriteLine("'abcd'.indexOf('c') : {0}", 
        JavaScript.Evaluator.EvalToString("'abc'.indexOf('c')"));

Output:


1==1 : True
'abcd'.indexOf('c') : 2


I spend most of my time working with Java these days and I keep banging my head against the wall regarding the a lack of decent multi-threading features. It is true that there are a lot of open source libraries out there that helps but why re-invent the wheel or go crazy integrating 3rd party libraries when you get all the features you need out of the box? Don't get me wrong; I have a lot of fun with Java but once in a while I miss my C#...


(Edited for layout issues on small screens)