/// <summary>Busca vuelos de IV</summary>
        /// <param name="departure">Id de la ciudad de origen</param>
        /// <param name="arrival">Id de la ciudad de destino</param>
        /// <param name="departuredate">Fecha de origen</param>
        /// <param name="arrivaldate">Fecha de destino</param>
        /// <param name="numpas">Cantidad de pasajeros</param>
        /// <returns>Devuelve la lista de reservacion de validado (IDA y VUELTA)</returns>
        public List <Entity> GetReservationFlightIV(int departure, int arrival, string departuredate, string arrivaldate, int numpas)
        {
            int cont    = 0;
            var ListRes = new List <Entity>();
            var listres = new ListRes();
            var table1  = new DataTable();
            var table2  = new DataTable();
            var table3  = new DataTable();
            var table4  = new DataTable();
            var table5  = new DataTable();

            try{
                table1 = PgConnection.Instance.ExecuteFunction(GET_ROUNDTRIP_RESERVATION
                                                               , departure, arrival, departuredate, arrivaldate);
                listres._price = table1.Rows.Count;

                /* if(listres._price.Equals("0")){
                 * throw new EmptyListFlight("Disculpe no se encontraron vuelos disponibles para esa fecha");
                 * }*/

                //Recorre la lista de vuelos
                for (int i = 0; i < table1.Rows.Count; i++)
                {
                    //Almacena el nombre de la locacion de salida
                    table4 = PgConnection.Instance.ExecuteFunction(GET_NAME_LOCATION
                                                                   , Convert.ToInt32(table1.Rows[i][5]));

                    //Almacena el nombre de la locacion de llegada
                    table5 = PgConnection.Instance.ExecuteFunction(GET_NAME_LOCATION
                                                                   , Convert.ToInt32(table1.Rows[i][6]));

                    //Almacena la cantidad de reservas del vuelo
                    table2 = PgConnection.Instance.ExecuteFunction("getSum(@id_flight)",
                                                                   Convert.ToInt32(table1.Rows[i][0].ToString()));

                    //Almacena la capacidad del avión del vuelo
                    table3 = PgConnection.Instance.ExecuteFunction(GET_CAPACITY,
                                                                   Convert.ToInt32(table1.Rows[i][0].ToString()));

                    //Almacena la cant de reservas y la capacidad del avión
                    listres._sum_pas      = Convert.ToInt32(table2.Rows[0][0].ToString());
                    listres._sum_capacity = Convert.ToInt32(table3.Rows[0][0].ToString());

                    //Almacena la cantidad de reservas disponibles
                    cont = listres._sum_capacity - listres._sum_pas;


                    //Si la cantidad de reservas disponibles es mayor entonces almacena el vuelo
                    if (cont >= numpas)
                    {
                        listres._id             = Convert.ToInt32(table1.Rows[i][0].ToString());
                        listres._price          = Convert.ToInt32(table1.Rows[i][2].ToString());
                        listres._priceupdate    = Convert.ToInt32(table1.Rows[i][2].ToString()) * numpas;
                        listres._dateI          = table1.Rows[i][3].ToString();
                        listres._dateV          = table1.Rows[i][4].ToString();
                        listres._seatavailable  = cont;
                        listres._name_country_i = table4.Rows[0][2].ToString();
                        listres._name_country_V = table5.Rows[0][2].ToString();
                        listres._name_city_i    = table4.Rows[0][1].ToString();
                        listres._name_city_V    = table5.Rows[0][1].ToString();

                        var listreservationflight = new ListRes(listres._id, listres._price,
                                                                listres._priceupdate, listres._dateI, listres._dateV, listres._name_country_i,
                                                                listres._name_country_V, listres._seatavailable, listres._name_city_i,
                                                                listres._name_city_V);

                        ListRes.Add(listreservationflight);
                        cont = 0;
                    }
                }

                return(ListRes);
            }catch (InvalidStoredProcedureSignatureException) {
                throw new InvalidStoredProcedureSignatureException("Tienes un error en el Stored Procedure");
            }
        }
Beispiel #2
0
        public void RefreshSearchResults(int mode)
        {
            ulong x = 0;
            bool reloadDump = false;
            ListView.ListViewItemCollection items = new ListView.ListViewItemCollection(lvSch);
            //lvSch.Items.

            switch (mode)
            {
                case 0: /* Refresh by reloading everything from the dump */
                    lvSch.Items.Clear();

                    if (Form1.SchResCnt == 0)
                        reloadDump = true;

                    if (reloadDump)
                    {
                        lvSch.BeginUpdate();
                        while (true)
                        {
                            String Addr = "";

                            CodeRes[] retRes = fileio.ReadDumpArray(dFileName, (int)x, (MaxRes - 1) + (int)x, (int)GlobAlign);
                            if (retRes == null)
                                return;

                            GlobAlign = (ulong)retRes[0].align;
                            NextSAlign = (int)retRes[0].align;

                            for (int z = 0; z < retRes.Length; z++)
                            {

                                if (retRes[z].val == null)
                                    goto nextZ;

                                ListRes a = misc.GetlvVals((int)GlobAlign, retRes[z].val, 0);

                                Addr = (retRes[z].addr).ToString("X8");

                                string[] row = { Addr, a.HexVal, a.DecVal, a.AlignStr };
                                var listViewItem = new ListViewItem(row);
                                //lvSch.Items.Add(listViewItem);
                                items.Add(listViewItem);

                            nextZ:
                                if ((x % 1000) == 0)
                                {
                                    statusLabel1.Text = "Results: " + x.ToString();
                                    Application.DoEvents();
                                }
                                if (retRes[z].val == null && reloadDump)
                                {
                                    Form1.SchResCnt = x;
                                    statusLabel1.Text = "Results: " + x.ToString();
                                    lvSch.EndUpdate();
                                    NewSearch = false;
                                    schNSearch.Enabled = true;
                                    return;
                                }
                                x++;
                            }
                        }
                    }
                    else
                    {
                        lvSch.BeginUpdate();
                        //for (x = 0; x < Form1.SchResCnt; x++)
                        while (x < Form1.SchResCnt)
                        {
                            String Addr = "";

                            CodeRes[] retRes = fileio.ReadDumpArray(dFileName, (int)x, (MaxRes - 1) + (int)x, (int)GlobAlign);
                            if (retRes == null)
                                return;

                            if ((int)x < retRes.Length)
                            {
                                GlobAlign = (ulong)retRes[x].align;
                                NextSAlign = (int)retRes[x].align;
                            }

                            int z = 0;
                            for (z = 0; z < retRes.Length; z++)
                            {
                                if (retRes[z].val == null)
                                    goto nextZ;

                                ListRes a = misc.GetlvVals((int)GlobAlign, retRes[z].val, 0);

                                Addr = (retRes[z].addr).ToString("X8");

                                string[] row = { Addr, a.HexVal, a.DecVal, a.AlignStr };
                                var listViewItem = new ListViewItem(row);
                                items.Add(listViewItem);

                            nextZ:
                                if ((z % 1000) == 0)
                                    Application.DoEvents();
                            }
                            x += (ulong)z;
                        }
                        lvSch.EndUpdate();
                    }

                    break;
                case 1: /* Refresh everything by grabbing the values from the PS3 */
                    lvSch.BeginUpdate();
                    for (x = 0; x < Form1.SchResCnt; x++)
                    {
                        String Addr = "";
                        int align = (int)GlobAlign;

                        CodeRes[] retRes = fileio.ReadDumpArray(dFileName, (int)x, MaxRes + (int)x, (int)GlobAlign);
                        if (retRes == null)
                            return;

                        for (int z = 0; z < retRes.Length; z++)
                        {

                            if (x >= Form1.SchResCnt)
                                break;

                            if ((int)GlobAlign == -1 || (int)GlobAlign == -2)
                                align = retRes[z].val.Length;

                            byte[] ret = new byte[align];
                            apiGetMem(retRes[z].addr, ref ret);

                            ListRes a = new ListRes();
                            a = misc.GetlvVals((int)GlobAlign, ret, 0);

                            Addr = (retRes[z].addr).ToString("X8");

                            if ((int)x < lvSch.Items.Count)
                            {
                                items[(int)x].SubItems[0].Text = Addr;
                                items[(int)x].SubItems[1].Text = a.HexVal;
                                items[(int)x].SubItems[2].Text = a.DecVal;
                                items[(int)x].SubItems[3].Text = a.AlignStr;
                            }
                            else
                            {
                                string[] row = { Addr, a.HexVal, a.DecVal, a.AlignStr };
                                var listViewItem = new ListViewItem(row);
                                items.Add(listViewItem);
                            }

                            x++;
                            if ((x % 500) == 0)
                                Application.DoEvents();
                        }
                    }
                    lvSch.EndUpdate();
                    break;
            }
        }
        /// <param name="departure">Id de la ciudad de origen</param>
        /// <param name="arrival">Id de la ciudad de destino</param>
        /// <param name="departuredate">Fecha de origen</param>
        /// <param name="arrivaldate">Fecha de destino</param>
        /// <param name="numpas">Cantidad de pasajeros</param>
        /// <returns>Devuelve la lista de reservacion de validado (IDA y VUELTA)</returns>
        public List <ListRes> GetReservationFlightIV(int departure, int arrival, string departuredate, string arrivaldate, int numpas)
        {
            int cont    = 0;
            var ListRes = new List <ListRes>();
            var listres = new ListRes();
            var table1  = new DataTable();
            var table2  = new DataTable();
            var table3  = new DataTable();
            var table4  = new DataTable();
            var table5  = new DataTable();

            try{
                table1 = PgConnection.Instance.ExecuteFunction("GetFlightsIDAVU(@_departure,@_arrival,@_departuredate,@arrivaldate)"
                                                               , departure, arrival, departuredate, arrivaldate);
                listres._price = table1.Rows.Count;

                if (listres._price.Equals("0"))
                {
                    throw new EmptyListFlight("Disculpe no se Encontraron Vuelos Disponibles para esa Fecha");
                }

                for (int i = 0; i < table1.Rows.Count; i++)
                {
                    table4 = PgConnection.Instance.ExecuteFunction("GetNameLocation(@_id_city)"
                                                                   , Convert.ToInt32(table1.Rows[i][5]));
                    table5 = PgConnection.Instance.ExecuteFunction("GetNameLocation(@_id_city)"
                                                                   , Convert.ToInt32(table1.Rows[i][6]));
                    table2 = PgConnection.Instance.ExecuteFunction("getSum(@id_flight)",
                                                                   Convert.ToInt32(table1.Rows[i][0].ToString()));
                    table3 = PgConnection.Instance.ExecuteFunction("getCapacity(@idfligh)",
                                                                   Convert.ToInt32(table1.Rows[i][0].ToString()));
                    listres._sum_pas      = Convert.ToInt32(table2.Rows[0][0].ToString());
                    listres._sum_capacity = Convert.ToInt32(table3.Rows[0][0].ToString());

                    cont = listres._sum_capacity - listres._sum_pas;

                    if (cont >= numpas)
                    {
                        Console.WriteLine(cont);
                        listres._id             = Convert.ToInt32(table1.Rows[i][0].ToString());
                        listres._price          = Convert.ToInt32(table1.Rows[i][2].ToString());
                        listres._priceupdate    = Convert.ToInt32(table1.Rows[i][2].ToString()) * numpas;
                        listres._dateI          = table1.Rows[i][3].ToString();
                        listres._dateV          = table1.Rows[i][4].ToString();
                        listres._seatavailable  = cont;
                        listres._name_country_i = table4.Rows[0][2].ToString();
                        listres._name_country_V = table5.Rows[0][2].ToString();
                        listres._name_city_i    = table4.Rows[0][1].ToString();
                        listres._name_city_V    = table5.Rows[0][1].ToString();

                        var listreservationflight = new ListRes(listres._id, listres._price,
                                                                listres._priceupdate, listres._dateI, listres._dateV, listres._name_country_i,
                                                                listres._name_country_V, listres._seatavailable, listres._name_city_i,
                                                                listres._name_city_V);

                        ListRes.Add(listreservationflight);
                        cont = 0;
                    }
                }

                return(ListRes);
            }catch (InvalidStoredProcedureSignatureException) {
                throw new InvalidStoredProcedureSignatureException("Tienes un error en el Stored Procedure");
            }
        }