Design and implement a template engine – part 1

Recently, I got a task which is typical in many systems: Template with merge fields. The common usage is for email.

Given that an employee is created, the system will notify the manager by email with template:

Dear Manager,

New employee {Name} has been created on {DateTime.Now}.

From the above statement, we have template with 2 merged fields: Employee Name and Created Date. There are some solutions. But I name the old way of doing it here for reference:

Replace merge fields using string.Replace or Regex.

You can imagine it and how to do it. Or you event did it some times.

A better approach: Take advantages of Razor Engine.

The template will be in razor syntax

Dear Manager,

New employee @Model.EmployeeName has been created on @DateTime.Now.ToString(“s”).

In the next post, I will discuss about implementation.

Things i should pay attention and improve immediately

There are so many tittle but important things that I have not paid any attention to for 30 years. For the past couple of months, I started reading more books about self-improvement, and due to the fact that I am father of my daughter, and I want to be a good father, a good husband. I started to look around for improvement.

In this post, I will just list out all the things I want to improve. And for each section, I plan to write many posts about it.

Personal lifestyle

  1. Keep on gym exercise, focus a lot on running
  2. Improve sitting posture. I am a developer but I created a very bad posture which hurts me a lot in long term
  3. Read more book

Career

  1. Expand knowledge to other area such as: Node.js, ReactiveUI, ReactiveX (Rx). Can be anything, will design later
  2. Focus time for business, work smart and hard with 180-200 hours/month

Family

It is the most important thing. I place it last since I do not want to change it or to emphasize it. It is a fact. I always want to create a fun – healthy – wealthy family. All my goals, my plan, my to-do are for it.

Get started – again

It has been a while I have not written anything. And I almost forgot that I do have a blog. Fortunately, from this August, I set some big goals for my life, targeting in next 2 years. As I learn from “Getting things done”, I better write them down and get started. Goals are not goals without writing them down.

Here they are:

  1. Work for 180-200 hours per month
  2. Running 5 KM within 30 minutes
  3. Spend time with my family – this is always a priority for me
  4. Improve English – just by writing blog is a good way and a good start
  5. Quit smoking completely (I have done this at the time of writing, I have not smoked for 3 weeks)

I love drinking and I love hanging around with friends. To archive those goals, things will have a slightly change. I need time and power for my week days. Therefore, here are rules:

  1. No drinking in the week days, except: wedding party
  2. Drink only on Friday, Saturday nights
  3. Avoid drink on Sunday (can drink but not much). The purpose is to have energy for next week.

Azure Continuous Delivery with Visual Studio Online

Last week, I had a project which uses Visual Studio Online and deploys the services to Azure cloud service. The deploy structure of the project is that, we have 3 versions: Test, Demo and Production. They all share the same codebase, just different in the configuration file.

Following this article http://www.windowsazure.com/en-us/documentation/articles/cloud-services-continuous-delivery-use-vso will easily setup the integration between Azure service and Visual Studio Online. However, as a newbie in this Azure, Deploy world I had trouble with making it work. Simply, the build was ok but the deployment was not. After some tries, I finally managed to make it work. Someone out there might have the same issue, or fighting with getting it work. I post my experience here, so hope It helps.

Have a look at this link (Image): http://screencast.com/t/01tqq0j7

In Deployment setting:

  1. Path to Deployment Setting: Path to the Publish profile you have when you created the Deployment Azure project
  2. Window Azure Deployment Environment: Auto filled when Azure cloud service and Visual Studio Online link together.

In Build section:

Make sure you point to the solution file. The solution file must contains ONE Azure Deploy project only. It seems not possible to deploy to 3 Azure Cloud Services in one single solution file. So I just made one for each.

Another notice: make sure the deployment project references ONLY to the Azure Role project.

MVP – Microsoft Vietnam Community

Last week, i had a change to take part in a community diner event, held by Microsoft Vietnam. It was so amazing. It was really a normal talk between us, which made us comfortable. It was the first meet of new Microsoft – related worker. The goal is to build up a community in Vietnam through the MVP – Most Valuable Professional program.

I knew this program for long time; however, i did not care about it for some reasons. Now, there is a program in Vietnam started by Microsoft Vietnam. I care. I want to be in this program.

I got a form to fill in and sent back to register. By doing that, i confirm that i will do more to get that MVP. Easy? No. Some ideas came in my mind:

  1. Need to move the blog to my own – Buy a new domain and host blog.
  2. Figure out what i should focus on – technical stuffs.
  3. Plan for community contributions.

Step by step.