Wednesday, July 1, 2009

Export to Excel Funcationality in ASP.Net

This artical we will learn Export grid values in to the excel file. In ASP.Net 2.0 Gridview and its data binding are for only for demonstrating the export funcationality.

The code to do the Excel Export is very straightforward. You can also export to different application type by changing the content-disposition and ContentType.
string attachment = "attachment; filename=Contacts.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();


if you run the code as above, it will give the http exception as followes

Control 'GridView1' of type 'GridView' must be placed inside a form tag with runat=server."

for this exception we need to add the below code for aspx code page.

public override void Verify RenderingInServerForm(Control control)
{
}
Example :
void ExportGrid(String strColumn)
{
String strValue = String.Empty; // StrValue is the Name of the file to export into excel.
switch (strColumn)
{
case "Zipcode" :
strValue = "attachment;filename=PDMIS_PrimaryLocation_DATA.xls";
break;
case "Specialty":
strValue = "attachment;filename=PDMIS_Specialty_DATA.xls";
break;}
Response.Clear();
Response.AddHeader("content-disposition", strValue);
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
switch (strColumn) // if you have the No's Grid's then this column is used to display the grid's. like
{
case "Zipcode":
grdViewZipcode.RenderControl(htmlWrite);
break;
case "Specialty":
grdviewSpeciality.RenderControl(htmlWrite);
break;
case "PayorType":
GridViewPayorType.RenderControl(htmlWrite);
break;}
Response.Write(stringWrite.ToString());
Response.End();
}

This is example is for only grid values are export into the excel format.If the grid is contains the Hyperlink buttons then you need visible false of the columns. after export the functionality then again you need to visible true of the particular columns.
______________________________________________________________________
If you want directly send the export table value you can do.Below is the example of that.
Create a class of Export to Excel :
Public Class clsExpExcel
Public Sub ExportToExcel(ByVal dt As Data.DataTable)
Dim filename As String = "ExcelFile.xls"
Dim response As HttpResponse = HttpContext.Current.Response
response.Clear() response.Charset = ""
response.ContentType = "application/vnd.ms-excel"

response.AddHeader("Content-Disposition", "attachment;filename=""" & filename & """")
Using sw As New StringWriter()

Using htw As New HtmlTextWriter(sw)
Dim dg As New GridView()
dg.DataSource = dt
dg.DataBind()
dg.RenderControl(htw)
'response.Write(Style)
response.Write(sw.ToString())
response.[End]() End Using End Using
End Sub

End Class
Use this class into all the form like :
Dim objConn As New clsConn.ConnDB
Protected Sub Btn_Excel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn_Excel.Click
Dim objExp As New clsExpExcel
Dim dt As New DataTable //View Departmetn_R_Pr is a Storeporcedure
dt = objConn.Select_StoreProc_WithoutPara("ViewDepartment_R_Pr") dt.Columns.Remove("ModifiedDate") //This will store into the table.

dt.Columns.Remove("ModifiedBy") // If you want to remove the ModifiedDate and ModifiedBy columns in the table you can to do. Then remaining will be export to into the excel format.
objExp.ExportToExcel(dt)
End Sub
This you can give the aspx page.This function will directly take the control value you no need to give the control value.
Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub


Tuesday, July 1, 2008

eGateINTELLIGENT QUEUE QUICK REFERENCE DOCUMENT


Hi,

Am going to brief explanantion about IQ, Intelligent Queue in egate environment, how it will work and how to manage the IQ....
Overiew of IQ:

SeeBeyond IQ services and associated IQs provide a high-performance, non-volatile
means for storing data inside the e*Gate Integrator environment. See beyond IQ Services provide the mechanism for moving Events between IQs and handling the low-level Implementation of data exchange (such as system calls to initialize or reorganize a Database).

SeeBeyond Provides File based IQ Service, Java Messages Service, Memory Loop IQ Service and Specialized IQ Services that work with Database Management System (DBMS). To Provide Additional Queuing and data Storage Functionality.

SeeBeyond IQ Services:
· SeeBeyond Standard IQ
· SeeBeyond Memory Loopback IQ
· SeeBeyond JMS IQ

SeeBeyond Standard IQ:- The SeeBeyond Standard IQ uses a file-based queuing mechanism with memory mapping of files to ensure high performance.

SeeBeyond Memory Loopback IQ:- The SeeBeyond Memory Loopback IQ is an in-process memory based mechanism to support an individual e*ways or Bobs module in a standalone manner.

SeeBeyond JMS IQ:- The JMS IQ is an implementation of Java Message Service. To use Significantly faster performance and better scalability. It can support for standard JMS Message types.

Database IQ Services:
· ODBC IQ (for Microsoft SQL Server 7.0 and 2000)
· Oracle IQ (for Oracle 8.1.6 and 8.1.7)
· Sybase IQ (for Sybase Open Client 11.1.1 and 12.0 and Sybase Server 11.9 and 12.0)
· IBM MQSeries IQ (for IBM MQSeries 5.1 and 5.2, server and client modes).

IQ Manager and Disk Space Thresholds:

a) The IQ Manager Checks The amount of free disk space on the system where IQ’s are located. If you have not set a disk space threshold for the participating host the IQ Manager shuts down if the amount of free disk space is less than 5 MB. The default threshold setting is 5MB and it will uses highest setting.

IQ Operations:

The SeeBeyond Standard IQ stores all data in disk files, including content of the Event, expiration times, and priority. The files are then named and organized into directories based on a combination of the Universal Unique Identification (UUID) for the IQ, publishing, and subscribing components, and the date and time the data is processed.

The IQ’s are Stored in
c:\eGate\Client\Iq directory.

1) The See Beyond Standard IQ uses two types of file structure

a) Index b) Data

2) Index files contain information related to the Events and pointers to the data files. They have an .rdb file extension.

3) Data files contain the actual contents of the Events. They have a .dat extension.

Message Status:
CLEAN : The Selected Subscriber has not retrieved the Event.
DONE : The Selected Subscriber has read and processes the Event.
EXPRIED : Either or both of the following:
�� for the publisher of this Event Type, the elapsed time since the Event was enqueued has exceeded the set expiration time.
�� The Event has been fully processed by all subscribers.
FETCHED : The selected subscriber has picked up and read the Event but has not
Finished processing it.
FETCHED, DONE : The selected subscriber has picked up, read, and processed the Event.
REVEALED : For the publisher of this Event Type, the Event has been made
Available for subscribers to retrieve.

Events Status:
Active Events are published but not yet written to the journal, and are waiting for
one or more subscribers to retrieve the Event and mark it DONE. An active Event is written to the journal after all subscribers mark it DONE or after its expiration time elapses, whichever comes first.

Journaled Events are Events that are no longer active, either because they were
Picked up and marked “done” by all their subscribers or because they expired. If a journaled Event remains journaled past its expiration time, it is deleted when you run an IQ cleanup operation.

Cleanup for the See beyond Standard IQ:
Each hour, e*Gate creates a new journal index file and a new data file to hold that
Hour’s IQ data. The cleanup process deletes the files only after all the entries in the journal index file have been marked OK to delete.
If the journal expiration time is set to zero, the IQ journal index and data files are never
deleted unless you selected the Do not store journaled option in the IQ properties.

Administering IQs:
IQ Administrator allows you to do any of the following:
1) Within the current schema, browse an expandable/collapsible hierarchy view of
IQ Managers, IQs, publishers, Event Types, subscribers, and individual Events.
2) View the status and contents of each IQ, with color-coding of each Event’s state:
White Events are Unread by subscriber; blue Events are Read by subscriber;
yellow Events are Journaled.
3) See a summary of Events for a specified Event Type or subscriber.
4) Query the details of any individual Event, such as its size, timestamp, and priority.
Note: Because IQ Administrator can be used simultaneously in many time zones, its
Timestamps are in GMT (Universal Time), unlike log file timestamps, which are in
Local time.
5) Edit or query the status of an individual Event or range of Events, so that you can
Locate an Event that is causing a problem, diagnose and possibly solve the problem,
And cause it to be deleted or re-sent.

Stciqutil Utility:
eGate includes an IQ Utility, stciqutil.exe, that enables you to view and manipulate an IQ’s content outside of the eGate environment. This will explains how to use stciqutil to perform basic tasks, but it doesn’t include a comprehensive list of all qualifiers and available flags.

NOTE: The Complexity of IQ storage, we strongly recommended that you only use See Beyond IQ utilities for interfacing with the IQ’s.
Be extremely careful if you use this command to manipulate and reload IQ data. Errors can cause e*Gate to process the queue data incorrectly, and may cause other consequences in the systems that receive the processed e*Gate data.

Dumping the Contents of an IQ:

When you use stciqutil to dump the content of an IQ, It will creates the four files per event using the following naming convention

IQname-YYYY-MM-DD-HH-mm-SS-sss-NNNNN-nnnnn.ext

IQ Name -> Name of the IQ
YYYY-MM-DD-HH-mm-SS-sss -> Date Time
NNNNN - > The Major Sequence Number
nnnnn - > The Minor Sequence Number
ext -> is the one of the following .att (attributes), .hdr (header), .pth (path blob) or .evt (event data)
1) Generally, only the .att file is human readable, unless the queued Event was in plain ASCII text (in which case .evt file will also be readable).
2) e*Gate imposes no limit on the size of the IQ that can be dumped; however, you must
have sufficient disk space to contain both the IQ data and the IQ dump.

Command for Dump IQ:


Stciqutil –rh -rs -un -up -event -iq -pub -od -qd (qd is flag for dumping).

Note: Dumping an IQ only Copies the Contents of an IQ; it does not empty the iq of it contents.

Display Events of an IQ’s:

You can display all minor and major events keys associated with an IQ. The output is printed in your screen and is not saved in a file.

Command for Display Events of an IQ’s:

Stciqutil –rh -rs -un -up -event -iq -pub -keys (Keys is a flag it shows all minor and major events associated with the current iq).

Reloading an IQ:
When you reload an IQ, you put new Events or Events you had dumped into a directory back into the IQ. The dumped events will be inserted into the queue as unique, new events with different enqueue times than the originals.

NOTE: Reloading Events does not overwrite the original Events in the IQ. For information
on deleting the original Events, see “Deleting Events from an IQ”, below, or see the Monk Developer’s Reference for information regarding the Monk command iq-mark-unusable.

Command for Reload an IQ:


Stciqutil -rh -rs -un -up -event -iq -sub -id -ld (is the flag for Reload the IQ).
Deleting Events from an IQ:


If you are reloading an IQ and you want eGate to use the new Events in place of original Events that were dumped, you should delete the existing Events before you perform the reload operation. If you perform the deletion procedure after reloading an IQ both the original and the reloaded events will be marked “deleted”.
The stciqutil command flag –mark DELETED marks only single event has deleted at a time. To delete multiple Events, you can run a shell script that runs the stciqutil command multiple times.

NOTE: The command flag -mark DELETED marks an Event as deleted in the IQ and make
it unavailable for processing. The Event is not physically deleted from the IQ until the next IQ cleanup is run.

Command for Delete an Singe Event form an IQ:


Stciqutil –rh -rs -un -up -iq -pub <> -event -mark DELETED –ma -mi -dt

Counting the No of Events from an IQ:
You can display No of events associated with an IQ. The output is printed in your screen and is not saved in a file.

Command to know that No of Events from an IQ:


Stciqutil –rh -rs -un -up -iq -pub -event -cnt (cnt is the flag to shows the no of events in an IQ).

Command to know the no of un-read messages form an IQ:


Stciqutil –rh -rs -un -up -iq -pub -sub -event -cnt –live. (live flag allows users to work with active Events only that is Events that have not been fetched and marked “done”).

Command to know the Journaled Events from an IQ:

Stciqutil –rh -rs -un -up -iq -pub -sub -event -cnt –ar (This command will work only for SeeBeyond Standard IQ’s).

Command to know the fetched but not marked Events:


Stciqutil –rh -rs -un -up -iq -pub -sub -event -cnt –fnd
It will gives the only events marked “fetched” but not marked “done”.

Verifying and Recovering IQ’s:
If you suspect a standard IQ has become corrupted, you have several tools for verifying and recovering data using command utilities stciqstdutil.exe and stciqutil.exe.

Note:Because of the complexity of IQ storage, we strongly recommend that you only use
the SeeBeyond IQ utilities for interfacing with the IQs.
Verifying and Recovering IQ’s:
If you suspect a standard IQ has become corrupted, you have several tools for verifying and recovering data using command utilities stciqstdutil.exe and stciqutil.exe.

NOTE: Because of the complexity of IQ storage, we strongly recommend that you only use
the SeeBeyond IQ utilities for interfacing with the IQs.

To verify that a Queue is intact:
Run stciqstdutil.exe against the index file (.rdb) you suspect. Enter the following command
Stciqstdutil.exe –ip eGate\client\iq\{3E2D28EE-010B-11D4-BE68-B62F6823CE53} (or Give the path of the iq directory and subdirectories). –n qlive_{71A66202-7D35-11D4-9271-E2D1B5816FCD}.rdb
If the utility can dump an entire index file, it displays the following message:
Wrote record(s) to file:

Repeat against any other index files you suspect.
If the utility is able to dump all the index files, then the index files are intact and you can ignore error messages like the following:
stciqstdutil (Error): Bad Column Counts: Table IQISubscriber In 13 Existing 11
However, if the utility fails to dump any one index file, then the queue is corrupted. In such cases to dump the queue message index and queue message content.

To dump the Queue Message index and Queue Message Content:
Run the stciqstdutil.exe against the index file, you suspect, but use an additional option –dp.

stciqstdutil.exe -ip egate/client/iq/{3E2D28EE-010B-11D4-BE68-B62F6823CE53}
-n qlive_{71A66202-7D35-11D4-9271-E2D1B5816FCD}.rdb -dp gate/client/iq/{3E2D28EE-010B-11D4-BE68-B62F6823CE53}

This command will dumps both the queue message index and queue message content. Be prepared for increased disk space usage.
If you see messages saying that the qmessages_*.dat file is corrupted, then the queue is corrupted. Continue with the step below to recover the Events in the IQ.
Use stciqstdutil.exe to dump messages in qmessages_*.dat files, using the
following command: stciqstdutil -extract
A new file, qmessages_.dat, is created every hour by the IQ Manager. You can
choose which hour's messages to dump by selecting the correct hour for the qmessages_*.dat file. If the qmessages_*.dat file is corrupted, then stciqstdutil.exe will stop at the last good message in the file.


Quick Way to Delete the Events from an IQ:
To delete entire IQ
1) First shutdown eWays
2) Shutdown the iq Manager that is associated with that outbound eWay collab first.
3) Find the QID that is in the iqmgr log. It should be in $EGATE/log directory called 'Name of the iq Manager'.log Look for something like {FFAB-8378-9........}
4) Go to the $EGATE/iq/{FFAB-8378-9......}
5) Under that directory, you should find some dates associated with the dates/times the message was subscribed to.
6) You will have to go down to the lowest level to delete the files.
7) Once you have deleted most of it, you can start the iq Manager. Then start the eWay ...maybe give it about 5 min or so...

IF you need more information about IQ's please go through the wesite
http://www.seebeyond.com

you we will get all information about eGate.



free hit counter codes