Example #1
0
        /// <summary>
        /// Llama al WebService FEParamGetPtosVenta
        /// Devuelve los Puntos de Venta y su descripción.
        /// Guarda en la B.D. el Puntos de Ventas y su descripción
        /// </summary>
        /// <param name="pTicket_Rta"></param>
        public Entidades.WebServices_AFIP.RespuestaWS FEParamGetPtosVenta(Entidades.Tickets_Acceso pTicket_Rta)
        {
            Entidades.WebServices_AFIP.RespuestaWS objEntidadesWebService_AFIP_Rta = new Entidades.WebServices_AFIP.RespuestaWS();
            /*
             * https://servicios1.afip.gov.ar/wsfev1/service.asmx?op=FEParamGetPtosVenta
             */
            /*WebService*/
            AFIP_WSFEV1_Produccion.FEAuthRequest autorizacion = new AFIP_WSFEV1_Produccion.FEAuthRequest();
            AFIP_WSFEV1_Produccion.FEPtoVentaResponse respuesta = new AFIP_WSFEV1_Produccion.FEPtoVentaResponse();
            /*Puntos de Venta Recuperados*/
            Entidades.PtosVenta objEntidadesPtosVenta= new Entidades.PtosVenta();
            Logica.PtosVenta objLogicaPtosVenta = new Logica.PtosVenta();
            /*Errores Devueltos*/
            Entidades.Errores_WS objEntidadesErroresWS = new Entidades.Errores_WS();
            Logica.Errores_WS objLogicaErroresWS = new Logica.Errores_WS();
            /*Eventos Devueltos*/
            Entidades.Eventos_WS objEntidadesEventosWS = new Entidades.Eventos_WS();
            Logica.Eventos_WS objLogicaEventosWS = new Logica.Eventos_WS();

            /*Asigno los datos a la autorización*/
            autorizacion.Cuit = pTicket_Rta.Cuit;
            autorizacion.Sign = pTicket_Rta.Sign;
            autorizacion.Token = pTicket_Rta.Token;

            /*Llamo al WebService*/
            AFIP_WSFEV1_Produccion.Service webService = new AFIP_WSFEV1_Produccion.Service();
            respuesta = webService.FEParamGetPtosVenta(autorizacion);

            /*Por cada Error devuelto lo agrego en la B.D.*/
            if (respuesta.Errors != null)
            {
                foreach (AFIP_WSFEV1_Produccion.Err errorItem in respuesta.Errors)
                {
                    objEntidadesErroresWS.Codigo = errorItem.Code;
                    objEntidadesErroresWS.Mensaje = errorItem.Msg;
                    objEntidadesErroresWS.Fecha = DateTime.Now;
                    objEntidadesErroresWS.Observaciones = "Llamando al WS: FEParamGetPtosVenta";

                    objLogicaErroresWS.Agregar(objEntidadesErroresWS);
                }

                objEntidadesWebService_AFIP_Rta = Entidades.WebServices_AFIP.RespuestaWS.Error;
            }

            /*Por cada Evento devuelto lo agrego en la B.D.*/
            if (respuesta.Events != null)
            {
                foreach (AFIP_WSFEV1_Produccion.Evt eventoItem in respuesta.Events)
                {
                    objEntidadesEventosWS.Codigo = eventoItem.Code;
                    objEntidadesEventosWS.Mensaje = eventoItem.Msg;
                    objEntidadesEventosWS.Fecha = DateTime.Now;
                    objEntidadesEventosWS.Observaciones = "Llamando al WS: FEParamGetPtosVenta";

                    objLogicaEventosWS.Agregar(objEntidadesEventosWS);
                }

                objEntidadesWebService_AFIP_Rta = Entidades.WebServices_AFIP.RespuestaWS.Evento;
            }

            /*Por cada Documento devuelto lo agrego en la B.D.*/
            if (respuesta.ResultGet != null)
            {
                /*Primero Borra el listado de la base para cargarlo de Cero*/
                objLogicaPtosVenta.BorrarTodos();

                foreach (AFIP_WSFEV1_Produccion.PtoVenta ptoVentaItem in respuesta.ResultGet)
                {
                    objEntidadesPtosVenta.Id_PtoVenta = ptoVentaItem.Nro;
                    objEntidadesPtosVenta.EmisionTipo = ptoVentaItem.EmisionTipo;
                    objEntidadesPtosVenta.Bloqueado = Convert.ToChar(ptoVentaItem.Bloqueado);

                    if (ptoVentaItem.FchBaja != "NULL")
                    {
                        objEntidadesPtosVenta.FchBaja = DateTime.ParseExact(ptoVentaItem.FchBaja, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
                    }


                    objLogicaPtosVenta.Agregar(objEntidadesPtosVenta);
                }

                objEntidadesWebService_AFIP_Rta = Entidades.WebServices_AFIP.RespuestaWS.Correcta;
            }

            return objEntidadesWebService_AFIP_Rta;
        }