예제 #1
0
        public string Extorno(RequestAnnulment requestAnnulment)
        {
            string json = string.Empty;

            try
            {
                var jsonRequestAnnulment = new JavaScriptSerializer().Serialize(requestAnnulment);
                var conn = new Conexioncs().QueryString;
                using (var cn = new SqlConnection(conn))
                {
                    cn.Open();
                    using (var cmd = new SqlCommand("GET_ANNULMENT", cn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@rqUUID", SqlDbType.VarChar).Value                   = requestAnnulment.rqUUID;
                        cmd.Parameters.Add("@operationDate", SqlDbType.VarChar).Value            = requestAnnulment.operationDate;
                        cmd.Parameters.Add("@operationNumber", SqlDbType.VarChar).Value          = requestAnnulment.operationNumber;
                        cmd.Parameters.Add("@operationNumberAnnulment", SqlDbType.VarChar).Value = requestAnnulment.operationNumberAnnulment;
                        cmd.Parameters.Add("@financialEntity", SqlDbType.VarChar).Value          = requestAnnulment.financialEntity;
                        cmd.Parameters.Add("@customerId", SqlDbType.VarChar).Value               = requestAnnulment.customerId;
                        cmd.Parameters.Add("@channel", SqlDbType.VarChar).Value                  = requestAnnulment.channel;
                        cmd.Parameters.Add("@request", SqlDbType.VarChar).Value                  = jsonRequestAnnulment;
                        SqlDataReader rd = cmd.ExecuteReader();
                        while (rd.Read())
                        {
                            json = rd[0].ToString();
                            json = json.Substring(1, json.Length - 2);
                        }
                    }
                }
                return(json);
            }catch (Exception ex)
            {
                var    dateFormat     = "yyyy-MM-ddTHH:mm:ss";
                string dateOperation  = DateTimeOffset.UtcNow.ToString(dateFormat);
                var    respuestaError = new ErrorResponse();
                respuestaError.rqUUID                   = requestAnnulment.rqUUID;
                respuestaError.resultCode               = "CP0138";
                respuestaError.resultDescription        = "ERROR AL PROCESAR TRANSACCION";
                respuestaError.resultCodeCompany        = "ERROR-21DB";
                respuestaError.resultDescriptionCompany = ex.Message.ToString().ToUpper();
                respuestaError.operationDate            = dateOperation;
                json = new JavaScriptSerializer().Serialize(respuestaError);
                log.Info("Error al ejecutar el llamado del metodo Inquire: " + json);
                return(json);
            }
        }
        public HttpResponseMessage Post(RequestAnnulment requestAnnulment, HttpRequestMessage requestMessage)
        {
            HttpResponseMessage response = null;

            try
            {
                var respuesta = new AnnulmentSQL().Extorno(requestAnnulment);
                response         = Request.CreateResponse(HttpStatusCode.OK);
                response.Content = new StringContent(respuesta, Encoding.UTF8, "application/json");
                return(response);
            }catch (Exception ex)
            {
                var    dateFormat     = "yyyy-MM-ddTHH:mm:ss";
                string dateOperation  = DateTimeOffset.UtcNow.ToString(dateFormat);
                var    request        = new JavaScriptSerializer().Serialize(requestAnnulment);
                var    respuestaError = new ErrorResponse();
                var    rqUUID         = string.Empty;
                if (requestAnnulment != null)
                {
                    if (requestAnnulment.rqUUID != null)
                    {
                        rqUUID = requestAnnulment.rqUUID;
                    }
                }
                respuestaError.rqUUID                   = rqUUID;
                respuestaError.resultCode               = "CP0138";
                respuestaError.resultDescription        = "ERROR AL PROCESAR TRANSACCION";
                respuestaError.resultCodeCompany        = "ERROR-15PROC";
                respuestaError.resultDescriptionCompany = "ERROR EN EL REQUEST";
                respuestaError.operationDate            = dateOperation;
                var respuesta = new JavaScriptSerializer().Serialize(respuestaError);
                log.Info("Error al ejecutar el llamado del metodo Inquire: " + respuesta + "request enviado: " + request + " detalle del error: " + ex.Message.ToString());
                response         = Request.CreateResponse(HttpStatusCode.OK);
                response.Content = new StringContent(respuesta, Encoding.UTF8, "application/json");
                return(response);
            }
        }