Setup Subversion and store projects to use by team


To setup SVN server follow the steps below :

1. Download VisualSVN from the link : http://www.visualsvn.com/server/ , choose the standard free version.

4.DownloadVisualSVN

2. Click to start download, Follow the steps

5.Download

6.InstallVisualSVN

7.Install_Step2

8.Install_Step3

9.Install_step_4

3. Change the port no as 80 port may be used by other services.

10.Staep_5_

4. Select ‘VisualSVN Server Manager’ from start menu.

11.Start-VisualSVN_Server_Manager

SVN Installation is completed!!!!!!!!!!!!!!!!!!!!!!!!!

<!––nextpage––>

To Create repository to the SVN server, Follow the steps below :

12.Create_new_repository

13.Provide_repository_name

14.SelectEmptyRepository

15.SelectCustomizePermmission

16.CustomToAssignUser

17.CreateUserToAssign

18.UserCreated

19.Select_user_to_Add

20.Complete_UserAssignment

21.Complete_RepCreationAndSecurity

22.RepoCreatedWithFollowingInformation

23.RepoCreatedShowingOnList

Repository creation is completed!!!!!!!!!!!!!!!!!!!!! URL is http://user-PC:70/svn/MyRepository/

<!––nextpage––>

Add project to the created repository

To add project to SVN follow the steps below :

1.  First install AnkhSvn-2.5.12116 (as visual studio SVN client)

2.  To add a solution to SVN, open it through visual studio.

3. Now make SVN as default source control.

1.Select_option

2.MakeSVNAsDefaultRepo

4.  Right click on the solution node, from the Solution Explorer.

3.SelectToAddSolnToSVN

4.URLandAuth

5.ChooseToAddProjectInTrunk

6.CompleteAddingProject

Solution Added to SVN repository!!!!!!!

Retrieve Project From SVN

1. Intall TortoiseSVN-1.8.1.24570-x64-svn-1.8.1

About TortoiseSVN

TortoiseSVN is an Apache Subversion (SVN)® client, implemented as a windows shell extension. It’s intuitive and easy to use, since it doesn’t require the Subversion command line client to run. Simply the coolest Interface to (Sub)Version Control!

Now Follow the steps below :

Right click on the directory where want to add the project.

1.RightClickONTheDirectoryTOGetProject

2.ProvideSVNUrl

3.BrowseProject

4.Authenticate

5.SelectProjectFolderTOGet

6.StartGettingTheFoder

7.DownloadComplete

 

Query profiler for MySQL


In the current age when developers are writing LINQ queries rather than Sql queries, a query profiler must plays vital role. When we write Sql queries we can easily tune the performance. But In case of writing LINQ queries its very important to make sure that it results a good sql query. It is easy to see the generated query in SQL server by using ‘microsoft sql server management studio’—> Tools—>’Sql server profiler’. But for MySql it seem hard to me to find a query profiler.

I looked around internet and found ‘Neor Profile SQL’  as a useful Query profiler for MySQL. Download it from

http://www.profilesql.com/download/ . Its very easy to install. Follow the Quick start from the link http://www.profilesql.com/use/. Enjoy life is very easy now to feel comfortable to write LINQ queries.

Getting started with Log4net


This document provides how to use log4net. Its just an intro to getting started with log4net in a project for logging purpose. Follow the steps below :

1. Download log4net from the link http://logging.apache.org/log4net/download.html

2. Add reference of log4net.dll to the project  where to log, .

3.  In Web.config or App.config add following chunk of configuration :


<configSections> 
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> 
</configSections>

<log4net> 
<appender name="rootRollingFile" type="log4net.Appender.RollingFileAppender,log4net"> 
<threshold value="ALL"/> 
<param name="File" value="E:\temp\Log.txt"/> 
<param name="AppendToFile" value="true"/> 
<param name="RollingStyle" value="Date"/> 
<param name="DatePattern" value=".yyyy.MM.dd.'log'"/> 
<param name="StaticLogFileName" value="false"/> 
<layout type="log4net.Layout.PatternLayout,log4net"> 
<param name="ConversionPattern" value="%date [%-5thread] %-5level %logger - %message%newline %exception"/> 
</layout> 
</appender> 
<root> 
<level value="ALL"/> 
<appender-ref ref="rootRollingFile"/> 
</root> 
</log4net>

remember to add the above configuration inside <configuration></configuration> tag. And change the File param value according to your choice.

4. At the start of your application call the following method :

 

log4net.Config.XmlConfigurator.Configure();

For web application the application starts from

protected void Application_Start(object sender, EventArgs e) {

log4net.Config.XmlConfigurator.Configure(); 
}
 

method in Global.asax.

For windows/console application application normally starts from the main method of program.cs, so place the code like :

[STAThread] 
static void Main() 
{ 
log4net.Config.XmlConfigurator.Configure(); 
Application.EnableVisualStyles(); 
Application.SetCompatibleTextRenderingDefault(false); 
Application.Run(new CheckNetStatus()); 
}

5. Its time to use log4net for logging.

6. Just use the following piece of code to log :

ILogger log = LoggerManager.GetLogger(this.GetType().Assembly, this.GetType());

log.Log(this.GetType(), Level.Info, "Error occured", null);

 

This is simply done!!!!!!!!!!!!

Data/Database migration in MySQL


Introduction: MySQL workbench used to migrate data from source database server to destination database server. The detail information card of MySQL Workbench is given below:

WorkBench

Figure 1: MySQLWorkBench Card

Add Source and destination server connection into Workbench.

image

Figure 2: Add Source and Destination

After adding source and destination connection.

image

Figure 3: Shows source and destination connection

Data will be migrated from Source server to Destination. So double click on the Source server. Now select migrate from the menu DatabaseàMigrate.

image

Figure 4: Choose Migrate

Now click on the start migration button.

image

Figure 5: Start Migration

Provide source information.

image

Figure 6: Provide source information

If the connection is tested successfully then click the next button. Now provide the destination information. And test it. If test successfully then click the next button.

image

Figure 7: Provide destination

Now wait for the ‘Schema Fetch list completion’. And after that click next button.

image

Figure 8: Fetch Schema list

Now select the DB to that you want to migrated from Source server to destination. After that click Next button.

image

Figure 9: Select the DB to migrate

After clicking next button wait to finish the ‘Reverse Engineer Source’.

image

Figure 10: Reverse Engineer Source

After finished click Next button. Now comes the sources object selection window, select the object that wanted to be migrated.

image

Figure 11: Source object selection

Click Next button. Now migration step starts. After finishing the selection of objects to migrate, click Next button. Manual editing step starts, in my case it results nothing. So clicking Next button. Opens the target creation option step.

image

Figure 12: Target Creation option

Now starts the ‘Create Schemata’ step. Wait to finish it. And click ‘Next Button’. Starts the ‘Create Target Results’ window. Click Next button. Opens the data transfer setup window.

image

Figure 13: Data transfer setup

After providing all the desired setup information, click Next button to start data transfer. Wait to complete the data transfer.

How to run a console application through ant script


Below is the ant script to run a console application by ant :

<project name="MyApplication" default="runmyapplication">

<!-- Initialization of the project. --> <target name="-init"> <!-- Load environment variables --> <property environment="env" /> <!-- Define directories in the source repository --> <!--The directory of the solution if its in the same directory as ant then only . is enough--> <property name="myapplicationexecutable.dir" location="C:\MyApplication\bin" /> <property name="msbuild" location="${env.windir}/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe" /> <property name="msbuild.logger" value="" /> <property name="myapplilcationexecutable" location="${myapplicationexecutable.dir}/myapplication.exe" /> <property name="param1" location="param1value" /> </target> <!-- Run the unit test --> <target name="runmyapplication" depends="-init"> <exec dir="${myapplicationexecutable.dir}" executable="${myapplilcationexecutable}" failonerror="true"> <arg line="${param1}"/> </exec> </target> </project>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Install prepare environment for Ant and create build script.


 

Follow the steps below to prepare environment for Ant and to write simple Ant build script to build a solution :

1. Download java from the link http://java.com/en/download/index.jsp

after download install Java.

2. set the JAVA_HOME variable in environment variable.

Go to Mycomputer–>properties–>Advanced–>Click Environment Variables button–>Click New button(in the system variables section)–>

set Variable name=JAVA_HOME

Variable value=c:\program Files\java\jre6(This is the path where java is installed it may vary)–> click ok button–>By clicking ok of all the window finish it.

Set JAVA_HOME variable

3. Download ant from http://ant.apache.org/bindownload.cgi

4. Unzip the download zip file(nothing to install for ant).

5.  Now set the ANT_HOME variable in environment variable.

Go to My Computer——>properties–>Advanced——->Click Environment Variables button——->Click New button(in the system variables section)—–>set Variable name=ANT_HOME

Variable value=C:\apache-ant-1.8.3-bin\apache-ant-1.8.3(The folder path where ant is unzipped)——> click ok button—–>By clicking ok of all the window finish it.

set the ANT_HOME variable in environment variable

6. Now set the ant path.

Go to Mycomputer–>properties–>Advanced–>Click Environment Variables button–>From System variables section select Path —–> click edit button——>in the last of the text box put the bin folder of the ant(from the unzipped location)precedding with semicolon like : ‘;C:\apache-ant-1.8.3-bin\apache-ant-1.8.3\bin’

Set ant Path

7. Open command prompt and type ant it will show error message ‘build.xml does not exist’. That means environment for ant is
prepared and now its time to prepare the build script with ant.

8. Here is a simple minimal ant script to build a project. Save the build script file as build.xml

<!--The project and the default task(target) that ant will execute if no target(task) is defined-->
<project name="MCSManagement" default="compile">
  
   <!--This task(target) initializes all the project variables-->
    <target name="init">
    
        <!-- Load environment variables -->
        <property environment="env" />
        
        <!-- Define the source repository -->
    <property name="src.dir"           location="C:\Developments\MCSManagement" />
    
    <!--Path of the msbuild which will be used as compiler -->
    <property name="msbuild"        location="${env.windir}/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe" />
    
    <!--Full path of the solution file that have to compile-->
    <property name="sln.file"       location="${src.dir}/MCSManagement.sln" />
    
  </target>
  
  <!--This target(task) compiles the project and initializes all the needed variables.This target(task) is dependent on the init target-->
  <target name="compile" depends="init">
    <!--Directory is the directory where the solution file is located-->
    <exec dir="${src.dir}" executable="${msbuild}" failonerror="true">
      <!--The path of the solution file-->
      <arg line="${sln.file}"/>
    </exec>
  </target>
  
</project>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

9. Now start the command prompt, use cd to enter the location where the build.xml is located. Now to build the solution enter the command "ant compile"

ant command

How to install and use MemCacheD / Distributed caching implimentation


Introduction: Caching is very important for performance improvement of applications. By caching data applications can reduce roundtrip to data storage.

There is lots of open source Cache Management application. MemCacheD is one of the widely used distributed caching system. Giants like Youtube, FaceBook are using MemCached for there cache management. In the following sections I will try to show how to install and use MemCacheD with ASP.Net application.

MemCacheD Installation: Download MemCacheD by click here. After completion of download follow the steps below to install MemCacheD:

  1. Installation is very simple just click on the downloaded msi.
  2. After that clicking on the couple of Next buttons will finish the installation.

Configure MemCacheD: From start menu–>MemCacheD Manager–>MemCacheD Manager. Pops up MemCacheD Manager Window.

Choose MemCacheD Manager from start menu.

Click on the Add Server button to add MemCacheD server (May be installed on local machine or on some other location) to MemCacheD manager. So MemCacheD manager can maintain multiple MemCacheD server.

Now provide the server information to the right side boxes. In the server name text box provide IP of the MemCacheD server. For our case as just installed in the local machine we will add the IP of local machine (127.0.0.1). Click on the apply button. And the server will be added.

Now add instance to the server by right clicking on the server left side tree node and choose Add New Instance from the context menu, it’s possible to create multiple instance of the same server and the cache is maintained instance wise separately by MemCacheD. To create instance provide the necessary information in the right side input boxes and click on the Apply button. as the snap below :

To add instance in a Server

The added server as well as the instances can be deleted or start/stop by just right clicking on the corresponding tree nodes. The snap above shows the servers as well as the instances as start state.

To see the caching status of the instances click on the Status tab, it shows the no of cached items, no of times items read/write and other information.

Monitor caching status of different Instances

So the MemCacheD is installed and configured and ready for use.

Using MemCacheD : Create new web application with name MemcachedWebClient from visual studio. Add a new page GetSetCacheData.aspx on the web application with the following html content.

<%@ Page Title=”” Language=”C#” MasterPageFile=”~/Site.Master” AutoEventWireup=”true” CodeBehind=”GetSetCacheData.aspx.cs” Inherits=”MemcachedWebClient.GetSetCacheData” %>

<asp:Content ID=”Content1″ ContentPlaceHolderID=”HeadContent” runat=”server”>

</asp:Content>

<asp:Content ID=”Content2″ ContentPlaceHolderID=”MainContent” runat=”server”>

<div>

<div style=”float:left;padding-right:20px”>

<div>Cached Key</div>

<div> <asp:TextBox runat=”server” id=”txtCacheKey”>

</asp:TextBox>

</div>

</div>

<div>

<div>CacheValue</div>

<div> <asp:TextBox runat=”server” id=”txtCacheValue” Width=”301px”></asp:TextBox>

</div>

</div>

<div style=”padding-top:20px;padding-bottom:20px”>

<asp:Button ID=”btnSetCacheValue” runat=”server” Text=”SetCacheValue” />

</div>

</div>

<div style=”float:none”>

<div style=”float:left;padding-right:20px”>

<div>KeyToRetrieveCache</div>

<div> <asp:TextBox runat=”server” id=”txtKeyToRetrieveCache”>

</asp:TextBox>

</div>

</div>

<div>

<div>CacheValue</div>

<div> <asp:TextBox runat=”server” id=”txtRetrievedValue” Width=”306px”></asp:TextBox>

</div>

</div>

<div style=”padding-top:20px;padding-bottom:20px”>

<asp:Button ID=”btnGetCacheValue” runat=”server” Text=”GetCacheValue” />

</div>

</div>

</asp:Content>

Viewing the page on browse looks like below:

Added page to test caching

The page is intended to set cache by providing cache key/value and by clicking on the SetCacheValue button.

And retrieves the cache value by providing the cache key on the KeyToRetrieveCache and clicking on the GetCacheValue button.

To implement these functionality add the button click events for GetCacheValue and SetCacheValue. Change the provided html code by the following to add the button events.

For GetCacheValue :

<asp:Button ID=”btnGetCacheValue” runat=”server” Text=”GetCacheValue”

onclick=”btnGetCacheValue_Click” />

For SetCacheValue :

<asp:Button ID=”btnSetCacheValue” runat=”server” Text=”SetCacheValue”

onclick=”btnSetCacheValue_Click” />

Add the following code in the GetSetCacheData.aspx.cs :

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using Memcached.ClientLibrary;

using System.Collections;

namespace MemcachedWebClient

{

public partial class GetSetCacheData : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

/* The list of the servers to which cached have to add*/

string[] serverlist = { “127.0.0.1:11212” };

SockIOPool oSockIOPool = SockIOPool.GetInstance();

oSockIOPool.SetServers(serverlist);

oSockIOPool.InitConnections = 3;

oSockIOPool.MinConnections = 3;

oSockIOPool.MaxConnections = 5;

oSockIOPool.SocketConnectTimeout = 1000;

oSockIOPool.SocketTimeout = 3000;

oSockIOPool.MaintenanceSleep = 30;

oSockIOPool.Failover = true;

oSockIOPool.Nagle = false;

oSockIOPool.Initialize();

}

}

protected void btnSetCacheValue_Click(object sender, EventArgs e)

{

MemcachedClient oMemcachedClient = new MemcachedClient();

oMemcachedClient.EnableCompression = false;

oMemcachedClient.Set(txtCacheKey.Text, txtCacheValue.Text);

}

protected void btnGetCacheValue_Click(object sender, EventArgs e)

{

MemcachedClient oMemcachedClient = new MemcachedClient();

oMemcachedClient.EnableCompression = false;

object retrievedvalue = oMemcachedClient.Get(txtKeyToRetrieveCache.Text);

txtRetrievedValue.Text = retrievedvalue != null ? retrievedvalue.ToString() : string.Empty;

}

}

}

Now view the added page in browser and set cache/ Get cache and follow the Status tab from the MemCacheD Manger, it reflects the no of cache added and no of times it read.

Server status after doing some caching