Exemplo n.º 1
0
        public void generarInfoDian(string factura, int oficina, int transaccion)
        {
            BuildCommands select = new BuildCommands();

            _vgp._TargetFile._Archivo = "pdbinfodian.txt";
            _vgp._ClienteID           = "pdbInfoDian";
            //string tipodoc = string.Empty;
            switch (transaccion)
            {
            case 1:
            {
                try
                {
                    _vgp._IcpdbInfoDian.tipodocumento            = "FC";
                    _vgp._IcpdbInfoDian.tipoDocumentoDescriptivo = "FACTURA";
                    OracleData _datos = new OracleData(_vgp);
                    _datos.execute((select.procedimientoInfoDianFactura(factura, oficina, _vgp._IcpdbInfoDian.tipodocumento, "I")), _vgp);
                }
                catch (Exception ex)
                {
                    string lo = ex.Message;
                }
                break;
            }

            case 2:
            {
                _vgp._IcpdbInfoDian.tipodocumento            = "NC";
                _vgp._IcpdbInfoDian.tipoDocumentoDescriptivo = "NOTA CREDITO";
                OracleData _datos = new OracleData(_vgp);
                _datos.execute((select.procedimientoInfoDianNota(factura, oficina, _vgp._IcpdbInfoDian.tipodocumento, "I")), _vgp);
                break;
            }

            case 3:
            {
                _vgp._IcpdbInfoDian.tipodocumento            = "ND";
                _vgp._IcpdbInfoDian.tipoDocumentoDescriptivo = "NOTA DEBITO";
                OracleData _datos = new OracleData(_vgp);
                _datos.execute((select.procedimientoInfoDianNota(factura, oficina, _vgp._IcpdbInfoDian.tipodocumento, "I")), _vgp);
                break;
            }

            default:
            {
                string _default = "El metodo caFEtysVS02_pdbInfoDian_generarInfoDian contiene un caso sin catalogar \r\n Informacion de parametro Nombre : transaccion Valor : " + transaccion;
                _log = new Registro.Registro();
                _log.wr(_vgp._Directorio, "Default.txt", _default);
                Correo.Correo _correo = new Correo.Correo(_vgp);
                _correo.envioCorreoDesarrollador("El metodo caFEtysVS02_pdbInfoDian_generarInfoDian contiene un caso sin catalogar", "El metodo caFEtysVS02_pdbInfoDian_generarInfoDian contiene un caso sin catalogar \r\n Parametros  factura : " + factura + "\r\n oficina : " + oficina + "\r\n transaccion: " + transaccion, _vgp);
                break;
            }
            }
        }
Exemplo n.º 2
0
        public string getHttpWebXml(string HttpWebResponseXml, string nombreArchivo, XmlDocument xmlDocumentResponse)
        {
            while (true)
            {
                using (XmlReader reader = XmlReader.Create(nombreArchivo))
                {
                    while (reader.Read())
                    {
                        // Only detect start elements.
                        if (reader.IsStartElement())
                        {
                            // Get element name and switch on it.
                            switch (reader.Name)
                            {
                            case "status":
                                Console.Write("<status>");
                                if (reader.Read())
                                {
                                    Console.WriteLine("  Valor : " + reader.Value.Trim());
                                    _vgp._HttpWebRequestFunction._status = reader.Value.Trim();
                                }
                                break;

                            case "transactionId":
                                Console.Write("<transactionId>");
                                if (reader.Read())
                                {
                                    Console.WriteLine("  Valor : " + reader.Value.Trim());
                                    _vgp._HttpWebRequestFunction._transactionId = reader.Value.Trim();
                                }
                                break;

                            default:
                                Console.WriteLine(reader.Name);
                                break;
                            }
                        }
                    }
                }
                break;
            }

            if (_vgp._HttpWebRequestFunction._status == "Archivo recibido con exito.")
            {
                if (_vgp._HttpWebRequestFunction._transactionId.Length > 12)
                {
                    actualizarlogReporteDian("E", HttpWebResponseXml);
                    _log.wr(_vgp._Directorio + "\\" + _vgp._LogReporteDian.LODI_LLAVE_V2 + "\\", _vgp._LogReporteDian.LODI_LLAVE_V2 + "_id.txt", _vgp._HttpWebRequestFunction._transactionId);
                }
            }

            /*if (HttpWebResponseXml.Contains("Error en el servidor remoto: (500) Error interno del servidor."))
             * {
             *  actualizarlogReporteDian("Z", HttpWebResponseXml);
             * }
             * else
             * {
             *  try
             *  {
             *      XmlDocument soapReturn = CreateSoapEnvelopeCarvajal(HttpWebResponseXml);
             *      XmlNodeList elemListstatus = soapReturn.GetElementsByTagName("status");
             *      _vgp.httpwebrequestFunction._status = elemListstatus[0].InnerXml.ToString();
             *      XmlNodeList elemListtransactionId = soapReturn.GetElementsByTagName("transactionId");
             *      _vgp.httpwebrequestFunction._transactionId = elemListtransactionId[0].InnerXml.ToString();
             *      if (_vgp.httpwebrequestFunction._status.Contains("Archivo recibido con exito"))
             *      {
             *          actualizarlogReporteDian("E", HttpWebResponseXml);
             *          _log.wr(_vgp.directorio + "\\" + _vgp.logreportedian.LODI_LLAVE_V2 + "\\", _vgp.logreportedian.LODI_LLAVE_V2 + "_id.txt", _vgp.httpwebrequestFunction._transactionId);
             *      }
             *      else
             *      {
             *          _log.wr(_vgp.directorio + "\\" + _vgp.logreportedian.LODI_LLAVE_V2 + "\\", _vgp.logreportedian.LODI_LLAVE_V2 + "_error.txt", HttpWebResponseXml);
             *      }
             *  }
             *  catch (Exception ex)
             *  {
             *      string _mensajeError = @"Exception : " + ex.Source + "\nData source: " + ex.Message + "\nInnerException: " + ex.InnerException +
             *                            "Procedimiento : caFEtysVS02_logicaProceso_public async void inicio()" + "\r\nSOAP : \r\n" + HttpWebResponseXml;
             *      _log.wr(_vgp.directorio, "Exception.txt", _mensajeError);
             *      ccorreo _correo = new ccorreo(_vgp);
             *      _correo.envioCorreoDesarrollador(ex.Message, _mensajeError, _vgp);
             *  }
             * }*/
            return(_vgp._HttpWebRequestFunction._transactionId);
        }
Exemplo n.º 3
0
        public void Inicio(string nfactura)
        {
            _vgp            = new Vgp();
            _log            = new Registro.Registro();
            _datos          = new OracleData(_vgp);
            _select         = new BuildCommands();
            _cronometro     = new Stopwatch();
            _correo         = new Correo.Correo(_vgp);
            _vgp._ClienteID = "FacElcV2_logicaProceso_inicio";
            DataTable dtlogReporteDian = new DataTable();

            string[] _nParametros;
            object[] _vParametros;
            _nParametros = new string[1] {
                ":LODI_ESTADO"
            };
            _vParametros = new object[1] {
                "P"
            };
            dtlogReporteDian = _datos.daDataTable(_select.logReporteDian(), _nParametros, _vParametros, _vgp);
            if (dtlogReporteDian.Rows.Count > 0)
            {
                try
                {
                    _vgp._LogReporteDian.totalFacturasPendientes = dtlogReporteDian.Rows.Count;
                    _log.msg("Facturas pendientes por procesar : " + _vgp._LogReporteDian.totalFacturasPendientes);
                    foreach (DataRow drFacturas in dtlogReporteDian.Rows)
                    {
                        _cronometro.Start();
                        inicializarVariablesLogReporteDian();
                        #region informacion log_reporte_dian
                        try
                        {
                            _vgp._LogReporteDian.LODI_SECUENCIA_NB = long.Parse(drFacturas[0].ToString());
                        }
                        catch (Exception ex)
                        {
                            _cronometro.Stop();
                            string _mensajeError = @"Exception : " + ex.Source + "\nData source: " + ex.Message + "\nInnerException: " + ex.InnerException +
                                                   "Procedimiento : caFEtysVS02_logicaProceso_public async void inicio() " +
                                                   "instruccion : _vgp._LogReporteDian.LODI_SECUENCIA_NB = long.Parse(drFacturas[0].ToString());" + "\r\nTiempo de proceso : " + _cronometro.Elapsed;
                            _log.wr(_vgp._Directorio, "Exception.txt", _mensajeError);
                            _correo.envioCorreoDesarrollador(ex.Message, _mensajeError, _vgp);
                        }
                        try
                        {
                            _vgp._LogReporteDian.LODI_OFICINA_NB = int.Parse(drFacturas[1].ToString());
                        }
                        catch (Exception ex)
                        {
                            _cronometro.Stop();
                            string _mensajeError = @"Exception : " + ex.Source + "\nData source: " + ex.Message + "\nInnerException: " + ex.InnerException +
                                                   "Procedimiento : caFEtysVS02_logicaProceso_public async void inicio() " +
                                                   "instruccion : _vgp._LogReporteDian.LODI_OFICINA_NB = int.Parse(drFacturas[1].ToString());" + "\r\nTiempo de proceso : " + _cronometro.Elapsed;
                            _log.wr(_vgp._Directorio, "Exception.txt", _mensajeError);
                            _correo.envioCorreoDesarrollador(ex.Message, _mensajeError, _vgp);
                        }
                        try
                        {
                            _vgp._LogReporteDian.LODI_TRANSACCION_NB = int.Parse(drFacturas[2].ToString());
                        }
                        catch (Exception ex)
                        {
                            _cronometro.Stop();
                            string _mensajeError = @"Exception : " + ex.Source + "\nData source: " + ex.Message + "\nInnerException: " + ex.InnerException +
                                                   "Procedimiento : caFEtysVS02_logicaProceso_public async void inicio() " +
                                                   "instruccion : _vgp._LogReporteDian.LODI_TRANSACCION_NB = int.Parse(drFacturas[2].ToString());" + "\r\nTiempo de proceso : " + _cronometro.Elapsed;
                            _log.wr(_vgp._Directorio, "Exception.txt", _mensajeError);
                            _correo.envioCorreoDesarrollador(ex.Message, _mensajeError, _vgp);
                        }
                        _vgp._LogReporteDian.LODI_LLAVE_V2 = drFacturas[3].ToString();
                        //consecutivo++;
                        //_newconsecutivo = "PRUE98000" + consecutivo.ToString();
                        _newconsecutivo = nfactura;//"SETT3";

                        try
                        {
                            _vgp._LogReporteDian.LODI_FECREGISTRO_DT = DateTime.Parse(drFacturas[4].ToString());
                        }
                        catch (Exception ex)
                        {
                            _cronometro.Stop();
                            string _mensajeError = @"Exception : " + ex.Source + "\nData source: " + ex.Message + "\nInnerException: " + ex.InnerException +
                                                   "Procedimiento : caFEtysVS02_logicaProceso_public async void inicio() " +
                                                   "instruccion : _vgp._LogReporteDian.LODI_FECREGISTRO_DT = DateTime.Parse(drFacturas[4].ToString());" + "\r\nTiempo de proceso : " + _cronometro.Elapsed;
                            _log.wr(_vgp._Directorio, "Exception.txt", _mensajeError);
                            _correo.envioCorreoDesarrollador(ex.Message, _mensajeError, _vgp);
                        }
                        _vgp._LogReporteDian.LODI_ESTADO_V2 = drFacturas[5].ToString();
                        try
                        {
                            _vgp._LogReporteDian.LODI_CAMPO1_NB = int.Parse(drFacturas[6].ToString());
                        }
                        catch (Exception ex)
                        {
                            _cronometro.Stop();
                            string _mensajeError = @"Exception : " + ex.Source + "\nData source: " + ex.Message + "\nInnerException: " + ex.InnerException +
                                                   "Procedimiento : caFEtysVS02_logicaProceso_public async void inicio() " +
                                                   "instruccion : _vgp._LogReporteDian.LODI_CAMPO1_NB = int.Parse(drFacturas[6].ToString());" + "\r\nTiempo de proceso : " + _cronometro.Elapsed;
                            //_log.wr(_vgp._Directorio, "Exception.txt", _mensajeError);
                            //_correo.envioCorreoDesarrollador(ex.Message, _mensajeError, _vgp);
                        }
                        _vgp._LogReporteDian.LODI_CAMPO2_V2 = drFacturas[7].ToString();
                        try
                        {
                            _vgp._LogReporteDian.LODI_CAMPO3_DT = DateTime.Parse(drFacturas[8].ToString());
                        }
                        catch (Exception ex)
                        {
                            _cronometro.Stop();
                            string _mensajeError = @"Exception : " + ex.Source + "\nData source: " + ex.Message + "\nInnerException: " + ex.InnerException +
                                                   "Procedimiento : caFEtysVS02_logicaProceso_public async void inicio() " +
                                                   "instruccion : _vgp._LogReporteDian.LODI_CAMPO1_NB = int.Parse(drFacturas[6].ToString());" + "\r\nTiempo de proceso : " + _cronometro.Elapsed;
                            //_log.wr(_vgp._Directorio, "Exception.txt", _mensajeError);
                            //_correo.envioCorreoDesarrollador(ex.Message, _mensajeError, _vgp);
                        }
                        _vgp._LogReporteDian.LODI_ESTADODIAN_V2 = drFacturas[9].ToString();
                        #endregion fin informacion log_reporte_dian

                        _log.msg("Secuencia : " + _vgp._LogReporteDian.LODI_SECUENCIA_NB + "  Oficina : " + _vgp._LogReporteDian.LODI_OFICINA_NB + "  Llave : " + _vgp._LogReporteDian.LODI_LLAVE_V2 + "  Fecha : " + _vgp._LogReporteDian.LODI_FECREGISTRO_DT);
                        if (_vgp._LogReporteDian.LODI_LLAVE_V2 == "EVVC653")
                        {
                            procesarFacturaAsync();
                        }
                        //procesarFacturaAsync();
                        _vgp._FacturasProcesadas += 1;
                        _cronometro.Stop();
                        _log.msg("Factura procesada : " + _vgp._LogReporteDian.LODI_LLAVE_V2 + "\r\nTiempo de proceso : " + _cronometro.Elapsed + "\r\n Facturas Procesadas : " + _vgp._FacturasProcesadas + "     Facturas Restantes : " + " " + (_vgp._LogReporteDian.totalFacturasPendientes - _vgp._FacturasProcesadas).ToString());
                        _cronometro.Reset();
                    }
                }
                catch (Exception ex)
                {
                    _cronometro.Stop();
                    string _mensajeError = @"Exception : " + ex.Source + "\nData source: " + ex.Message + "\nInnerException: " + ex.InnerException +
                                           "Procedimiento : caFEtysVS02_logicaProceso_public async void inicio() \r\nTiempo de proceso : " + _cronometro.Elapsed;
                    _log.wr(_vgp._Directorio, "Exception.txt", _mensajeError);
                    _correo.envioCorreoDesarrollador(ex.Message, _mensajeError, _vgp);
                }
            }
            else
            {
                _log.wr(_vgp._TargetFile._Directorio, _vgp._TargetFile._Archivo, "No hay facturas para procesar.");
            }
        }