//Analiza el comando enviado, para crear la etiqueta de Quality Controls C80
        private void EvaluateCommand()
        {
            string seg            = string.Empty;
            string res            = string.Empty;
            string itinerary      = string.Empty;
            string bysegment      = string.Empty;
            string commandSegment = string.Empty;
            string konnect        = string.Empty;
            int    lenght         = 0;
            int    resplenght     = 0;
            int    lenghtcommand  = 0;
            int    aux            = 0;
            int    row            = 0;
            int    col            = 0;
            int    row1           = 0;
            int    col1           = 0;
            int    i = 0;
            int    j = 0;

            if (command.Contains("‡DPE"))
            {
                command = command.Replace("‡DPE", "‡DPB");
            }
            else if (!command.Contains("‡DPB"))
            {
                command = string.Concat(command, "‡DPB");
            }

            //Obtiene segmentos
            if (command.Contains("‡S"))
            {
                char[] charCommand = command.ToCharArray();
                for (int x = 0; x <= charCommand.Length; x++)
                {
                    int y = x + 1;
                    if (charCommand[x] == '‡' & charCommand[x + 1] == 'S')
                    {
                        x++;
                        while (x < charCommand.Length)
                        {
                            if (charCommand[x] != '‡')
                            {
                                segment = string.Concat(segment, charCommand[x]);
                                x++;
                            }
                            else
                            {
                                break;
                            }
                        }
                        break;
                    }
                }
            }

            //Creación de la etiqueta C80



            if (!string.IsNullOrEmpty(segment))
            {
                segment   = segment.Replace('-', '/');
                bysegment = segment.Replace('S', ' ').Trim();
                newlabel  = string.Concat("5.</C80*");
                seg       = string.Concat("*IA");
                using (CommandsAPI2 objCommand = new CommandsAPI2())
                {
                    res = objCommand.SendReceive(seg, 0, 0);
                }

                string[] segments1 = bysegment.Split(new char[] { '/' });



                for (int a = 0; a < segments1.Length; a++)
                {
                    col = 0; row = 0;
                    CommandsQik.searchResponse(segments1[a], "-", ref row, ref col);
                    if (col != 0 || row != 0)
                    {
                        int num1 = 0;
                        int num2 = 0;

                        string[] seg1       = segments1[a].Split(new char[] { '-' });
                        string   replace    = string.Empty;
                        string   bysegment2 = string.Empty;

                        num1 = Convert.ToInt32(seg1[0]);
                        num2 = Convert.ToInt32(seg1[1]);

                        for (int f = num1; f <= num2; f++)
                        {
                            bysegment2 = string.Concat(bysegment2, f.ToString(), "/");
                        }
                        bysegment2 = bysegment2.Remove(bysegment2.Length - 1, 1);
                        replace    = string.Concat(num1.ToString(), "-", num2.ToString());
                        bysegment  = bysegment.Replace(replace, bysegment2);
                    }
                }

                string[] segments = bysegment.Split(new char[] { '/' });
                lenght = segments.Length - 1;


                string[] resp = res.Split(new char[] { '\n' });
                resplenght = resp.Length;


                for (i = 0; i <= lenght; i++)
                {
                    aux = 0;
                    for (j = 1; j < resplenght; j++)
                    {
                        j = aux + 1;

                        col = 0; row = 0; col1 = 0; row1 = 0;
                        CommandsQik.searchResponse(resp[j], "ARNK", ref row, ref col);
                        if (row == 0 || col == 0)
                        {
                            col = 0; row = 0; col1 = 0; row1 = 0;
                            CommandsQik.searchResponse(resp[j], segments[i], ref row, ref col, 1, 3, 1, 3);
                            if (row != 0 || col != 0)
                            {
                                CommandsQik.CopyResponse(resp[j], ref itinerary, row, 19, 8);
                                itinerary      = itinerary.Replace("*", "").Trim();
                                commandSegment = string.Concat(commandSegment, itinerary.Substring(0, 3), ".",
                                                               itinerary.Substring(3, 3), ".");
                                aux = j;
                                break;
                            }
                        }
                        aux = j;
                    }
                }

                if (!string.IsNullOrEmpty(commandSegment))
                {
                    commandSegment = commandSegment.Remove(commandSegment.Length - 1);
                    if (commandSegment.Length > 7)
                    {
                        string[] commands = commandSegment.Split(new char[] { '.' });
                        lenghtcommand = commands.Length - 1;
                        for (int z = 0; z <= lenghtcommand - 1; z++)
                        {
                            if (commands[z] == commands[z + 1])
                            {
                                commands[z] = string.Empty;
                            }
                        }

                        commandSegment = string.Empty;

                        for (int a = 0; a <= lenghtcommand; a++)
                        {
                            if (!string.IsNullOrEmpty(commands[a]))
                            {
                                commandSegment = string.Concat(commandSegment, commands[a].Trim(), ".");
                            }
                        }
                        commandSegment = commandSegment.Remove(commandSegment.Length - 1);
                    }

                    newlabel = string.Concat(newlabel, commandSegment, "/>");
                    c80      = newlabel;
                }
            }
        }
Ejemplo n.º 2
0
        //Evento click del Boton btnTicketEmission
        private void btnTicketEmission_Click(object sender, EventArgs e)
        {
            bool   validAuthCode = true;
            string sabreAnswer   = string.Empty;
            bool   UsuarioValidoParaCargosPorServicio = false;

            // Validamos usuario para generar remark en el caso de las versiones anteriores
            UsuarioValidoParaCargosPorServicio = UsuarioValidoCargosPorServicio();

            if (!UsuarioValidoParaCargosPorServicio)
            {
                for (int i = 0; i < ucServicesFeePayApply.lstDatosTarjeta.Count; i++)
                {
                    if (ucServicesFeePayApply.lstDatosTarjeta[i].MontoCargo != 0)
                    {
                        string sError = string.Empty;
                        ChargesPerService.BuilCommandToSendOld(ucServicesFeePayApply.lstDatosTarjeta[i].PaxNumber, ucServicesFeePayApply.lstDatosTarjeta[i]);
                    }
                }
            }

            if (string.IsNullOrEmpty(ucTicketsEmissionInstructions.CodeAuth.Code))
            {
                if (!string.IsNullOrEmpty(ucFormPayment.CommandGetAuthorizationCode))
                {
                    if (!string.IsNullOrEmpty(ucPromo.PromoCode))
                    {
                        ucFormPayment.CommandGetAuthorizationCode = string.Concat(ucFormPayment.CommandGetAuthorizationCode, "*", ucPromo.PromoCode, "/*C", ucFormPayment.SecurityCode);
                    }
                    else
                    {
                        ucFormPayment.CommandGetAuthorizationCode = string.Concat(ucFormPayment.CommandGetAuthorizationCode, "/*C", ucFormPayment.SecurityCode);
                    }

                    using (CommandsAPI2 objCommand = new CommandsAPI2())
                    {
                        sabreAnswer = objCommand.SendReceive(ucFormPayment.CommandGetAuthorizationCode, 0, 0, 4000);
                    }

                    ucPromo.PromoCode = string.Empty;

                    if (sabreAnswer.Contains(Resources.TicketEmission.Constants.OK))
                    {
                        string[] sabreArray = sabreAnswer.Replace("\n", "-").Split('-');
                        for (int i = 0; i < sabreArray.Length; i++)
                        {
                            int row = 0; int col = 0;
                            CommandsQik.searchResponse(sabreArray[i], Resources.TicketEmission.Constants.OK, ref row, ref col, 1, 2);
                            if (row != 0 || col != 0)
                            {
                                CommandsQik.CopyResponse(sabreArray[i], ref authCode, 1, 4, 6);
                            }
                        }
                        if (!string.IsNullOrEmpty(authCode))
                        {
                            if (ucTicketsEmissionInstructions.wayPayment == Resources.TicketEmission.Constants.PAYMENT_MIXPAYMENT)
                            {
                                ucFormPayment.FormPayment = string.Concat(ucFormPayment.FormPayment, Resources.TicketEmission.Constants.COMMANDS_AST_Z,
                                                                          authCode, Resources.TicketEmission.Constants.SLASH, ucFormPayment.Amount);
                            }
                            else
                            {
                                ucFormPayment.FormPayment = string.Concat(ucFormPayment.FormPayment, Resources.TicketEmission.Constants.COMMANDS_AST_Z, authCode);
                            }
                        }
                    }
                    else if (sabreAnswer.Contains(Resources.TicketEmission.Constants.INVALID))
                    {
                        MessageBox.Show("TARJETA RECHAZADA \n" + sabreAnswer, Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        validAuthCode = false;
                    }
                    else if (sabreAnswer.Contains(Resources.TicketEmission.Constants.DECLINED))
                    {
                        MessageBox.Show("TARJETA RECHAZADA \n" + sabreAnswer, Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        validAuthCode = false;
                    }
                    else if (sabreAnswer.Contains(Resources.TicketEmission.Constants.INCORRECT_CARD))
                    {
                        MessageBox.Show("TARJETA RECHAZADA \n" + sabreAnswer, Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        validAuthCode = false;
                    }
                    else if (sabreAnswer.Contains(Resources.TicketEmission.Constants.PROCESSING_ERROR))
                    {
                        MessageBox.Show("TARJETA RECHAZADA \n" + sabreAnswer, Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        validAuthCode = false;
                    }
                    else if (sabreAnswer.Contains(Resources.TicketEmission.Constants.REFERRAL))
                    {
                        MessageBox.Show("TARJETA RECHAZADA \n" + sabreAnswer, Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        validAuthCode = false;
                    }

                    //Continua con el flujo de boleto, va al paso 8
                    if (!validAuthCode)
                    {
                        SetAuthCodeBL.SetErrorCK(ucFirstValidations.LocatorRecord, ucFormPayment.CardType, ucFormPayment.Amount, ucFormPayment.Bank, sabreAnswer, DateTime.Now, ucFormPayment.CommandGetAuthorizationCode);
                        ucFormPayment.CommandGetAuthorizationCode = string.Empty;
                        Loader.AddToPanel(Loader.Zone.Middle, this, Resources.TicketEmission.Constants.UCTICKETSEMISSIONINSTRUCTIONS);
                    }
                    else if (validatebusinessrules)
                    {
                        Loader.AddToPanel(Loader.Zone.Middle, this, Resources.TicketEmission.Constants.UC_ARMED_COMMANDS);
                    }
                }
                else
                {
                    if (validatebusinessrules)
                    {
                        // Aqui se actualizan los boletos en la tabla de log services fee
                        Loader.AddToPanel(Loader.Zone.Middle, this, Resources.TicketEmission.Constants.UC_ARMED_COMMANDS);
                    }
                }
            }
            else
            {
                if (validatebusinessrules)
                {
                    AuthCode = ucTicketsEmissionInstructions.CodeAuth.Code;

                    if (ucTicketsEmissionInstructions.wayPayment == Resources.TicketEmission.Constants.PAYMENT_MIXPAYMENT)
                    {
                        ucFormPayment.FormPayment = string.Concat(ucFormPayment.FormPayment, Resources.TicketEmission.Constants.COMMANDS_AST_Z,
                                                                  authCode, Resources.TicketEmission.Constants.SLASH, ucFormPayment.Amount);
                    }
                    else
                    {
                        ucFormPayment.FormPayment = string.Concat(ucFormPayment.FormPayment, Resources.TicketEmission.Constants.COMMANDS_AST_Z, authCode);
                    }

                    Loader.AddToPanel(Loader.Zone.Middle, this, Resources.TicketEmission.Constants.UC_ARMED_COMMANDS);
                }
                else
                {
                    Loader.AddToPanel(Loader.Zone.Middle, this, Resources.TicketEmission.Constants.UCTICKETSEMISSIONINSTRUCTIONS);
                }
            }
        }