Пример #1
0
        public AnulacionOS Anular(Anular model)
        {
            var anulacionOs = new AnulacionOS();

            try
            {
                var authRepo      = new AutorizacionRepository();
                var sIdInternoAut = authRepo.GetIdAuth(model.AuthId);

                var output = "MSH|^~\\&|TRIA0100M|TRIA00007160|MEDIFE|MEDIFE^222222^IIN|";
                output += DateTime.Now.ToString("yyyyMMddHHmmss") + "||ZQA^Z04^ZQA_Z02|10121509341187324160|P|2.4|||NE|AL|ARG";
                output += Environment.NewLine;
                output += "ZAU||" + sIdInternoAut;
                output += Environment.NewLine;
                output += "PRD|PS^CIRCULO MEDICO DE SALTA||^^^C||||30543364610^CU|";
                output += Environment.NewLine;
                output += "PID|||" + model.Credencial + "^^^MEDIFE^HC^MEDIFE||UNKNOWN";

                var resultado = _traditum.Send(output);
                logResult(output.ToString(), resultado.ToString(), "D");

                if (resultado.Substring(0, 4) == "MSH|")
                {
                    return(SetAnulacionOs(resultado, model));
                }
                anulacionOs.SetError(GetType().Name, 0, resultado, string.Empty, model, string.Empty);
            }
            catch (Exception ex)
            {
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), Mensajes.Get("AnulFail"), ex.InnerException?.ToString() ?? "", model, string.Empty);
            }
            return(anulacionOs);
        }
Пример #2
0
        public AnulacionOS Anular(Anular model)
        {
            var anulacionOs = new AnulacionOS();

            try
            {
                var authRepo      = new AutorizacionRepository();
                var sIdInternoAut = authRepo.GetIdAuth(model.AuthId);

                var output = "MSH|^~\\&|TRIA0100M|TRIA00000003|SANCOR_SALUD|SANCOR_SALUD^604940^IIN|";
                output += DateTime.Now.ToString("yyyyMMddHHmmss") + "||ZQA^Z04^ZQA_Z04|18071613545151234567890|P|2.4|||NE|AL|ARG";
                output += Environment.NewLine;
                output += "ZAU||" + sIdInternoAut;
                output += Environment.NewLine;
                output += "PRD|PS^CIRCULO MEDICO DE SALTA||^^^C||||96065^PR|";


                output += Environment.NewLine;
                output += "PID|||" + model.Credencial + "^^^SANCOR_SALUD^HC^SANCOR_SALUD||UNKNOWN";

                Sancor.MessageResponse resultado = _sancor.MessageAsync(8, output).Result;
                logResult(output.ToString(), resultado.ToString(), "D");

                if (resultado.resultado.Substring(0, 4) == "MSH|")
                {
                    return(SetAnulacionOs(resultado.ToString(), model));
                }
                anulacionOs.SetError(GetType().Name, 0, resultado.resultado.ToString(), string.Empty, model, string.Empty);
            }
            catch (Exception ex)
            {
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? "", model, string.Empty);
            }
            return(anulacionOs);
        }
Пример #3
0
        public AnulacionOS Anular(Anular model)
        {
            var anulacionOs = new AnulacionOS();

            try
            {
                var authRepo      = new AutorizacionRepository();
                var sIdInternoAut = authRepo.GetIdAuth(model.AuthId);

                var output = new StringBuilder();
                using (var writer = XmlWriter.Create(output))
                {
                    writer.WriteStartElement("Mensaje");
                    writer.WriteStartElement("EncabezadoMensaje");
                    writer.WriteElementString("VersionMsj", "ACT20");
                    writer.WriteElementString("NroReferenciaCancel", sIdInternoAut);
                    writer.WriteElementString("TipoMsj", "OL");
                    writer.WriteElementString("TipoTransaccion", "04A");
                    writer.WriteStartElement("InicioTrx");
                    writer.WriteElementString("FechaTrx", DateTime.Now.ToString("yyyyMMdd"));
                    writer.WriteEndElement();
                    writer.WriteStartElement("Terminal");
                    writer.WriteElementString("TipoTerminal", "PC");
                    writer.WriteElementString("NumeroTerminal", "60000001");
                    writer.WriteEndElement();
                    writer.WriteStartElement("Financiador");
                    writer.WriteElementString("CodigoFinanciador", "PATCAB");
                    writer.WriteEndElement();
                    writer.WriteStartElement("Prestador");
                    writer.WriteElementString("CuitPrestador", "30543364610");
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }

                var resultado = service.ExecuteFileTransactionSLAsync("0000", output.ToString()).Result;
                logResult(output.ToString(), resultado.ToString(), "A");

                if (resultado != "")
                {
                    return(SetAnulacionOs(resultado, model));
                }

                anulacionOs.SetError(GetType().Name, 0, Mensajes.Get("AnulFail"), string.Empty, model, string.Empty);
            }
            catch (Exception ex)
            {
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? string.Empty, model, string.Empty);
            }

            return(anulacionOs);
        }
Пример #4
0
        public AnulacionOS Anular(Anular model)
        {
            const string url         = "http://ws1.rsmprestadores.com/anular.php?cuit=30-54336461-0&clave=4610&numorden=";
            var          anulacionOs = new AnulacionOS();

            try
            {
                var authRepo      = new AutorizacionRepository();
                var sIdInternoAut = authRepo.GetIdAuth(model.AuthId);
                var request       = WebRequest.Create(url + sIdInternoAut);
                var response      = request.GetResponse();
                var dataStream    = response.GetResponseStream();
                var reader        = new StreamReader(dataStream);
                var resultado     = reader.ReadToEnd();
                reader.Close();
                response.Close();

                logResult(request.ToString(), resultado.ToString(), "D");

                if (resultado.Substring(0, 3) == "ERR")
                {
                    anulacionOs.SetError(GetType().Name, 0, resultado, string.Empty, model, string.Empty);
                }
                else
                {
                    anulacionOs = new AnulacionOS
                    {
                        IdAuth       = model.AuthId.ToString(),
                        Nestado      = "1",
                        Fecha        = DateTime.Now.ToString(),
                        CodAnulacion = model.AuthId.ToString(),
                        Estado       = "Ok"
                    };
                }
            }
            catch (Exception ex)
            {
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), Mensajes.Get("AnulFail"), ex.InnerException?.ToString() ?? "", model, string.Empty);
            }
            return(anulacionOs);
        }
Пример #5
0
        public AnulacionOS Anular(Anular model)
        {
            try
            {
                var authRepo      = new AutorizacionRepository();
                var sIdInternoAut = authRepo.GetIdAuth(model.AuthId);

                //armado del xml de solicitud
                var output = new StringBuilder();
                using (var writer = XmlWriter.Create(output))
                {
                    writer.WriteStartElement("BOREAL");
                    writer.WriteStartElement("Mensaje");
                    writer.WriteElementString("Canal", "ID");
                    writer.WriteElementString("SitioEmisor", "CMSws");
                    writer.WriteElementString("Empresa", "BOREAL");
                    writer.WriteStartElement("Receptor");
                    writer.WriteElementString("Nombre", "BOREAL");
                    writer.WriteElementString("ID", "222023");
                    writer.WriteElementString("Tipo", "IIN");
                    writer.WriteEndElement();
                    writer.WriteStartElement("MsgTipo");
                    writer.WriteElementString("Tipo", "ZQA");
                    writer.WriteElementString("Evento", "Z04");
                    writer.WriteElementString("Estructura", "ZQA_Z02");
                    writer.WriteEndElement();
                    writer.WriteElementString("MsgEntorno", "P");
                    writer.WriteEndElement();
                    writer.WriteStartElement("Seguridad");
                    writer.WriteElementString("Usuario", "cmsws");
                    writer.WriteElementString("Clave", _clave);
                    writer.WriteEndElement();
                    writer.WriteStartElement("Prestador");
                    writer.WriteElementString("PrestadorId", "30543364610");
                    writer.WriteElementString("PrestadorNombre", "");
                    writer.WriteElementString("PrestadorTipoIdent", "CU");
                    writer.WriteEndElement();
                    writer.WriteStartElement("Autorizacion");
                    writer.WriteElementString("AutCod", "");
                    writer.WriteElementString("AutEstadoId", "");
                    writer.WriteElementString("AutObs", "");
                    writer.WriteElementString("AutCodAnulacion", sIdInternoAut);
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }

                var mensajexml = output.ToString();
                mensajexml = mensajexml.Replace(" />", "/>");

                try
                {
                    var resultado = _objBoreal.ExecuteAsync(HttpUtility.HtmlDecode(mensajexml)).Result;
                    logResult(mensajexml, resultado.Egresoxml, "A");

                    return(SetAnulacionOs(resultado.ToString(), model));

                    //Todo: Si vuelve Vacio error, ver como tratar
                }
                catch (Exception ex)
                {
                    var anulacionOs = new AnulacionOS();
                    anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), Mensajes.Get("AnulFail"), ex.InnerException?.ToString() ?? "", model, string.Empty);
                    return(anulacionOs);
                }
            }
            catch (Exception ex)
            {
                var anulacionOs = new AnulacionOS();
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? "", model, string.Empty);
                return(anulacionOs);
            }
        }
Пример #6
0
        public async Task <AnulacionOS> AnularAsync(Anular model)
        {
            var    anulacionOs = new AnulacionOS();
            string resultado;

            try
            {
                var authRepo      = new AutorizacionRepository();
                var sIdInternoAut = authRepo.GetIdAuth(model.AuthId);

                var output = new StringBuilder();
                using (var writer = XmlWriter.Create(output))
                {
                    writer.WriteStartElement("SOLICITUD");

                    writer.WriteStartElement("EMISOR");
                    writer.WriteElementString("ID", "00001-22222");
                    writer.WriteElementString("PROT", "CA_V20");
                    writer.WriteElementString("MSGID", DateTime.Now.ToString("yyyyMMdd") + model.Matricula);//completar
                    writer.WriteElementString("TER", "");
                    writer.WriteElementString("APP", "HMS_CAWEB");
                    writer.WriteElementString("TIME", DateTime.Now.ToString());
                    writer.WriteEndElement();

                    writer.WriteStartElement("SEGURIDAD");
                    writer.WriteElementString("TIPOAUT", "U");
                    writer.WriteElementString("USRID", "7040521");
                    writer.WriteElementString("USRPASS", "DAT_MGR");
                    writer.WriteEndElement();

                    writer.WriteStartElement("OPER");
                    writer.WriteElementString("TIPO", "ATR");
                    writer.WriteElementString("FECHA", DateTime.Now.ToString("yyyy-MM-dd"));
                    writer.WriteElementString("IDASEG", "ACA_SALUD");
                    writer.WriteElementString("IDPRESTADOR", "7040521");
                    writer.WriteElementString("TIPOIDANUL", "IDTRAN");
                    writer.WriteElementString("IDANUL", sIdInternoAut);
                    writer.WriteEndElement();

                    writer.WriteStartElement("PID");
                    writer.WriteElementString("TIPOID", "CODIGO_AFI");
                    writer.WriteElementString("ID", model.Credencial);
                    writer.WriteEndElement();
                }

                using (var client = new HttpClient())
                {
                    var url = urlBase + HttpUtility.UrlEncode(output.ToString());
                    client.BaseAddress = new Uri(url);
                    client.DefaultRequestHeaders.Accept.Clear();

                    Task <HttpResponseMessage> response = client.GetAsync(url);
                    resultado = await response.Result.Content.ReadAsStringAsync();

                    resultado = HttpUtility.HtmlDecode(resultado);
                }

                logResult(output.ToString(), resultado, "D");

                if (resultado != "")
                {
                    return(SetAnulacionOs(resultado, model));
                }

                anulacionOs.SetError(GetType().Name, 0, Mensajes.Get("AnulFail"), string.Empty, model, string.Empty);
            }
            catch (Exception ex)
            {
                anulacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? string.Empty, model, string.Empty);
            }

            return(anulacionOs);
        }