예제 #1
0
        public string Timbrar(string fechai, string fechaf, string cveSede, string IDs = "")
        {
            int ok       = 0;
            int fallidos = 0;

            if (sesion == null)
            {
                sesion = SessionDB.start(Request, Response, false, db);
            }

            string[,] sXML = RegresafacturasaTimbrarXML(fechai, fechaf, IDs);

            using (var client = new srv_mySuiteTest.FactWSFrontSoapClient("FactWSFrontSoap1"))
            {
                string server = ConfigurationManager.AppSettings["serverMySuite"];

                TimbradoMySuiteModel objMySuite = new TimbradoMySuiteModel();
                objMySuite.camp_code = cveSede;
                objMySuite.server    = server;

                for (int i = 0; i <= sXML.Length - 1; i++)
                {
                    try
                    { // debido a que el índice se sale de la matriz
                        if (sXML[i, 0] != null && sXML[i, 1] != null)
                        {
                            if (objMySuite.getDatosTimbradoMySuite())
                            {
                                srv_mySuiteTest.TransactionTag tag = client.RequestTransaction(objMySuite.requestor,
                                                                                               objMySuite.xtransaction,
                                                                                               objMySuite.country,
                                                                                               objMySuite.rfcentity,
                                                                                               objMySuite.user_r,
                                                                                               objMySuite.username,
                                                                                               sXML[i, 1], "PDF XML", "");

                                if (tag.Response.Result)
                                {
                                    var _x = guarda_regreso_timbrado(sXML[i, 0], tag.ResponseData.ResponseData1, tag.ResponseData.ResponseData3, "OK", tag.Response.Identifier.DocumentGUID);
                                    ok = ok + _x;
                                }
                                else
                                {
                                    fallidos++;
                                    guarda_regreso_timbrado_error(sXML[i, 0], tag.Response.Data);
                                }
                            }
                        }
                    }
                    catch { }
                }
            }

            return("Timbrados correctamente " + ok.ToString() + " Timbrados con error " + fallidos.ToString());
        }
예제 #2
0
        public string TimbradoTest(string fechai, string fechaf, string cveSede)
        {
            int ok       = 0;
            int fallidos = 0;

            if (sesion == null)
            {
                sesion = SessionDB.start(Request, Response, false, db);
            }

            string[,] sXML = RegresafacturasaTimbrarXML(fechai, fechaf);

            using (var client = new srv_mySuiteTest.FactWSFrontSoapClient("FactWSFrontSoap1"))
            {
                string server = ConfigurationManager.AppSettings["serverMySuite"];

                TimbradoMySuiteModel objMySuite = new TimbradoMySuiteModel();
                objMySuite.camp_code = cveSede;
                objMySuite.server    = server;

                for (int i = 0; i <= sXML.Length - 1; i++)
                {
                    try
                    { // debido a que el índice se sale de la matriz
                        if (sXML[i, 0] != null && sXML[i, 1] != null)
                        {
                            if (objMySuite.getDatosTimbradoMySuite())
                            {
                                //srv_mySuiteTest.TransactionTag tag = client.RequestTransaction("cb6b2b32-2d5c-4c82-adc0-e1375c95a1a2",
                                //    "CONVERT_NATIVE_XML",
                                //    "MX",
                                //    "AAA010101AAA",
                                //    "cb6b2b32-2d5c-4c82-adc0-e1375c95a1a2",
                                //    "ISCOM",
                                //    sXML[i, 1], "PDF XML", "");
                                srv_mySuiteTest.TransactionTag tag = client.RequestTransaction(objMySuite.requestor,
                                                                                               objMySuite.xtransaction,
                                                                                               objMySuite.country,
                                                                                               objMySuite.rfcentity,
                                                                                               objMySuite.user_r,
                                                                                               objMySuite.username,
                                                                                               sXML[i, 1], "PDF XML", "");

                                if (tag.Response.Result)
                                {
                                    var _x = guarda_regreso_timbrado(sXML[i, 0], tag.ResponseData.ResponseData1, tag.ResponseData.ResponseData3, "OK", tag.Response.Identifier.DocumentGUID);
                                    ok = ok + _x;
                                }
                                else
                                {
                                    fallidos++;
                                    guarda_regreso_timbrado_error(sXML[i, 0], tag.Response.Data);
                                }
                            }
                        }
                    }
                    catch { }
                }
            }

            /*string date_inicio = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
             *
             * for (int i = 0; i <= s.Length -1; i++)
             * {
             *  try
             *  { // debido a que el índice se sale de la matriz
             *      if (s[i, 0] != null && s[i, 1] != null)
             *      {
             *          string respuesta = LlamadaPost(s[i, 1]);
             *          dynamic dynObj = JsonConvert.DeserializeObject(respuesta);
             *
             *          if (dynObj.result.Value)
             *          {
             *              //ok++;
             *              var _x = guarda_regreso_timbrado(s[i, 0], dynObj.xml.Value, dynObj.pdf.Value, respuesta);
             *              ok = ok + _x;
             *          }
             *          else
             *          {
             *              fallidos++;
             *              guarda_regreso_timbrado_error(s[i, 0], dynObj.errormsg.Value);
             *          }
             *      }
             *  }
             *  catch { }
             * }*/

            return("Timbrados correctamente " + ok.ToString() + " Timbrados con error " + fallidos.ToString());

            //string date_fin = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
            //Console.WriteLine("s");
        }