Example #1
0
        //Peticion web service descarga documento
        public static string DownloadDocFE(string codeLog, string docType, string numDoc, string downloadType)
        {
            Procesos.responseStatus = "";
            try
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
                CarvajalWS.invoiceServiceClient client           = new CarvajalWS.invoiceServiceClient();
                CarvajalWS.DownloadResponse     resultadoCliente = null;

                var requestInterceptor = new CustomEndpointBehavior();
                client.Endpoint.Behaviors.Add(requestInterceptor);

                client.Open();

                CarvajalWS.Download        cuerpo             = new CarvajalWS.Download();
                CarvajalWS.DownloadRequest requestDownloadDoc = new CarvajalWS.DownloadRequest();

                if (Procesos.nit.IndexOf('_') > 0)
                {
                    requestDownloadDoc.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('_'));
                }
                else if (Procesos.nit.IndexOf('-') > 0)
                {
                    requestDownloadDoc.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('-'));
                }
                else
                {
                    requestDownloadDoc.companyId = Procesos.nit;
                }
                requestDownloadDoc.accountId      = Procesos.nit;
                requestDownloadDoc.documentType   = docType;
                requestDownloadDoc.documentNumber = numDoc;
                requestDownloadDoc.resourceType   = downloadType;

                cuerpo.DownloadRequest = requestDownloadDoc;

                resultadoCliente = new CarvajalWS.DownloadResponse();
                resultadoCliente = client.Download(cuerpo.DownloadRequest);
                Procesos.EscribirLogFileTXT(downloadType + resultadoCliente.status);
                //Procesos.EscribirLogFileTXT("Archivo" + resultadoCliente.downloadData);
                client.Close();
                //if()
                Procesos.requestSend = "";
                return(resultadoCliente.downloadData);
            }
            catch (Exception ex)
            {
                Procesos.EscribirLogFileTXT("DownloadDocFE: " + ex.Message);
                return(ex.Message);
            }
        }
Example #2
0
        //Peticion web service descarga documento
        public static string DownloadDocFE(string codeLog, string docType, string numDoc, string downloadType)
        {
            Procesos.responseStatus = "";
            try
            {
                CarvajalWS.invoiceServiceClient client = new CarvajalWS.invoiceServiceClient();

                var requestInterceptor = new CustomEndpointBehavior();
                client.Endpoint.Behaviors.Add(requestInterceptor);

                client.Open();

                CarvajalWS.Download        cuerpo             = new CarvajalWS.Download();
                CarvajalWS.DownloadRequest requestDownloadDoc = new CarvajalWS.DownloadRequest();

                if (Procesos.nit.IndexOf('_') > 0)
                {
                    requestDownloadDoc.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('_'));
                }
                else if (Procesos.nit.IndexOf('-') > 0)
                {
                    requestDownloadDoc.companyId = Procesos.nit.Substring(0, Procesos.nit.IndexOf('-'));
                }
                else
                {
                    requestDownloadDoc.companyId = Procesos.nit;
                }
                requestDownloadDoc.accountId      = Procesos.nit;
                requestDownloadDoc.documentType   = docType;
                requestDownloadDoc.documentNumber = numDoc;
                requestDownloadDoc.resourceType   = downloadType;

                cuerpo.DownloadRequest = requestDownloadDoc;

                CarvajalWS.DownloadResponse resultadoCliente = new CarvajalWS.DownloadResponse();
                resultadoCliente = client.Download(cuerpo.DownloadRequest);
                Procesos.RepoMensajes("catch", resultadoCliente.status);
                client.Close();
                return(resultadoCliente.downloadData);
            }
            catch (Exception ex)
            {
                Procesos.RepoMensajes("catch", ex.Message);
                Procesos.EscribirLogFileTXT("DocStatusFE: " + ex.Message);
                return(ex.Message);
            }
        }