NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

public static void SetDbConnectionsForReport(ReportDocument rd)
{
ConnectionInfo crconnectioninfo = new ConnectionInfo();
crconnectioninfo.ServerName = dbServer;
crconnectioninfo.DatabaseName = dbName;
crconnectioninfo.UserID = dbUserName;
crconnectioninfo.Password = dbPassword;
Tables CrTables;
if (rd != null)
{
CrTables = rd.Database.Tables;
TableLogOnInfo crtablelogoninfo = new TableLogOnInfo();
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtablelogoninfo = CrTable.LogOnInfo;
crtablelogoninfo.ConnectionInfo = crconnectioninfo;
CrTable.ApplyLogOnInfo(crtablelogoninfo);
}
}
}

public void ViewInvoice(int invoiceId, string lastName, string MaiNo)
{
try
{

bool isValid = true;
string strReportName = "InvoiceDetailsReport.rpt";

string maiNo = Convert.ToString(MaiNo);

//var targetFilePath = Server.MapPath("~/Content/UserFiles/" + maiNo + "/Invoice/");
var targetFilePath = defaultUserFilePath + maiNo + "/Uploaded Documents/";
if (!Directory.Exists(targetFilePath))
Directory.CreateDirectory(targetFilePath);
//targetFilePath = Server.MapPath(Path.Combine("~/Content/UserFiles/" + maiNo + "/Invoice/", fileName));

string outPutFile = maiNo + "" + lastName + "_Invoice.pdf";


//List<string> filePathsList = Directory.GetFiles(targetFilePath, "*.pdf", SearchOption.AllDirectories).Where(x => x.Contains(maiNo + "" + lastName + "_Invoice (") && x.Contains(").pdf")).ToList();
//if (filePathsList != null && filePathsList.Count > 0)
//{
// int number = 0;
// foreach (var item in filePathsList)
// {
// int fileNumber = 0;
// var validConversation = int.TryParse(Path.GetFileName(item).Split('(')[1].Split(')')[0], out fileNumber);
// if (validConversation)
// {
// if (fileNumber > number)
// number = fileNumber;
// }
// }
// if (number > 0)
// {
// number++;
// outPutFile = maiNo + "" + lastName + "_Invoice (" + number + ").pdf";
// }
//}


targetFilePath = Path.Combine(defaultUserFilePath + maiNo + "/Uploaded Documents/", outPutFile);


if (System.IO.File.Exists(targetFilePath))
{
string Comment = "Archive - " + Utility.CurrentLoginUser.FullName + " generate new invoice so archive existing invoice from ";
var response = CommonMoveToArchive("Uploaded Documents", Comment, maiNo, targetFilePath, "Invoice & Reports");

//if archive not working then file deleted without file log.
if (!response)
{
System.IO.File.Delete(targetFilePath);
}
}
System.IO.File.Delete(targetFilePath);

//for password
string tempPdfPath = Server.MapPath(Path.Combine(defaultPathForCoverLetter + "ClonedFilesForCoverletter/", Guid.NewGuid() + ".pdf"));
if (string.IsNullOrEmpty(strReportName))
isValid = false;

if (isValid)
{
ReportDocument rd = new ReportDocument();
string strRptPath = System.Web.HttpContext.Current.Server.MapPath("~/") + "Reports//" + strReportName;
rd.Load(strRptPath);
TextObject headerTextObj = (TextObject)rd.ReportDefinition.Sections["Section1"].ReportObjects["HeaderRight"];
string headerText = "39500 High Pointe Boulevard n";
headerText = headerText + "Suite 400 n";
headerText = headerText + "Novi, Michigan 48375 - 5379 n";
headerText = headerText + "Phone: (855) 306 - 4155 n";
headerText = headerText + "Fax: (248) 344 - 3100";
headerTextObj.Text = headerText;
//TextObject invoiceTitleObj = (TextObject)rd.ReportDefinition.Sections["Section2"].ReportObjects["InvoiceTitle"];
//invoiceTitleObj.Text = "INVOICE";
TextObject footerTextObj = (TextObject)rd.ReportDefinition.Sections["Section1"].ReportObjects["FooterLeft"];
string footerText = "ManageAbility IME, Inc. n";
footerText = footerText + headerText;
footerTextObj.Text = footerText;

//Section section = rd.ReportDefinition.Sections[2];
//section.Height = 600;

rd.SetParameterValue("@InvoiceId", invoiceId);

SetDbConnectionsForReport(rd);
//rd.SetDatabaseLogon(dbUserName, dbPassword, dbServer, dbName);

rd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, tempPdfPath); //tempFilepath for password
rd.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, "InvoiceDetails");
//Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
//return File(stream, "application/pdf");

//string tempPdfPath2 = Server.MapPath(Path.Combine(defaultPathForCoverLetter + "ClonedFilesForCoverletter/", Guid.NewGuid() + ".pdf"));

using (FileStream fs = new FileStream(targetFilePath, FileMode.Create, FileAccess.Write, FileShare.None))
{
PdfReader reader = new PdfReader(tempPdfPath);
using (PdfStamper stamper = new PdfStamper(reader, fs))
{
Dictionary<String, String> info = reader.Info;
if (info.ContainsKey("Title"))
{
info["Title"] = "Invoice & Reports";
}
else
{
info.Add("Title", "Invoice & Reports");
}

//info.Add("Subject", "Hello World with changed metadata");
//info.Add("Keywords", "iText in Action, PdfStamper");
//info.Add("Creator", "Silly standalone example");
//info.Add("Author", "Also Bruno Lowagie");
stamper.MoreInfo = info;
stamper.Close();
}
reader.Close();
}
System.IO.File.Delete(tempPdfPath);

// for password
//using (Stream input = new FileStream(tempPdfPath2, FileMode.Open, FileAccess.Read, FileShare.Read))
//{
// using (Stream output = new FileStream(targetFilePath, FileMode.Create, FileAccess.Write, FileShare.None))
// {
// PdfReader reader = new PdfReader(input);
// string Password = maiNo = maiNo.Contains("-") ? maiNo.Split('-')[0].ToString() : maiNo;
// PdfEncryptor.Encrypt(reader, output, true, null, null, PdfWriter.ALLOW_PRINTING | PdfWriter.AllowModifyContents | PdfWriter.ALLOW_COPY);
// }
//}
//System.IO.File.Delete(tempPdfPath2);

//file log for new invoice file
string Comment = "New - Invoice generated by " + Utility.CurrentLoginUser.FullName + " and its save at " + targetFilePath;
CommonInsertFileLog("Invoice", Comment);
}
else
{
Response.Write("<H2>Nothing Found; No Report name found</H2>");
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.