/// <summary>
        /// Obtiene el link que permite revisar un boleto electrónico por medio
        /// de virtually there y abre la pagina web que lo contiene
        /// </summary>
        private void GetLinkVirtualyThere()
        {
            string linkVirtually          = string.Empty;
            List <GetLinkByTkt> indexList = new List <GetLinkByTkt>();

            indexList = GetLinkByTktBL.GetLinkByTkt(txtInvoice.Text, Login.OrgId);
            if (indexList.Count > 0)
            {
                if (!string.IsNullOrEmpty(indexList[0].LinkVirtuallyThere))
                {
                    linkVirtually = indexList[0].LinkVirtuallyThere;
                    try
                    {
                        Process.Start(linkVirtually);
                        Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
                    }
                    catch
                    {
                        MessageBox.Show("EXISTE UN PROBLEMA CON LA RED, INTENTELO MÁS TARDE", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
                    }
                }
                else
                {
                    MessageBox.Show("NO EXISTE RECIBO ELECTRÓNICO PARA ESTE BOLETO", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
                }
            }
            else
            {
                MessageBox.Show("EL NÚMERO DE BOLETO NO EXISTE", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
            }
        }
 private void btnAccept_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtNumberTicket.Text))
     {
         MessageBox.Show("INGRESE EL NÚMERO DE BOLETO", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
         txtNumberTicket.Focus();
     }
     else if (!string.IsNullOrEmpty(txtNumberTicket.Text) && txtNumberTicket.TextLength != 13)
     {
         MessageBox.Show("EL NÚMERO DE BOLETO DEBE SER DE 13 DIGITOS", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
         txtNumberTicket.Focus();
     }
     else if (!string.IsNullOrEmpty(txtCCMail.Text) && !ValidateRegularExpression.ValidateEmailFormat(txtCCMail.Text))
     {
         MessageBox.Show("EL FORMATO DE CORREO ELECTRÓNICO ES INCORRECTO", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
         txtCCMail.Focus();
     }
     else
     {
         List <GetLinkByTkt> ticketList = new List <GetLinkByTkt>();
         ticketList = GetLinkByTktBL.GetLinkByTkt(txtNumberTicket.Text.Substring(3, 10), Login.OrgId);
         if (ticketList.Count > 0)
         {
             if (!string.IsNullOrEmpty(ticketList[0].LinkPassengerReceipt) && !string.IsNullOrEmpty(ticketList[0].LinkTicketPrinter))
             {
                 SendPDFDelgate(txtNumberTicket.Text, ticketList[0].LinkVirtuallyThere, txtCCMail.Text.ToLower());
                 MessageBox.Show("SU SOLICITUD FUE ENVIADA CON ÉXITO", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
             }
             else
             {
                 addTicketInBD = false;
                 try
                 {
                     RegenarateInvoice();
                 }
                 catch
                 {
                     MessageBox.Show("HA OCURRIDO UN ERROR EN LA REGENERACIÓN DEL BOLETO, FAVOR DE REPORTARLO A SISTEMAS", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                     Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
                 }
             }
         }
         else
         {
             addTicketInBD = true;
             try
             {
                 RegenarateInvoice();
             }
             catch
             {
                 MessageBox.Show("HA OCURRIDO UN ERROR EN LA REGENERACIÓN DEL BOLETO, FAVOR DE REPORTARLO A SISTEMAS", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
             }
         }
     }
 }
 /// <summary>
 /// Obtiene la factura de un boleto en formato PDF y la guarda en
 /// archivos temporales del usuario
 /// </summary>
 private void GetInvoice()
 {
     linkInvoice = string.Empty;
     indexList.Clear();
     GridViewFacturas.Visible = false;
     lblInfoFacturas.Visible  = false;
     indexList = GetLinkByTktBL.GetLinkByTkt(txtInvoice.Text, Login.OrgId);
     if (indexList.Count > 0)
     {
         if (!string.IsNullOrEmpty(indexList[0].LinkInvoice) && indexList.Count == 1)
         {
             linkInvoice = indexList[0].LinkInvoice;
             Microsoft.VisualBasic.Devices.Computer MyComputer = new Microsoft.VisualBasic.Devices.Computer();
             string fileName = string.Empty;
             fileName = MyComputer.FileSystem.SpecialDirectories.Temp;
             fileName = fileName + string.Format("\\TempFile_{0}.pdf", Guid.NewGuid().ToString());
             if (DownloadFile(linkInvoice, fileName))
             {
                 try
                 {
                     Process.Start(fileName);
                     Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
                 }
                 catch
                 {
                     MessageBox.Show("NO CUENTA CON EL PROGRAMA CORRECTO PARA ABRIR ESTE ARCHIVO", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                     Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
                 }
             }
         }
         else if (string.IsNullOrEmpty(indexList[0].LinkInvoice))
         {
             CommandsAPI2.send_MessageToEmulator("BUSCANDO FACTURA, FAVOR DE ESPERAR.................");
             Parameter timeOut = ParameterBL.GetParameterValue("TimeOutInvoice");
             int       time    = Convert.ToInt32(timeOut.Values);
             AddLinksInvoicesPerTicketBL.AddLinksInvoicesPerTicket(txtInvoice.Text, time);
             indexList.Clear();
             indexList = GetLinkByTktBL.GetLinkByTkt(txtInvoice.Text, Login.OrgId);
             if (string.IsNullOrEmpty(indexList[0].LinkInvoice))
             {
                 MessageBox.Show("LA INTERFASE AUN NO HA PROCESADO SU FACTURA, FAVOR DE VERIFICARLO MAS TARDE", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
             }
             else if (!string.IsNullOrEmpty(indexList[0].LinkInvoice) && indexList.Count == 1)
             {
                 linkInvoice = indexList[0].LinkInvoice;
                 Microsoft.VisualBasic.Devices.Computer MyComputer = new Microsoft.VisualBasic.Devices.Computer();
                 string fileName = string.Empty;
                 fileName = MyComputer.FileSystem.SpecialDirectories.Temp;
                 fileName = fileName + string.Format("\\TempFile_{0}.pdf", Guid.NewGuid().ToString());
                 if (DownloadFile(linkInvoice, fileName))
                 {
                     try
                     {
                         Process.Start(fileName);
                         Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
                     }
                     catch
                     {
                         MessageBox.Show("NO CUENTA CON EL PROGRAMA CORRECTO PARA ABRIR ESTE ARCHIVO", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                         Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
                     }
                 }
             }
             else if (!string.IsNullOrEmpty(indexList[0].LinkInvoice) && indexList.Count > 1)
             {
                 GridViewFacturas.Visible = true;
                 GridViewFacturas.Rows.Clear();
                 int index  = 0;
                 int index2 = 0;
                 for (int i = 0; i < indexList.Count; i++)
                 {
                     index  = indexList[i].LinkInvoice.LastIndexOf(".");
                     index2 = indexList[i].LinkInvoice.LastIndexOf("/");
                     GridViewFacturas.Rows.Add(indexList[i].LinkInvoice.Substring(54, (index - index2 - 1)), indexList[i].DescriptionType);
                 }
                 GridViewFacturas.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                 lblInfoFacturas.Visible = true;
             }
         }
         else if (!string.IsNullOrEmpty(indexList[0].LinkInvoice) && indexList.Count > 1)
         {
             GridViewFacturas.Visible = true;
             GridViewFacturas.Rows.Clear();
             int index  = 0;
             int index2 = 0;
             for (int i = 0; i < indexList.Count; i++)
             {
                 index  = indexList[i].LinkInvoice.LastIndexOf(".");
                 index2 = indexList[i].LinkInvoice.LastIndexOf("/");
                 GridViewFacturas.Rows.Add(indexList[i].LinkInvoice.Substring(54, (index - index2 - 1)), indexList[i].DescriptionType);
             }
             GridViewFacturas.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
             lblInfoFacturas.Visible = true;
         }
     }
     else
     {
         MessageBox.Show("EL NÚMERO DE BOLETO NO EXISTE", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
         Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCWELCOME);
     }
 }
        public static void CreateFilesPDF(List <string> tickets)
        {
            Parameter mailToSend   = ParameterBL.GetParameterValue("MailThatSendFeeRule");
            Parameter mailPassword = ParameterBL.GetParameterValue("PasswordThatMailToSend");
            Parameter displyName   = ParameterBL.GetParameterValue("NameSendEmail");

            string[]            tiketsArray    = new string[tickets.Count];
            string[]            virtuallyThere = new string[tickets.Count];
            List <GetLinkByTkt> indexList      = null;

            for (int j = 0; j < tickets.Count; j++)
            {
                tiketsArray[j] = tickets[j];
                indexList      = new List <GetLinkByTkt>();
                indexList      = GetLinkByTktBL.GetLinkByTkt(tickets[j].Substring(3, 10), Login.OrgId);
                if (indexList.Count > 0)
                {
                    virtuallyThere[j] = indexList[0].LinkVirtuallyThere;
                }
                else
                {
                    virtuallyThere[j] = "http://www.google.com.mx";
                }
            }
            if (tickets.Count > 0)
            {
                try
                {
                    string mail = Login.Mail;
                    if (!string.IsNullOrEmpty(ucSendTicketPrinter.TempCCMail))
                    {
                        mail = string.Concat(mail, ";", ucSendTicketPrinter.TempCCMail);
                        ucSendTicketPrinter.TempCCMail = string.Empty;
                    }
                    if (ucFirstValidations.Attribute1 != null)
                    {
                        if (ucFirstValidations.Attribute1.Equals(Resources.TicketEmission.Constants.ATTRIBUTE1_CFE100))
                        {
                            BuildElectronicTicketCFEContract ws = new BuildElectronicTicketCFEContract();
                            ws.SendInfoToBuilPDF(tiketsArray, virtuallyThere,
                                                 ucTicketsEmissionInstructions.Airline, mailToSend.Values,
                                                 mailPassword.Values, mail, displyName.Values);
                        }
                        else
                        {
                            BuildElectronicTicketContract ws = new BuildElectronicTicketContract();
                            ws.SendInfoToBuilPDF(tiketsArray, virtuallyThere,
                                                 ucTicketsEmissionInstructions.Airline, mailToSend.Values,
                                                 mailPassword.Values, mail, displyName.Values);
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(ucSendTicketPrinter.DK))
                        {
                            GetAttribute1 attribute1 = GetAttribute1BL.GetAttribute(ucSendTicketPrinter.DK, Login.OrgId);
                            if (attribute1.Attribute1.Equals(Resources.TicketEmission.Constants.ATTRIBUTE1_CFE100))
                            {
                                BuildElectronicTicketCFEContract ws = new BuildElectronicTicketCFEContract();
                                ws.SendInfoToBuilPDF(tiketsArray, virtuallyThere,
                                                     ucTicketsEmissionInstructions.Airline, mailToSend.Values,
                                                     mailPassword.Values, mail, displyName.Values);
                            }
                            else
                            {
                                BuildElectronicTicketContract ws = new BuildElectronicTicketContract();
                                ws.SendInfoToBuilPDF(tiketsArray, virtuallyThere,
                                                     ucTicketsEmissionInstructions.Airline, mailToSend.Values,
                                                     mailPassword.Values, mail, displyName.Values);
                            }
                            ucSendTicketPrinter.DK = string.Empty;
                        }
                        else
                        {
                            BuildElectronicTicketContract ws = new BuildElectronicTicketContract();
                            ws.SendInfoToBuilPDF(tiketsArray, virtuallyThere,
                                                 ucTicketsEmissionInstructions.Airline, mailToSend.Values,
                                                 mailPassword.Values, mail, displyName.Values);
                        }
                    }
                }
                catch { }
            }
        }