Wednesday 22 February 2012

IIS 7.0 Concepts

IIS 7.0 is more structured than IIS 6.0. It has a hierarchy of individual objects in IIS 7.0 schema. Sites are root object and contains application and applications contain virtual directory.
Web Sites :  
A web site is a collection of pages, images, video, or other digital content that is available via HTTP. The pages are usually in HTML, ASP, ASPX, or PHP format. Web Sites are hosted in Web Servers. Web Servers take request from browser and return data in the form of web site. Sites are the root objects that are containers for applications and virtual directories. Sites provide binding through which it can be accessed.

Binding contains two things : 
1. Binding Protocol : HTTP and HTTPS
2. Binding Information : IP Address, Port Number and and the host header(optional)

Multiple binding protocols also can be used for the same site.

Applications :
An application in IIS 7.0 is a collection of files and folders that serves content or provides services over protocols such as HTTP or HTTPS. In IIS 7.0, every site has at least one application, the root application, but sites can have many applications if needed.

Applications in IIS 7.0 support not only HTTP and HTTPS protocols, but other protocols as well. To support a protocol, a listener adapter must be specified in the <listenerAdapters> section in the configuration, and the protocol must be enabled in the <enabledProtocols> section of the configuration. As an example, the FTP protocol can be added to an application to create an FTP binding. Below is the section from applicationHost.config :

<listenerAdapters>
            <add name="http" />
            <add name="net.tcp" identity="S-1-5-80-3579033775-2824656752-1522793541-1960352512-462907086" />
            <add name="net.pipe" identity="S-1-5-80-2943419899-937267781-4189664001-1229628381-3982115073" />
            <add name="net.msmq" identity="S-1-5-80-89244771-1762554971-1007993102-348796144-2203111529" />
            <add name="msmq.formatname" identity="S-1-5-80-89244771-1762554971-1007993102-348796144-2203111529" />
</listenerAdapters>

Virtual Directories :
A virtual directory is the directory, or path, that maps to the physical location of the files on the local or remote server.

Creating a Web Site Using IIS Manager
1. Start IIS Manager by clicking Start Run, entering inetmgr, and then pressing Enter
2. Select the server to administer, click the Sites icon, and then select Add Web Site from the
Actions pane or by right-clicking the Sites icon.



Monday 13 February 2012

Drill Down Grid Export using Telerik Grid



Please check the below code. This is a double drill down grid.
The PDF export has following capabilities :
- Exports all the data of all the pages with the detail view
- Adds a header on top of the PDF "this is a test"

<div>
 <div id="divExportIcons" runat="server"><asp:linkbutton id="lnkPDF" runat="server" text="PDF" onclick="lnkPDF_Click"></asp:linkbutton><asp:linkbutton id="lnkExcel" runat="server" text="Excel" onclick="lnkExcel_Click"></asp:linkbutton>
 <telerik:radgrid runat="server" id="trdDemo" skin="Black" onneeddatasource="trdDemo_OnNeedDataSource"gridlines="None" allowsorting="True" allowpaging="True" autogeneratecolumns="False"showstatusbar="True" ondetailtabledatabind="trdDemo_OnDetailTableDataBind" onitemcreated="RadGrid1_ItemCreated"
 <HeaderContextMenu EnableAutoScroll="True">
 <ExportSettings IgnorePaging="true" OpenInNewWindow="true" >
 
 <SortExpressions><telerik:GridSortExpression FieldName="Plan_Name" /></SortExpressions><DetailTables>
<DetailTables>
<telerik:GridTableView Name="Employee" runat="server" ExpandCollapseColumn-ShowSortIcon="true" AutoGenerateColumns="false">
<Columns><telerik:GridBoundColumn UniqueName="Title_Id" DataField="Title_Id" DataType="System.String" HeaderText="Title_Id"> </telerik:GridBoundColumn><telerik:GridBoundColumn UniqueName="Surname" DataField="Surname" DataType="System.String" HeaderText="Surname"> </telerik:GridBoundColumn>
</Columns>
</telerik:GridTableView></DetailTables><Columns><telerik:GridBoundColumn UniqueName="Employer_Name" DataField="Employer_Name" DataType="System.String" HeaderText="Employer_Name"> </telerik:GridBoundColumn><telerik:GridBoundColumn UniqueName="Trading_Name" DataField="Trading_Name" DataType="System.String" HeaderText="Trading Name"> </telerik:GridBoundColumn><telerik:GridBoundColumn UniqueName="Created_Dt" DataField="Created_Dt" DataType="System.DateTime" HeaderText="Created_Dt"> </telerik:GridBoundColumn></Columns><ExpandCollapseColumn Visible="True"></ExpandCollapseColumn></telerik:GridTableView>
</DetailTables> <ExpandCollapseColumn Visible="True"></ExpandCollapseColumn><Columns><telerik:GridBoundColumn UniqueName="Plan_Id" DataField="Plan_Id" DataType="System.Int32" HeaderText="Plan Id"> </telerik:GridBoundColumn><telerik:GridBoundColumn UniqueName="Plan_Name" DataField="Plan_Name" DataType="System.String" HeaderText="Plan Name"> </telerik:GridBoundColumn><telerik:GridBoundColumn UniqueName="Plan_Code" DataField="Plan_Code" DataType="System.String" HeaderText="Plan Code"> </telerik:GridBoundColumn></Columns><CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true"ShowExportToCsvButton="true" /></MasterTableView></telerik:radgrid></div>

 protected void Page_Load(object sender, EventArgs e)

{ }
protected void trdDemo_OnNeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
AAS_ProdEntities3 aasContext = new AAS_ProdEntities3();
trdDemo.DataSource = aasContext.Web_Plan.ToList<Web_Plan>();
}
 protected void trdDemo_OnDetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)
{
GridDataItem gridDataItem = (GridDataItem)e.DetailTableView.ParentItem;

if (e.DetailTableView.Name == DetailTableType.Employer.ToString())
e.DetailTableView.DataSource = GetEmployerForPlan(gridDataItem.GetDataKeyValue("Plan_Id"));

if (e.DetailTableView.Name == DetailTableType.Employee.ToString())
e.DetailTableView.DataSource = GetMemberForEmployer(gridDataItem.GetDataKeyValue("Employer_Id"));
}



protected void trdDemo_OnPdfExporting(object sender, GridPdfExportingArgs e)
{
e.RawHTML =
"<div style='color: #606010; background-color: #88afea; font-weight: bold;'>this is a test</div>"
+ e.RawHTML;


}
protected void lnkPDF_Click(object sender, EventArgs e)
{
if ((trdDemo.MasterTableView.Items.Count) > 0
{
trdDemo.ExportSettings.ExportOnlyData = false;
trdDemo.ExportSettings.IgnorePaging = true;
trdDemo.MasterTableView.HierarchyDefaultExpanded = true;
trdDemo.MasterTableView.DetailTables[0].HierarchyDefaultExpanded = true;
trdDemo.MasterTableView.DetailTables[0].DetailTables[0].HierarchyDefaultExpanded = true;
trdDemo.GridLines = GridLines.Both;


trdDemo.MasterTableView.ExportToPdf();}

}

{

{
protected void lnkExcel_Click(object sender, EventArgs e)

{
if ((trdDemo.MasterTableView.Items.Count) > 0
{
trdDemo.ExportSettings.ExportOnlyData = false;
trdDemo.ExportSettings.IgnorePaging = true;
trdDemo.MasterTableView.HierarchyDefaultExpanded = true;
trdDemo.MasterTableView.DetailTables[0].HierarchyDefaultExpanded = true;
trdDemo.MasterTableView.DetailTables[0].DetailTables[0].HierarchyDefaultExpanded = true;
trdDemo.GridLines = GridLines.Both;


trdDemo.MasterTableView.ExportToExcel();
}


}{
lstMember = aasContext.GetMemberForEmployer(
}

}
private List<GetMemberForEmployer_View> GetMemberForEmployer(object employerId)

{
List<GetMemberForEmployer_View> lstMember = null;
using (AAS_ProdEntities3 aasContext = new AAS_ProdEntities3())
lstEmployer = aasContext.GetAllEmployerPerPlan(
Convert
.ToInt32(employerId)).ToList<GetMemberForEmployer_View>();


return lstMember

}
private List<GetEmployerPerPlan_View> GetEmployerForPlan(object planId)
{
List<GetEmployerPerPlan_View> lstEmployer = null;
using (AAS_ProdEntities3 aasContext = new AAS_ProdEntities3())
Convert.ToInt32(planId)).ToList<GetEmployerPerPlan_View>();
return lstEmployer;
}

}

public enum DetailTableType{
Employer,
Employee
}


</div>
<telerik:GridBoundColumn UniqueName="Given_Name" DataField="Given_Name" DataType="System.String" HeaderText="Given_Name"> </telerik:GridBoundColumn>
<telerik:GridTableView Name="Employer" runat="server" DataKeyNames="Employer_Id" ExpandCollapseColumn-ShowSortIcon="true" AutoGenerateColumns="false">
<MasterTableView DataKeyNames="Plan_Id">
</ExportSettings>
</HeaderContextMenu>
onitemcommand="RadGrid1_ItemCommand" onpdfexporting="trdDemo_OnPdfExporting">
<div>
<asp:scriptmanager id="ScriptManager1" runat="server"></asp:scriptmanager>

Mapping Complex Type Stored Procedure in Entity Framework 3.5

Please flow the below steps to map a complex type stored procedure in entity framework 3.5 :
  1. Write the stored procedure.
  2. Create a View with same set result. Both name of the column and the data type should match.
  3. Import the View.
  4. Create a function import for the stored procedure.
  5. Choose the return type as Complex and map to the view.
Now the result returned can be type casted to the view's entity.
Still there is one more limitation in Entity Framework 3.5, that the multiple result set can't be mapped. This can be achieved using Entity Framework Extnesion in EF 3.5.

Both the issues are resolved in EF 4.1.