Click here to Skip to main content
16,013,816 members

Comments by Mahesh.Dhiman27 (Top 3 by date)

Mahesh.Dhiman27 30-Mar-15 3:12am View    
Hi,

Here my code, please check.

public static void GenerateNAVPDF(string strBoxID, string strWebOrder, string strDocketNo, string ftpIP, string folderName)
{
ReportViewer rptViewer = new ReportViewer();
try
{

logger.Debug("Generate PDF start");
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
string devInfo = "<deviceinfo><outputformat>PDF" +
"<PageWidth>5.83in</PageWidth>" +
"<PageHeight>8.27in</PageHeight>" +
"<margintop>0in" +
"<marginleft>0in" +
"<marginright>0in" +
"<marginbottom>0in" +
"";

ProcessInvoiceDataBL objInvoiceBL = new ProcessInvoiceDataBL();
DataSet dsInvoice = null;

dsInvoice = objInvoiceBL.GetPostedInvoiceDetail(strBoxID);
logger.Debug("Fetch Invoice Data Successfully.");
if (dsInvoice != null && dsInvoice.Tables.Count > 1)
{
if (dsInvoice.Tables[0].Rows.Count > 0)
{
if (Convert.ToString(dsInvoice.Tables[0].Rows[0]["giftorder"]) == "1")
{
logger.Debug("This is a Gift Order,Please use Nav for Printing this Invoice. Shipment label is being printed.");
}
else
{
logger.Debug("Invoice Pdf start");
BarcodeLib.Barcode b = new BarcodeLib.Barcode();
b.Alignment = BarcodeLib.AlignmentPositions.CENTER;
b.LabelPosition = BarcodeLib.LabelPositions.TOPCENTER;
BarcodeLib.TYPE type = BarcodeLib.TYPE.CODE128;
b.IncludeLabel = false;
b.LabelPosition = BarcodeLib.LabelPositions.TOPCENTER;
System.Drawing.Image img = b.Encode(type, Convert.ToString(dsInvoice.Tables[0].Rows[0]["DocketNo"]), 400, 100);
dsInvoice.Tables[0].Columns.Add("ImgData", typeof(byte[]));
dsInvoice.Tables[0].Rows[0]["ImgData"] = imageToByteArray(img);

rptViewer.ProcessingMode = ProcessingMode.Local;

rptViewer.LocalReport.DataSources.Clear();

rptViewer.LocalReport.ReportPath = @"C:\UploadNAVPDFToFTPLog\Invoice.rdlc";

rptViewer.LocalReport.DataSources.Clear();
rptViewer.LocalReport.DataSources.Add(new ReportDataSource("dsInvoice_Header", dsInvoice.Tables[0]));
rptViewer.LocalReport.DataSources.Add(new ReportDataSource("dsInvoice_Lines", dsInvoice.Tables[1]));
logger.Debug("RPT Datasource Assiged, Render Start");
byte[] bytes = rptViewer.LocalReport.Render("PDF", devInfo, out mimeType, out encoding, out extension, out streamIds, out warnings);
logger.Debug("RPT Render Ends");

string file_name = strWebOrder + "_" + strDocketNo + ".pdf"; //save the file




System.Net.FtpWebRequest ftpRequest = null;


logger.Debug("FTP Request Start");
ftpRequest
Mahesh.Dhiman27 30-Mar-15 3:05am View    
Hi,

My service fetching data from sqlserver database and create pdf using report viewer and then save that pdf on ftp server. I am not using any window form.

Steps:
1) craeting report viewer object in method like ReportViewer rptViewer = new ReportViewer();
2) Fetching data from database and fill dataset.
3) Set all report viewer properties.
4) Create ftp request.
5) write report viewer bytes data on the ftp server using ftp stream.
6) rptViewer.LocalReport.Refresh(); rptViewer.RefreshReport();
7) Clear and Dispose dataset object.
8) clear and Dispose report viewer object

After that same process for next record.

Thanks
Mahesh Dhiman
Mahesh.Dhiman27 1-Jul-11 7:59am View    
Thanks Sir