/// <summary>TBD</summary>
 /// <param name="sender">TBD</param>
 /// <param name="e">TBD</param>
 protected void downloadPDFs_Click(object sender, EventArgs e)
 {
     try
     {
         if (attachmentIDs.Value == "")
         {
             throw new Exception("No attachment IDs were specified.");
         }
         PdfMerge5 pdfMerger = new PdfMerge5();
         string extension = "pdf";
         string fileName = string.Format("{0}_{1}{2}{3}{4}{5}{6}.{7}", "QuattroAttachments", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, extension);
         if (attachmentIDs.Value.Contains(","))
         {
             string[] attachmentIdList = attachmentIDs.Value.Split(',');
             foreach (string attachmentId in attachmentIdList)
             {
                 pdfMerger.AddDocument(GetAttachment(attachmentId));
             }
         }
         else
         {
             pdfMerger.AddDocument(GetAttachment(attachmentIDs.Value));
         }
         Response.Clear();
         Response.ContentType = "application/octet-stream";
         Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
         pdfMerger.Merge(Response.OutputStream);
         Response.Flush();
     }
     catch (Exception ex)
     {
         WebCommon.LogExceptionInfo(ex);
         WebCommon.ShowAlert("An error occurred while trying to download the attachments.");
     }
 }
Пример #2
0
 /// <summary>TBD</summary>
 /// <param name="sender">TBD</param>
 /// <param name="e">TBD</param>
 protected void buttonServerPrint_Click(object sender, EventArgs e)
 {
     try
     {
         string[] invoiceNumbers = GetInvoiceNumbers();
         int companyId = Convert.ToInt32(dropDownCompany.SelectedValue);
         byte[] results = null;
         PdfMerge5 pdfMerger = new PdfMerge5();
         string extension = "pdf";
         string fileName = string.Format("{0}_{1}{2}{3}{4}{5}{6}.{7}", "InvoiceReprint", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, extension);
         StringBuilder invoiceList = new StringBuilder();
         foreach (string invoiceNumber in invoiceNumbers)
         {
             invoiceList.Append((String.IsNullOrEmpty(invoiceList.ToString()) ? "" : ",") + invoiceNumber);
             GetWebResponse(invoiceNumber, companyId, out results);
             pdfMerger.AddDocument(results);
         }
         WebCommon.WriteDebugMessage(string.Format("Invoice Reprint requested by: {0}. For Invoice(s): {1}", Security.GetCurrentUserId, invoiceList.ToString()));
         Response.Clear();
         Response.ContentType = "application/octet-stream";
         Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
         pdfMerger.Merge(Response.OutputStream);
         Response.Flush();
         //pdfMerger.Merge(fileName);
     }
     catch (Exception ex)
     {
         WebCommon.LogExceptionInfo(ex);
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "invoiceReprintErrorAlert", @"alert(""An error occurred while trying to reprint the invoice(s). Please make sure the Invoice(s) you entered exist and the Invoice Number(s) were entered in the correct format."");", true);
     }
 }