Showing posts with label asp .net. Show all posts
Showing posts with label asp .net. Show all posts

Saturday, 30 June 2012

3tier architecture and Multitier architecture



multi-tier architecture (often referred to as n-tier architecture) is a

client–server architecture in which

the presentation,
the application processing, and
the data management


are logically separate processes

The most widespread use of multi-tier architecture is the three-tier architecture.

There should be

a presentation tier,
a business or data access tier, and
a data tier.


Three-tier architecture


It was developed by John J. Donovan

The three-tier model is a software architecture and a software design pattern.

a change of operating system in the presentation tier would only affect the user interface code.





Presentation tier


-This is the topmost level of the application.

-The presentation tier displays information related to such services as browsing merchandise, purchasing, and shopping cart contents.

-It communicates with other tiers by outputting results to the browser/client tier and all other tiers in the network.

Application tier (business logic, logic tier, data access tier, or middle tier)

-The logic tier is pulled out from the presentation tier and, as its own layer, it controls an application’s functionality by performing detailed processing.

Data tier


-This tier consists of database servers.

-Here information is stored and retrieved.

-This tier keeps data neutral and independent from application servers or business logic. Giving data on its own tier also improves scalability and performance.


Data transfer between tiers is part of the architecture.

Protocols involved may include one or more of SNMP, CORBA, Java RMI, .NET Remoting, Windows Communication Foundation, sockets, UDP, web services or other standard or proprietary protocols.

Often middleware is used to connect the separate tiers.

Wednesday, 27 June 2012

Create PDF from DataTable in Asp.net,pdf generator without report viewer,

In this article ,i am explaining you how to create pdf file from datatable.i am passing a datatable in this function and code to convert this in pdf file. I am using iTextSharp you can download it from internet. it is free. you need to create a simple asp.net page and get data from database.Then pass it to ExportToPDF method. We can set PDF page margins, change page orientation (portrait, landscape), customize headers and footers add page numbers and more.Do some R & D with iTextSharp.
public void ExportToPdf(DataTable myDataTable)  
{
Document pdfDoc = new Document(PageSize.A4, 10, 10, 10, 10);
try
{
PdfWriter.GetInstance(pdfDoc, System.Web.HttpContext.Current.Response.OutputStream);
pdfDoc.Open();
Chunk c = new Chunk("" + System.Web.HttpContext.Current.Session["CompanyName"] + "", FontFactory.GetFont("Verdana", 11));
Paragraph p = new Paragraph();
p.Alignment = Element.ALIGN_CENTER;
p.Add(c);
pdfDoc.Add(p);
string clientLogo = System.Web.HttpContext.Current.Session["CompanyName"].ToString();
clientLogo = clientLogo.Replace(" ", "");
string clogo = clientLogo + ".jpg";
string imageFilePath = System.Web.HttpContext.Current.Server.MapPath("../ClientLogo/" + clogo + "");
iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imageFilePath);
//Resize image depend upon your need
jpg.ScaleToFit(80f, 60f);
//Give space before image
jpg.SpacingBefore = 0f;
//Give some space after the image
jpg.SpacingAfter = 1f;
jpg.Alignment = Element.HEADER;
pdfDoc.Add(jpg);
Font font8 = FontFactory.GetFont("ARIAL", 7);
DataTable dt = myDataTable;
if (dt != null)
{
//Craete instance of the pdf table and set the number of column in that table
PdfPTable PdfTable = new PdfPTable(dt.Columns.Count);
PdfPCell PdfPCell = null;
for (int rows = 0; rows < dt.Rows.Count; rows++)
{
for (int column = 0; column < dt.Columns.Count; column++)
{
PdfPCell = new PdfPCell(new Phrase(new Chunk(dt.Rows[rows][column].ToString(), font8)));
PdfTable.AddCell(PdfPCell);
}
}
//PdfTable.SpacingBefore = 15f; // Give some space after the text or it may overlap the table
pdfDoc.Add(PdfTable); // add pdf table to the document
}
pdfDoc.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename= SampleExport.pdf");
System.Web.HttpContext.Current.Response.Write(pdfDoc);
Response.Flush();
Response.End();
//HttpContext.Current.ApplicationInstance.CompleteRequest();
}
catch (DocumentException de)
{
System.Web.HttpContext.Current.Response.Write(de.Message);
}
catch (IOException ioEx)
{
System.Web.HttpContext.Current.Response.Write(ioEx.Message);
}
catch (Exception ex)
{
System.Web.HttpContext.Current.Response.Write(ex.Message);
}
}

Monday, 18 June 2012

asp .net : three different development models

Web Pages Single Pages Model Simplest ASP.NET model. Similar to PHP and classic ASP. Built-in templates and helpers for database, video, graphics, social media and more. MVC Model View Controller MVC separates web applications into 3 different components: Models for data Views for display Controllers for input Web Forms Event Driven Model The traditional ASP.NET event driven development model: Web pages with added server controls, server events, and server code. Visual Web Developer Development tool tailor made for MVC and Web Forms ASP.NET Framework .NET is a framework for developing virtually any type of computer application. The ASP.NET framework is the part of .NET designed for creating web applications.