Thursday, July 29, 2010

Configuration of webHttpBinding and wsDualHttpBinding

< ?xml version="1.0"?>
< configuration>
< system.serviceModel>
< serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
< behaviors>
< endpointBehaviors>
< behavior name="webHttpEnablingBehavior">
< webHttp />
< /behavior>
< /endpointBehaviors>
< serviceBehaviors>
< behavior name="webHttpEnablingBehavior">
< serviceMetadata httpGetEnabled="true"/>
< serviceDebug includeExceptionDetailInFaults="true" />
< /behavior>
< /serviceBehaviors>
< /behaviors>
< services>
< service name="WCFService" behaviorConfiguration="webHttpEnablingBehavior">
< endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
< endpoint address="" binding="webHttpBinding" bindingConfiguration="default" contract="IWCFService" behaviorConfiguration="webHttpEnablingBehavior" />
< endpoint address="MyOperation" binding="wsDualHttpBinding" bindingConfiguration="default" contract="IWCFService" />
< /service>
< /services>
< client />
< bindings>
< webHttpBinding>
< binding name="default" />
< /webHttpBinding>
< wsDualHttpBinding>
< binding name="default" />
< /wsDualHttpBinding>
< /bindings>
< /system.serviceModel>
< system.web>
< compilation debug="true"/>
< /system.web>
< /configuration>

Monday, May 24, 2010

Using CSS with Inline Images

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> .clip { position: absolute; top: 0; left: 0; } .pos-1 { clip:rect(0 48px 48px 0); } .pos-2 { clip:rect(0 96px 48px 48px); left: -48px; } .pos-3 { clip:rect(48px 48px 96px 0); top: -48px; } .pos-4 { clip:rect(48px 96px 96px 48px); top: -48px;left: -48px; } .clipwrapper { position: relative; height: 48px; width: 48px; } </style> <title></title> </head> <body> <div class="clipwrapper"> <img src="Images/arrow-sprite.png" alt="arrow" class="clip pos-1" /> </div> </body> </html>

Wednesday, May 5, 2010

SQL Server built in functions

1. First day of the week
select @@DateFirst output: 7 - Monday , 1 - Sunday
Set dateFirst 1
To see the permissions in the database.
select * from fn_my_permissions('null','database')
SELECT DISTINCT class_desc FROM fn_builtin_permissions(default) ORDER BY class_desc;
GO

Wednesday, April 7, 2010

Design patterns

One way is to call carpenter and let him take the measurements and then get you the door. --- factory method
Second way is to go to shop which sells doors and get the one which fits your requirements. --- abstract factory
Tracking a Session counter creates a single object - Singleton pattern

Wednesday, March 24, 2010

Using Server.Transfer

This is somewhat complex but sophisticated method of passing values  across pages. Here you expose the values you want to access in other  pages as  properties of the page class. This methods require you to code extra  properties that you can access in another web form. However, the efforts  are worth considering. Overall this method is much cleaner and object  oriented than earlier methods. The entire process works as follows:
  • Create the web form with controls
  • Create property Get procedures that will return control values
  • Provide some button or link button that posts the form back
  • In the button click event handler call Server.Transfer method that will transfer execution to the specified form
  • In the second form you can get a reference to the first form instance by using Context.Handler property. Then you will use the get properties we created to access the control values.
The code to accomplish this is somewhat complex and is shown below:
Source Web Form
Add following properties to the web form:
public string Name
{
get
{
return TextBox1.Text;
}
}

public string EMail
{
get
{
return TextBox2.Text;
}
}
Now, call Server.Transfer.
private void Button1_Click
(object sender, System.EventArgs e)
{
Server.Transfer("anotherwebform.aspx");
}
Destination Web Form
private void Page_Load
(object sender, System.EventArgs e)
{
//create instance of source web form
WebForm1 wf1;
//get reference to current handler instance
wf1=(WebForm1)Context.Handler;
Label1.Text=wf1.Name;
Label2.Text=wf1.EMail;
}

Fault Exception in WCF

calling the FaultException in Catch block

catch (Exception ex)

{

throw ex ;

// useful when FaultException attribute is mentioned in the web method called.

//with method declaration in interface.

////[FaultContract(typeof (MyFaultException))]

//MyFaultException myException = new MyFaultException();

//myException.Reason = "Reason for this error is : " + ex.Message.ToString();

}

Fault exception definition

// optional but a good practice.

[DataContract]

public class MyFaultException

{

private string _reason;

[DataMember]

public string Reason

{

get { return _reason; }

set { _reason = value; }

}

}

Thursday, March 18, 2010

How to Deploy and Test An SSIS Package

When working with SSIS, it is not immediately obvious how to deploy a package. Following are my short notes on deploying an SSIS package*.

Deploy the Package

  1. While in the Package designer, choose Project > [Package Name] Properties. The Configuration manager dialog will appear.
  2. Choose Deployment Utility from the tree.
  3. Change the CreateDeploymentUtility option from False to True. Note the DeploymentOutputPath variable. Push OK to close the dialog.
  4. Open the Solution Explorer and right-click on the .dtsx file and choose Properties. Copy the Full Path variable and use it to find the bin\Deployment folder.
  5. Locate the [Package Name].SSISDeploymentManifest file. Double-click on the file and follow the steps outlined by the wizard to deploy the package.

Test the deployed Package

  1. Open MSFT SQL Server Management Studio and choose Connect > Integration Services from the UI. Choose the Server and connect.
  2. The packages will be saved under the MSDB folder. Right-click on the package to run it.

---

* To re-deploy a package, follow steps 1-5 again.