private void BandejaEDataGridView_DoubleClick(object sender, EventArgs e) { if (BandejaEDataGridView.SelectedRows.Count != 0) { eFact_RN.IBKP.error[] respErroresComprobantes = new eFact_RN.IBKP.error[0]; FeaEntidades.InterFacturas.comprobante cIBK = new FeaEntidades.InterFacturas.comprobante(); eFact_RN.IBKP.consulta_detalle_comprobante cdc = new eFact_RN.IBKP.consulta_detalle_comprobante(); try { cdc.cod_interno_canal = ""; cdc.cuit_canal = Convert.ToInt64(@System.Configuration.ConfigurationManager.AppSettings["CuitCanal"]); cdc.cuit_vendedor = Convert.ToInt64(BandejaEDataGridView.Rows[BandejaEDataGridView.SelectedRows[0].Index].Cells["cuit_vendedor"].Value.ToString()); cdc.punto_de_venta = Convert.ToInt32(BandejaEDataGridView.Rows[BandejaEDataGridView.SelectedRows[0].Index].Cells["punto_de_venta"].Value.ToString()); cdc.numero_comprobante = Convert.ToInt32(BandejaEDataGridView.Rows[BandejaEDataGridView.SelectedRows[0].Index].Cells["numero_comprobante"].Value.ToString()); cdc.tipo_de_comprobante = Convert.ToInt32(BandejaEDataGridView.Rows[BandejaEDataGridView.SelectedRows[0].Index].Cells["tipo_de_comprobante"].Value.ToString()); cdc.tipo_doc_comprador = Convert.ToInt32("80"); cdc.doc_comprador = Convert.ToInt64(CuitCompradorTextBox.Text); cdc.usuario_consulta = Aplicacion.Sesion.Usuario.IdUsuario; eFact_RN.Comprobante cc = new eFact_RN.Comprobante(); cIBK = cc.ConsultarIBKP(cdc, "012f0775357c"); //lcIBK = eFact_RNComprobante.ConsultarIBK(out respErroresLote, out respErroresComprobantes, clc, WSCertificado); //RespErroresLote = respErroresLote; //RespErroresComprobantes = respErroresComprobantes; } catch (Exception ex) { //RespErroresLote = respErroresLote; //RespErroresComprobantes = respErroresComprobantes; Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex); } } }
private void EnviarAIF() { try { Cursor=System.Windows.Forms.Cursors.WaitCursor; EventosComboBox.Enabled = false; if (BandejaSDataGridView.SelectedRows.Count != 0) { eFact_Entidades.Lote l = new eFact_Entidades.Lote(); List<eFact_Entidades.Lote> llotes = new List<eFact_Entidades.Lote>(); for (int i = 0; i < BandejaSDataGridView.SelectedRows.Count; i++) { int renglon = BandejaSDataGridView.SelectedRows[i].Index; l = dtBandejaSalida[renglon]; llotes.Add(l); } llotes = SortListaLotes(llotes); for (int i = 0; i < llotes.Count; i++) { //Envio del lote a IF eFact_Entidades.Lote lote = new eFact_Entidades.Lote(); lote = llotes[i]; List<CedEntidades.Evento> eventosposibles = new List<CedEntidades.Evento>(); eventosposibles = lote.WF.EventosPosibles.FindAll((delegate(CedEntidades.Evento e1) { return e1.IdEstadoDsd.IdEstado.ToString() == "PteEnvio"; })); if (eventosposibles.Count == 0) { MessageBox.Show("Imposible enviar el lote: " + lote.NumeroLote + " en el estado actual.", "Envio de Lotes", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); break; } FeaEntidades.InterFacturas.lote_comprobantes lc = new FeaEntidades.InterFacturas.lote_comprobantes(); eFact_RN.Lote.DeserializarLc(out lc, lote, false); //Antes de ejecutar el envio a Interfacturas, cambiar el estado. EjecutarEventoBandejaS("EnviarAIF", "", lote); //Actualizar el WF del lote. eFact_RN.Lote.Leer(lote, Aplicacion.Sesion); //Consultar si exite el lote en Interfacturas FeaEntidades.InterFacturas.lote_comprobantes Lc = new FeaEntidades.InterFacturas.lote_comprobantes(); eFact_RN.IBK.error[] respErroresLote = new eFact_RN.IBK.error[0]; eFact_RN.IBK.error[] respErroresComprobantes = new eFact_RN.IBK.error[0]; eFact_RN.IBK.consulta_lote_responseErrores_consulta RespErroresLote = new eFact_RN.IBK.consulta_lote_responseErrores_consulta(); eFact_RN.IBK.consulta_lote_comprobantes_responseErrores_response RespErroresComprobantes = new eFact_RN.IBK.consulta_lote_comprobantes_responseErrores_response(); //Enviar a Interfacturas si el lote no existe. eFact_RN.Comprobante eFact_RNComprobante = new eFact_RN.Comprobante(); eFact_RN.IBK.lote_response Lr = new eFact_RN.IBK.lote_response(); try { eFact_Entidades.Vendedor v = Aplicacion.Vendedores.Find(delegate(eFact_Entidades.Vendedor e1) { return e1.CuitVendedor == lc.cabecera_lote.cuit_vendedor.ToString(); }); if (v == null) { throw new Microsoft.ApplicationBlocks.ExceptionManagement.Vendedor.Inexistente("CUIT " + lc.cabecera_lote.cuit_vendedor.ToString()); } eFact_RNComprobante.EnviarIBK(out Lr, lc, v.NumeroSerieCertificado.ToString()); EjecutarEventoBandejaS("RegAceptIF", "", lote); } catch (Exception ex2) { //Si el lote tiene errores al ser enviado, grabar el rechazo. string edescr = ""; if (Lr.estado == null && Lr.errores_lote == null && Lr.comprobante_response == null) { //Cuando el error es local, previo a la respuesta de IF se usa el código 99 (Cedeira) para mostrar el error. //Ejemplo: cuando no está instalado el certificado. Lr.estado = "99"; Lr.errores_lote = new eFact_RN.IBK.error[1]; Lr.errores_lote[0] = new eFact_RN.IBK.error(); Lr.errores_lote[0].codigo_error = 99; edescr = ex2.Message.Replace("'", "''"); Lr.errores_lote[0].descripcion_error = edescr; //------ Datos del lote, que genera el error ------ Lr.id_lote = Convert.ToInt64(lote.NumeroLote); Lr.cuit_vendedor = Convert.ToInt64(lote.CuitVendedor); Lr.punto_de_venta = Convert.ToInt32(lote.PuntoVenta); Lr.cantidad_reg = lote.CantidadRegistros; //------------------------------------------------- if (edescr.IndexOf("500 - error") != -1) { Lr.errores_lote[0].codigo_error = 500; } if (edescr.IndexOf("600 - error") != -1) { Lr.errores_lote[0].codigo_error = 600; } } eFact_RN.Lote.ActualizarDatosError(lote, Lr); edescr = ex2.Message.Replace("'", "''"); EjecutarEventoBandejaS("RegRechIF", edescr, lote); //Va a revertir el rechazo (si el error es "Timed Out" hasta 10 ocurrencias. if (Lr.estado == "99" && Lr.errores_lote != null && Lr.errores_lote[0].descripcion_error.ToUpper().Trim() == "THE OPERATION HAS TIMED OUT") { eFact_Entidades.Lote loteAux = new eFact_Entidades.Lote(); loteAux.IdLote = lote.IdLote; eFact_RN.Lote.Leer(loteAux, Aplicacion.Sesion); List<CedEntidades.Log> log = loteAux.WF.Log.FindAll(delegate(CedEntidades.Log e1) { return e1.Comentario.ToUpper().Trim() == "THE OPERATION HAS TIMED OUT"; }); if (log != null && log.Count > 0 && log.Count < 10) { //Actualizar el WF del lote. eFact_RN.Lote.Leer(lote, Aplicacion.Sesion); EjecutarEventoBandejaS("RevertirRechIFA", "", lote); } } throw new Exception(ex2.Message); } } } } catch (Exception ex) { Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex); } finally { RefreshBandejaSalida(); EventosComboBox.Enabled = true; Cursor = System.Windows.Forms.Cursors.Default; } }
private void ActualizarBandejaE() { VerificarServicio(); eFact_RN.IBKP.error[] respErroresListadoComprobantes = new eFact_RN.IBKP.error[0]; List<FeaEntidades.InterFacturas.comprobante_listado> lcIBK = new List<FeaEntidades.InterFacturas.comprobante_listado>(); eFact_RN.IBKP.consulta_listado_comprobante clc = new eFact_RN.IBKP.consulta_listado_comprobante(); try { clc.cod_interno_canal = ""; clc.cuit_canal = Convert.ToInt64(@System.Configuration.ConfigurationManager.AppSettings["CuitCanal"]); clc.cuit_vendedor = Convert.ToInt64("20225018805"); clc.cuit_vendedorSpecified = true; if (PuntoVentaTextBox.Text != "") { clc.punto_de_venta = Convert.ToInt32(PuntoVentaTextBox.Text); } if (NumeroComprobanteTextBox.Text != "") { clc.numero_comprobante_desde = Convert.ToInt32(NumeroComprobanteTextBox.Text); clc.numero_comprobante_hasta = Convert.ToInt32(NumeroComprobanteTextBox.Text); } if (TipoComprobanteComboBox.SelectedValue != null && TipoComprobanteComboBox.SelectedValue.ToString() != "-1") { clc.tipo_de_comprobante = Convert.ToInt32(TipoComprobanteComboBox.SelectedValue); } clc.tipo_doc_comprador = Convert.ToInt32("80"); clc.doc_comprador = Convert.ToInt64(CuitCompradorTextBox.Text); eFact_RN.Comprobante cc = new eFact_RN.Comprobante(); lcIBK = cc.ConsultarListadoIBKP(clc, "012f0775357c"); BandejaEDataGridView.DataSource = lcIBK; BandejaEDataGridView.Refresh(); } catch (Exception ex) { //RespErroresLote = respErroresLote; //RespErroresComprobantes = respErroresComprobantes; Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex); } }
public static void ConsultarLoteIF(out FeaEntidades.InterFacturas.lote_comprobantes Lc, out eFact_RN.IBK.error[] RespErroresLote, out eFact_RN.IBK.error[] RespErroresComprobantes, eFact_Entidades.Lote Lote, string WSCertificado) { eFact_RN.IBK.error[] respErroresLote = new eFact_RN.IBK.error[0]; eFact_RN.IBK.error[] respErroresComprobantes = new eFact_RN.IBK.error[0]; FeaEntidades.InterFacturas.lote_comprobantes lcIBK = new FeaEntidades.InterFacturas.lote_comprobantes(); eFact_RN.IBK.consulta_lote_comprobantes clc = new eFact_RN.IBK.consulta_lote_comprobantes(); try { eFact_RN.Comprobante eFact_RNComprobante = new eFact_RN.Comprobante(); if (Lote.LoteXml != null || Lote.LoteXmlIF != null) { FeaEntidades.InterFacturas.lote_comprobantes lc = new FeaEntidades.InterFacturas.lote_comprobantes(); if (Lote.LoteXmlIF != null && (Lote.LoteXmlIF != "" && (Lote.IdEstado != null && (Lote.IdEstado == "AceptadoAFIP" || Lote.IdEstado == "AceptadoAFIPO" || Lote.IdEstado == "AceptadoAFIPP")))) { eFact_RN.Lote.DeserializarLc(out lc, Lote, true); } else { eFact_RN.Lote.DeserializarLc(out lc, Lote, false); } clc.cod_interno_canal = lc.cabecera_lote.cod_interno_canal; clc.cuit_canal = lc.cabecera_lote.cuit_canal; clc.cuit_vendedor = lc.cabecera_lote.cuit_vendedor; clc.punto_de_venta = lc.cabecera_lote.punto_de_venta; clc.punto_de_ventaSpecified = true; clc.id_lote = lc.cabecera_lote.id_lote; } else { clc.cuit_canal = Convert.ToInt64(@System.Configuration.ConfigurationManager.AppSettings["CuitCanal"]); clc.id_lote = Convert.ToInt64(Lote.NumeroLote); clc.cuit_vendedor = Convert.ToInt64(Lote.CuitVendedor); clc.punto_de_venta = Convert.ToInt32(Lote.PuntoVenta); clc.punto_de_ventaSpecified = true; } lcIBK = eFact_RNComprobante.ConsultarIBK(out respErroresLote, out respErroresComprobantes, clc, WSCertificado); RespErroresLote = respErroresLote; RespErroresComprobantes = respErroresComprobantes; } catch (Exception ex) { RespErroresLote = respErroresLote; RespErroresComprobantes = respErroresComprobantes; throw new Exception(ex.Message); } Lc = lcIBK; }