Tuesday, March 10, 2009

NTFS File System for USB Flash Drives

Recently I came across a situation where I wanted to copy a virtual hard disk (which is about 12GB in size) to my USB drive. Though there was enough free space on the disk I wasn't able to copy the file. Reason for this was maximum file size allowed in FAT file system is 4096MB.

So I thought of formatting my flash drive with NTFS file system and just searched for pros and cons.

Pros:

  • Avoid file size restriction
  • NTFS allow file compression
  • Manage permissions for individual files and folders
  • Use windows XP built in file encryption

Cons:

  • Additional data writes – NTFS logs disk transactions separately on the disk adding considerable amount of extra disk activity, which leads to wearing out your USB drive faster
  • Windows 98/ ME, and most Linux systems cannot read NTFS partitions
  • Must go through removal dialog, or else you have a good chance of losing data as you have to switch from the 'Optimize for quick removal' mode

Therefore it is up to you to choose between formatting flash drive with NTFS or not. As I read, if you have done your research and decided to format your flash drive with NTFS, here is how to do it.

  • Right Click My Computer-> Select Manage-> Open Device Manager
  • Select your USB Drive-> Right Click-> Select Properties-> Select Policies Tab -> Select Optimize for performance option-> Click OK

  • Open My Computer-> Right Click on your USB Drive-> Select Format-> Select File System as NTFS-> Start

A good article on "Format a USB drive with NTFS file system" can be found here.

Friday, February 6, 2009

Install & Configure Microsoft Commerce Server 2007

1. Install Microsoft Commerce Server 2007 Developer Edition on a standard Visual Studio 2005 workstation with default options selected. If you don't want to develop web applications Microsoft .NET Framework 2.0 is sufficient.

Commerce Server 2007 needs several prerequisites, including .NET Framework 2.0 and IIS. If these main prerequisites are installed, you can select "Automatically install the platform prerequisites" option so that additional components like hot fixes will be downloaded and installed during the installation process.

Before you install Commerce Server, you must create several accounts to run the Commerce Server services. Refer "Create User Accounts" section in the installation guide for more information.

2. Commerce Server Configuration Wizard allows you to configure commerce server and it can be found in start menu. Once you configured commerce server, it won't allow you to configure again. In the case invoke "CSConfig.exe /f" from Commerce Server command prompt to force the new configuration.

In the configuration wizard select a DB Server to create admin DBs (EX: MSCS_Admin)

3. Unpack .pup file (site) using Commerce Server Site Packager.

This will create Commerce DBs, Web services and application virtual directory.

4. Make sure you granted all relevant permissions, so that application can connect to the DBs (Create Users/Roles in DB, Setup AppPools in IIS).

5. Assign users to commerce server web services in AzMan.

Open AzMan.msc, open AzMan store from xml files that is in each unpacked Web Service folder (Right Click the Authorization Manager node and click on Open Authorization Store). (EX: CatalogAuthorizationStore.xml)

Add your domain account to the roles you wish to manage in Azman (Ex: Go to CatalogAuthorizationStore -> CatalogandInventorySystem -> Role Assignments -> Administrator. Then right click on the roles you wish to manage and choose "Assign Windows Users or Groups").

6. Install Business User Applications on a work station.

Before installing follow these sections in the "installation Guide" to grant required permissions.

  • Assign Write Permissions to the Catalog Authorization Policy
  • Assign Write Permissions to the Temporary ASP.NET Folder
  • Assign Permissions for the Windows Temporary Folder
  • Add Users or Windows Groups to the Authorization Policy Roles
  • Add Users or Windows Groups to the Authorization Policy Roles
  • Add the Worker Process Accounts to the IIS_WPG group

7. Then Configure Catalog Manager, etc to your Web Services and you are done!!!

In case if you get "WebService was not available" error message and WebServices can be navigated through IE without any issue, the reason would be the Catalog Web Service does not have write access to the AuthorizationPolicy path.

To resolve this issue you have to assign write permissions on CatalogAuthorizationStore.xml to the account running the AppPool. (CatalogAuthorizationStore.xml file can be found in the same directory as CatalogWebService.asmx. Account running the AppPool can be found from IIS Manager.)

Hope this help someone, as configuring Commerce Server is always tricky.

Thursday, January 15, 2009

How to Add a Tooltip to a Dropdown List

It is common in most web pages that whole text in dropdown lists cannot be seen due to width limitation. One solution for this would be adding tooltip for the dropdown, so that when selecting a value from dropdown, whole text will be appear as a tooltip. For most of browsers implementing tooltip on dropdown control is not a big deal. We can simply add tooltip text with 'title' attribute. C# implementation for this would be as follows;

public static void BindTooltip(DropDownList ddl) {
for (int i = 0; i < ddl.Items.Count; i++)
{
ddl.Items[i].Attributes.Add("title", ddl.Items[i].Text);
}
}

But this will not work in Internet Explorer version 6, as IE V6 does not support the 'title' attribute on the <select> control. (IE 7, Firefox … support the 'title' attribute). This is because IE 6 creates a separate window/layer for the <select> tag that is above the rest of the browser window. And Tooltip property is also not working in IE V6.

A partial solution for this issue is add a separate <div> to the form, set the required text, and show/hide that <div> based on mouse activity over dropdown list. Anyway this method will not show the tooltip when selecting an item from the dropdown list. But once you selected an item and move the mouse over dropdown list, it will show the tool tip. Here is the implementation;

DropDown
ddlNames.ID = "DDL_NAMES_ID";
ddlNames.Width = 100;
ddlNames.DataSource = dtNames;
ddlNames.DataTextField = "Full_Name";
ddlNames.DataValueField = "Reg_ID";
ddlNames.DataBind();
ddlNames.Attributes.Add("onmouseover", "showDropDownToolTip(this);");
ddlNames.Attributes.Add("onmouseout", "hideDropDownToolTip();");

DIV
<div id="divDropDownToolTip" style="position:absolute; display:none; background:lightyellow; border:1px solid gray; padding:2px; font-size:8pt; font-family:Verdana;" onMouseOut
="hideDropDownToolTip()">
<span id="toolTipText"></span>
</div>

Java Script
protected override void OnPreRender(EventArgs e)
{
string script = string.Concat(@"
<script type=""text/javascript"" language=""javascript"">
function showDropDownToolTip(ddl){
if ( ddl.options[ddl.selectedIndex].value == '')
return;
var toolTipSpan = document.getElementById('toolTipText');
toolTipSpan.innerHTML = ddl.options[ddl.selectedIndex].text;
var toolTipDiv = document.getElementById('divDropDownToolTip');
toolTipDiv.style.top = window.event.clientY + 140;
toolTipDiv.style.left = window.event.clientX;
toolTipDiv.style.display = 'block';
}

function hideDropDownToolTip()
{
document.getElementById('divDropDownToolTip').style.display = 'none';
}
</script>");

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "NamesToolTipControl", script);
}

Thursday, January 1, 2009

Passing an Event to the Parent Control by Using Delegates

For the purpose implementation of inner control should implement event handler, custom argument class and delegate. Custom argument class is used to pass inner control specific values to the container control.

using System.Web.UI.WebControls;

namespace InteractiveControls{
// Interactive Control
public class MyInteractiveControl : CompositeControl
{
/// <summary>
/// Event for delegate method
/// </summary>
public event ShowClickEventHandler ShowClicked;

/// <summary>
/// Button control
/// </summary>
private Button btnShow;

/// <summary>
/// CreateChildControls is responsible for creating the controls to form this composite control
/// </summary>
protected override void CreateChildControls()
{
this.btnShow = new
Button();
this.btnShow.Text = "Show";
this.btnShow.Click += new
EventHandler(btnShow_Click);
this.Controls.Add(btnShow);
}

private void btnShow_Click(object sender, EventArgs e)
{
OnShowClick(new ShowClickEventArgs(25, 100));
}
void OnShowClick(ShowClickEventArgs e)
{
ShowClicked(this, e);
}
}

/// <summary>
/// Delegate method for Show button clicked event handler
/// </summary>
public delegate void ShowClickEventHandler(object sender, ShowClickEventArgs e);
/// <summary>
/// Event argument class for ShowClickEventArgs
/// </summary>
public class ShowClickEventArgs : EventArgs
{
private int m_From;
private int m_To;
public ShowClickEventArgs(int from, int to)
{
this.m_From = from;
this.m_To = to;
}
public int From
{
get { return m_From; }
}
public int To
{
get { return m_To; }
}
}
}

'MyInteractiveControl_ShowClicked' method in the container control will be invoked in 'Show' button click, which is residing in the inner control. By implementing custom argument class appropriately, can access values in the interactive control from container control.

namespace ContainerControls
{
// Container Control
public class MyInteractiveControl : CompositeControl
{
protected override void CreateChildControls()
{
MyInteractiveControl ctrl = new MyInteractiveControl();
ctrl.ShowClicked += new ShowClickEventHandler(MyInteractiveControl_ShowClicked);
this.Controls.Add(ctrl);
}

/// <summary>
/// Event fires when the Show button clicked
/// </summary>
private void MyInteractiveControl_ShowClicked(object sender, ShowClickEventArgs e)
{
Controls.Add(new
LiteralControl(string.Concat("From:", e.From.ToString(), " - To:", e.To.ToString())));
}
}
}

More about delegates.....

Tuesday, December 30, 2008

Unlock TFS Files Locked by Other Developers

It is a common experience that someone needs to unlock a file, locked in Team Foundation Server by another developer at a moment that the developer who locked the file is not available to unlock it. Same thing happens if the original login used for lock a file is no longer exists. For the both cases one solution would be the use of 'tf undo' command from Visual Studio command prompt. The undo command removes any locks so that other developers can check out the file. It should be noted that you should have enough privileges to execute this command. Command syntax is:

tf undo /Projects/Project1/Controls/FileName.cs"
/WORKSPACE:Dev123;Domain\UserName /s:http://tfs01:8080 /recursive

Here the Workspace and the User are the ones who locked the file. This information can obtain from source control explorer. If you want to find list of files locked by a developer use the 'tf status' command.

One important thing to remember when using 'tf undo' command is, you may have to use server name as "http://…" if you are executing command from a developer box. Otherwise you will get the ‘cannot find server’ error message for server name as well as for IP address though you are in the same domain, etc. By using server name as a URL it will uses web services to invoke the command.

You can read more detail about “Tf Command Line Utility Commands” from MSDN here.