Pages - Menu

Setup NopCommerce in Development Environment

Download the source from NopCommerce

http://www.nopcommerce.com/downloads.aspx

Open the solution, set Nop.Web as default and build.

Capture4

In IIS, setup website and point to the Nop.Web folder.

Capture5
We need to change the App Pool to use .Net 4 under Advanced Settings.




Open the site in the browser and should see the following:-

Capture3

Go thru the wizard and we are done!!

Setup Jenkins on TFS 2008 for MSBuild project

Installation

Download TFS plugin from https://wiki.jenkins-ci.org/display/JENKINS/Team+Foundation+Server+Plugin

Download MSBuild plugin from https://wiki.jenkins-ci.org/display/JENKINS/MSBuild+Plugin

You may go to the jenkins-ci wiki page to download the plugin manually or it can be downloaded via Manage Plugin page, either way is fine.

Install plugin under Manage Jenkins.






Now TFS is available as an option in Source Code Management.



Plugin can also be found and installed by using the plugin manager.



Troubleshooting during installation


The following error maybe encountered if TF.exe is not installed or path to access TF.exe is not configured in Jenkins.
Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\jobs\XXX\workspace
[workspace] $ tf workspaces -format:brief -server:tfs.server.com ********
java.io.IOException: Cannot run program "tf" (in directory "C:\Program Files (x86)\Jenkins\jobs\XXX\workspace"): CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessBuilder.start(Unknown Source)
 at hudson.Proc$LocalProc.<init>(Proc.java:244)
 at hudson.Proc$LocalProc.<init>(Proc.java:216)
 at hudson.Launcher$LocalLauncher.launch(Launcher.java:773)
 at hudson.Launcher$ProcStarter.start(Launcher.java:353)
 at hudson.plugins.tfs.TfTool.execute(TfTool.java:99)
 at hudson.plugins.tfs.model.Server.execute(Server.java:47)
 at hudson.plugins.tfs.model.Workspaces.getListFromServer(Workspaces.java:38)
 at hudson.plugins.tfs.model.Workspaces.populateMapFromServer(Workspaces.java:50)
 at hudson.plugins.tfs.model.Workspaces.exists(Workspaces.java:76)
 at hudson.plugins.tfs.actions.CheckoutAction.checkout(CheckoutAction.java:36)
 at hudson.plugins.tfs.TeamFoundationServerScm.checkout(TeamFoundationServerScm.java:175)
 at hudson.model.AbstractProject.checkout(AbstractProject.java:1408)
 at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
 at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
 at hudson.model.Run.execute(Run.java:1603)
 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
 at hudson.model.ResourceController.execute(ResourceController.java:88)
 at hudson.model.Executor.run(Executor.java:247)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessImpl.create(Native Method)
 at java.lang.ProcessImpl.<init>(Unknown Source)
 at java.lang.ProcessImpl.start(Unknown Source)
 ... 20 more
Finished: FAILURE

The missing file can be downloaded in here.

http://www.microsoft.com/en-us/download/details.aspx?id=16338

Install in progress….



The following error maybe encountered if path to TF is not given.




The next step is to tell Jenkins where TF is. In Jenkins –> Configure System, depends on the version of .Net Framework, apply the path as follow.



Setup for MSBuild Project

Once the Jenkins is setup, by default it is only getting the files. The next step is to setup the MSBuild for the project.



In [Project] –> configuration –> Build –> Add build step, we will setup as follow.

Add build step will now have an option to use MSBuild.



As described in the jenkins-ci wiki page, we need to configure the MSBuild. A simple setup for .Net framework 4.0 as follow.


Trigger a build from check in

Perhaps, one of the most interesting feature of CI is the ability to continuously ensure the integrity of the build. Hence the name continuous integration. With the ability to trigger a build from any check-ins from developers, we have immediate feedback if any piece of check-ins causing troubles. This can be achieved by polling the SCM periodically. The online help with Jenkins is quite comprehensive, it follows the cron syntax.


The “quickest” steps to refresh complex entity type in entity framework


  1. Go to .edmx diagram

  2. Right click -> Update Model From Database

  3. image

  4. From Model Browser, go to Function Imports folder, right click Edit the sproc that needs update.

  5. image

  6. Click update on Complex

  7. Click Get Column Information –> OK

  8. image

  9. Make sure to Run Custom Tool on the EF again :(

Kentico Prev Next navigation thru document

Just a quick dirt hack to get prev next working with a repeater webpart.

image6

Under transformation we will do this. (This particular case use the Blog document type)


   1: <p class="linked" <%# (Eval("DocumentNodeID").ToString() == CMSContext.CurrentDocument.GetValue("DocumentNodeID").ToString()) ? string.Empty : "style='display:none;'"%>>

   2:     <span class="prev"> <a href="<%# (DataItemIndex >= DataRowView.DataView.Count - 1) ? string.Empty : DataRowView.DataView[DataItemIndex + 1]["NodeAliasPath"].ToString() %>" rel="prev"> 

   3:     <%# (DataItemIndex >= DataRowView.DataView.Count - 1) ? string.Empty : "&laquo; " + DataRowView.DataView[DataItemIndex + 1]["BlogPostTitle"].ToString() %> </a> </span>

   4:     

   5:     <span class="next"> <a href="<%# (DataItemIndex <= 0) ? string.Empty : DataRowView.DataView[DataItemIndex - 1]["NodeAliasPath"].ToString() %>" rel="next"> 

   6:     <%# (DataItemIndex <= 0) ? string.Empty : DataRowView.DataView[DataItemIndex - 1]["BlogPostTitle"].ToString() + " &raquo;" %> </a></span>

   7: </p>


And look something like this.
image

Get non modern ui adobe reader without download manager


It was quite an annoying thing to have full screen modern ui adobe reader in Windows 8. Regular download link would yield to the Adobe download manager. Solution?

The following should be bookmarked!!
http://www.adobe.com/support/downloads/product.jsp?platform=windows&product=10

Calculate age in .Net

Scope

I wanted to calculate a person's age in .Net. I am a little disappointed there is no SQL-like DateDiff function in .Net Framework.
If you search on Google, you will find these with high rank and votes.
I didn't like the idea of converting dates to float back and forth so that you can add milliseconds to the date or trying to divide the date by 365.242199 so that we are catering leap years that occur every 4 years but not the 100th but then the 400th year again and so on….

Solution

If someone ask me how old am I, it is simple logical process.
  • What year am I in? 
  • What year did I born? 
  • And have I had my birthday this year yet?
With this in mind, the pseudocode is simple. If I didn’t pass my birthday, then my age is calculated by this year but take out 1.

public int? Age
{
    get
    {
        return (DateTime.Today.DayOfYear >= DOB.DayOfYear)
                    ? (DateTime.Today.Year - DOB.Year)
                    : (DateTime.Today.Year - DOB.Year - 1);
    }
}

The SMART rule of KPI

KPI - Key Performance Index needs to comply to the following SMART rules:-

  • Specific
  • Measureable
  • Achievable
  • Relevant
  • Time-bounded
KPI should contain 2 - 4 conceptual items over a period of time, then break it down further to include quality and quantity or other quantifiers.
The following illustrate as an example.