Exemplo n.º 1
0
 public FEXResponse_Idi GetIdiomas(ClsFEXAuthRequest fexAuthRequest)
 {
     try
     {
         using (Ws.Wsfex.ServiceSoapClient client =
                    new Ws.Wsfex.ServiceSoapClient())
         {
             return(client.FEXGetPARAM_Idiomas(fexAuthRequest));
         }
     }
     catch (Exception excepcionAlInvocarWsfe)
     {
         throw new Exception(errorWsfex + excepcionAlInvocarWsfe.Message);
     }
 }
Exemplo n.º 2
0
 public FEXResponse_Ctz GetFexCotizacion(ClsFEXAuthRequest fexAuthRequest, string monId)
 {
     try
     {
         using (Ws.Wsfex.ServiceSoapClient client =
                    new Ws.Wsfex.ServiceSoapClient())
         {
             return(client.FEXGetPARAM_Ctz(fexAuthRequest, monId));
         }
     }
     catch (Exception excepcionAlInvocarWsfe)
     {
         throw new Exception(errorWsfex + excepcionAlInvocarWsfe.Message);
     }
 }
Exemplo n.º 3
0
 public FEXResponse_Cbte_Tipo GetTiposComprobantes(ClsFEXAuthRequest fexAuthRequest)
 {
     try
     {
         using (Ws.Wsfex.ServiceSoapClient client =
                    new Ws.Wsfex.ServiceSoapClient())
         {
             return(client.FEXGetPARAM_Cbte_Tipo(fexAuthRequest));
         }
     }
     catch (Exception excepcionAlInvocarWsfe)
     {
         throw new Exception(errorWsfex + excepcionAlInvocarWsfe.Message);
     }
 }
Exemplo n.º 4
0
 public FEXGetCMPResponse GetComprobante(ClsFEXAuthRequest fexAuthRequest, ClsFEXGetCMP fexGetCmp)
 {
     try
     {
         using (Ws.Wsfex.ServiceSoapClient client =
                    new Ws.Wsfex.ServiceSoapClient())
         {
             return(client.FEXGetCMP(fexAuthRequest, fexGetCmp));
         }
     }
     catch (Exception excepcionAlInvocarWsfe)
     {
         throw new Exception(errorWsfex + excepcionAlInvocarWsfe.Message);
     }
 }
Exemplo n.º 5
0
 public FEXResponse_CheckPermiso CheckPermiso(ClsFEXAuthRequest fexAuthRequest, string idPermiso, int destMerc)
 {
     try
     {
         using (Ws.Wsfex.ServiceSoapClient client =
                    new Ws.Wsfex.ServiceSoapClient())
         {
             return(client.FEXCheck_Permiso(fexAuthRequest, idPermiso, destMerc));
         }
     }
     catch (Exception excepcionAlInvocarWsfe)
     {
         throw new Exception(errorWsfex + excepcionAlInvocarWsfe.Message);
     }
 }
Exemplo n.º 6
0
        public FEXResponseAuthorize AutorizarComprobanteExportacion(ClsFEXAuthRequest fexAuthRequest, ClsFEXRequest fexRequest)
        {
            try
            {
                using (Ws.Wsfex.ServiceSoapClient client = new Ws.Wsfex.ServiceSoapClient())
                {
                    return(client.FEXAuthorize(fexAuthRequest, fexRequest));
                }
            }

            catch (Exception ex)
            {
                throw new Exception(errorWsfe + ex.Message);
            }
        }
Exemplo n.º 7
0
        public FEXResponse_Umed GetUnidadesDeMedida(ClsFEXAuthRequest fexAuthRequest)
        {
            AfipWrapperServiceClient client = new AfipWrapperServiceClient();

            ClientCredentialHelper.SetCredentials(client.ClientCredentials);
            try
            {
                var t = client.GetUnidadesDeMedida(fexAuthRequest);
                client.Close();
                return(t);
            }
            catch
            {
                if (client.State != System.ServiceModel.CommunicationState.Closed)
                {
                    client.Abort();
                }

                throw;
            }
        }
Exemplo n.º 8
0
        public FEXResponseAuthorize AutorizarComprobanteExportacion(ClsFEXAuthRequest fexAuthRequest, ClsFEXRequest fexRequest)
        {
            AfipWrapperServiceClient client = new AfipWrapperServiceClient();

            ClientCredentialHelper.SetCredentials(client.ClientCredentials);
            try
            {
                var t = client.AutorizarComprobanteExportacion(fexAuthRequest, fexRequest);
                client.Close();
                return(t);
            }
            catch
            {
                if (client.State != System.ServiceModel.CommunicationState.Closed)
                {
                    client.Abort();
                }

                throw;
            }
        }
Exemplo n.º 9
0
        public FEXResponse_Cbte_Tipo GetTiposComprobantes(ClsFEXAuthRequest fexAuthRequest)
        {
            AfipWrapperServiceClient client = new AfipWrapperServiceClient();

            ClientCredentialHelper.SetCredentials(client.ClientCredentials);
            try
            {
                var t = client.GetTiposComprobantes(fexAuthRequest);
                client.Close();
                return(t);
            }
            catch
            {
                if (client.State != System.ServiceModel.CommunicationState.Closed)
                {
                    client.Abort();
                }

                throw;
            }
        }
Exemplo n.º 10
0
        public FEXResponse_CheckPermiso CheckPermiso(ClsFEXAuthRequest fexAuthRequest, string idPermiso, int destMerc)
        {
            AfipWrapperServiceClient client = new AfipWrapperServiceClient();

            ClientCredentialHelper.SetCredentials(client.ClientCredentials);
            try
            {
                var t = client.CheckPermiso(fexAuthRequest, idPermiso, destMerc);
                client.Close();
                return(t);
            }
            catch
            {
                if (client.State != System.ServiceModel.CommunicationState.Closed)
                {
                    client.Abort();
                }

                throw;
            }
        }
Exemplo n.º 11
0
        public FEXResponse_Ctz GetFexCotizacion(ClsFEXAuthRequest fexAuthRequest, string monId)
        {
            AfipWrapperServiceClient client = new AfipWrapperServiceClient();

            ClientCredentialHelper.SetCredentials(client.ClientCredentials);
            try
            {
                var t = client.GetFexCotizacion(fexAuthRequest, monId);
                client.Close();
                return(t);
            }
            catch
            {
                if (client.State != System.ServiceModel.CommunicationState.Closed)
                {
                    client.Abort();
                }

                throw;
            }
        }
 public FEXResponse_Inc FEXGetPARAM_Incoterms( ClsFEXAuthRequest Auth )
 {
     object[] results = this.Invoke( "FEXGetPARAM_Incoterms", new object[] {
                 Auth} );
         return ( (FEXResponse_Inc) ( results[0] ) );
 }
 /// <remarks/>
 public System.IAsyncResult BeginFEXCheck_Permiso( ClsFEXAuthRequest Auth, string ID_Permiso, int Dst_merc, System.AsyncCallback callback, object asyncState )
 {
     return this.BeginInvoke( "FEXCheck_Permiso", new object[] {
                 Auth,
                 ID_Permiso,
                 Dst_merc}, callback, asyncState );
 }
 /// <remarks/>
 public void FEXGetPARAM_DST_paisAsync( ClsFEXAuthRequest Auth )
 {
     this.FEXGetPARAM_DST_paisAsync( Auth, null );
 }
 public FEXResponse_Umed FEXGetPARAM_UMed( ClsFEXAuthRequest Auth )
 {
     object[] results = this.Invoke( "FEXGetPARAM_UMed", new object[] {
                 Auth} );
         return ( (FEXResponse_Umed) ( results[0] ) );
 }
 public FEXResponseAuthorize FEXAuthorize( ClsFEXAuthRequest Auth, ClsFEXRequest Cmp )
 {
     object[] results = this.Invoke( "FEXAuthorize", new object[] {
                 Auth,
                 Cmp} );
         return ( (FEXResponseAuthorize) ( results[0] ) );
 }
 public FEXResponse_PtoVenta FEXGetPARAM_PtoVenta( ClsFEXAuthRequest Auth )
 {
     object[] results = this.Invoke( "FEXGetPARAM_PtoVenta", new object[] {
                 Auth} );
         return ( (FEXResponse_PtoVenta) ( results[0] ) );
 }
 public FEXResponse_Tex FEXGetPARAM_Tipo_Expo( ClsFEXAuthRequest Auth )
 {
     object[] results = this.Invoke( "FEXGetPARAM_Tipo_Expo", new object[] {
                 Auth} );
         return ( (FEXResponse_Tex) ( results[0] ) );
 }
 public FEXGetCMPResponse FEXGetCMP( ClsFEXAuthRequest Auth, ClsFEXGetCMP Cmp )
 {
     object[] results = this.Invoke( "FEXGetCMP", new object[] {
                 Auth,
                 Cmp} );
         return ( (FEXGetCMPResponse) ( results[0] ) );
 }
 /// <remarks/>
 public void FEXGetCMPAsync( ClsFEXAuthRequest Auth, ClsFEXGetCMP Cmp )
 {
     this.FEXGetCMPAsync( Auth, Cmp, null );
 }
 /// <remarks/>
 public void FEXCheck_PermisoAsync( ClsFEXAuthRequest Auth, string ID_Permiso, int Dst_merc )
 {
     this.FEXCheck_PermisoAsync( Auth, ID_Permiso, Dst_merc, null );
 }
 /// <remarks/>
 public void FEXCheck_PermisoAsync( ClsFEXAuthRequest Auth, string ID_Permiso, int Dst_merc, object userState )
 {
     if ( ( this.FEXCheck_PermisoOperationCompleted == null ) )
         {
             this.FEXCheck_PermisoOperationCompleted = new System.Threading.SendOrPostCallback( this.OnFEXCheck_PermisoOperationCompleted );
         }
         this.InvokeAsync( "FEXCheck_Permiso", new object[] {
                 Auth,
                 ID_Permiso,
                 Dst_merc}, this.FEXCheck_PermisoOperationCompleted, userState );
 }
 public FEXResponse_CheckPermiso FEXCheck_Permiso( ClsFEXAuthRequest Auth, string ID_Permiso, int Dst_merc )
 {
     object[] results = this.Invoke( "FEXCheck_Permiso", new object[] {
                 Auth,
                 ID_Permiso,
                 Dst_merc} );
         return ( (FEXResponse_CheckPermiso) ( results[0] ) );
 }
 /// <remarks/>
 public void FEXAuthorizeAsync( ClsFEXAuthRequest Auth, ClsFEXRequest Cmp, object userState )
 {
     if ( ( this.FEXAuthorizeOperationCompleted == null ) )
         {
             this.FEXAuthorizeOperationCompleted = new System.Threading.SendOrPostCallback( this.OnFEXAuthorizeOperationCompleted );
         }
         this.InvokeAsync( "FEXAuthorize", new object[] {
                 Auth,
                 Cmp}, this.FEXAuthorizeOperationCompleted, userState );
 }
 /// <remarks/>
 public void FEXAuthorizeAsync( ClsFEXAuthRequest Auth, ClsFEXRequest Cmp )
 {
     this.FEXAuthorizeAsync( Auth, Cmp, null );
 }
 /// <remarks/>
 public void FEXGetPARAM_IncotermsAsync( ClsFEXAuthRequest Auth )
 {
     this.FEXGetPARAM_IncotermsAsync( Auth, null );
 }
Exemplo n.º 27
0
        public CorridaAutorizacionDto AutorizarComprobantesParaWsFeX(CorridaAutorizacionDto corridaDto)
        {
            try
            {
                this.corridaDto = corridaDto;
                string pathArchivoOrigen = corridaDto.PathArchivo;

                if (string.IsNullOrEmpty(corridaDto.PathArchivo))
                {
                    this.Log("ERROR: No se ha ingresado el path del archivo");
                }

                // Marco la corrida como en proceso en la base de datos
                if (this.corridaSvc.MarcarCorridaEnProceso(corridaDto.Id))
                {
                    // Inicio Proceso
                    this.Log(string.Format("Iniciando procesamiento de archivo {0}...", this.nombreDeArchivo));

                    // Valido el Esquema de Xml
                    this.Log(string.Format("Validando esquema de archivo"));
                    string xmlSchemaPath = "";

                    if (!this.ValidarEsquemaXml(corridaDto.PathArchivo, xmlSchemaPath))
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("ERROR: el formato del archivo es invalido");
                        sb.AppendLine(this.validacionesEsquema.ToString());
                        this.Log(sb.ToString());
                        return(null);
                    }

                    // Leo archivo XML y lo paso a string
                    this.Log("Leyendo archivo...");
                    string xmlString = LeerArchivo(corridaDto.PathArchivo);

                    // Reemplazo <Lote></Lote> por <FeCAEReq></FeCAEReq>
                    xmlString = xmlString.Replace("<FacturaExportacion>", "<ClsFEXRequest>").Replace("</FacturaExportacion>", "</ClsFEXRequest>");

                    // Deserealizo el XML y obtengo solo la parte del request
                    ClsFEXRequest feXCAERequest = null;
                    try
                    {
                        feXCAERequest = DeserializarXml <ClsFEXRequest>(xmlString, "http://ar.gov.afip.dif.fexv1/");

                        //feXCAERequest = new ClsFEXRequest();
                        //feXCAERequest.Id = 1;
                        //feXCAERequest.Fecha_cbte = "20120820";
                        //feXCAERequest.Punto_vta = 19;
                        //feXCAERequest.Cbte_nro = 1;
                        //feXCAERequest.Tipo_expo = 1;
                        //feXCAERequest.Permiso_existente = "S";
                        //feXCAERequest.Permisos = new Permiso[2];
                        //feXCAERequest.Permisos[0] = new Permiso();
                        //feXCAERequest.Permisos[0].Dst_merc = 203;
                        //feXCAERequest.Permisos[1] = new Permiso();
                        //feXCAERequest.Permisos[1].Id_permiso = "09052EC01006154G";
                        //feXCAERequest.Permisos[1].Dst_merc = 202;
                        //feXCAERequest.Dst_cmp = 203;
                        //feXCAERequest.Cliente = "Joao Da Silva";
                        //feXCAERequest.Cuit_pais_cliente = 50000000016;
                        //feXCAERequest.Domicilio_cliente = "Rua 76 km 34.5 Alagoas";
                        //feXCAERequest.Id_impositivo = "PJ54482221-l";
                        //feXCAERequest.Moneda_Id = "012";
                        //feXCAERequest.Moneda_ctz = 0.51M;
                        //feXCAERequest.Obs_comerciales = "Sin observaciones";
                        //feXCAERequest.Imp_total = 500;
                        //feXCAERequest.Forma_pago = "Contado";
                        //feXCAERequest.Incoterms = "CIF";
                        //feXCAERequest.Incoterms_Ds = "Texto dic.";
                        //feXCAERequest.Idioma_cbte = 1;
                        //feXCAERequest.Items = new Item[1];
                        //feXCAERequest.Items[0] = new Item();
                        //feXCAERequest.Items[0].Pro_codigo = "PRO1";
                        //feXCAERequest.Items[0].Pro_ds = "Producto Tipo 1 Exportacion MERCOSUR ISO 9001";
                        //feXCAERequest.Items[0].Pro_qty = 2;
                        //feXCAERequest.Items[0].Pro_umed = 7;
                        //feXCAERequest.Items[0].Pro_precio_uni = 250;
                        //feXCAERequest.Items[0].Pro_total_item = 500;

                        //feXCAERequest.Cmps_asoc = new Cmp_asoc[0];

                        //var revisar = SerializarXml<ClsFEXRequest>(feXCAERequest);
                        //revisar = revisar.ToString();
                    }
                    catch (Exception ex)
                    {
                        this.Log("El formato del archivo es inválido.");
                        return(null);
                    }

                    // Obtengo Ticket de Autorizacion
                    this.Log("Iniciando comunicacion con la AFIP");
                    ClsFEXAuthRequest feXAuthRequest = this.ObtenerTicketWSFeX();

                    // Cargo los comprobantes que estan autorizados en la AFIP
                    // pero que no fueron cargados en la DB por problemas en
                    // la comunicacion
                    //-------------------------------------
                    //-------------------------------------
                    // IMPORTANTE!!!!!!
                    //-------------------------------------
                    //-------------------------------------
                    // El siguiente codigo tiene que refactorearse según como trabaja este nuevo servicio
                    // ByAd TODO: this.CargarComprobantesYaAutorizados(feAuthRequest, feCAERequest);


                    // Remover Comprobantes que ya han sido autorizados
                    //string resultado = this.RemoverComprobantesAutorizados(feAuthRequest, feCAERequest);
                    //if (!string.IsNullOrEmpty(resultado))
                    //{
                    //    this.Log(resultado);
                    //    feCAERequest.FeCabReq.CantReg = feCAERequest.FeDetReq.Count();
                    //}
                    //-------------------------------------
                    //-------------------------------------
                    //-------------------------------------

                    if (feXCAERequest != null)
                    {
                        // Autorizar Comprobantes con la AFIP
                        this.Log("Autorizando Comprobantes con la AFIP...");
                        FEXResponseAuthorize feXCAEResponse = this.AutorizarComprobantes(feXAuthRequest, feXCAERequest);

                        // Proceso Resultado AFIP
                        this.Log("Procesando respuesta de la AFIP...");
                        corridaDto = this.corridaSvc.ProcesarCorridaWsFeX(corridaDto, feXCAEResponse, feXCAERequest);
                    }
                    else
                    {
                        // Todos los comprobantes del archivo ya tienen un CAE asignado
                        // y existen en DB
                        this.Log("Todos los comprobantes del archivo ya han sido autorizados");
                    }

                    // Muevo el archivo a una carpeta de procesados
                    GuardarArchivoProcesado(pathArchivoOrigen);

                    this.Log("Fin procesamiento de archivo.");
                }
                else
                {
                    this.Log("La corrida ya se está ejecutando");
                }

                return(corridaDto);
            }
            catch (Exception ex)
            {
                string detalle = string.Format("ex.Message: {0} ex.StackTrace: {1}", ex.Message, ex.StackTrace);
                this.Log(string.Format("ERROR: Se ha producido un error. Contactese con el administrador. Error: {0}", ex.Message), detalle);
                return(null);
            }
            finally
            {
                this.Log(CorridaService.FinCorridaMsg);
            }
        }
 public FEXResponse_Mon FEXGetPARAM_MON( ClsFEXAuthRequest Auth )
 {
     object[] results = this.Invoke( "FEXGetPARAM_MON", new object[] {
                 Auth} );
         return ( (FEXResponse_Mon) ( results[0] ) );
 }
 /// <remarks/>
 public void FEXGetLast_IDAsync( ClsFEXAuthRequest Auth )
 {
     this.FEXGetLast_IDAsync( Auth, null );
 }
 /// <remarks/>
 public void FEXGetPARAM_PtoVentaAsync( ClsFEXAuthRequest Auth )
 {
     this.FEXGetPARAM_PtoVentaAsync( Auth, null );
 }
 /// <remarks/>
 public void FEXGetPARAM_UMedAsync( ClsFEXAuthRequest Auth, object userState )
 {
     if ( ( this.FEXGetPARAM_UMedOperationCompleted == null ) )
         {
             this.FEXGetPARAM_UMedOperationCompleted = new System.Threading.SendOrPostCallback( this.OnFEXGetPARAM_UMedOperationCompleted );
         }
         this.InvokeAsync( "FEXGetPARAM_UMed", new object[] {
                 Auth}, this.FEXGetPARAM_UMedOperationCompleted, userState );
 }
 /// <remarks/>
 public void FEXGetPARAM_Tipo_ExpoAsync( ClsFEXAuthRequest Auth )
 {
     this.FEXGetPARAM_Tipo_ExpoAsync( Auth, null );
 }
 /// <remarks/>
 public System.IAsyncResult BeginFEXGetPARAM_Ctz( ClsFEXAuthRequest Auth, string Mon_id, System.AsyncCallback callback, object asyncState )
 {
     return this.BeginInvoke( "FEXGetPARAM_Ctz", new object[] {
                 Auth,
                 Mon_id}, callback, asyncState );
 }
 /// <remarks/>
 public void FEXGetPARAM_UMedAsync( ClsFEXAuthRequest Auth )
 {
     this.FEXGetPARAM_UMedAsync( Auth, null );
 }
 /// <remarks/>
 public System.IAsyncResult BeginFEXGetPARAM_UMed( ClsFEXAuthRequest Auth, System.AsyncCallback callback, object asyncState )
 {
     return this.BeginInvoke( "FEXGetPARAM_UMed", new object[] {
                 Auth}, callback, asyncState );
 }
 public FEXResponse_Ctz FEXGetPARAM_Ctz( ClsFEXAuthRequest Auth, string Mon_id )
 {
     object[] results = this.Invoke( "FEXGetPARAM_Ctz", new object[] {
                 Auth,
                 Mon_id} );
         return ( (FEXResponse_Ctz) ( results[0] ) );
 }
 /// <remarks/>
 public System.IAsyncResult BeginFEXGetCMP( ClsFEXAuthRequest Auth, ClsFEXGetCMP Cmp, System.AsyncCallback callback, object asyncState )
 {
     return this.BeginInvoke( "FEXGetCMP", new object[] {
                 Auth,
                 Cmp}, callback, asyncState );
 }
 /// <remarks/>
 public void FEXGetPARAM_CtzAsync( ClsFEXAuthRequest Auth, string Mon_id )
 {
     this.FEXGetPARAM_CtzAsync( Auth, Mon_id, null );
 }
 public FEXResponse_DST_pais FEXGetPARAM_DST_pais( ClsFEXAuthRequest Auth )
 {
     object[] results = this.Invoke( "FEXGetPARAM_DST_pais", new object[] {
                 Auth} );
         return ( (FEXResponse_DST_pais) ( results[0] ) );
 }
 public FEXResponse_LastID FEXGetLast_ID( ClsFEXAuthRequest Auth )
 {
     object[] results = this.Invoke( "FEXGetLast_ID", new object[] {
                 Auth} );
         return ( (FEXResponse_LastID) ( results[0] ) );
 }
Exemplo n.º 41
0
        private FEXResponseAuthorize AutorizarComprobantes(ClsFEXAuthRequest feXAuthRequest, ClsFEXRequest feXCAERequest)
        {
            WsfeClient client = new WsfeClient();

            return(client.AutorizarComprobanteExportacion(feXAuthRequest, feXCAERequest));
        }