Welcome

You have reached the blog of Keith Elder. Thank you for visiting! Feel free to click the twitter icon to the right and follow me on twitter.

TechEd Day 2

Posted by Keith Elder | Posted in .Net, Asp.Net, Smart Clients, Web Services | Posted on 07-06-2007

0

It is day two of TechEd and my feet and legs are killing me.  My feet didn’t get a chance to rest after the four day whirlwind tour of Disney World.  I told my wife that I was going to have to go to TechEd just so I could rest 🙂  Here is day two’s activities.

Biztalk WCF Adapter

The first session I attended this morning was an overview of the WCF Adapter for Biztalk which is in the R2 release.  Don’t get your hopes up just yet because it isn’t available.  I was told it  wouldn’t be out until 3rd quarter.  The good thing is the WCF adapters bring a lot of cool things to the table.  I can’t remember all the reasons they gave but the one that a lot of people will use is the ability to do TCP binary messages to Biztalk I am sure.  Actually there are seven WCF adapters, one for each binding type.  The demo they showed was a message from a smart client being sent to Biztalk, and then Biztalk hitting SQL Server and then another service.  The orchestration had to route the message and handle the transaction so if the write to SQL Server failed or the the other service failed then it rolled back the data in SQL Server.  Definitely a real world example and it shows the ability of WCF to handle transactions.   

Wondering Around the Expo

After the Biztalk session I was walking from the north building back to the south building and ran into Bruce Thomas at the MVP booth.  I also saw Joe Healy, Jeff Palermo, DonXML, Miguel Castro, and Joe Fuentes.  I then walked down and caught some of the “Speaker Idol” that Carl Franklin and Richard Campbell were hosting.  This was pretty cool and I wish I had heard about it sooner so I could have entered.  The way it works is a speaker gets up on stage and does a 5 minute presentation.  Then they get judged by a bunch of Regional Directors.  It is a really great way to get feedback about your presentation skills no doubt.  The big challenge is doing just a 5 minute talk!

Smart Client Applications in Visual Studio 2008

After lunch I went to a presentation on the new smart client features in Visual Studio.  Some of these are nothing new in terms of new information (linq and wpf) but they are technically “new” in 2008 and some are new exciting features.

Working With Data

LINQ is of course the new way to work with data in VS2008.  The demos they showed were just connecting to a database locally which isn’t a true Smart Client architecture in my opinion since it isn’t services based.  Nevertheless, LINQ is new in VS2008 and we’ll all love him, hug him and call him George.

Taking Data Offline

This is something that I hadn’t seen yet and it really peaked my interest since we have a lot of uses for it.  SQL Server Compact Edition 3.5 which is in beta right now will be available to us.  You can read about the new features here.  The nice thing about 3.5 is it can be deployed with your application through ClickOnce and it doesn’t run as a service.  It also supports about 2-4 GBs of data which should be PLENTY for any application that needs to run offline.  The other piece is the Sync Agent which is tasked with the joy of keeping data in sync.  As soon as they said this I immediately thought “Smart Clients shouldn’t connect to the database directly” and as soon as I thought that the presenter said it supports sync via services.  Hotness! 

User Profiles

Something else that is new is Client Application Services.   Today web applications can store user profile information which is used for themes, preferences and so on but it is tough for Smart Clients that are service enabled.  Client Application Services allows us to reuse the existing profile and role based mechanisms Asp.Net offers today to allow us to centrally store profile information.  This may not sound like a big deal but today we have to create a lot of plumbing in Smart Clients to store application preferences and profile information away from the client’s desktop machine.  Storing preferences on the desktop machine doesn’t allow users to move from machine to machine and have the application setup the same way. Client Application Services fixes this by leveraging existing functionality so this will be good.  There will be a new services tab when you right click on properties on your project.  In the services tab you point to a web server which will hold the profile settings and any settings you create in your app are stored and retrieved from there. 

User Experience

Another new feature in VS2008 is going to be WPF.  They call this the “user experience” but a lot of us already know about WPF.  This will change how we build Smart Clients no doubt but we’ve been hearing about WPF since 2005 so nothing to see here.  Moving on.

Deployment

In VS2005 we got a new deployment technology called ClickOnce.  In VS2008 ClickOnce doesn’t go away, it just gets enhanced.  There are six new enhancements to it but the one I like the best is the ability to change the deployment URL and not have to rebuild the entire manifests.  I didn’t write them all down but there was something mentioned about ISV branding in ClickOnce in VS2008. 

Reusability – Acropolis

This was the new bomb shell that was dropped called “Acropolis”.  Acropolis is a framework that simplifies building composite clients and will replace the Smart Client Software Factory moving forward.  Bryan Adams just blogged about this on June 4th so read his initial post if this is your first time to hear about it (just remember you heard it hear first 🙂 ).  After you read that, read this one with more questions and this one with additional information including video and live docs.

Certification Study Hall

After the what’s new in Visual Studio 2008 I went to the certification center where I started practicing some certification exams.  At TechEd you can take certification exams for $50 here onsite as well as go through tons of test questions.   I studied until I just about fell asleep and then rolled to the hotel.  Day two is now in the books.

Day of .Net Ann Arbor – I killed the projector

Posted by Keith Elder | Posted in .Net, Smart Clients, Speaking | Posted on 06-05-2007

2

Yesterday was the Day of .Net hosted in Ann Arbor.  It was great to see tons of people I haven’t seen in years.  I went to several talks including Dustin Campbell’s talk on Reflection.  I learned more about reflection during Dustin’s talk than I ever wanted to know.  I also went to Dan Hibbitts talk on Mobile Software Factory.  Rounding out the day I went to Mark Miller’s talks on WPF and WPF/WCF.  I have to hand it to Mark, he did a really good demo of WPF and WCF whereby he built a hockey game whereby one could be the server and the other the client.  Moving the mouse on one application moved it on the other.  From the gaming industry standpoint this is nothing new since network games have done this for awhile.  However, it was a great WPF and WCF demo to show tcpBinary messages being sent from application to application. 

As Dan has already vocally exclaimed on my other post I killed the projector during my talk.  My talk was scheduled during the last session of the day and I was ready.  What I wasn’t ready for is about 45 minutes into the session, right before I got into the really cool demos of deploying the application using ClickOnce, I kicked the power cord out of the socket and took down the projector.  If you know projectors at all you know they don’t like being shut off without warming down so essentially I took the projector out for the remaining of the talk.  Let me apologize to everyone for robbing you of what was going to be the best most well thought out earth shattering demo you would have seen the entire day.  🙂 

For those that are in the area I promise to makeup for it Wednesday when I speak at the Ann Arbor .Net User Group.

.Net Engineer Openings – Those Who Have Passion Need Apply

Posted by Keith Elder | Posted in Asp.Net, Smart Clients | Posted on 20-02-2007

2

If you’ve been waiting for the right job to come along, specifically a job opening at one of the top companies in the country, your wait is officially over.   If you are passionate about programming and designing large scale Enterprise systems where you get to have a direct impact on the business, we need you!

We have several .Net Engineer openings available at my current employer Quicken Loans.  You can’t be considered if you don’t apply and you won’t get preferential treatment with your resume if you don’t contact me directly!

We have openings in several different areas and need people who have skills in all sorts of areas including Asp.Net, Smart Clients and back-end people with certain talents ( Biztalk, Workflow, WCF, etc).  The great thing about these positions is you will become part of a team who loves to automate business practices, embrace industry standards, embrace change and adopt early.  You’ll be given all the tools you need to succeed as well as a culture that is unlike any you’ve probably seen. 

If you would like my email address run this code in a console application, or guess the output. 

using System;

using System.Collections.Generic;

using System.Text;

 

namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            Email myEmailAddress = new Email();

            myEmailAddress.Prefix = “keith”;

            myEmailAddress.Connector = “@”;

            myEmailAddress.Domain = “keithelder.net”;

            Console.WriteLine(myEmailAddress.ToString());

            Console.ReadLine();

        }

    }

 

    class Email

    {

        private string prefix;

 

        public string Prefix

        {

            get { return prefix; }

            set { prefix = value; }

        }

 

        private string connector;

 

        public string Connector

        {

            get { return connector; }

            set { connector = value; }

        }

 

        private string domain;

 

        public string Domain

        {

            get { return domain; }

            set { domain = value; }

        }

 

        public override string ToString()

        {

            StringBuilder sb = new StringBuilder(3);

            sb.Append(this.prefix);

            sb.Append(this.connector);

            sb.Append(domain);

            return sb.ToString();

        }

 

    }

}

 

Slides and Demos From CodeMash Presentations

Posted by Keith Elder | Posted in Presentations, Smart Clients | Posted on 21-01-2007

0

If you attended my sessions and are looking for the demos along with the powerpoint slides you’ll find them here:

http://keithelder.net/Presentations/DevelopingSmartClientAppsForEnterprise/default.aspx

If you are one of the attendees that is new to .Net then download Visual Studio Express which is a free download that will allow you to open the solutions to run the demos.  Everything else you need to get up and running is listed in the presentations page.

Technorati tags:

WinForm Programming: Send Email Using Outlook Interop or System.Diagnostics.Process

Posted by Keith Elder | Posted in .Net, Programming, Smart Clients | Posted on 11-01-2007

14

A lot of applications generate emails to alert users or send out notifications.  If you do WinForm programming the need to generate email from your application is something you will probably come across at one point or another.  There are essentially two ways I use to generate emails from WinForms or Smart Clients.  One is using the Outlook Interop and the other is simply starting a process using the System.Diagnostics.Process class.  Each has their own merits.  Depending on why you are generating an email from your application will ultimately determine which method you should use.  For starters, let’s take the easy road and start with the Process class.

Using System.Diagnostics.Process To Generate Emails

If you aren’t familiar with this namespace the purpose of it is to provide the .Net developer with a means to access processes running on the local computer.  It can also be used to start processes as well. 

Using this class we are going to borrower something from our HTML friends.  The “mailto” tag has been around forever and we can utilize this tag to start a new process.  The idea is that whichever mail client is setup as the default mail client, a process will be started to create a new email message.  The result is no different than clicking a mailto tag in a web browser.  The code for this is simple, only a few lines.  Since the process class implements IDisposable we are going to use the using construct to assist in disposing of the process once it is done.  Here’s the code.

            using (Process process = new Process())

            {

                process.StartInfo.FileName = “mailto:me@foo.com&subject=Hello”;

                process.Start();

            }

As you see in the above example, the “mailto” tag is used as the FileName property.  A new process is going to start and launch a new email message screen for the user with the email address of me@foo.com already entered and the subject “Hello”.    Here is the sample application running:

When the LinkLabel named “Send Email Without Outlook API” is clicked, it launches the default email client on our computer and enters a To and a Subject for us automatically.  Nothing fancy or ground breaking but it works.

System.Diagnostics.Process vs Outlook Interop

As we see above sending emails from our WinForm application with the Process class is very simple.  Why would we want to go through the trouble of using the Outlook Interop to send emails?  Won’t the above example work for any Windows computer no matter which email client the user has running, so isn’t that more flexible?   The answer is yes.  This solution will work on any Windows computer launching whatever the configured default email client is.  However, what if you need to log what the user wrote in the email?  This is where System.Diagnostics.Process falls down.

Let me expand on this.  Say for example you have a CRM application that needs to log emails sent by users to your clients or contacts or customers (whatever acronym you adopt).  Even though your user’s will have the message saved in their Sent folder in Outlook having it just in their email client doesn’t easily give the users of your CRM a quick view of activity.  You may also have auditing rules in your business requirements whereby you need to save the first 500 characters of each correspondence sent to client.  Using the Process example above doesn’t allow us to intercept the message so we have access to the complete message being sent.  However, using the Outlook Interop API we can keep track of everything as well as log the email to suite our business requirements. 

Let me go ahead and get this out of the way.  Yes this does require you to be in a controlled environment.  Most corporate and enterprise networks are controlled and you’ll know if this approach will work for you in your business. 

Using Outlook Interop To Generate Emails

To get started using the Outlook Interop we first need to add the required DLL to our solution. In order to do this, right click on Add References in your solution and select the COM tab.  Scroll down about half way and select the Microsoft Outlook 11.0 Object Library.  Add this as a reference to your project. 

Once you add the required DLL to your project you are ready to start coding for the API.  One of the things I like to do is create wrapper classes for these interop classes that allow me to call them when I need them with just a few lines of code.  Here is an example of a wrapper class. 

using System;

using System.Collections.Generic;

using System.Text;

using OutlookApp = Microsoft.Office.Interop.Outlook;

 

namespace Common.Outlook

{

    /// <summary>

    /// Provides functionality so Outlook can be used to generate Emails.  Use the

    /// write event to log the email.

    /// <example>

    /// Email outlookMsg = new Email();

    /// outlookMsg.Message.Subject = “Foo bar”;

    /// outlookMsg.Show();

    /// </example>

    /// </summary>

    public class Email

    {

        /// <summary>

        /// Gets the current instance of Outlook

        /// </summary>

        OutlookApp.Application _outlookInstance = new Microsoft.Office.Interop.Outlook.Application();

 

        private OutlookApp.MailItem _message;

        public OutlookApp.MailItem Message

        {

            get

            {

                return this._message;

            }

            set

            {

                this._message = value;

            }

 

        }

 

 

        /// <summary>

        /// Constructor, gets current outlook instance

        /// and creates a blank email message

        /// </summary>

        public Email()

        {

            Initialize();

        }

 

        private void Initialize()

        {

            // create a blank email

            _message = (OutlookApp.MailItem)_outlookInstance.CreateItem(OutlookApp.OlItemType.olMailItem);

 

            // wire up the write event for logging

            _message.Write += new Microsoft.Office.Interop.Outlook.ItemEvents_10_WriteEventHandler(Message_Write);

        }

 

        /// <summary>

        ///  Used for logging after the end user presses the send

        ///  button in Outlook.  If you need to log the email that was

        ///  sent to a web service or something else, fill this in.  This is

        ///  called after the email is sent via Outlook.

        /// </summary>

        /// <param name=”Cancel”></param>

        void Message_Write(ref bool Cancel)

        {

          // ADD LOGGING HERE IF YOU NEED IT

        }

 

        /// <summary>

        /// Displays the outlook screen and shows the email message.

        /// </summary>

        public void Show()

        {

            _message.Display(false);

        }

    }

}

 Using the code above we can now enable the first link in our sample Email form above.  To create an email with Outlook it is now a few lines of code.

Common.Outlook.Email msg = new Common.Outlook.Email();

msg.Show();

Since we have access to the Outlook message we can set the Subject, To, CC, BCC, Format and other options.  We get a lot more control over our email message than with just by starting a process.  Here is a more fleshed out example.

            Common.Outlook.Email outlookEmail = new Common.Outlook.Email();

            outlookEmail.Message.To = “me@foo.com”;

            outlookEmail.Message.CC = “me2@foo.com”;

            outlookEmail.Message.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatPlain;

            outlookEmail.Message.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;

            outlookEmail.Message.Body = “I love cookies!”;

            outlookEmail.Show();

 Will create the following:

The other thing using the Outlook Interop allows us to do is log the messages as noted earlier.  To do this we would add our business requirements into the Message_Write event.   In this event we have access to lots of information including a real sent time, the complete body, what importance was set, the subject and so on.  Obviously any property exposed in the API we can still reference.  This gives us a way to log the information via a database, web service or other means.

Like this story?  Then kick it on DotNetKicks.com