public DataSet factura(string encabezado, string detalle, string tipoDoc, string fact_num, string est)
        {
            RespuestaServicio respuesta = new RespuestaServicio();
            string            xml       = "";

            FACT_NUM          = fact_num;
            TIPODOC           = tipoDoc;
            Configuracion.DOC = tipoDoc;
            VFPData    data    = Deserialize <VFPData>(encabezado);
            VFPDataDet dataDet = DeserializeDetail <VFPDataDet>(detalle);

            xml = XML.setXML(data, dataDet, tipoDoc);
            saveXML(xml, fact_num, Configuracion.path);
            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            com.guatefacturas.dte.Guatefac guatefac = new com.guatefacturas.dte.Guatefac();
            guatefac.Credentials     = new NetworkCredential(Configuracion.auth_user, Configuracion.auth_password);
            guatefac.PreAuthenticate = true;

            int    pTipoDoc = setTipoDoc(tipoDoc);
            string s        = guatefac
                              .generaDocumento(
                Configuracion.usuario,
                Configuracion.password,
                Configuracion.nit,
                Int32.Parse(est),
                pTipoDoc,
                Configuracion.maquina, "D", xml);

            return(generateDS(evaluateResponse(s)));
        }
        RespuestaServicio evaluateResponse(string s)
        {
            RespuestaServicio respuestaGuate = new RespuestaServicio();
            Resultado         serialize;
            string            resultado = "";
            var matches = Regex.Matches(s, @"<dte:GTDocumento (.*)<\/dte:GTDocumento>", RegexOptions.Singleline)
                          .Cast <Match>()
                          .Select(m => m.Value)
                          .ToArray();

            if (matches.Length > 0)
            {
                resultado = matches[0];
                // getInfo(resultado);
                GTDocumento gTDocumento = DeserializeDate <GTDocumento>(resultado);
                respuestaGuate.resultado = true;
                respuestaGuate.mensaje   = "Sin errores";
                respuestaGuate.XML       = resultado;
                respuestaGuate.UUUI      = gTDocumento.SAT.DTE.Certificacion.NumeroAutorizacion.Text;
                respuestaGuate.fecha     = gTDocumento.SAT.DTE.Certificacion.FechaHoraCertificacion;
            }
            else
            {
                ///    serialize = DeserializeResponse<Resultado>(s);
                respuestaGuate.resultado = false;
                respuestaGuate.mensaje   = s;
                if (respuestaGuate.mensaje == null)
                {
                    respuestaGuate.mensaje = s;
                }
            }
            return(respuestaGuate);
        }
Example #3
0
        RespuestaServicio evaluateResponse(string s)
        {
            RespuestaServicio respuestaGuate = new RespuestaServicio();
            string            resultado      = "";
            var matches = Regex.Matches(s, @"<ESTADO>(.*)<\/ESTADO>", RegexOptions.Singleline)
                          .Cast <Match>()
                          .Select(m => m.Value)
                          .ToArray();

            if (matches.Length > 0)
            {
                resultado = matches[0];
                // getInfo(resultado);
                GTDocumento gTDocumento = null;// DeserializeDate<GTDocumento>(resultado);
                respuestaGuate.resultado = true;
                respuestaGuate.mensaje   = matches[0];
            }
            else
            {
                respuestaGuate.resultado = false;
                respuestaGuate.mensaje   = s;
                if (respuestaGuate.mensaje == null)
                {
                    respuestaGuate.mensaje = s;
                }
            }
            return(respuestaGuate);
        }
Example #4
0
        private DataSet generateDS(RespuestaServicio respuestaServicio)
        {
            DataSet   DSdetalle = new DataSet();
            DataTable dt        = new DataTable("resultado");

            dt.Columns.Add(new DataColumn("resultado", typeof(string)));
            dt.Columns.Add(new DataColumn("mensaje", typeof(string)));
            DataRow dr = dt.NewRow();

            dr["resultado"] = respuestaServicio.resultado; //.resultado;
            dr["mensaje"]   = respuestaServicio.mensaje;   //.mensaje;
            dt.Rows.Add(dr);
            DSdetalle.Tables.Add(dt);

            return(DSdetalle);
        }
        RespuestaServicio getInfo(string xml)
        {
            string            pattern   = @"<dte:FechaHoraCertificacion>(.*)<\/dte:FechaHoraCertificacion>";
            RespuestaServicio respuesta = new RespuestaServicio();

            string[] matches = checkRegex(xml, pattern);

            if (matches.Length > 0)
            {
                // FechaHora fechaHora = DeserializeDate<FechaHora>(matches[0]);
            }

            respuesta.resultado = true;
            respuesta.XML       = xml;
            string fecha = matches[0];

            return(respuesta);
        }
        private DataSet generateDS(RespuestaServicio respuestaServicio)
        {
            DataSet   DSdetalle = new DataSet();
            DataTable dt        = new DataTable("resultado");

            dt.Columns.Add(new DataColumn("resultado", typeof(string)));
            dt.Columns.Add(new DataColumn("mensaje", typeof(string)));
            dt.Columns.Add(new DataColumn("xml", typeof(string)));
            dt.Columns.Add(new DataColumn("uuui", typeof(string)));
            dt.Columns.Add(new DataColumn("fecha", typeof(string)));
            DataRow dr = dt.NewRow();

            dr["resultado"] = respuestaServicio.resultado;
            dr["mensaje"]   = respuestaServicio.mensaje;
            dr["xml"]       = respuestaServicio.XML;
            dr["uuui"]      = respuestaServicio.UUUI;
            dr["fecha"]     = respuestaServicio.fecha;
            dt.Rows.Add(dr);
            DSdetalle.Tables.Add(dt);

            saveXML(respuestaServicio.XML, TIPODOC + FACT_NUM, Configuracion.pathRes);

            return(DSdetalle);
        }