Ejemplo n.º 1
0
        private Boolean Descargar_PDF_RIDE(tb_Comprobante_Info InfoCbteT, string Ruta_File, string OpcionNombreDes)
        {
            try
            {
                string     msg           = "";
                string     nombreArchivo = "";
                XtraReport Reporte       = new XtraReport();
                Reporte = Rpt_Ride_Bus.Optener_reporte(InfoCbteT, ref msg);
                Stream FileBinary;
                if (OpcionNombreDes == "claveAcceso")
                {
                    XmlDocument xmlOrigenCdata = new XmlDocument();
                    xmlOrigenCdata.LoadXml(InfoCbteT.s_XML);
                    string claveAcceso = xmlOrigenCdata.GetElementsByTagName("comprobante")[0].InnerXml.Replace("<![CDATA[", "").Replace("]]>", "");
                    xmlOrigenCdata.LoadXml(claveAcceso);
                    nombreArchivo = xmlOrigenCdata.GetElementsByTagName("claveAcceso")[0].InnerText;
                }
                else
                {
                    nombreArchivo = InfoCbteT.Nom_emisor + "_" + InfoCbteT.IdComprobante;
                }


                FileBinary = new FileStream(Ruta_File + "\\" + nombreArchivo + ".pdf", FileMode.Create);
                DevExpress.XtraPrinting.PdfExportOptions Optione = new DevExpress.XtraPrinting.PdfExportOptions();
                Reporte.ExportToPdf(FileBinary, Optione);
                FileBinary.Close();

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        protected string pivotgridExpoort(string contentType)
        {
            string fileName = USERID + "_" + TitleHeader.Text + "." + contentType;
            string filepath = MapPath("~/Upload/Report");

            System.IO.FileStream fs = new System.IO.FileStream(filepath + "\\" + fileName, System.IO.FileMode.Create, System.IO.FileAccess.Write);

            switch (contentType)
            {
            case "pdf":
                DevExpress.XtraPrinting.PdfExportOptions pdfxport = new DevExpress.XtraPrinting.PdfExportOptions();
                gridExport.WritePdf(fs, pdfxport);
                break;

            case "xls":
                gridExport.WriteXls(fs);
                break;

            case "rtf":
                gridExport.WriteRtf(fs);
                break;

            case "csv":
                gridExport.WriteCsv(fs);
                break;
            }
            fs.Dispose();
            return("../Upload/Report/" + fileName);
        }
Ejemplo n.º 3
0
        private Boolean Crear_Pdf_en_TMP(tb_Comprobante_Info InfoCbteT, string Ruta_File)
        {
            try
            {
                string         msg     = "";
                XtraReport     Reporte = new XtraReport();
                tb_Empresa_Bus EmB     = new tb_Empresa_Bus();



                Rpt_Ride_bus Rpt_Ride_Bus = new Rpt_Ride_bus(listEmpr);
                Reporte = Rpt_Ride_Bus.Optener_reporte(InfoCbteT, ref msg);
                //pdf
                Stream FileBinary;
                FileBinary = new FileStream(Ruta_File + "\\" + InfoCbteT.IdComprobante + ".pdf", FileMode.Create);
                DevExpress.XtraPrinting.PdfExportOptions Optione = new DevExpress.XtraPrinting.PdfExportOptions();
                Reporte.ExportToPdf(FileBinary, Optione);
                FileBinary.Close();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                BusSisLog.Log_Error(ex.Message.ToString(), eTipoError.ERROR, this.ToString());
                return(false);
            }
        }
Ejemplo n.º 4
0
 private void createPDFFile()
 {
     foreach (DocumentTreeView documentTreeView in this.documentTreeViews)
     {
         if (documentTreeView.Leaf)
         {
             try
             {
                 this.appendDocument(documentTreeView.NodeName + ".docx");
             }
             catch (Exception)
             {
             }
         }
     }
     //Set the required export options:
     DevExpress.XtraPrinting.PdfExportOptions options = new DevExpress.XtraPrinting.PdfExportOptions();
     //options.DocumentOptions.Author = "Mark Jones";
     //options.Compressed = false;
     options.ImageQuality = DevExpress.XtraPrinting.PdfJpegImageQuality.High;
     //Export the document to the file:
     this.richEditControl1.ExportToPdf(this.doc_template_id + ".pdf", options);
     DocUtil.fileCopy(this.doc_template_id, this.wpd_file_name, "pdf");
     //Export the document to the file stream:
     using (FileStream pdfFileStream = new FileStream(this.wpd_file_name + ".pdf", FileMode.Create))
     {
         this.richEditControl1.ExportToPdf(pdfFileStream, options);
     }
 }
Ejemplo n.º 5
0
        public ActionResult Print(long layoutId)
        {
            string error;
            var    viewModel = GetModelFromSession(layoutId, out error);

            if (viewModel == null)
            {
                return(View("AvrServiceError", (object)error));
            }
            var options = new DevExpress.XtraPrinting.PdfExportOptions();

            options.ShowPrintDialogOnOpen = true;
            return(DevExpress.Web.Mvc.GridViewExtension.ExportToPdf(LayoutViewHelper.GetGridViewSettings(viewModel.ViewHeader), viewModel.ViewData, false, options));
        }
Ejemplo n.º 6
0
        static public void GridExport(GridView gridView, string Title)
        {
            Result res = null;

            try
            {
                SaveFileDialog dlg = new SaveFileDialog();

                dlg.Title            = Title;
                dlg.Filter           = "Excel Workbook|*.xlsx|Excel 97-2003 Workbook|*.xls|Acrobat Reader|*.pdf|Text Format|*.txt";
                dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                dlg.RestoreDirectory = true;

                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    switch (dlg.FilterIndex)
                    {
                    case 1:
                        DevExpress.XtraPrinting.XlsxExportOptions opt = new DevExpress.XtraPrinting.XlsxExportOptions();
                        opt.ExportMode     = DevExpress.XtraPrinting.XlsxExportMode.SingleFile;
                        opt.TextExportMode = DevExpress.XtraPrinting.TextExportMode.Value;
                        gridView.ExportToXlsx(dlg.FileName, opt);
                        break;

                    case 2:
                        gridView.ExportToXls(dlg.FileName);
                        break;

                    case 3:
                        DevExpress.XtraPrinting.PdfExportOptions pdf = new DevExpress.XtraPrinting.PdfExportOptions();
                        pdf.ConvertImagesToJpeg = true;
                        gridView.ExportToPdf(dlg.FileName);
                        break;

                    case 4:
                        gridView.ExportToText(dlg.FileName);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Result r = new Result(1, ex.ToString());
                ValidateQuery(res);
            }
        }
Ejemplo n.º 7
0
        public override int Export(object sender, object neuObject)
        {
            string         saveFileName = "";
            SaveFileDialog saveDialog   = new SaveFileDialog();

            saveDialog.DefaultExt       = "PDF";
            saveDialog.Filter           = "PDF|*.pdf";
            saveDialog.RestoreDirectory = true;
            if (saveDialog.ShowDialog() == DialogResult.Cancel)
            {
                return(0);
            }
            saveFileName = saveDialog.FileName;

            DevExpress.XtraPrinting.PdfExportOptions options = new DevExpress.XtraPrinting.PdfExportOptions();

            this.chartControl2.ExportToPdf(saveFileName);
            return(1);
        }
        static void buttonCustomAction_ItemClick_PDF(object sender, ItemClickEventArgs e)
        {
            RichEditControl richEdit = e.Item.Tag as RichEditControl;

            richEdit.LoadDocument("Documents\\Grimm.docx");
            //Set the required export options:
            DevExpress.XtraPrinting.PdfExportOptions options = new DevExpress.XtraPrinting.PdfExportOptions();
            options.DocumentOptions.Author = "Mark Jones";
            options.Compressed             = false;
            options.ImageQuality           = DevExpress.XtraPrinting.PdfJpegImageQuality.High;
            //Export the document to the file:
            richEdit.ExportToPdf("resultingDocument.pdf", options);
            //Export the document to the file stream:
            using (FileStream pdfFileStream = new FileStream("resultingDocumentFromStream.pdf", FileMode.Create)) {
                richEdit.ExportToPdf(pdfFileStream, options);
            }

            System.Diagnostics.Process.Start("resultingDocument.pdf");
        }
Ejemplo n.º 9
0
        public FrayteResult GenerateSeperateLabelReport(int DirectShipmentId, string image)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                ReportTemplate.Other.PackageLabelReport re = new ReportTemplate.Other.PackageLabelReport();

                DevExpress.XtraPrinting.PdfExportOptions pdfOptions = re.ExportOptions.Pdf;

                pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;


                string[] ff = image.ToString().Split('.');

                string name = ff[0].ToString();

                var imageToSave = HttpContext.Current.Server.MapPath(AppSettings.LabelFolder) + "/" + DirectShipmentId + "/" + image;

                re.Parameters["ImagePath"].Value = imageToSave;

                if (File.Exists(HttpContext.Current.Server.MapPath(AppSettings.LabelFolder) + "/" + DirectShipmentId + "/" + name + ".pdf"))
                {
                    File.Delete(HttpContext.Current.Server.MapPath(AppSettings.LabelFolder) + "/" + DirectShipmentId + "/" + name + ".pdf");
                }

                if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(AppSettings.LabelFolder) + "/" + DirectShipmentId))
                {
                    System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(AppSettings.LabelFolder) + "/" + DirectShipmentId);
                }

                re.ExportToPdf(HttpContext.Current.Server.MapPath(AppSettings.LabelFolder) + "/" + DirectShipmentId + "/" + name + ".pdf", pdfOptions);
                result.Status = true;
                return(result);
            }
            catch (Exception ex)
            {
                result.Status = false;
                return(result);
            }
        }
Ejemplo n.º 10
0
        protected string pivotgridExpoort(string contentType)
        {
            gridExport.OptionsPrint.PrintHeadersOnEveryPage = true;
            gridExport.OptionsPrint.PrintFilterHeaders      = DefaultBoolean.True;
            gridExport.OptionsPrint.PrintColumnHeaders      = DefaultBoolean.True;
            gridExport.OptionsPrint.PrintRowHeaders         = DefaultBoolean.True;
            gridExport.OptionsPrint.PrintDataHeaders        = DefaultBoolean.True;
            string fileName = USERID + "_" + TitleHeader.Text + "." + contentType;
            string filepath = MapPath("~/Upload/Report");

            switch (contentType)
            {
            case "pdf":
                DevExpress.XtraPrinting.PdfExportOptions pdfxport = new DevExpress.XtraPrinting.PdfExportOptions();
                gridExport.ExportToPdf(filepath + "\\" + fileName, pdfxport);
                break;

            case "xls":
                gridExport.ExportToXls(filepath + "\\" + fileName);
                break;

            case "mht":
                gridExport.ExportToMht(filepath + "\\" + fileName);
                break;

            case "rtf":
                gridExport.ExportToRtf(filepath + "\\" + fileName);
                break;

            case "txt":
                gridExport.ExportToText(filepath + "\\" + fileName);
                break;

            case "htm":
                gridExport.ExportToHtml(filepath + "\\" + fileName);
                break;
            }
            return("../Upload/Report/" + fileName);
        }
Ejemplo n.º 11
0
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //this.appendDocument("E:\\Program Files (x86)\\灵活使用指针.docx");
            //this.appendDocument("E:\\Program Files (x86)\\灵活使用指针.docx");
            //this.appendDocument("E:\\Program Files (x86)\\灵活使用指针.docx");
            this.richEditControl1.CreateNewDocument();

            foreach (DocumentTreeView documentTreeView in this.dockeyValues[this.specCode])
            {
                if (documentTreeView.Leaf)
                {
                    try
                    {
                        this.appendDocument("C:\\"
                                            + documentTreeView.NodeName
                                            + ".docx"
                                            );
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            //Set the required export options:
            DevExpress.XtraPrinting.PdfExportOptions options = new DevExpress.XtraPrinting.PdfExportOptions();
            //options.DocumentOptions.Author = "Mark Jones";
            //options.Compressed = false;
            options.ImageQuality = DevExpress.XtraPrinting.PdfJpegImageQuality.High;
            //Export the document to the file:
            this.richEditControl1.ExportToPdf("resultingDocument.pdf", options);
            //Export the document to the file stream:
            using (FileStream pdfFileStream = new FileStream("resultingDocumentFromStream.pdf", FileMode.Create))
            {
                this.richEditControl1.ExportToPdf(pdfFileStream, options);
            }

            System.Diagnostics.Process.Start("resultingDocument.pdf");
        }
Ejemplo n.º 12
0
        public FrayteResult GenerateECommerceLabelUploadShipmentReport(int eCommerceShipmentId, FrayteUploadshipment eCommerceBookingDetail, List <string> imgList, string CourierName)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                List <PdfImage> imglist = new List <PdfImage>();

                PdfImage pbimage;
                foreach (var img in imgList)
                {
                    pbimage          = new PdfImage();
                    pbimage.FullPath = HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + eCommerceShipmentId + "/" + img;
                    imglist.Add(pbimage);
                }

                string pdfPath = string.Empty;
                if (eCommerceBookingDetail != null)
                {
                    string CourierCompany = eCommerceBookingDetail.CourierCompany;
                    string TrackingNo     = new eCommerceShipmentRepository().GetTrackingNo(eCommerceShipmentId);
                    if (!string.IsNullOrEmpty(CourierCompany))
                    {
                        pdfPath = HttpContext.Current.Server.MapPath("~/PackageLabel/eCommerce/" + eCommerceShipmentId + "/") + CourierCompany.Replace(" ", "") + "-" + TrackingNo + ".pdf";
                    }
                    else
                    {
                        pdfPath = HttpContext.Current.Server.MapPath("~/PackageLabel/eCommerce/" + eCommerceShipmentId + "/") + CourierCompany.Replace(" ", "") + "-" + TrackingNo + ".pdf";
                    }
                }
                else
                {
                    string[] ff   = imgList[0].ToString().Split('.');
                    string   name = ff[0].ToString();
                    pdfPath = HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + eCommerceShipmentId + "/" + name + ".pdf";
                }
                if (File.Exists(pdfPath))
                {
                    File.Delete(pdfPath);
                }
                if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + "/" + eCommerceShipmentId))
                {
                    System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + "/" + eCommerceShipmentId);
                }

                if (CourierName == FrayteCourierCompany.TNT)
                {
                    ReportTemplate.Other.TNTImagesToPDFReport report = new ReportTemplate.Other.TNTImagesToPDFReport();
                    report.DataSource = imglist;
                    DevExpress.XtraPrinting.PdfExportOptions pdfOptions = report.ExportOptions.Pdf;
                    pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                    pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;
                    report.ExportToPdf(pdfPath, pdfOptions);
                    result.Status = true;
                }
                else if (CourierName.Contains(FrayteCourierCompany.DHL))
                {
                    ReportTemplate.Other.DHLImageToPDFReport dhlReport = new ReportTemplate.Other.DHLImageToPDFReport();
                    dhlReport.DataSource = imglist;
                    DevExpress.XtraPrinting.PdfExportOptions pdfOptions = dhlReport.ExportOptions.Pdf;
                    pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                    pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;
                    dhlReport.ExportToPdf(pdfPath, pdfOptions);
                    result.Status = true;
                }
                else
                {
                    ReportTemplate.Other.PackageLabelsPdfReport pbreport = new ReportTemplate.Other.PackageLabelsPdfReport();
                    pbreport.DataSource = imglist;
                    DevExpress.XtraPrinting.PdfExportOptions pdfOptions = pbreport.ExportOptions.Pdf;
                    pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                    pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;
                    pbreport.ExportToPdf(pdfPath, pdfOptions);
                    result.Status = true;
                }


                return(result);
            }
            catch (Exception ex)
            {
                result.Status = false;

                return(result);
            }
        }
Ejemplo n.º 13
0
        public Boolean Enviar_Correo_hold(mail_Mensaje_Info MensajeInfo, ref string mensajeErrorOut)
        {
            string SConfigCta = "";

            try
            {
                if (param.AUTORIZADO_ENVIO_CORREO == false)
                {
                    mensajeErrorOut = "No esta autorizado para envio de correo ";
                    return(false);
                }

                string mensajeError            = "";
                string tipo_conex_cifrada_smtp = "";


                //optengo el nombre de la pc para saber desde donde se envi el correo para auditar la duplicacion...
                MensajeInfo.Texto_mensaje = MensajeInfo.Texto_mensaje + " PC/Envio: " + Funciones.Get_Nombre_PC();
                /////////////


                mail_Cuentas_Correo_Info InfoCtaMail_Remitente = new mail_Cuentas_Correo_Info();
                InfoCtaMail_Remitente = listMail_cta.FirstOrDefault(v => v.IdCuenta == MensajeInfo.IdCuenta);


                if (listMail_x_Empresa.Count == 0)
                {
                    mensajeErrorOut = "No Existe cuentas para envio de correo configuradas en la base ";
                    return(false);
                }

                if (InfoCtaMail_Remitente == null || InfoCtaMail_Remitente.IdCuenta == null)
                {
                    mensajeErrorOut = "No existe una cuenta relaciona en la base para la cuenta del mensaje verique por base";
                    return(false);
                }


                if (!mailValida.email_bien_escrito(MensajeInfo.Para))
                {
                    mensajeErrorOut            = "La cuenta de correo es Invalida ";
                    MensajeInfo.IdTipo_Mensaje = eTipoMail.Mail_NO_Env_x_error;
                    datamaMail.Actualizar_TipoMensaje(MensajeInfo, ref mensajeErrorOut);
                    return(false);
                }

                if (MensajeInfo.IdCuenta == "" || MensajeInfo.IdCuenta == null)
                {
                    InfoCtaMail_Remitente      = listMail_cta.FirstOrDefault(v => v.cta_predeterminada == true);
                    MensajeInfo.IdCuenta       = InfoCtaMail_Remitente.IdCuenta;
                    MensajeInfo.mail_remitente = InfoCtaMail_Remitente.direccion_correo;

                    datamaMail.Actualizar_Datos_Cuenta(MensajeInfo, ref mensajeErrorOut);

                    mensajeErrorOut = "la Cuenta Remitente no esta establecido en el mensaje se enviara con la cuenta por default ...";
                }
                SmtpMail              oSmtpMail_msg = new SmtpMail("ES-C1407722592-00106-56VB4AE2B4F8TB75-641B598EBE4D439A");
                SmtpServer            oSmtpServer   = new SmtpServer(InfoCtaMail_Remitente.ServidorCorreoSaliente, InfoCtaMail_Remitente.Port_salida);
                EASendMail.SmtpClient oclienteSmtp  = new EASendMail.SmtpClient();



                if (InfoCtaMail_Remitente.Confirmacion_de_Entrega == true || InfoCtaMail_Remitente.Confirmacion_de_Lectura == true)
                {
                    oSmtpMail_msg.DeliveryNotification = EASendMail.DeliveryNotificationOptions.OnFailure | EASendMail.DeliveryNotificationOptions.OnSuccess | EASendMail.DeliveryNotificationOptions.Delay;

                    if (InfoCtaMail_Remitente.Confirmacion_de_Lectura == true)
                    {
                        oSmtpMail_msg.Headers.Add("Read-Receipt-To", InfoCtaMail_Remitente.direccion_correo);
                    }
                    if (InfoCtaMail_Remitente.Confirmacion_de_Entrega == true)
                    {
                        oSmtpMail_msg.Headers.Add("Disposition-Notification-To", InfoCtaMail_Remitente.direccion_correo);
                    }
                }

                // si tiene archivo adjunto
                if (MensajeInfo.Tiene_Adjunto == true)
                {
                    #region codigo viejo q actualiza el campo de mail



                    #endregion


                    //optengo los archivos adjuntos
                    MensajeInfo.list_Archivos_Adjuntos = OdataArchivoAdjunto.Lista_ArchivoAdjunto_Mensaje_x_comprobante(MensajeInfo.IdMensaje, ref mensajeErrorOut);
                    foreach (var item in MensajeInfo.list_Archivos_Adjuntos)
                    {
                        comprobante = new tb_Comprobante_Info();
                        comprobante = Bus_Comprobante_emisor.Comprobante_consulta_Id_Comprobante(item.IdEmpresa, item.IdComprobante, ref mensajeError);

                        byte[] BinarioFileAdjunto = null;



                        if (comprobante.IdComprobante != null)
                        {
                            // si la extencion ex .pdf lo creo en el tmp
                            if (item.extensionArchivo.ToUpper() == ".PDF")
                            {
                                XtraReport   Reporte      = new XtraReport();
                                Rpt_Ride_bus Rpt_Ride_Bus = new Rpt_Ride_bus(listEmpr);
                                Reporte = Rpt_Ride_Bus.Optener_reporte(comprobante, ref mensajeError);
                                //pdf
                                FileStream FileBinary;
                                FileBinary = new FileStream(RutaArchivos + "\\" + comprobante.IdComprobante + ".pdf", FileMode.Create);
                                DevExpress.XtraPrinting.PdfExportOptions Optione = new DevExpress.XtraPrinting.PdfExportOptions();
                                Reporte.ExportToPdf(FileBinary, Optione);
                                FileBinary.Close();
                                // lleno la clase archivo adjunto con el pdf que se creo en el tmp
                                DirectoryInfo   Directorio_Pdf_Xml = new DirectoryInfo(RutaArchivos);
                                List <FileInfo> listaFiles         = Directorio_Pdf_Xml.GetFiles(comprobante.IdComprobante + ".pdf").ToList();
                                foreach (var itemBi in listaFiles)
                                {
                                    FileStream file = new FileStream(RutaArchivos + itemBi.Name, FileMode.Open);
                                    BinarioFileAdjunto = new byte[file.Length];

                                    file.Read(BinarioFileAdjunto, 0, Convert.ToInt32(file.Length));
                                    file.Close();
                                }
                            }
                        }

                        // LLENO EL BINARIO PARA EL XML
                        if (item.extensionArchivo.ToUpper() == ".XML")
                        {
                            XmlDocument xmlOrigen = new XmlDocument();
                            xmlOrigen.Load(new StringReader(comprobante.s_XML));
                            BinarioFileAdjunto = Encoding.UTF8.GetBytes(xmlOrigen.OuterXml);
                        }


                        oSmtpMail_msg.AddAttachment(item.IdComprobante + item.extensionArchivo, BinarioFileAdjunto);
                    }
                }


                tipo_conex_cifrada_smtp = InfoCtaMail_Remitente.tipo_Seguridad;

                if (InfoCtaMail_Remitente.tipo_Seguridad != "Ninguno")
                {
                    oSmtpServer.User     = InfoCtaMail_Remitente.Usuario;
                    oSmtpServer.Password = InfoCtaMail_Remitente.Password;
                }


                switch (tipo_conex_cifrada_smtp)
                {
                case "SSL":
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
                    oSmtpServer.Port        = 465;
                    break;

                case "TLS":
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
                    break;

                case "Ninguno":
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectNormal;
                    break;

                case "STARTTLS":
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectSTARTTLS;
                    break;

                default:
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectNormal;
                    break;
                }



                oSmtpMail_msg.To.Add(new EASendMail.MailAddress(MensajeInfo.Para));

                if (MensajeInfo.Para_CC != "" && MensajeInfo.Para_CC != null)
                {
                    string[] slistaCorreo = MensajeInfo.Para_CC.Split(';');

                    foreach (var item in slistaCorreo)
                    {
                        oSmtpMail_msg.Cc.Add(new EASendMail.MailAddress(item.Trim()));
                    }
                }

                oSmtpMail_msg.From     = new EASendMail.MailAddress(InfoCtaMail_Remitente.direccion_correo);
                oSmtpMail_msg.Subject  = MensajeInfo.Asunto;
                oSmtpMail_msg.TextBody = MensajeInfo.Texto_mensaje;



                SConfigCta = "msg.From :" + oSmtpMail_msg.From.ToString() + "\n";
                SConfigCta = SConfigCta + " msg.To:" + oSmtpMail_msg.To.ToString() + "\n";
                SConfigCta = SConfigCta + " msg.Subject " + oSmtpMail_msg.Subject.ToString() + "\n";
                SConfigCta = SConfigCta + "msg.Body :" + oSmtpMail_msg.TextBody.ToString() + "\n";
                SConfigCta = SConfigCta + "oSmtpServer.Port:" + oSmtpServer.Port.ToString() + "\n";
                SConfigCta = SConfigCta + " oSmtpServer.User:"******"\n";
                SConfigCta = SConfigCta + " oSmtpServer.Password:"******"\n";
                SConfigCta = SConfigCta + " oSmtpServer.Protocol :" + oSmtpServer.Protocol + "\n";

                if (MensajeInfo.Para == "")
                {
                    mensajeErrorOut = "No hay cuenta de correo a quien enviar ";
                    return(false);
                }

                //enviando correo

                oclienteSmtp.SendMail(oSmtpServer, oSmtpMail_msg);

                if (MensajeInfo.IdMensaje > 0)// modificar
                {
                    MensajeInfo.IdTipo_Mensaje = eTipoMail.Enviado;
                    datamaMail.Actualizar_TipoMensaje(MensajeInfo, ref mensajeErrorOut);
                }
                else
                {
                    MensajeInfo.IdTipo_Mensaje = eTipoMail.Enviado;
                    datamaMail.GrabarMensajeDB(MensajeInfo, ref mensajeErrorOut);
                }

                return(true);
            }
            catch (Exception ex)
            {
                mensajeErrorOut = "catch (SmtpException ex) : " + ex.Message + " " + ex.InnerException + " datos de la cta:" + SConfigCta;
                return(false);
            }
        }
        public FrayteResult GeteCommerceUploadShipmentLabelReportDetail(int eCommerceShipmentId, FrayteeCommerceUploadShipmentLabelReport obj, int FileName)
        {
            FrayteResult result = new FrayteResult();

            FrayteeCommerceUploadShipmentLabelReport        frayteeCommerceLabelReport = new eCommerceUploadShipmentRepository().GeteCommerceUploadShipmentLabelReportDetail(obj);
            List <FrayteeCommerceUploadShipmentLabelReport> reportDataSource           = new List <FrayteeCommerceUploadShipmentLabelReport>();

            if (frayteeCommerceLabelReport != null)
            {
                ReportTemplate.Other.eCommerceLabelReport re = new ReportTemplate.Other.eCommerceLabelReport();

                // Set ShipFrom Address In Label
                re.xrRichText1.Text = frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.FirstName.ToUpper() + " " + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.LastName.ToUpper() +
                                      System.Environment.NewLine +
                                      frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.CompanyName.ToUpper() + System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.Address.ToUpper();

                if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.Address2))
                {
                    re.xrRichText1.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.Address2.ToUpper();
                }

                re.xrRichText1.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.City.ToUpper();

                if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.PostCode))
                {
                    re.xrRichText1.Text += " -  " + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.PostCode.ToUpper();
                }
                if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.State))
                {
                    re.xrRichText1.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.State.ToUpper();
                }

                // Set Shipto Address In Label
                re.xrRichText2.Text = frayteeCommerceLabelReport.eCommerceShipment.ShipTo.FirstName.ToUpper() + " " + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.LastName.ToUpper() +
                                      System.Environment.NewLine +
                                      frayteeCommerceLabelReport.eCommerceShipment.ShipTo.CompanyName.ToUpper() + System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.Address.ToUpper();

                if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipTo.Address2))
                {
                    re.xrRichText2.Text += ", " + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.Address2.ToUpper();
                }

                re.xrRichText2.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.City.ToUpper();
                if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipTo.PostCode))
                {
                    re.xrRichText2.Text += " -  " + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.PostCode.ToUpper();
                }
                if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipTo.State))
                {
                    re.xrRichText2.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.State.ToUpper();
                }

                reportDataSource.Add(frayteeCommerceLabelReport);
                re.Parameters["LogoPath"].Value = obj.BarcodePath;
                re.DataSource = reportDataSource;

                string filePathToSave = AppSettings.eCommerceUploadShipmentLabelFolder + "/" + eCommerceShipmentId.ToString();
                DevExpress.XtraPrinting.PdfExportOptions pdfOptions = re.ExportOptions.Pdf;
                pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;

                if (!System.IO.Directory.Exists(filePathToSave))
                {
                    System.IO.Directory.CreateDirectory(filePathToSave);
                }
                re.ExportToPdf(AppSettings.eCommerceUploadShipmentLabelFolder + "/" + eCommerceShipmentId + "/" + FileName.ToString() + ".pdf", pdfOptions);
                result.Status = true;
            }
            else
            {
                result.Status = false;
            }

            return(result);
        }
        public FrayteResult GeteCommerceShipmentLabelReportDetail(int eCommerceShipmentId, FrayteeCommerceShipmentLabelReport obj, string filename)
        {
            FrayteResult result = new FrayteResult();

            FrayteeCommerceShipmentLabelReport        frayteeCommerceLabelReport = new eCommerceShipmentRepository().GeteCommerceShipmentLabelReportDetail(obj);
            List <FrayteeCommerceShipmentLabelReport> reportDataSource           = new List <FrayteeCommerceShipmentLabelReport>();

            if (frayteeCommerceLabelReport != null)
            {
                ReportTemplate.Other.eCommerceLabelReport re = new ReportTemplate.Other.eCommerceLabelReport();

                // Set ShipFrom Address In Label
                re.xrRichText1.Text = frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.FirstName.ToUpper() + " " + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.LastName.ToUpper() +
                                      System.Environment.NewLine +
                                      frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.CompanyName.ToUpper() + System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.Address.ToUpper();

                if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.Address2))
                {
                    re.xrRichText1.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.Address2.ToUpper();
                }

                re.xrRichText1.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.City.ToUpper();

                if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.PostCode))
                {
                    re.xrRichText1.Text += " -  " + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.PostCode.ToUpper();
                }
                if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.State))
                {
                    re.xrRichText1.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.State.ToUpper();
                }

                // Set Shipto Address In Label
                re.xrRichText2.Text = frayteeCommerceLabelReport.eCommerceShipment.ShipTo.FirstName.ToUpper() + " " + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.LastName.ToUpper() +
                                      System.Environment.NewLine +
                                      frayteeCommerceLabelReport.eCommerceShipment.ShipTo.CompanyName.ToUpper() + System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.Address.ToUpper();

                if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipTo.Address2))
                {
                    re.xrRichText2.Text += ", " + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.Address2.ToUpper();
                }

                re.xrRichText2.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.City.ToUpper();
                if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipTo.PostCode))
                {
                    re.xrRichText2.Text += " -  " + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.PostCode.ToUpper();
                }
                if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipTo.State))
                {
                    re.xrRichText2.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.State.ToUpper();
                }

                reportDataSource.Add(frayteeCommerceLabelReport);


                re.Parameters["LogoPath"].Value = obj.BarcodePath;
                re.DataSource = reportDataSource;

                string filePathToSave = AppSettings.eCommerceLabelFolder + "/" + eCommerceShipmentId.ToString();
                if (AppSettings.ShipmentCreatedFrom == "BATCH")
                {
                    filePathToSave = AppSettings.eCommerceUploadLabelFolder + eCommerceShipmentId.ToString();
                    //filePathToSave = filePathToSave;
                }
                else
                {
                    filePathToSave = HttpContext.Current.Server.MapPath(filePathToSave);
                }
                //DevExpress.XtraPrinting.ExportOptions options = re.ExportOptions;
                DevExpress.XtraPrinting.ImageExportOptions imageOptions = re.PrintingSystem.ExportOptions.Image;
                if (imageOptions != null)
                {
                    // Setup 150 DPI as default resolution for image exports
                    imageOptions.Resolution = 3000;
                    imageOptions.Format     = ImageFormat.Jpeg;
                }

                DevExpress.XtraPrinting.PdfExportOptions pdfOptions = re.ExportOptions.Pdf;
                //pdfOptions.PageRange = "1";
                pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;

                if (!System.IO.Directory.Exists(filePathToSave))
                {
                    System.IO.Directory.CreateDirectory(filePathToSave);
                }
                //re.ExportToImage(HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + "/" + eCommerceShipmentId + "/" + FileName.ToString() + ".Jpeg", imageOptions);
                if (AppSettings.ShipmentCreatedFrom == "BATCH")
                {
                    re.ExportToImage(AppSettings.eCommerceUploadLabelFolder + eCommerceShipmentId + "/" + filename + ".jpg", imageOptions);
                    re.ExportToPdf(AppSettings.eCommerceUploadLabelFolder + eCommerceShipmentId + "/" + filename + ".pdf", pdfOptions);
                }
                else
                {
                    re.ExportToImage(HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + "/" + eCommerceShipmentId + "/" + filename + ".jpg", imageOptions);
                    re.ExportToPdf(HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + "/" + eCommerceShipmentId + "/" + filename + ".pdf", pdfOptions);
                }
                result.Status = true;
            }
            else
            {
                result.Status = false;
            }

            return(result);
        }
Ejemplo n.º 16
0
        public FrayteResult GenerateAllLabelReport(int DirectShipmentId, DirectBookingShipmentDraftDetail directBookingDetail, List <string> imgList, string CourierName, string LogisticLabel)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                List <PdfImage> imglist = new List <PdfImage>();
                if (AppSettings.LabelSave == "")
                {
                    PdfImage pbimage;
                    foreach (var img in imgList)
                    {
                        pbimage          = new PdfImage();
                        pbimage.FullPath = AppSettings.WebApiPath + "/PackageLabel/" + DirectShipmentId + "/" + img;
                        imglist.Add(pbimage);
                    }

                    string pdfPath = string.Empty;
                    if (directBookingDetail != null)
                    {
                        pdfPath = AppSettings.WebApiPath + "/PackageLabel/" + DirectShipmentId + "/" + LogisticLabel;
                    }
                    else
                    {
                        string[] ff   = imgList[0].ToString().Split('.');
                        string   name = ff[0].ToString();
                        pdfPath = AppSettings.WebApiPath + "/PackageLabel/" + DirectShipmentId + "/" + name + ".pdf";
                    }
                    if (File.Exists(pdfPath))
                    {
                        File.Delete(pdfPath);
                    }
                    if (!System.IO.Directory.Exists(AppSettings.WebApiPath + "/PackageLabel/" + DirectShipmentId))
                    {
                        System.IO.Directory.CreateDirectory(AppSettings.WebApiPath + "/PackageLabel/" + DirectShipmentId);
                    }

                    if (CourierName == FrayteCourierCompany.TNT)
                    {
                        ReportTemplate.Other.TNTImagesToPDFReport report = new ReportTemplate.Other.TNTImagesToPDFReport();
                        report.DataSource = imglist;
                        DevExpress.XtraPrinting.PdfExportOptions pdfOptions = report.ExportOptions.Pdf;
                        pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                        pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;
                        report.ExportToPdf(pdfPath, pdfOptions);
                        result.Status = true;
                    }
                    else
                    {
                        ReportTemplate.Other.DHLImageToPDFReport dhlReport = new ReportTemplate.Other.DHLImageToPDFReport();
                        dhlReport.DataSource = imglist;
                        DevExpress.XtraPrinting.PdfExportOptions pdfOptions = dhlReport.ExportOptions.Pdf;
                        pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                        pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;
                        dhlReport.ExportToPdf(pdfPath, pdfOptions);
                        result.Status = true;
                    }

                    return(result);
                }
                else
                {
                    PdfImage pbimage;
                    foreach (var img in imgList)
                    {
                        pbimage = new PdfImage();
                        if (AppSettings.ShipmentCreatedFrom == "BATCH")
                        {
                            pbimage.FullPath = AppSettings.LabelFolder + "/" + DirectShipmentId + "/" + img;
                        }
                        else
                        {
                            pbimage.FullPath = HttpContext.Current.Server.MapPath(AppSettings.LabelFolder) + DirectShipmentId + "/" + img;
                        }

                        imglist.Add(pbimage);
                    }

                    string pdfPath = string.Empty;
                    if (directBookingDetail != null)
                    {
                        if (AppSettings.ShipmentCreatedFrom == "BATCH")
                        {
                            pdfPath = AppSettings.LabelFolder + "/" + DirectShipmentId + "/" + LogisticLabel;
                        }
                        else
                        {
                            pdfPath = HttpContext.Current.Server.MapPath("~/PackageLabel/" + DirectShipmentId + "/") + LogisticLabel;
                        }
                    }
                    else
                    {
                        string[] ff   = imgList[0].ToString().Split('.');
                        string   name = ff[0].ToString();
                        if (AppSettings.ShipmentCreatedFrom == "BATCH")
                        {
                            pdfPath = AppSettings.LabelFolder + "/" + DirectShipmentId + "/" + name + ".pdf";
                        }
                        else
                        {
                            pdfPath = HttpContext.Current.Server.MapPath(AppSettings.LabelFolder) + DirectShipmentId + "/" + name + ".pdf";
                        }
                    }
                    if (File.Exists(pdfPath))
                    {
                        File.Delete(pdfPath);
                    }
                    if (AppSettings.ShipmentCreatedFrom == "BATCH")
                    {
                        if (!System.IO.Directory.Exists(AppSettings.LabelFolder + "/" + DirectShipmentId))
                        {
                            System.IO.Directory.CreateDirectory(AppSettings.LabelFolder + "/" + DirectShipmentId);
                        }
                    }
                    else
                    {
                        if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(AppSettings.LabelFolder) + "/" + DirectShipmentId))
                        {
                            System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(AppSettings.LabelFolder) + "/" + DirectShipmentId);
                        }
                    }
                    if (CourierName == FrayteCourierCompany.TNT)
                    {
                        ReportTemplate.Other.TNTImagesToPDFReport report = new ReportTemplate.Other.TNTImagesToPDFReport();
                        report.DataSource = imglist;
                        DevExpress.XtraPrinting.PdfExportOptions pdfOptions = report.ExportOptions.Pdf;
                        pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                        pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;
                        report.ExportToPdf(pdfPath, pdfOptions);
                        result.Status = true;
                    }
                    else
                    {
                        ReportTemplate.Other.DHLImageToPDFReport dhlReport = new ReportTemplate.Other.DHLImageToPDFReport();
                        dhlReport.DataSource = imglist;
                        DevExpress.XtraPrinting.PdfExportOptions pdfOptions = dhlReport.ExportOptions.Pdf;
                        pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                        pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;
                        dhlReport.ExportToPdf(pdfPath, pdfOptions);
                        result.Status = true;
                    }

                    return(result);
                }
            }
            catch (Exception ex)
            {
                result.Status = false;

                return(result);
            }
        }
Ejemplo n.º 17
0
        public Boolean Enviar_Correo(mail_Mensaje_Info MensajeInfo, ref string mensajeErrorOut)
        {
            string SConfigCta = "";

            try
            {
                if (param.AUTORIZADO_ENVIO_CORREO == false)
                {
                    mensajeErrorOut = "No esta autorizado para envio de correo ";
                    return(false);
                }

                string mensajeError            = "";
                string tipo_conex_cifrada_smtp = "";


                //optengo el nombre de la pc para saber desde donde se envi el correo para auditar la duplicacion...
                MensajeInfo.Texto_mensaje = MensajeInfo.Texto_mensaje + " PC/Envio: " + Funciones.Get_Nombre_PC();
                /////////////


                mail_Cuentas_Correo_Info InfoCtaMail_Remitente = new mail_Cuentas_Correo_Info();
                InfoCtaMail_Remitente = listMail_cta.FirstOrDefault(v => v.IdCuenta == MensajeInfo.IdCuenta);


                if (listMail_x_Empresa.Count == 0)
                {
                    mensajeErrorOut = "No Existe cuentas para envio de correo configuradas en la base ";
                    return(false);
                }

                if (InfoCtaMail_Remitente == null || InfoCtaMail_Remitente.IdCuenta == null)
                {
                    mensajeErrorOut = "No existe una cuenta relaciona en la base para la cuenta del mensaje verique por base";
                    return(false);
                }


                //if (!mailValida.email_bien_escrito(MensajeInfo.Para))
                //{
                //    mensajeErrorOut = "La cuenta de correo es Invalida ";
                //    MensajeInfo.IdTipo_Mensaje = eTipoMail.Mail_NO_Env_x_error;
                //    datamaMail.Actualizar_TipoMensaje(MensajeInfo, ref mensajeErrorOut);
                //    return false;
                //}

                if (MensajeInfo.IdCuenta == "" || MensajeInfo.IdCuenta == null)
                {
                    InfoCtaMail_Remitente      = listMail_cta.FirstOrDefault(v => v.cta_predeterminada == true);
                    MensajeInfo.IdCuenta       = InfoCtaMail_Remitente.IdCuenta;
                    MensajeInfo.mail_remitente = InfoCtaMail_Remitente.direccion_correo;

                    datamaMail.Actualizar_Datos_Cuenta(MensajeInfo, ref mensajeErrorOut);

                    mensajeErrorOut = "la Cuenta Remitente no esta establecido en el mensaje se enviara con la cuenta por default ...";
                }
                MailMessage oSmtpMail_msg = new MailMessage();


                // si tiene archivo adjunto
                if (MensajeInfo.Tiene_Adjunto == true)
                {
                    //optengo los archivos adjuntos
                    MensajeInfo.list_Archivos_Adjuntos = OdataArchivoAdjunto.Lista_ArchivoAdjunto_Mensaje_x_comprobante(MensajeInfo.IdMensaje, ref mensajeErrorOut);
                    foreach (var item in MensajeInfo.list_Archivos_Adjuntos)
                    {
                        comprobante = new tb_Comprobante_Info();
                        comprobante = Bus_Comprobante_emisor.Comprobante_consulta_Id_Comprobante(item.IdEmpresa, item.IdComprobante, ref mensajeError);

                        byte[] BinarioFileAdjunto = null;
                        if (comprobante.IdComprobante != null)
                        {
                            // si la extencion ex .pdf lo creo en el tmp
                            if (item.extensionArchivo.ToUpper() == ".PDF")
                            {
                                XtraReport   Reporte      = new XtraReport();
                                Rpt_Ride_bus Rpt_Ride_Bus = new Rpt_Ride_bus(listEmpr);
                                Reporte = Rpt_Ride_Bus.Optener_reporte(comprobante, ref mensajeError);
                                //pdf
                                FileStream FileBinary;
                                FileBinary = new FileStream(RutaArchivos + "\\" + comprobante.IdComprobante + ".pdf", FileMode.Create);
                                DevExpress.XtraPrinting.PdfExportOptions Optione = new DevExpress.XtraPrinting.PdfExportOptions();
                                Reporte.ExportToPdf(FileBinary, Optione);
                                FileBinary.Close();
                                // lleno la clase archivo adjunto con el pdf que se creo en el tmp
                                DirectoryInfo   Directorio_Pdf_Xml = new DirectoryInfo(RutaArchivos);
                                List <FileInfo> listaFiles         = Directorio_Pdf_Xml.GetFiles(comprobante.IdComprobante + ".pdf").ToList();
                                foreach (var itemBi in listaFiles)
                                {
                                    FileStream file = new FileStream(RutaArchivos + itemBi.Name, FileMode.Open);
                                    BinarioFileAdjunto = new byte[file.Length];

                                    file.Read(BinarioFileAdjunto, 0, Convert.ToInt32(file.Length));
                                    file.Close();
                                }
                            }
                        }

                        // LLENO EL BINARIO PARA EL XML
                        if (item.extensionArchivo.ToUpper() == ".XML")
                        {
                            XmlDocument xmlOrigen = new XmlDocument();
                            xmlOrigen.Load(new StringReader(comprobante.s_XML));
                            BinarioFileAdjunto = Encoding.UTF8.GetBytes(xmlOrigen.OuterXml);
                        }


                        oSmtpMail_msg.Attachments.Add(new System.Net.Mail.Attachment(new MemoryStream(BinarioFileAdjunto), item.IdComprobante + item.extensionArchivo));
                    }
                }


                tipo_conex_cifrada_smtp = InfoCtaMail_Remitente.tipo_Seguridad;


                if (MensajeInfo.Para == "")
                {
                    return(false);
                }
                oSmtpMail_msg.To.Add(MensajeInfo.Para);

                if (MensajeInfo.Para_CC != "" && MensajeInfo.Para_CC != null)
                {
                    string[] slistaCorreo = MensajeInfo.Para_CC.Split(';');

                    foreach (var item in slistaCorreo)
                    {
                        oSmtpMail_msg.CC.Add(item.Trim());
                    }
                }

                oSmtpMail_msg.From    = new System.Net.Mail.MailAddress(InfoCtaMail_Remitente.direccion_correo);
                oSmtpMail_msg.Subject = MensajeInfo.Asunto;
                oSmtpMail_msg.Body    = MensajeInfo.Asunto + "\n\n\n\n";
                oSmtpMail_msg.Body    = oSmtpMail_msg.Body + " " + MensajeInfo.RazonSocial_Emisor;


                if (MensajeInfo.Para == "")
                {
                    mensajeErrorOut = "No hay cuenta de correo a quien enviar ";
                    return(false);
                }

                //enviando correo


                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
                smtp.Host        = InfoCtaMail_Remitente.ServidorCorreoSaliente;
                smtp.EnableSsl   = InfoCtaMail_Remitente.precisa_conexion_cifrada;
                smtp.Port        = InfoCtaMail_Remitente.Port_salida;
                smtp.Credentials = new NetworkCredential(InfoCtaMail_Remitente.direccion_correo, InfoCtaMail_Remitente.Password);
                smtp.Send(oSmtpMail_msg);


                if (MensajeInfo.IdMensaje > 0)// modificar
                {
                    MensajeInfo.IdTipo_Mensaje = eTipoMail.Enviado;
                    datamaMail.Actualizar_TipoMensaje(MensajeInfo, ref mensajeErrorOut);
                }
                //else
                //{
                //    MensajeInfo.IdTipo_Mensaje = eTipoMail.Enviado;
                //    datamaMail.GrabarMensajeDB(MensajeInfo, ref mensajeErrorOut);
                //}

                return(true);
            }
            catch (Exception ex)
            {
                mensajeErrorOut = "catch (SmtpException ex) : " + ex.Message + " " + ex.InnerException + " datos de la cta:" + SConfigCta;
                return(false);
            }
        }
Ejemplo n.º 18
0
        public FrayteResult GenerateInvoiceReport(int eCommerceShipmentId, eCommerceTaxAndDutyInvoiceReport obj)
        {
            FrayteResult result = new FrayteResult();

            if (!File.Exists(HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + "/" + eCommerceShipmentId + "/" + obj.InvoiceRef.ToString() + ".pdf"))
            {
                List <eCommerceTaxAndDutyInvoiceReport> reportDataSource = new List <eCommerceTaxAndDutyInvoiceReport>();

                if (obj != null)
                {
                    ReportTemplate.Other.eCommerceInvoiceReport re = new ReportTemplate.Other.eCommerceInvoiceReport();
                    re.xrRichText5.Text = obj.eCommerceBookingDetail.ShipTo.FirstName.ToUpper() + " " + obj.eCommerceBookingDetail.ShipTo.LastName.ToUpper() +
                                          System.Environment.NewLine +
                                          obj.eCommerceBookingDetail.ShipTo.CompanyName.ToUpper() + System.Environment.NewLine + obj.eCommerceBookingDetail.ShipTo.Address.ToUpper();

                    if (!string.IsNullOrEmpty(obj.eCommerceBookingDetail.ShipTo.Address2))
                    {
                        re.xrRichText5.Text += System.Environment.NewLine + obj.eCommerceBookingDetail.ShipTo.Address2.ToUpper();
                    }

                    re.xrRichText5.Text += System.Environment.NewLine + obj.eCommerceBookingDetail.ShipTo.City.ToUpper();

                    if (!string.IsNullOrEmpty(obj.eCommerceBookingDetail.ShipTo.PostCode))
                    {
                        re.xrRichText5.Text += " -  " + obj.eCommerceBookingDetail.ShipTo.PostCode.ToUpper();
                    }
                    if (!string.IsNullOrEmpty(obj.eCommerceBookingDetail.ShipTo.State))
                    {
                        re.xrRichText5.Text += System.Environment.NewLine + obj.eCommerceBookingDetail.ShipTo.State.ToUpper();
                    }
                    if (obj.eCommerceBookingDetail.ShipTo != null && obj.eCommerceBookingDetail.ShipTo.Country != null && !string.IsNullOrEmpty(obj.eCommerceBookingDetail.ShipTo.Country.Name))
                    {
                        re.xrRichText5.Text += System.Environment.NewLine + obj.eCommerceBookingDetail.ShipTo.Country.Name.ToUpper();
                    }

                    obj.FreeStorageTime = "YOUR FREE STORAGE PERIOD ENDS " + obj.FreeStorageTime + " HOURS AFTER SHIPMENT ARRIVAL INTO THE UK - £5 per KG will be charged thereafter";

                    if (!string.IsNullOrEmpty(obj.CompanyDetail.Address.Address2))
                    {
                        //re.xrRichText2.Text += ", " + obj.CompanyDetail.Address.Address2;
                    }
                    if (!string.IsNullOrEmpty(obj.CompanyDetail.Address.City))
                    {
                        //re.xrRichText2.Text += ", " + obj.CompanyDetail.Address.City;
                    }
                    if (!string.IsNullOrEmpty(obj.CompanyDetail.Address.Zip))
                    {
                        //re.xrRichText2.Text += " " + obj.CompanyDetail.Address.Zip;
                    }
                    if (!string.IsNullOrEmpty(obj.CompanyDetail.Address.State))
                    {
                        //re.xrRichText2.Text += ", " + obj.CompanyDetail.Address.State;
                    }
                    if (!string.IsNullOrEmpty(obj.CompanyDetail.Address.Country.Name))
                    {
                        //re.xrRichText2.Text += ", " + obj.CompanyDetail.Address.Country.Name;
                    }

                    //re.xrRichText1.Text = obj.BankDetail.Address.Address1;
                    if (!string.IsNullOrEmpty(obj.BankDetail.Address.Address2))
                    {
                        //re.xrRichText1.Text += ", " + obj.BankDetail.Address.Address2;
                    }
                    if (!string.IsNullOrEmpty(obj.BankDetail.Address.City))
                    {
                        //re.xrRichText1.Text += ", " + obj.BankDetail.Address.City;
                    }
                    if (!string.IsNullOrEmpty(obj.BankDetail.Address.Zip))
                    {
                        //re.xrRichText1.Text += ", " + obj.BankDetail.Address.Zip;
                    }
                    //re.xrTableCell14.Text = "Company No:" + " " + obj.CompanyDetail.CompanyNo + ".";
                    //re.xrTableCell14.Text += "Company Registration Number " + "+44 " + obj.CompanyDetail.CompanyPhoneCode + " " + obj.CompanyDetail.CompanyPhone + ". ";
                    //re.xrTableCell14.Text += "Crest Code " + obj.CompanyDetail.CrestCode + ". ";
                    //re.xrTableCell14.Text += "Registered address: ";
                    //re.xrTableCell14.Text += System.Environment.NewLine;

                    //re.xrTableCell14.Text += obj.CompanyDetail.CompanyName + ", " + obj.CompanyDetail.Address.Address1;

                    if (!string.IsNullOrEmpty(obj.CompanyDetail.Address.Address2))
                    {
                        //re.xrTableCell14.Text += ", " + obj.CompanyDetail.Address.Address2;
                    }
                    if (!string.IsNullOrEmpty(obj.CompanyDetail.Address.City))
                    {
                        //re.xrTableCell14.Text += ", " + obj.CompanyDetail.Address.City;
                    }
                    if (!string.IsNullOrEmpty(obj.CompanyDetail.Address.Zip))
                    {
                        //re.xrTableCell14.Text += " " + obj.CompanyDetail.Address.Zip;
                    }
                    if (!string.IsNullOrEmpty(obj.CompanyDetail.Address.State))
                    {
                        //re.xrTableCell14.Text += ", " + obj.CompanyDetail.Address.State;
                    }
                    if (!string.IsNullOrEmpty(obj.CompanyDetail.Address.Country.Name))
                    {
                        //re.xrTableCell14.Text += ", " + obj.CompanyDetail.Address.Country.Name;
                    }

                    //  re.xrTableCell14.Text

                    //re.xrRichText4.Text = "P " + "+44" + obj.CompanyDetail.CompanyPhoneCode + " " + obj.CompanyDetail.CompanyPhone;
                    //re.xrRichText4.Text += " | " + " E " + obj.CompanyDetail.SalesEmail;

                    reportDataSource.Add(obj);
                    re.DataSource = reportDataSource;

                    var FileName = "CCS - Customs Duty - Vat Invoice [" + obj.InvoiceRef + "]  [" + obj.CustomerName + "].pdf";

                    string filePathToSave = AppSettings.eCommerceLabelFolder + "/" + eCommerceShipmentId.ToString();
                    filePathToSave = HttpContext.Current.Server.MapPath(filePathToSave);

                    DevExpress.XtraPrinting.PdfExportOptions pdfOptions = re.ExportOptions.Pdf;

                    pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                    pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;

                    if (!System.IO.Directory.Exists(filePathToSave))
                    {
                        System.IO.Directory.CreateDirectory(filePathToSave);
                    }
                    re.ExportToPdf(HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + "/" + eCommerceShipmentId + "/" + FileName, pdfOptions);
                    result.Status = true;
                }
            }
            else
            {
                result.Status = true;
            }

            return(result);
        }