예제 #1
0
        private void button20_Click(object sender, EventArgs e)
        {
            LocalDataBase l = new LocalDataBase();

            l.addCollumnToReenvio();
        }
예제 #2
0
        public string sendInvoice(Documento doc, String pdfTfileName, String pdfCfileName, String filename, String fileCliente, String fileFactura, String conEnv)
        {
            try
            {
                string HtmlResult = String.Empty;
                string postUri    = string.Format("{0}{1}/invoice.json",
                                                  //server,
                                                  cdb.GetUrl().ToString(),
                                                  version);

                MemoryStream stream           = new MemoryStream();
                DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(Documento));
                ds.WriteObject(stream, doc);
                string jsonString = Encoding.UTF8.GetString(stream.ToArray());
                stream.Close();

                String json = jsonString.Replace("null", "\"\"");
                json = json.Replace("\":", ":");
                json = json.Replace(",\"", ",");
                json = json.Replace("{\"", "{");
                json = json.Replace("detalle", "detalles_attributes");
                json = json.Replace("Referencia", "ref_detalles_attributes");
                json = json.Replace("comisiones", "comisions_attributes");
                json = json.Replace("dscRcgGlobal", "dsc_rcg_globals_attributes");
                json = json.Replace("imptoReten", "impuesto_retens_attributes");
                json = json.Replace("mntpagos", "monto_pagos_attributes");



                if (json.IndexOf("detalles_attributes:\"\"") != -1)
                {
                    json = json.Replace("detalles_attributes:\"\"", "detalles_attributes:[]");
                }
                if (json.IndexOf("ref_detalles_attributes:\"\"") != -1)
                {
                    json = json.Replace("ref_detalles_attributes:\"\"", "ref_detalles_attributes:[]");
                }
                if (json.IndexOf("comisions_attributes:\"\"") != -1)
                {
                    json = json.Replace("comisions_attributes:\"\"", "comisions_attributes:[{}]");
                }
                if (json.IndexOf("dsc_rcg_globals_attributes:\"\"") != -1)
                {
                    json = json.Replace("dsc_rcg_globals_attributes:\"\"", "dsc_rcg_globals_attributes:[]");
                }
                if (json.IndexOf("impuesto_retens_attributes:\"\"") != -1)
                {
                    json = json.Replace("impuesto_retens_attributes:\"\"", "impuesto_retens_attributes:[]");
                }
                if (json.IndexOf("monto_pagos_attributes:\"\"") != -1)
                {
                    json = json.Replace("monto_pagos_attributes:\"\"", "monto_pagos_attributes:[]");
                }


                return(sendToServer(doc.Folio, fileCliente, fileFactura, doc.fileName, filename, json, pdfTfileName, pdfCfileName, conEnv));
            }
            catch (Exception err)
            {
                Log        log  = new Log();
                ReenvioSql renv = new ReenvioSql();
                log.addLog("ERROR envio al Core TipoDTE :" + doc.TipoDTE + " Folio :" + doc.Folio, "ERROR");
                //si no existen las columnas de fileCliente y FileFactura las crea
                LocalDataBase ldb = new LocalDataBase();
                ldb.addCollumnToReenvio();

                renv.addReenvio(doc.fileName, filename, pdfTfileName, pdfCfileName, fileCliente, fileFactura);

                Console.WriteLine(err);
                return(err.Message);
            }
        }