0 Comments
Ditto is a great model mapper for Umbraco. It automatically map the properties to the object class properties which allows user to use strong-type object in the code. The idea behind the model mapper is to use reflection and custom attributes to map object for simple type properties (i.e. string, int etc). If you are not familiar with custom attributes, you can read a great article here. For a complex type (i.e. JObject), You can create a custom type converter to map the properties. However, the issue I was having is when converting the JObject into the class which has the custom type converter .

Issue:


I have a class with custom type converter LinkPickerTypeConverter

[TypeConverter(typeof(LinkPickerTypeConverter))]
public class LinkPicker
{
/// <summary>
/// Gets or sets the id.
/// </summary>
public int Id { get; set; }

/// <summary>
/// Gets or sets the name.
/// </summary>
public string Name { get; set; }

/// <summary>
/// Gets or sets the url.
/// </summary>
public string Url { get; set; }

/// <summary>
/// Gets or sets the target.
/// </summary>
public string Target { get; set; }
}

In LinkPickerTypeConverter,I need to covert JObject to Link Picker. So I used the ToObject method to convert. i.e. json.ToObject<LinkPicker>();

However, because NewtonJson is using Type converter which is overwritten by my custom type converter, which causing the failing when covert JObject to the class.

Solution:


For walk around the issue, I just change ToObject method with Deserialize of JavaScriptSerializer.

var serializer = new JavaScriptSerializer();

serializer.Deserialize<LinkPicker>(value.ToString());

I figured out another better solution by dynamically assigning the JsonConverter.

TypeDescriptor.AddAttributes(typeof(LinkPicker), new TypeConverterAttribute(typeof(JsonConverter)));

After this, you can use ToObject method to convert the JObject to the custom class. i.e. value.ToObject<LinkPicker>();

0 Comments
Setup Octopus

The example contains two processes:
1. Deploy
2. Send email

Follow the settings below for your Deploy process

Settings
Value
Comment
Step NameDeploy Git-Test To Develop
Targets / Machine rolesiis7 iis8
Package / NuGet feedOctopus Server(built-in)
Package / NuGet package IDGit-Test.Dev

Custom install directory

#{Server.webroot}\#{Server.sitename.develop}i.e e:\www\demo\
Configuration variablesReplace appSettings and connectionString entries in any.config files
Configuration transforms / XML transformsAutomatically run configuration transformation files
Configuration transforms / Additional transforms#{Octopus.Environment.Name}.config
IIS WebSite / Web SiteCreate or update an IIS Web Site and Application Pool
IIS WebSite / Web Site Name#{Server.sitename.develop}(Site name in IIS) i.e. demo.dev.localhost
IIS WebSite / Relative home directory#{Server.webroot}\#{Server.sitename.develop}Website folder
IIS Application Pool/ Application Pool Name#{Server.sitename.develop}i.e. demo.dev.localhost
IIS Application Pool/ .NET CLR versionv4.0
IIS Application Pool/ IdentityNetwork Service
IIS Bindings
  • Protocol: http
  • Port: 80
  • Host: #{Server.binging.develop}
i.e. demo.dev.localhost
IIS AuthenticationEnable Anonymous authentication
Environmentsdevelop.localdev

Variables
Name
Value
Email.Notificationswalle.z.yuan@gmail.com
Server.binding.developgit-test.dev.localhost
Server.sitename.developgit-test.dev.localhost
Server.webroote:\demo\git-test

0 Comments
This Date format issue I am going to talk about is in WebForm for marketers module 2.4. for Sitecore. Recently, a client reports the date format of datepicker is incorrect.

By looking into that, I found there literally has three different issues/things we need to understand, before we can make the datepicker formatting work.

First issue
Parameters for datepicker called "DateFormat" is always overwritten when it gets initial. For example, the parameter the client configured in the form is <DateFormat>dd-MM-yyyy</DateFormat>. and then it gets overwritten as "yy-mm-dd".

Second issue
It's related to the parameters, take the above example that <DateFormat>dd-MM-yyyy</DateFormat>. Initially I thought dd-MM-yyyyis the format. However, it is not. It is the Item Name of a Date Format item in sitecore. the the format that datepicker applied is the value of that Date Format Item.

Third issue
Due to the fact that the datepicker is using JQuey datepicker, the date format is different from the standard date and time format defined by Microsoft. the Jquery datepicker format is as below

$.datepicker.formatDate( format, date, options )

Format a date into a string value with a specified format.

The format can be combinations of the following:

  • d - day of month (no leading zero)
  • dd - day of month (two digit)
  • o - day of the year (no leading zeros)
  • oo - day of the year (three digit)
  • D - day name short
  • DD - day name long
  • m - month of year (no leading zero)
  • mm - month of year (two digit)
  • M - month name short
  • MM - month name long
  • y - year (two digit)
  • yy - year (four digit)
  • @ - Unix timestamp (ms since 01/01/1970)
  • ! - Windows ticks (100ns since 01/01/0001)
  • '...' - literal text
  • '' - single quote
  • anything else - literal text

Conclusion
So, to walk around the issue that the client is having. I just update the value of the Date Format Item (as explained above, it will be always "yy-mm-dd" item) with the Jquery date format. i.e. d-mm-yy


References
1. https://api.jqueryui.com/datepicker/

0 Comments
  •   Posted in: 
  • IIS
To optimize SEO, the most common requirement is to redirect all non-www requests to www requests. i.e. redirect example.com.au to www.example.com.au. However, when you setup this 301 redirect in IIS, the querystring will be strip out. However, we can simply solve this by using IIS magic placeholder "$S$Q". For example, set the redirect destination to "www.example.com.au$S$Q".

So what $S$Q does?
IIS will replace $S with the subdirectory location i.e. /tickets and will replace $Q with querystring i.e. ?token=xyz

NOTE, you will need to tick the option "The exact URL entered above"

References:
[1] http://forums.iis.net/t/1170477.aspx?IIS7+passing+query+strings+or+URL+redirect
[2] http://www.developerfusion.com/code/4678/permanent-301-redirect-with-querystring-in-iis/

0 Comments
Microsoft, the operating system giant, has released their new version of operating system Windows 10 this week. Windows Fans has been disappointed at Windows 8, but now the new release become the hope. As claimed by Microsoft, the latest version was installed on 14 million devices in the first 24 hours (read more). I was just one of the millions of people, =P. This article is written for those who want to upgrade to Windows 10. It contains two sections 1. How to upgrade to Windows 10, 2. A quick review of Windows 10. Getting excited?

1. How to upgrade to Windows 10

Microsoft Windows 10 is Freefor upgrade, but it requests a minimum system requirements (the check the system requirements below or visit here). The Free upgrade offer is for a full version of Windows 10, not a trial. 3GB download is required, and to take the advantage of the offer, you must upgrade within one year of availability.

System requirements

Make sure that you are running on the latest version of either window 7 SP1 or Windows 8.1.

To reserve your fee upgrade, click on the Windows 10 icon located in the lower right side of the system tray. If you can't see the icon please try the following steps:
  • Open windows Update
  • Check any available required or recommended updates for your existing windows 7 / Windows 8
  • If it's still not appearing on your PC, please read this

Otherwise, you are good to reserve your upgrade.
  • Once you click the icon
  • Click reserve, you will see a Thank you page.
  • After that you don't need to do anything, Windows 10 will automatically download on your PC in background. To me, it approximately costed 2-3 days to make the Windows 10 be ready for upgrade. As claimed by Microsoft that your notification to upgrade could come as soon as a few days or weeks. So be patient .

2. A quick review of Windows 10

Now let's look at the exciting bit. The first impression after I upgrade to Windows 10 is the performance. Windows 8 kept the disk utilize rate at 100% all the time, and I tried many recommended solutions, however none of them was working for me. So I checked the performance again after it's upgrade, it was surprised that the disk utilize rate is dropped sharply.

Microsoft bring the Start Menu back!

In Windows 8, if you click the Start menu, it opens the matrix interface in full screen. Now Windows 10 brings back the popular Start Menu. Clicking the start button brings up a menu, which is not exactly the same as windows 7 or previous version, as it also enabled the matrix interface as a side menu, which is nice. I guess Windows 10 attempts to combine the best of Windows 7 with Windows 8. Not only the menu is back, but also the app interface is changed back to window mode. It's no longer a full screen app, but if you prefer to use a full screen mode, you can simply enable it in settings.
Brand new browser
Like most of you, I don't like IE at all. However, I noticed a brand new browser "Windows Edge" has been introduced with the release of Windows 10. Windows Edge has a simple and responsive interface with a few interesting features such as add a web note, reading list, cortana etc. This more than
enough for most of users, especially when Google chrome become a memory hog. As a developer, you might need more, this can be discovered, once you get there.


Thanks for your reading and hope will enjoy Window 10!

References
  • http://www.skynews.com.au/business/tech/2015/07/31/14-million-windows-10-installs-in-24-hours.html
  • http://www.microsoft.com/en-au/windows/windows-10-specifications
  • http://www.microsoft.com/en-au/windows/windows-10-upgrade
  • https://support.microsoft.com/en-au/kb/3081048