Beispiel #1
0
        /// <summary>
        /// Processes the m59 message. If all goes OK, returns an ACK_PROCESSED with the current time
        /// </summary>
        /// <returns></returns>
        public StringCollection Process()
        {
            AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();
            double            nDifHour    = 0;

            try
            {
                nDifHour = (double)appSettings.GetValue("HOUR_DIFFERENCE", typeof(double));
            }
            catch
            {
                nDifHour = 0;
            }

            string          sResponse         = "<t>" + OPS.Comm.Dtx.DtxToString(DateTime.Now.AddHours(nDifHour)) + "</t>";
            CmpParametersDB cmpParam          = new CmpParametersDB();
            string          strHourDifference = cmpParam.GetParameter("P_HOUR_DIFF");

            if (strHourDifference != "")
            {
                sResponse = sResponse + "<hd>" + strHourDifference + "</hd>";
            }

            AckMessage       ret = new AckMessage(_msgId, sResponse);
            StringCollection sc  = new StringCollection();

            sc.Add(ret.ToString());
            return(sc);
        }
        public System.Collections.Specialized.StringCollection Process()
        {
            //***** Parameters needed for FINES
            //id is not necessary
            //defId is FINE_TYPE_PAYMENT
            //number is the "fineNumber" parameter (optional)
            string vehicleId    = null;
            string model        = null;
            string manufacturer = null;
            string colour       = null;
            int    groupId      = -1;
            int    streetId     = -1;
            int    streetNumber = -1;
            //date is the "date" parameter
            string comments = null;
            int    userId   = -1;

            //unitId is the "unitId" parameter
            //payed is TRUE
            //int paymentDefId = -1; // Could be calculated through the "paymentDefDescShort" parameter, but is not used
            //sent is not necessary
            //extrasent is not necessary

            //***** Parameters needed for OPERATIONS (see also parameters for FINES)
            //quantity is the "quantity" parameter

            try
            {
                Console.WriteLine("M04.cs:Proccess - Inicio del procesado del M04");
                ILogger        logger = null;
                IDbTransaction tran   = null;
                logger = DatabaseFactory.Logger;
                if (logger != null)
                {
                    logger.AddLog("[Msg04:Process]", LoggerSeverities.Debug);
                }

                // this._paymentDefId == OPERATIONS_BILLREADER_REFUNDRECEIPT !!!!!!!!!!!!!!!! chapuza momentanea
                if (_operType == OPERATIONS_BILLREADER_REFUNDRECEIPT || this._paymentDefId == OPERATIONS_BILLREADER_REFUNDRECEIPT)
                {
                    CmpBillReaderRefundsFineDB cmp = new CmpBillReaderRefundsFineDB();
                    if (cmp.Insert(_unitId, _date, Convert.ToInt32(_quantity), _fineNumber, _lfineDef) < 0)
                    {
                        if (logger != null)
                        {
                            logger.AddLog("[Msg04:Process]:ERROR ON INSERT", LoggerSeverities.Debug);
                        }
                        return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));
                    }
                    else
                    {
                        if (logger != null)
                        {
                            logger.AddLog("[Msg04:Process]: RESULT OK", LoggerSeverities.Debug);
                        }
                        return(ReturnAck(AckMessage.AckTypes.ACK_PROCESSED));
                    }
                }
                else
                {
                    int iBinFormat = -1;
                    if (_binType == -1)
                    {
                        CmpParametersDB cmpParam     = new CmpParametersDB();
                        string          strBinFormat = cmpParam.GetParameter("P_BIN_FORMAT");
                        if (strBinFormat != "")
                        {
                            iBinFormat = Convert.ToInt32(strBinFormat);
                        }
                    }
                    else
                    {
                        iBinFormat = _binType;
                    }

                    if (!Msg07.ListaNegra(logger, _szCCNumber, iBinFormat))
                    {
                        // Step 1: Search for an existing fine
                        DataTable  dt  = null;
                        CmpFinesDB fdb = new CmpFinesDB();
                        if (_fineNumber != null)
                        {
                            string sql = "SELECT * "
                                         + "FROM FINES "
                                         + "INNER JOIN FINES_DEF ON FINES.FIN_DFIN_ID = FINES_DEF.DFIN_ID "
                                         + "WHERE FIN_NUMBER = @FINES.FIN_NUMBER@ "
                                         + "AND DFIN_COD_ID = @FINES_DEF.DFIN_COD_ID@";
                            dt = fdb.GetData(sql, new object[] { _fineNumber, FINES_DEF_CODES_FINE });
                            if (dt.Rows.Count > 0)
                            {
                                vehicleId    = (dt.Rows[0]["FIN_VEHICLEID"] == DBNull.Value ? null : (string)dt.Rows[0]["FIN_VEHICLEID"]);
                                model        = (dt.Rows[0]["FIN_MODEL"] == DBNull.Value ? null : (string)dt.Rows[0]["FIN_MODEL"]);
                                manufacturer = (dt.Rows[0]["FIN_MANUFACTURER"] == DBNull.Value ? null : (string)dt.Rows[0]["FIN_MANUFACTURER"]);
                                colour       = (dt.Rows[0]["FIN_COLOUR"] == DBNull.Value ? null : (string)dt.Rows[0]["FIN_COLOUR"]);
                                groupId      = (dt.Rows[0]["FIN_GRP_ID"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[0]["FIN_GRP_ID"]));
                                streetId     = (dt.Rows[0]["FIN_STR_ID"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[0]["FIN_STR_ID"]));
                                streetNumber = (dt.Rows[0]["FIN_STRNUMBER"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[0]["FIN_STRNUMBER"]));
                                comments     = (dt.Rows[0]["FIN_COMMENTS"] == DBNull.Value ? null : (string)dt.Rows[0]["FIN_COMMENTS"]);
                                userId       = (dt.Rows[0]["FIN_USR_ID"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[0]["FIN_USR_ID"]));
                                //quantity = Convert.ToDouble(dt.Rows[0]["DFIN_VALUE"]);
                            }
                            else
                            {
                                CmpFinesHisDB fhdb = new CmpFinesHisDB();
                                sql = "SELECT * "
                                      + "FROM FINES_HIS "
                                      + "INNER JOIN FINES_DEF ON FINES_HIS.HFIN_DFIN_ID = FINES_DEF.DFIN_ID "
                                      + "WHERE HFIN_NUMBER = @FINES_HIS.HFIN_NUMBER@ "
                                      + "AND DFIN_COD_ID = @FINES_DEF.DFIN_COD_ID@";
                                dt = fhdb.GetData(sql, new object[] { _fineNumber, FINES_DEF_CODES_FINE });
                                if (dt.Rows.Count > 0)
                                {
                                    vehicleId    = (dt.Rows[0]["HFIN_VEHICLEID"] == DBNull.Value ? null : (string)dt.Rows[0]["HFIN_VEHICLEID"]);
                                    model        = (dt.Rows[0]["HFIN_MODEL"] == DBNull.Value ? null : (string)dt.Rows[0]["HFIN_MODEL"]);
                                    manufacturer = (dt.Rows[0]["HFIN_MANUFACTURER"] == DBNull.Value ? null : (string)dt.Rows[0]["HFIN_MANUFACTURER"]);
                                    colour       = (dt.Rows[0]["HFIN_COLOUR"] == DBNull.Value ? null : (string)dt.Rows[0]["HFIN_COLOUR"]);
                                    groupId      = (dt.Rows[0]["HFIN_GRP_ID"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[0]["HFIN_GRP_ID"]));
                                    streetId     = (dt.Rows[0]["HFIN_STR_ID"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[0]["HFIN_STR_ID"]));
                                    streetNumber = (dt.Rows[0]["HFIN_STRNUMBER"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[0]["HFIN_STRNUMBER"]));
                                    comments     = (dt.Rows[0]["HFIN_COMMENTS"] == DBNull.Value ? null : (string)dt.Rows[0]["HFIN_COMMENTS"]);
                                    userId       = (dt.Rows[0]["HFIN_USR_ID"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[0]["HFIN_USR_ID"]));
                                    //quantity = Convert.ToDouble(dt.Rows[0]["DFIN_VALUE"]);
                                }
                            }
                        }
                        //				else
                        //				{
                        //					// Quantity can be calculated based on _fineDefId parameter
                        //					CmpFinesDefDB fddb = new CmpFinesDefDB();
                        //					DataTable fddt = fddb.GetData(null, "DFIN_DESCSHORT = @FINES_DEF.DFIN_DESCSHORT@",
                        //						new object[] {_fineDefDescShort});
                        //					if (fddt.Rows.Count > 0)
                        //						quantity = (double)fddt.Rows[0]["DFIN_VALUE"];
                        //				}
                        if (groupId == -1)
                        {
                            // Get the physical groups tree and store it in parentsList
                            CmpGroupsChildsDB gcdb = new CmpGroupsChildsDB();
                            groupId = gcdb.GetFirstPhysicalParent(_unitId);
                        }

                        // Step 2: Insert the payed register in the FINES table

                        // ESTO NO FUNCIONA Y LO SE, LO SE ... falta la adecuación a la nueva tabla FINES

                        /*
                         * CFE - 020705 - Elimino inserción en fines de pagos llegados por m4
                         * fdb.InsertFine(FINES_DEF_PAYMENT,  vehicleId, model, manufacturer,
                         *      colour, groupId, groupId, streetId, streetNumber, _date, comments, userId, _unitId, _paymentDefId,-1,-1);
                         */

                        // Step 3: Insert the register in the OPERATIONS table
                        CmpOperationsDB odb             = new CmpOperationsDB();
                        int             nNewOperationID = 0;


                        /// Returns 0 = 0K, -1 = ERR, 1 = OPERACION YA EXISTENTE
                        int nInsOperRdo = odb.InsertOperation(OPERATIONS_DEF_PAYMENT, _operationId, -1, groupId,
                                                              _unitId, _paymentDefId, _date, DateTime.MinValue, DateTime.MinValue, -1, _quantity, vehicleId, -1, _mobileUserId, -1,
                                                              _dChipCardCredit, _ulChipCardId, (_fineNumber == null ? -1 : Convert.ToDouble(_fineNumber)),
                                                              _lfineDef, -1, -1, _onlineMessage, _ticketNumber, ref nNewOperationID, out tran);

                        // Smartcode implementation
                        if (_fineNumber.Length <= 10)
                        {
                            if ((nInsOperRdo == 0) && (_fineNumber != null))
                            {
                                CFineManager oFineManager = new CFineManager();
                                oFineManager.SetLogger(logger);
                                oFineManager.SetDBTransaction(tran);
                                oFineManager.SetFineStatus(int.Parse(_fineNumber));
                            }
                        }
                        else
                        {
                            string sFineCode = "";
                            for (int i = 0; i < 10; i++)
                            {
                                string sByte  = _fineNumber.Substring(i * 2, 2);
                                int    nValue = Convert.ToInt32(sByte);
                                char   cByte  = (char)nValue;
                                sFineCode += cByte.ToString();
                            }
                            CFineManager oFineManager = new CFineManager();
                            oFineManager.SetLogger(logger);
                            oFineManager.SetDBTransaction(tran);
                            oFineManager.UpdateOperationFineNumber(nNewOperationID, sFineCode);
                        }

                        if (nInsOperRdo == 0)
                        {
                            if (!UpdateCloudData(nNewOperationID, tran))
                            {
                                RollbackTrans(tran);
                                return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));
                            }

                            OPS.Components.Data.CmpCreditCardDB cmpCreditCard = null;
                            cmpCreditCard = new OPS.Components.Data.CmpCreditCardDB();

                            if (cmpCreditCard == null)
                            {
                                RollbackTrans(tran);
                                return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));
                            }

                            try
                            {
                                if (_szCCNumber != "")
                                {
                                    if (logger != null)
                                    {
                                        logger.AddLog("[Msg04:Process]: Operation WITH CARD Id", LoggerSeverities.Debug);
                                    }


                                    CmpCreditCardsTransactionsDB cmpCreditCardsTransactionsDB = new CmpCreditCardsTransactionsDB();

                                    if (_szCCNumber == "CCZ_OPERATIONID")
                                    {
                                        //szCCName contiene el número de transacción
                                        //nNewOperationID
                                        OracleConnection oraDBConn = null;
                                        OracleCommand    oraCmd    = null;


                                        Database d = OPS.Components.Data.DatabaseFactory.GetDatabase();
                                        logger    = DatabaseFactory.Logger;
                                        oraDBConn = (OracleConnection)tran.Connection;


                                        //
                                        string state     = String.Empty;
                                        string selectMFT = "select mft_status from mifare_transaction where MFT_UNI_TRANS_ID = " + _szCCName;
                                        selectMFT += " and MFT_UNI_ID = " + _unitId;

                                        if (oraDBConn.State == System.Data.ConnectionState.Open)
                                        {
                                            oraCmd             = new OracleCommand();
                                            oraCmd.Connection  = (OracleConnection)oraDBConn;
                                            oraCmd.CommandText = selectMFT;
                                            oraCmd.Transaction = (OracleTransaction)tran;

                                            OracleDataReader rd = oraCmd.ExecuteReader();

                                            while (rd.Read())
                                            {
                                                int i = rd.GetOrdinal("MFT_STATUS");
                                                state = (rd.GetInt32(rd.GetOrdinal("MFT_STATUS"))).ToString();
                                            }
                                        }
                                        else
                                        {
                                            RollbackTrans(tran);
                                            return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));
                                        }

                                        if (state == "20")
                                        {
                                            string updateMFT = "update mifare_transaction ";
                                            updateMFT += "set mft_status = 30, mft_ope_id = " + nNewOperationID.ToString();
                                            updateMFT += "  where MFT_UNI_TRANS_ID= " + _szCCName + " and MFT_UNI_ID = " + _unitId;

                                            if (oraDBConn.State == System.Data.ConnectionState.Open)
                                            {
                                                oraCmd             = new OracleCommand();
                                                oraCmd.Connection  = (OracleConnection)oraDBConn;
                                                oraCmd.CommandText = updateMFT;
                                                oraCmd.Transaction = (OracleTransaction)tran;
                                                int numRowsAffected = oraCmd.ExecuteNonQuery();

                                                if (numRowsAffected == 0)
                                                {
                                                    RollbackTrans(tran);
                                                    ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS);
                                                    return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));
                                                }
                                            }
                                            else
                                            {
                                                RollbackTrans(tran);
                                                return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));
                                            }
                                        }
                                        else
                                        {
                                            RollbackTrans(tran);
                                            return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));
                                        }
                                    }
                                    else if (iBinFormat == Msg07.DEF_BIN_FORMAT_EMV_TAS && _szCCNumber == "TRANSACTION_ID")
                                    {
                                        int iTransId = -1;
                                        if (cmpCreditCardsTransactionsDB.InsertCommitTrans(tran, _szCCName, _date, nNewOperationID, Convert.ToInt32(_quantity), _unitId, _fineNumber, out iTransId) < 0)
                                        {
                                            RollbackTrans(tran);
                                            if (logger != null)
                                            {
                                                logger.AddLog("[Msg02:Process]:ERROR ON INSERT", LoggerSeverities.Debug);
                                            }
                                            return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));
                                        }
                                        else
                                        {
                                            if (logger != null)
                                            {
                                                logger.AddLog("[Msg02:Process]: RESULT OK", LoggerSeverities.Debug);
                                            }
                                        }
                                    }
                                    else if (iBinFormat == Msg07.DEF_BIN_FORMAT_EMV_TAS && _szCCNumber != "TRANSACTION_ID")
                                    {
                                        RollbackTrans(tran);
                                        if (logger != null)
                                        {
                                            logger.AddLog("[Msg02:Process]:TRANSACTION ID IS NOT ATTACHED", LoggerSeverities.Debug);
                                        }
                                        return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));
                                    }
                                    else
                                    {
                                        _nStatus = STATUS_INSERT;
                                        if (cmpCreditCard.Insert(tran, nNewOperationID, _szCCNumber, _szCCName, _dtExpirDate, _nStatus, _szCCCodServ, _szCCDiscData) < 0)
                                        {
                                            RollbackTrans(tran);
                                            if (logger != null)
                                            {
                                                logger.AddLog("[Msg04:Process]:ERROR ON INSERT", LoggerSeverities.Debug);
                                            }
                                            return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));
                                        }
                                        else
                                        {
                                            if (logger != null)
                                            {
                                                logger.AddLog("[Msg04:Process]: RESULT OK", LoggerSeverities.Debug);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    if (logger != null)
                                    {
                                        logger.AddLog("[Msg04:Process]: Operation WITHOUT CARD Id", LoggerSeverities.Debug);
                                    }
                                }
                            }
                            catch (Exception exc)
                            {
                                RollbackTrans(tran);
                                if (logger != null)
                                {
                                    logger.AddLog("[Msg04:Process]" + exc.Message, LoggerSeverities.Debug);
                                }
                                return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));;
                            }
                        }
                        else if (nInsOperRdo == 1)
                        {
                            //RollbackTrans(tran);
                            if (logger != null)
                            {
                                logger.AddLog("[Msg04:Process]: Operation already exists in DB", LoggerSeverities.Debug);
                            }
                            return(ReturnAck(AckMessage.AckTypes.ACK_PROCESSED));
                        }
                        else
                        {
                            RollbackTrans(tran);
                            return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));
                        }
                    }
                    else
                    {
                        if (!InsertFraudMsgs(logger))
                        {
                            return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));
                        }
                    }
                }

                CommitTrans(tran);
                // Finished.
                return(ReturnAck(AckMessage.AckTypes.ACK_PROCESSED));
            }
            catch (Exception)
            {
                return(ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Inserts a new register in the OPERATIONS table, and if everything is succesful sends an ACK_PROCESSED
        /// </summary>
        /// <returns>Message to send back to the sender</returns>
        public System.Collections.Specialized.StringCollection Process()
        {
            StringCollection ret    = new StringCollection();
            ILogger          logger = null;

            #region COMENTADO POR FALTA DLL CardEaseXMLClient
            //int responseResult = Msg07.DEF_CREDIT_CARD_NOK;
            #endregion

            string strTransId = "";
            int    iTransId   = -1;;
            string response   = "";

            try
            {
                Database d = OPS.Components.Data.DatabaseFactory.GetDatabase();
                logger = DatabaseFactory.Logger;

                int iBinFormat = -1;
                if (_binType == -1)
                {
                    CmpParametersDB cmpParam     = new CmpParametersDB();
                    string          strBinFormat = cmpParam.GetParameter("P_BIN_FORMAT");
                    if (strBinFormat != "")
                    {
                        iBinFormat = Convert.ToInt32(strBinFormat);
                    }
                }
                else
                {
                    iBinFormat = _binType;
                }


                #region COMENTADO POR FALTA DLL CardEaseXMLClient
                //           if (iBinFormat == Msg07.DEF_BIN_FORMAT_CARDEASEXML)
                //           {
                //               int iSpecErrorCode = (int)CardEaseXML.ErrorCode.Empty;
                //               string errMessage = "";

                //               if (Msg07.CardEaseAuth(logger, _szCCNumber, _dtExpirDate, ref strTransId, Convert.ToInt32(_quantity), false, true,
                //                   out responseResult, out iSpecErrorCode, out errMessage))
                //               {
                //                   CmpCreditCardsTransactionsDB cmpCreditCardsTransactionsDB = new CmpCreditCardsTransactionsDB();
                //                   if (cmpCreditCardsTransactionsDB.InsertAuthTrans(strTransId, _date, _szCCNumber, _szCCName, _dtExpirDate,
                //                       _szCCCodServ, _szCCDiscData, Convert.ToInt32(_quantity), _unit, _szInfoField, out iTransId) == 1)
                //                   {
                //                       responseResult = Msg07.DEF_CREDIT_CARD_OK;

                //                   }
                //                   else
                //                   {
                //                       responseResult = Msg07.DEF_CREDIT_CARD_CHECK_NO_POSIBLE;

                //                   }

                //               }

                //               // Build response
                //               response = "<r>" + Convert.ToString(responseResult) + "</r>";
                //               if (responseResult == Msg07.DEF_CREDIT_CARD_OK)
                //               {
                //                   CultureInfo culture = new CultureInfo("", false);
                //                   response += "<ti>" + Convert.ToString(iTransId, (IFormatProvider)culture.NumberFormat) + "</ti>";
                //               }

                //               logger.AddLog("[Msg08:Process]: Response: " + response, LoggerSeverities.Debug);
                //               ret.Add(new AckMessage(_msgId, response).ToString());

                //           }
                //           else if (iBinFormat == Msg07.DEF_BIN_FORMAT_TRANSAX_ONLINE)
                //           {
                //               CS_M8_TRANSAX pCS_M8_TRANSAX = new CS_M8_TRANSAX();

                //               pCS_M8_TRANSAX._TRXTerminalUser = _TRXTerminalUser;
                //               pCS_M8_TRANSAX._TRXTerminalPass = _TRXTerminalPass;
                //               pCS_M8_TRANSAX._TRXTerminalStore = _TRXTerminalStore;
                //               pCS_M8_TRANSAX._TRXTerminalStation = _TRXTerminalStation;
                //               pCS_M8_TRANSAX._TRXRequestId = _TRXRequestId;
                //               pCS_M8_TRANSAX._TRXRequestInvoice = _TRXRequestInvoice;
                //               double dAmount = Convert.ToDouble(_TRXRequestAmountNumber) / 100.0;
                //               _TRXRequestAmount = dAmount.ToString().Replace(",", ".");
                //               pCS_M8_TRANSAX._TRXRequestAmount = _TRXRequestAmount;
                //               pCS_M8_TRANSAX._TRXRequestTrack2 = _TRXRequestTrack2;

                //               int iRes = pCS_M8_TRANSAX.TRXAuthorize();


                //               /*
                // *
                // *        public int			pCS_M8_TRANSAX._TRXResponseOperStatus=-1;  trxos
                //		public string       pCS_M8_TRANSAX._TRXResponseId="";  trri
                //		public string       pCS_M8_TRANSAX._TRXResponseTransStatus="";  trr
                //		public string       pCS_M8_TRANSAX._TRXResponseISORespCode=""; trrc
                //		public string       pCS_M8_TRANSAX._TRXResponseApproval=""; trid
                //		public string       pCS_M8_TRANSAX._TRXResponseBatch=""; trba
                //		public string       pCS_M8_TRANSAX._TRXResponseInvoice=""; tri
                //		public string       pCS_M8_TRANSAX._TRXResponseCardName=""; trna
                //		public string       pCS_M8_TRANSAX._TRXResponseMaskedPAN=""; trnb
                //		public string       pCS_M8_TRANSAX._TRXResponseAmount=""; tra
                //*/
                //               // Build response
                //               response = "<trrr>" + Convert.ToString(iRes) + "</trrr>";
                //               response += "<tros>" + Convert.ToString(pCS_M8_TRANSAX._TRXResponseOperStatus) + "</tros>";
                //               response += "<trri>" + Convert.ToString(pCS_M8_TRANSAX._TRXResponseId) + "</trri>";
                //               response += "<trr>" + Convert.ToString(pCS_M8_TRANSAX._TRXResponseTransStatus) + "</trr>";
                //               response += "<trrc>" + Convert.ToString(pCS_M8_TRANSAX._TRXResponseISORespCode) + "</trrc>";
                //               response += "<trid>" + Convert.ToString(pCS_M8_TRANSAX._TRXResponseApproval) + "</trid>";
                //               response += "<trba>" + Convert.ToString(pCS_M8_TRANSAX._TRXResponseBatch) + "</trba>";
                //               response += "<tri>" + Convert.ToString(pCS_M8_TRANSAX._TRXResponseInvoice) + "</tri>";
                //               response += "<trna>" + Convert.ToString(pCS_M8_TRANSAX._TRXResponseCardName) + "</trna>";
                //               response += "<trnb>" + Convert.ToString(pCS_M8_TRANSAX._TRXResponseMaskedPAN) + "</trnb>";
                //               if (pCS_M8_TRANSAX._TRXResponseAmount != "")
                //               {
                //                   NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;
                //                   double dResponseAmount = double.Parse(pCS_M8_TRANSAX._TRXResponseAmount, nfi);
                //                   dResponseAmount *= 100;
                //                   response += "<tra>" + Convert.ToInt32(dResponseAmount).ToString() + "</tra>";
                //               }

                //               IDbConnection con = d.GetNewConnection();
                //               con.Open();
                //               // Put the two operations inside a TRANSACTION because we want a block (updates to the
                //               // table cannot be allowed when we are reading the PK and inserting the data).
                //               IDbTransaction tran = con.BeginTransaction(IsolationLevel.Serializable);
                //               CmpCreditCardsDataDB cmpCreditCardsDataDB = new CmpCreditCardsDataDB();



                //               if (cmpCreditCardsDataDB.Insert(tran, -1, pCS_M8_TRANSAX._TRXResponseApproval, pCS_M8_TRANSAX._TRXResponseMaskedPAN, pCS_M8_TRANSAX._TRXResponseCardName,
                //                   "**/**", _quantity, pCS_M8_TRANSAX._TRXResponseBatch, (pCS_M8_TRANSAX._TRXResponseInvoice.Length == 0) ? 0 : Convert.ToUInt32(pCS_M8_TRANSAX._TRXResponseInvoice), pCS_M8_TRANSAX._TRXResponseId,
                //                   "PURCHASE", pCS_M8_TRANSAX._TRXResponseTransStatus, pCS_M8_TRANSAX._TRXResponseISORespCode,
                //                   (pCS_M8_TRANSAX._TRXResponseTransStatus == "AUTHORIZED") ? Msg08.DEF_TRANSAX_AUTHORIZED : Msg08.DEF_TRANSAX_DECLINED) < 0)
                //               {
                //                   RollbackTrans(tran);
                //                   if (logger != null)
                //                       logger.AddLog("[Msg08:Process]:ERROR ON INSERT", LoggerSeverities.Debug);
                //                   return ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS);
                //               }
                //               else
                //               {
                //                   CommitTrans(tran);
                //                   if (logger != null)
                //                       logger.AddLog("[Msg08:Process]: RESULT OK", LoggerSeverities.Debug);
                //               }



                //               logger.AddLog("[Msg08:Process]: Response: " + response, LoggerSeverities.Debug);
                //               ret.Add(new AckMessage(_msgId, response).ToString());

                //           }
                //           else
                //           {
                //               //ret.Add(new AckMessage(_msgId, response).ToString());
                //               ret = ReturnAck(AckMessage.AckTypes.ACK_PROCESSED);

                //           }
                #endregion

                // INFO - Extarido del codigo comentado para que el proceso tenga valor de retorno
                ret = ReturnAck(AckMessage.AckTypes.ACK_PROCESSED);
            }
            catch (Exception e)
            {
                logger.AddLog("[Msg08:Process]: Response: " + response, LoggerSeverities.Error);
                if (logger != null)
                {
                    logger.AddLog("[Msg08:Process]: Error: " + e.Message, LoggerSeverities.Error);
                }
                ret = ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS);
                return(ret);
            }



            return(ret);
        }
        /// <summary>
        /// Inserts a new register in the OPERATIONS table, and if everything is succesful sends an ACK_PROCESSED
        /// </summary>
        /// <returns>Message to send back to the sender</returns>
        public System.Collections.Specialized.StringCollection Process()
        {
            StringCollection ret    = new StringCollection();
            ILogger          logger = null;
            int responseResult      = DEF_CREDIT_CARD_UNDEF;
            int iInfLimit           = DEF_CREDIT_CARD_UNDEF;
            int iSupLimit           = DEF_CREDIT_CARD_UNDEF;
            int iBinInfLimit        = DEF_CREDIT_CARD_UNDEF;
            int iBinSupLimit        = DEF_CREDIT_CARD_UNDEF;

            try
            {
                Database d = OPS.Components.Data.DatabaseFactory.GetDatabase();
                logger = DatabaseFactory.Logger;

                if (_cardType == DEF_CARD_TYPE_CHIP_CARD)
                {
                    if (IsCardInBlackList(logger, _szCCNumber))
                    {
                        responseResult = DEF_CREDIT_CARD_BL;
                    }
                    else
                    {
                        responseResult = DEF_CREDIT_CARD_OK;
                    }
                }
                else if (_cardType == DEF_CARD_TYPE_CREDIT_CARD)
                {
                    if (IsCardInBlackList(logger, _szCCNumber))
                    {
                        responseResult = DEF_CREDIT_CARD_BL;
                    }
                    else
                    {
                        CmpParametersDB cmpParam           = new CmpParametersDB();
                        string          strCheckBines      = cmpParam.GetParameter("P_CHECK_BINES");
                        string          strBinFormat       = cmpParam.GetParameter("P_BIN_FORMAT");
                        string          strMaxMoneyCardDay = cmpParam.GetParameter("P_MAX_MONEY_CARD_DAY");
                        bool            bCheckBines        = true;
                        int             iBinFormat         = DEF_BIN_FORMAT_4B;
                        int             iMaxMoneyCardDay   = DEF_CREDIT_CARD_UNDEF;

                        if (strCheckBines == "")
                        {
                            bCheckBines = true;
                        }
                        else
                        {
                            bCheckBines = (strCheckBines != "0");
                        }


                        if (_binType == -1)
                        {
                            if (strBinFormat != "")
                            {
                                iBinFormat = Convert.ToInt32(strBinFormat);
                            }
                        }
                        else
                        {
                            iBinFormat = _binType;
                        }

                        bCheckBines = (bCheckBines &&
                                       (iBinFormat != DEF_BIN_FORMAT_CARDEASEXML) &&
                                       (iBinFormat != DEF_BIN_FORMAT_EMV_CREDITCALL) &&
                                       (iBinFormat != DEF_BIN_FORMAT_EMV_TAS) &&
                                       (iBinFormat != DEF_BIN_FORMAT_TRANSAX));

                        if (strMaxMoneyCardDay != "")
                        {
                            iMaxMoneyCardDay = Convert.ToInt32(strMaxMoneyCardDay);;
                        }


                        if (ListaNegra(logger, _szCCNumber, iBinFormat))
                        {
                            responseResult = DEF_CREDIT_CARD_BL;
                        }
                        else
                        {
                            if (bCheckBines)
                            {
                                switch (iBinFormat)
                                {
                                case DEF_BIN_FORMAT_LA_CAIXA:

                                    if (!BinesLaCaixa(logger, ref iBinInfLimit, ref iBinSupLimit))
                                    {
                                        responseResult = DEF_CREDIT_CARD_BIN_NOT_FOUND;
                                    }
                                    else
                                    {
                                        responseResult = DEF_CREDIT_CARD_OK;
                                    }
                                    break;

                                case DEF_BIN_FORMAT_4B:
                                default:

                                    if (!Bines4B(logger))
                                    {
                                        responseResult = DEF_CREDIT_CARD_BIN_NOT_FOUND;
                                    }
                                    else
                                    {
                                        responseResult = DEF_CREDIT_CARD_OK;
                                    }

                                    break;
                                }
                            }
                            else if (!bCheckBines)
                            {
                                responseResult = DEF_CREDIT_CARD_OK;
                            }
                        }


                        if (responseResult == DEF_CREDIT_CARD_OK)
                        {
                            if (iMaxMoneyCardDay > 0)
                            {
                                iMaxMoneyCardDay -= SaldoConsumidoHoy(logger);

                                if (iMaxMoneyCardDay < 0)
                                {
                                    iMaxMoneyCardDay = 0;
                                }
                            }

                            iInfLimit = iBinInfLimit;
                            iSupLimit = iBinSupLimit;

                            if (iSupLimit >= 0)
                            {
                                if (iMaxMoneyCardDay >= 0)
                                {
                                    iSupLimit = Math.Min(iSupLimit, iMaxMoneyCardDay);
                                }
                            }
                            else
                            {
                                if (iMaxMoneyCardDay >= 0)
                                {
                                    iSupLimit = iMaxMoneyCardDay;
                                }
                            }

                            if ((iSupLimit >= 0) && (iInfLimit < 0))
                            {
                                iInfLimit = 0;
                            }


                            if ((iSupLimit >= 0) && (iInfLimit >= 0) && (iInfLimit > iSupLimit))
                            {
                                responseResult = DEF_CREDIT_CARD_NO_BALANCE;
                            }
                            else if ((iInfLimit >= 0) && (iSupLimit == 0))
                            {
                                responseResult = DEF_CREDIT_CARD_NO_BALANCE;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (logger != null)
                {
                    logger.AddLog("[Msg07:Process]: Error: " + e.Message, LoggerSeverities.Error);
                }
                ret = ReturnNack(NackMessage.NackTypes.NACK_ERROR_BECS);
                return(ret);
            }



            // Build response
            string response = "<r>" + Convert.ToString(responseResult) + "</r>";

            if (responseResult == DEF_CREDIT_CARD_OK)
            {
                CultureInfo culture = new CultureInfo("", false);
                response += "<q1>" + Convert.ToString(iInfLimit, (IFormatProvider)culture.NumberFormat) + "</q1>";
                response += "<q2>" + Convert.ToString(iSupLimit, (IFormatProvider)culture.NumberFormat) + "</q2>";
            }

            logger.AddLog("[Msg07:Process]: Response: " + response, LoggerSeverities.Debug);
            ret.Add(new AckMessage(_msgId, response).ToString());
            return(ret);
        }