Exemplo n.º 1
0
        private void ReturnImageData(long transactionId)
        {
            byte[]            bytes      = new byte[1];
            InterFax.InterFax myInterFax = new InterFax.InterFax();

            try
            {
                long returnValue = myInterFax.GetFaxImage(Configuration.InterFaxUserName, Configuration.InterFaxPassword, transactionId, ref bytes);

                if (returnValue == 0)
                {
                    Response.Clear();
                    Response.ContentType = "image/tiff";
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + transactionId.ToString() + ".tiff");
                    Response.OutputStream.Write(bytes, 0, bytes.Length);
                    Response.End();
                }
                else
                {
                    lblConfirmation.Text = "The requested fax could not be retrieved, the error code returned was: " + returnValue.ToString();
                    Orchestrator.Logging.ApplicationLog.WriteError("Orchestrator.WebUI.adminstration.audit.sentFaxes.ReturnImageData", "Fax retrieval failed: " + returnValue.ToString());
                }
            }
            catch {}
        }
Exemplo n.º 2
0
        public void btnResend_Click(object sender, EventArgs e)
        {
            int         count         = int.MinValue;
            long        transactionId = long.MinValue;
            string      faxNumber     = string.Empty;
            eReportType reportType    = 0;

            InterFax.InterFax myInterFax;

            count = dgFaxes.SelectedItems.Count;
            if (count != 0)
            {
                // Should only have one select as this is multiple selects on the grid are not allowed.
                foreach (ComponentArt.Web.UI.GridItem item in dgFaxes.SelectedItems)
                {
                    transactionId = Convert.ToInt64(item["TransactionId"]);
                    faxNumber     = item["FaxNumber"].ToString();
                    reportType    = (eReportType)Enum.Parse(typeof(eReportType), item["Description"].ToString());
                }

                myInterFax = new InterFax.InterFax();
                long returnedTransactionId = myInterFax.ReSendFax(Configuration.InterFaxUserName, Configuration.InterFaxPassword, transactionId, faxNumber);

                if (returnedTransactionId > 0)
                {
                    Facade.IAudit facAudit = new Facade.Audit();
                    facAudit.FaxSent(reportType, returnedTransactionId, faxNumber, ((Entities.CustomPrincipal)Page.User).UserName);

                    lblConfirmation.Text = "The fax was resent.";

                    // Cause the data to be updated.
                    BindFaxData();
                }
                else
                {
                    lblConfirmation.Text = "The fax was not resent.";
                    Orchestrator.Logging.ApplicationLog.WriteError("Orchestrator.WebUI.adminstration.audit.sentFaxes.ResendFax", "Fax resend failed: " + returnedTransactionId);
                }

                lblConfirmation.Visible = true;
            }
        }
Exemplo n.º 3
0
        public string FaxReport(string faxNumber)
        {
            string      message = string.Empty;
            bool        success = false;
            eReportType reportType;
            ReportBase  activeReport = this.GetCurrentActiveReport(out reportType);

            if (activeReport != null)
            {
                // Use the override fax number if provided
                if (Configuration.InterFaxOverrideFaxNumber != String.Empty)
                {
                    faxNumber = Configuration.InterFaxOverrideFaxNumber;
                }

                // Strip the faxNumber into a pure telephone number (i.e. no non-numeric characters)
                Regex stripper = new Regex("[^0-9]*");
                faxNumber = stripper.Replace(faxNumber, String.Empty);

                // Create an international number for this UK number
                if (faxNumber.IndexOf("0") == 0)
                {
                    faxNumber = faxNumber.Substring(1);
                    faxNumber = "+44" + faxNumber;
                }

                // Create a memory stream to put the exported PDF into.
                PdfExport    pdfExporter  = new PdfExport();
                MemoryStream outputStream = new MemoryStream();

                // Use the pdf exporter to load the memory stream with the resulting PDF document
                pdfExporter.Export(activeReport.Document, outputStream);

                // Move the position back to the beginning of the stream.
                outputStream.Seek(0, SeekOrigin.Begin);

                // Create a byte array buffer to read the memory stream into.
                byte[] bytes = new byte[outputStream.Length];
                outputStream.Read(bytes, 0, (int)outputStream.Length);

                // Make the fax call (via WS)
                InterFax.InterFax myInterFax = new InterFax.InterFax();

                // Record the audit information
                long transactionId = myInterFax.Sendfax(Configuration.InterFaxUserName, Configuration.InterFaxPassword, faxNumber, bytes, "PDF");

                if (transactionId > 0)
                {
                    // The fax has been sent - record the event
                    Facade.IAudit facAudit = new Facade.Audit();
                    string        userId   = ((Entities.CustomPrincipal)HttpContext.Current.User).UserName;

                    // If faxing Client Delivery & Returns Log, LogId Session variable will be present.
                    if (HttpContext.Current.Session["LogId"] == null)
                    {
                        success = facAudit.FaxSent(reportType, transactionId, faxNumber, userId);
                    }
                    else
                    {
                        success = facAudit.LogFaxSent(transactionId, (int)HttpContext.Current.Session["LogId"], faxNumber, userId);
                    }

                    message = "Your report has been faxed.";
                }
                else
                {
                    message = "Your report has not been faxed. <!--(" + transactionId.ToString() + ")-->";

                    // An error occurred
                    if (Configuration.EventLogEnabled && Configuration.EventLogTraceLevel > 0)
                    {
                        ApplicationLog.WriteInfo("Orchestrator.ReportRunner.FaxReport", "Fax to " + faxNumber.ToString() + " Failed - Error reported as " + transactionId.ToString());
                    }
                }
            }

            return(message);
        }