Пример #1
0
        public int InsertaSolicitud(Inserta_SolicitudEmisionRQ obj)
        {
            var nmOracle     = new Conexion();
            var intSolicitud = 0;
            OracleConnection connection;

            using (connection = new OracleConnection(nmOracle.strCadena))
            {
                if (nmOracle.Connect(connection))
                {
                    var objTx = connection.BeginTransaction(IsolationLevel.ReadCommitted);
                    nmOracle.Transaction(objTx);

                    try
                    {
                        nmOracle.SP_Command(nmOracle.Esquema + ".PKG_SOLICITUD.SP_SOL_INSERTA2", nmOracle.strStoredProcedure);

                        nmOracle.AgregarParametro("pNumIdWeb_in", obj.idWeb, OracleDbType.Int32, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pNumIdLang_in", obj.idLang, OracleDbType.Int32, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pNumIdUsuWeb_in", obj.idUsuWeb, OracleDbType.Int32, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pVarPnrCod_in", obj.pnrCod, OracleDbType.Varchar2, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pVarTipoReserva_in", obj.tipoReserva, OracleDbType.Varchar2, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pVarPromotor_in", obj.promotor, OracleDbType.Varchar2, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pNumTarfBruta_in", obj.tarfBruta, OracleDbType.Decimal, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pNumIgv_in", obj.igv, OracleDbType.Decimal, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pNumPorcentaje_in", obj.porcentaje, OracleDbType.Decimal, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pNumQueues_in", obj.queues, OracleDbType.Decimal, ParameterDirection.Input);         //0
                        nmOracle.AgregarParametro("pNumOtrosPagos_in", obj.otrosPagos, OracleDbType.Decimal, ParameterDirection.Input); //0
                        nmOracle.AgregarParametro("pNumIncentivos_in", obj.incentivos, OracleDbType.Decimal, ParameterDirection.Input); //0
                        nmOracle.AgregarParametro("pNumTarfNeta_in", obj.tarfNeta, OracleDbType.Decimal, ParameterDirection.Input);     //0
                        nmOracle.AgregarParametro("pVarObservacion_in", obj.observacion, OracleDbType.Varchar2, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pNumEstado_in", obj.estado, OracleDbType.Int32, ParameterDirection.Input);           //0
                        nmOracle.AgregarParametro("pNumIdOfiDestino_in", obj.idOfiDestino, OracleDbType.Int32, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pVarTipoTarifa_in", obj.tipoTarifa, OracleDbType.Varchar2, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pNumIdUsuWebSeg_in", obj.idUsuWebSeg, OracleDbType.Int32, ParameterDirection.Input); //-1
                        nmOracle.AgregarParametro("pChrDoc1_in", obj.doc1, OracleDbType.Char, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pVarNroDoc1_in", obj.nroDoc1, OracleDbType.Varchar2, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pChrDoc2_in", obj.doc2, OracleDbType.Char, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pVarNroDoc2_in", obj.nroDoc2, OracleDbType.Varchar2, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pNumIdUsuWebProc_in", obj.idUsuWebProc, OracleDbType.Int32, ParameterDirection.Input); //-1
                        nmOracle.AgregarParametro("pNumIdDepDestino_in", obj.idDepDestino, OracleDbType.Int32, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pVarNomPagador_in", obj.nomPagador, OracleDbType.Varchar2, ParameterDirection.Input);  //""
                        nmOracle.AgregarParametro("pVarApePagador_in", obj.apePagador, OracleDbType.Varchar2, ParameterDirection.Input);  //""
                        nmOracle.AgregarParametro("pChrPaisDestino_in", obj.paisDestino, OracleDbType.Char, ParameterDirection.Input);
                        nmOracle.AgregarParametro("pNumSistOrigen_in", obj.sistemaOrigen, OracleDbType.Int16, ParameterDirection.Input);  //1
                        nmOracle.AgregarParametro("pChrSabreAmadeus_in", obj.sabreAmadeus, OracleDbType.Char, ParameterDirection.Input);

                        nmOracle.AgregarParametro("pID_PUNTO_EMISION_PTA_in", obj.idPuntoEmision, OracleDbType.Int16, ParameterDirection.Input);       //null
                        nmOracle.AgregarParametro("pID_SUCURSAL_EMISION_PTA_in", obj.idsucursalEmision, OracleDbType.Int16, ParameterDirection.Input); //null
                        nmOracle.AgregarParametro("pNumConWaiver_in", obj.conWaiver, OracleDbType.Int16, ParameterDirection.Input);                    //0
                        nmOracle.AgregarParametro("pNumIdSubcodigo_in", obj.idSubCodigo, OracleDbType.Int16, ParameterDirection.Input);                //0

                        nmOracle.AgregarParametro("pFileReferencia_in", obj.fileReferencia, OracleDbType.Varchar2, ParameterDirection.Input);          //null

                        nmOracle.AgregarParametro("pNumIdNewSol_out", null, OracleDbType.Int32, ParameterDirection.Output);

                        nmOracle._ExecuteNonQuery(false);

                        var queryLog = nmOracle.objSBQuery;

                        intSolicitud = int.Parse(nmOracle.LeeParametros("pNumIdNewSol_out", null));

                        if (obj.pasajeros != null)
                        {
                            foreach (var item in obj.pasajeros)
                            {
                                InsertaPasajeros(item, intSolicitud, obj.idUsuWeb, obj.strNombrePagina, obj.idLang, obj.idWeb, connection, objTx);
                            }
                        }

                        if (obj.itinerarios != null)
                        {
                            if (obj.itinerarios.Any(a => !string.IsNullOrEmpty(a.familyFare)))
                            {
                                foreach (var item in obj.itinerarios)
                                {
                                    InsertSegmento2(item, intSolicitud, obj.idUsuWeb, obj.strNombrePagina, obj.idLang, obj.idWeb, connection, objTx);
                                }
                            }
                            else
                            {
                                foreach (var item in obj.itinerarios)
                                {
                                    InsertSegmento(item, intSolicitud, obj.idUsuWeb, obj.strNombrePagina, obj.idLang, obj.idWeb, connection, objTx);
                                }
                            }
                        }

                        if (obj.pagos != null)
                        {
                            foreach (var item in obj.pagos)
                            {
                                InsertaFormaPago(item, intSolicitud, obj.idUsuWeb, obj.strNombrePagina, obj.idLang, obj.idWeb, connection, objTx);
                            }
                        }

                        Inserta(obj.idUsuWeb, obj.strNombrePagina, string.Empty, obj.idLang, obj.idWeb, queryLog, connection, objTx);

                        objTx.Commit();
                    }
                    catch (Exception ex)
                    {
                        // registrando evento
                        Bitacora.Current.Error <cdSolicitudesWebTicket>(ex, new { obj });

                        //intSolicitud = 0;
                        objTx.Rollback();
                        throw;
                    }
                }
            }

            return(intSolicitud);
        }