Monday, December 29, 2008

VM Ware Server 2.0 Experience

I have been doing a lot of virtualization in the past 2 months or so. The engine of choice so far is VM Ware. Microsoft also has a virtualization engine called Virtual PC - I have never used it, but a lot of people that I know use VM Ware, so basically I just follow suit. Maybe when I have a chance to play around with Virtual PC, I will write a blog post comparing them against each other.

What I want to highlight in this post is some of the tips and tricks that got mine to work as I needed. Your needs may differ, but hopefully some of these are generic enough that they can still be helpful.

VM Ware Server site: http://www.vmware.com/products/server/

When you click download, you will need to fill in a form to get your key. It is free, so go ahead and fill in the form and the instruction to get the key will be emailed to you. Once you get the downloaded file, run it to execute the installation procedure.

Installation is pretty straight forward - just follow the instruction provided by the installer. At some point, you will be required to enter a license key - this is the key you got from the registration process.

Once the installation is done, usually it will create a shortcut on your desktop called "VMWare Server Home Page". This is the main executable that will launch the interface for VMWare Infrastructure interface. When you run it (by double clicking it), it will open a browser (whatever browser set to be the default) and there are 3 things that you will typically see.

1. There is a problem with this website's security certificate.
If you get this screen/page, all you need to do is to click on the second link on the page that says "Continue to this website (not recommended). "
Then on the next screen you will get a login screen. This is a login to the VMWare Infrastructure interface - you can login using the username and password that you use to login to the computer. So if you login to the computer using "myname" and with password "mypassword", then you use the same username & password to login to this VMWare web interface.
If your machine is in the domain, you do not need to include your domain name in the login process. So instead of login with DOMAIN\username, just use "username".






2. Internet Explorer cannot display the webpage.
If you get this screen when you open the VMWare Server Home Page, I will check several things: a) Is the URL correct? b) Is the port number correct? c) Is VMWare Host Agent service running? You can check this in "Services", located in Administrator Tools under Control Panel. If this service does not exist, you will need to reinstall VMWare Server. If it is there and not running, you need to start it. Once it is started, close all browser with VMWare stuff in it, and try again.
Also keep in mind, in FireFox or other browsers, it may look different.

3. VM Ware also has this tool that's called VM Ware Converter 3.0. This is a very useful tool to convert your physical PC into a VM or vice versa. It also allows you tp change the configuration of your VM by cloning it. The free version has limited functionality, but it should be able to do the things I mentioned above. The paid version has more robust functionality.

Related Posts:
How to Increase HD Space in a VM
Win XP 64 bit and VMWare Server
-- read more and comment ...

Tuesday, December 16, 2008

CSLA & ASP.NET MVC (part 3: Adding)

As I have mentioned previously in the last post, editing and adding is not that much different - one pulls an existing one and modify it with incoming data, the other is just creating a new instance and filling it up with incoming data. We discussed "editing" in my last post, and now we are going elaborate on "adding".

First, let's take a look on the displaying of the empty form. This one is pretty easy, just get a new customer and bind it into the model as CurrentCustomer.


[AcceptVerbs(HttpVerbs.Get)]
public ActionResult New()
{

viewData.CurrentCustomer = Customer.NewCustomer();
viewData.CustomerList = CustomerInfoList.GetCustomerInfoList();
viewData.Titles = TitleInfoList.GetTitleInfoList();

return View("New", viewData);
}

We also want to bind the list of titles to be able to populate the drop down for title selection.

in handling the post, we are doing essentially the same thing as in edit, except this time we are mapping it to en empty object since it is a new one.
        [ActionName("New"), AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create()
{
try
{
Customer customer = Customer.NewCustomer();
UpdateModel(customer, new[]
{
"TitleId",
"FirstName",
"MiddleName",
"LastName",
"DOB"
});
customer.DateEntered = DateTime.Now;
customer.DateUpdated = DateTime.Now;

if (!customer.IsValid)
{
foreach (Csla.Validation.BrokenRule brokenRule in customer.BrokenRulesCollection)
{
ModelState.SetAttemptedValue(brokenRule.Property, brokenRule.Property);
ModelState.AddModelError(brokenRule.Property, brokenRule.Description);
}
viewData.Titles = TitleInfoList.GetTitleInfoList();
viewData.CurrentCustomer = customer;
return View(viewData);
}
else {
customer.Save();
TempData["Message"] = "I saved " + customer.LastName + " to the database";
return RedirectToAction("List", "Customer");
}
catch (Exception ex)
{
TempData["ErrorMessage"] = ex.Message;
return RedirectToAction("New");
}
}

So upon save, we want to display the confirmation message whether there is an error or the record is saved successfully. In the code above we also utilize CSLA rules validation - this is really useful in a way that we have a central place to put our format rules, business rules, validation at. If there is an error, we want to redisplay the new customer screen and if save is successful, we want to update the list with the current data.


Related Posts:
ASP.NET MVC, AJAX, jQuery
CSLA & ASP.NET MVC (part 1)
CSLA & ASP.NET MVC (part 2)
-- read more and comment ...

Saturday, December 13, 2008

CSLA & ASP.NET MVC (part 2: Editing)

In the last post, we discussed about listing viewing detail for objects built with CSLA framework via ASP.NET MVC. Now in this post, I will show the editing and adding of the object - in our example here, using "Customer".

In essence, editing and adding is not that much different - one pulls an existing one and modify it with incoming data, the other is just creating a new instance and filling it up with incoming data. In our code, we try to leverage CSLA as much as possible, where the "Save" method is called only when the object is "dirty". Another thing is that we also want to get as much as data validation within the CSLA object as possible rather than manual/custom checking in our controller.

First, editing.

        [AcceptVerbs(HttpVerbs.Get)]
public ActionResult Edit(int id)
{
viewData.CurrentCustomer = Customer.GetCustomer(id);
viewData.Titles = TitleInfoList.GetTitleInfoList();
return View("~/Views/Customer/Controls/CustomerEdit.ascx", viewData);
}

The method Edit is tagged with "AcceptVerbs" attribute and scoped to only accept "Get" request. What this means is that this method can and will only be executed during a GET. Scott Guthrie has an excellent post regarding this attributes in his blog - I suggest for you to check it out.
The rest of the code is pretty simple, get the Customer record that is selected (passed in as a Id parameter in the method), put the customer instance into my viewData, get the list of titles to populate my Titles drop down, and then pass the view data into the viewer - pretty straight forward.

Now, let's take a look at the handler code for edit submission/post - for when somebody hit submit on our edit form.
        [ActionName("Edit"), AcceptVerbs(HttpVerbs.Post)]
public ActionResult Update(int id)
{
try
{
Customer customer = Customer.GetCustomer(id);
UpdateModel(customer, Request.Form.AllKeys);
if (!customer.IsValid)
{
foreach (Csla.Validation.BrokenRule brokenRule in customer.BrokenRulesCollection)
{
ModelState.SetAttemptedValue(brokenRule.Property, customer.GetType().GetProperty(brokenRule.Property).GetValue(customer, null).ToString());
ModelState.AddModelError(brokenRule.Property, brokenRule.Description);
}
viewData.CustomerList = CustomerInfoList.GetCustomerInfoList();
viewData.Titles = TitleInfoList.GetTitleInfoList();
viewData.CurrentCustomer = customer;
viewData.ValidationErrorFlag = true;
return View("~/Views/Customer/Controls/CustomerEdit.ascx",viewData);
}
else
{
if (customer.IsDirty)
{
customer.DateUpdated = DateTime.Now;
customer.Save();
TempData["Message"] = "I saved " + customer.LastName + " to the database";
}
else
{
TempData["Message"] = "There were no changes to be made";
}
return null;
}
}
catch (Exception ex)
{
TempData["ErrorMessage"] = ex.Message;
return RedirectToAction("Edit", new { id = id });
}
}

OK, that seems long - so let's examine the code bit by bit so we can fully understand what is going on. If you notice, above the method name, there is also an "AcceptVerb" attribute, but this time it is set to "POST". Another thing is that it has ActionName("Edit") - which when combined with the AcceptVerb attribute, it will have the meaning that if there is an action "Edit" called on the controller with a POST, it will then get redirected into this method "Update".
        
try
{
Customer customer = Customer.GetCustomer(id);
UpdateModel(customer, Request.Form.AllKeys);
...

The 2 lines of code above, it is basically getting the Customer record being edited, and then call "UpdateModel" method, where it tries to match the instance of Customer called "customer" with the data submitted into the Request.Form.
                if (!customer.IsValid)
{
foreach (Csla.Validation.BrokenRule brokenRule in customer.BrokenRulesCollection)
{
ModelState.SetAttemptedValue(brokenRule.Property, customer.GetType().GetProperty(brokenRule.Property).GetValue(customer, null).ToString());
ModelState.AddModelError(brokenRule.Property, brokenRule.Description);
}
viewData.Titles = TitleInfoList.GetTitleInfoList();
viewData.CurrentCustomer = customer;
viewData.ValidationErrorFlag = true;
return View("~/Views/Customer/Controls/CustomerEdit.ascx",viewData);
}
...

Here we check whether the instance filled with data from the form is valid based on the rules specified in the CSLA rules. If it is not valid then iterate the broken rules collection and set the model marked with error messages appropriately. Now after the model is marked with the error, we want to display back the form with the model so the error messages can be displayed accordingly field by field. To do this, we then populate the Titles field in our viewdata back with list of available titles, and also populating our CurrentCustomer property with the edited customer, set the error flag and return the viewer for "Edit".
                else
{
if (customer.IsDirty)
{
customer.DateUpdated = DateTime.Now;
customer.Save();
TempData["Message"] = "I saved " + customer.LastName + " to the database";
}
else
{
TempData["Message"] = "There were no changes to be made";
}
return null;
}
...

If the instance does not violate any rules, then we can save if necessary. Even though CSLA will detect automatically whether the instance is dirty or not before saving to the database, but we chose to check in our controller so we then can display whether there are data being saved or not. Since there is nothing else needed to be done after the saving, we then return null value.


Related Posts:
ASP.NET MVC, AJAX, jQuery
CSLA & ASP.NET MVC (part 1)
CSLA & ASP.NET MVC (part 3)
-- read more and comment ...

Thursday, December 11, 2008

Jonathan is 3 years old - time flies!

Three years ago, early December was nervous time for me. Helen, my wife, was pregnant and the baby is due anytime. Jonathan was born Dec 10th 2005, 7am, @ Riverside hospital - 51cm, 7lbs 8oz. There were no complications, the delivery was smooth, and we went home being proud parents.


The first couple of months were rough. Helen sister stayed with us for the rest of the year and went home end of December. My mom came after that and stayed for 2 months to help us along. Jonathan loves his milk and he had no problem with food or milk. He had eczema on his cheeks which worried us for a bit, but after the 1st year and a half it pretty much went away. He started eating solid food at 4 months, and by that time, Jon could hold his own bottle. He was huge fir his age at the time - I believed he was in the 70-90 percentile back then.
Another thing we worried about back then was that Jon threw up a lot, especially when he was crying. This led us to eventually not allowing him to sleep by himself in the crib until he was almost 2 years old. Putting a humidifier in his room helps a lot too.

Jon started walking on his own when he was 11 months. I remembered that his first attempt to walk across the room in our living room was during a OSU-Michigan game (OSU won 42-39 - GO BUCKS!!). He was a fast walker and he was the type that cannot stay still - so we installed gates in our house to prevent him from going too far or going into unsafe rooms. Grandma and grandpa came during Jon's 1st birthday and we threw a party. Since the Buckeyes were going to National Championship that year, the theme for the party was "Buckeyes". Everybody came wearing scarlet or grey apparels. Even though Jon has not understand football yet at the time, but he was able to respond to "O-H" with an "I-O"! I was soo proud ...

Jon 1st birthday party!


Jon and his first snow ...


Jon's first haircut - done by mommy and daddy!


Halloween!

By the time Jon was 2 years old, he was talking Indonesian and English, sleeping on his own bed, ate all kinds of food, understand that OSU is the best, what an email is, how to chat to daddy, etc etc.

Jon's 2nd birthday party - can't wait to eat cake!

Yesterday was Jon's 3rd birthday - o how time flies. He is wearing bigger clothes now, brushes hi own teeth, talks in full sentences, ask the most difficult question I can ever imagined ("Why daddy has to go to work?"), loves staying in a cabin, etc. Jon loves his train set (me too) and looking forward to have it expanded. Taking pictures of Jon regularly also pays off big time.


BTW, Jon now has his own blog, written by mommy - http://jonathansetiabudi.blogspot.com, check it out.
-- read more and comment ...

Wednesday, December 10, 2008

CSLA & ASP.NET MVC (part 1: listing & viewing detail)

The easiest implementation for ASP.NET MVC is usually via LINQ to SQL. Now, for larger projects that must be scalable, one will need object development framework that is also scalable and more robust. My framework of choice CSLA.NET. Assuming you have built your CSLA classes, wiring it in with MVC is a piece of cake.

I recommend to make your view to be strongly typed to the object of your controller. So in my example, I have a CSLA class for "Customer" and also its corresponding read-only list, read-only item, editable, etc. Hence, I name my controller to be "CustomerController". In it, I created a class to carry around stuff as a single object, instead of stuffing everything in ViewData and cast when needed.

    public class CustomerControllerViewData
{
// list of read-only customer available to me
public CustomerInfoList CustomerList { get; set; }
// current editable customer seleted
public Customer CurrentCustomer { get; set; }
// list read-only Title available to the Customer
public TitleInfoList Titles { get; set;}
}

Then in the controller class, I declared a global variable to hold the instance of the CustomerControllerViewData class. I initialized it right away.
    public class CustomerController : Controller
{
CustomerControllerViewData viewData = new CustomerControllerViewData();

public ActionResult Index()
{
return RedirectToAction("FullList");
}
...
}

During list, I put all the necessary data into CustomerControllerViewData class, rest the validation, and then I pass that instance into the viewer as a strongly typed model. I do not fill in the CurrentCustomer property nor the Titles - since I won't be needing those to display my list of customers.
        public ActionResult List()
{
viewData.CustomerList = CustomerInfoList.GetCustomerInfoList();
viewData.ValidationErrorFlag = false;
return View("~/Views/Customer/Controls/CustomerListing.ascx", viewData);
}

The viewer looks like this - it should be pretty simple with the exception that it is strongly typed. So in the code behind, I have to add the type in the generic constructor of the viewer:
    public partial class CustomerListing : System.Web.Mvc.ViewUserControl
{
...
}

Now for viewing detail if a customer, we also do not need to fill out CustomerList property, since at this point we only care about a specific customer. Titles is needed since to populate a look up/drop down field.
        public ActionResult Detail(int id)
{
viewData.CurrentCustomer = Customer.GetCustomer(id);
viewData.Titles = TitleInfoList.GetTitleInfoList();
viewData.ValidationErrorFlag = false;
return View("~/Views/Customer/Controls/CustomerDetail.ascx", viewData);
}

Do the same thing for the code behind of the viewer to make it strongly typed:
    public partial class CustomerDetail : System.Web.Mvc.ViewUserControl
{
...
}


Related Posts:
ASP.NET MVC, AJAX, jQuery
CSLA & ASP.NET MVC (part 2)
CSLA & ASP.NET MVC (part 3)
-- read more and comment ...

Wednesday, December 3, 2008

New Nikkor!

By getting Nikkor AF-S 24-70mm f/2.8G, I have completed my Nikkor lenses line up that covers 17-200mm for FX (full frame) and 10-200 for DX (crop format). So now, my lens line up is consisting of these lenses:

  • Nikkor AF-S 17-35 f/2.8
  • Nikkor AF-S 24-70 f/2.8G
  • Nikkor AF-S 70-200 f/2.8G

Nikon has come up with Nikkor AF-S 14-24 f/2.8G and some people say that this lens is suppose to replace AF-S 17-35. I am not sure whether that is true or not, but since I bought my 17-35 before 14-24 came out and it still performs its job exceptionally well - then I am keeping it. I also have not tried 14-24 in person other than reading some reviews and seeing sample photos. Most people agree that 14-24 is one of Nikon's best - to the point even Canon people are looking for converted to be able to use with Canon cameras.

This is not a full spec detail review, but rather an experience based narrative. So I am going to write about my experience in using 24-70 for the last 1 month or so (I had it since early November). For the last month, I can say I use this lens almost exclusively - not because all my other lenses are bad - but because I have done mostly indoor shooting/photography. I took a lot of pictures of my son, thanksgiving parties, etc - and I can say that 24-70 is perfect for indoors.

Previously I usually use my 50mm f/1.4 AF-D or AF-S 18-200. If I use my 50mm, I can set it to f/4 and set my camera to A mode and be happy. If I am using multiple flashes, I set my camera to M mode and adjust exposure accordingly. My gripe with the 50mm is that it is not a zoom and also the speed of focusing is rather slow - so as a result I often missed some critical shot of my son acting funny.

I was not expecting that this lens will be so much faster in focusing - but apparently it is faster enough that I have more keeper than before. This lens is also very very sharp - even with normal sharpening setting in my camera, it produce a very sharp image - I would say that it is comparable to 50mm prime.

Compared to 18-200 is like night and day. Although 18-200 has its place as a travel lens, compared to 24-70, its flaws and compromised got exposed. The 24-70 is sharp wide open and stay sharp throughout the aperture range. The 18-200 is soft wide open and sharpest at f/6.3 - but even its sharpest is not comparable to 24-70 wide open.

The zoom ring of the 24-70 is also consistent and balanced, making it easy to zoom and compose - where 18-200 has zoom creep and imbalance zoom ring stiffness.

All in all, I am extremely satisfied with this new lens, AF-S 24-70 f/2.8G - worth every penny that I put into it.

-- read more and comment ...