Example #1
0
        //protected string UploadFile()filename
        //{
        //    log.Debug("AltaFectura.ascx.cs - UploadFile() - Inicio.");
        //    if (oRta != string.Empty)
        //    {
        //        deleteImgFunction();
        //        oRta = string.Empty;
        //    }
        //    if (!FileUploadControl.HasFile)
        //    {
        //        StatusLabel.Text = "Upload status: Debe elegir un archivo a subir!";
        //        oRta = string.Empty;
        //        return oRta;
        //    }
        //    if (FileUploadControl.PostedFile.ContentType != "image/jpeg" && FileUploadControl.PostedFile.ContentType != "image/png" && FileUploadControl.PostedFile.ContentType != "application/pdf")
        //    {
        //        StatusLabel.Text = "Upload status: Solo archivos .jpg, .png y .pdf son aceptados!";
        //        oRta = string.Empty;
        //        return oRta;
        //    }
        //    if (FileUploadControl.PostedFile.ContentLength > 1048576)
        //    {
        //        StatusLabel.Text = "Upload status:Los Archivos pueden ser de hasta 1 MB !";
        //        oRta = string.Empty;
        //        return oRta;
        //    }
        //    try
        //    {
        //        log.Debug("AltaFectura.ascx.cs - UploadFile() - entra al try");
        //        DigiWeb.DigitalizacionServicio service = new DigiWeb.DigitalizacionServicio();
        //        service.Credentials = CredentialCache.DefaultCredentials;
        //        log.Debug("AltaFectura.ascx.cs - UploadFile() - antes de service.CalcularRutaSistema()");
        //        oRuta = service.CalcularRutaSistema("3W-SERVPUB");
        //        log.Debug("AltaFectura.ascx.cs - UploadFile() - paso service.CalcularRutaSistema() - ruta calculada: oRuta: " + oRuta.ToString());
        //        string filename = string.Empty;
        //        byte[] oFileToSave = null;
        //        filename = Path.GetFileName(FileUploadControl.FileName);
        //        filename = filename.Substring(0, filename.IndexOf(".")) + ".pdf";
        //        log.Debug("AltaFectura.ascx.cs - UploadFile() - filename: " + filename.ToString());
        //        if (FileUploadControl.PostedFile.ContentType == "image/jpeg" || FileUploadControl.PostedFile.ContentType == "image/png")
        //        {
        //            log.Debug("AltaFectura.ascx.cs - UploadFile() - es imagen: convertir a pdf y cargar a oFileToSave");
        //            Stream stream = new MemoryStream(FileUploadControl.FileBytes);
        //            oFileToSave = ConvertImageToPdf(filename, stream);
        //        }
        //        else
        //        {
        //            log.Debug("AltaFectura.ascx.cs - UploadFile() - es pdf: cargar a oFileToSave");
        //            oFileToSave = FileUploadControl.FileBytes;
        //        }
        //        #region Upload
        //        log.Debug("AltaFectura.ascx.cs - UploadFile() - convertir oFileToSave a Base64String");
        //        String oFileToSaveStr = Convert.ToBase64String(oFileToSave);
        //        ServPubSitio.AnsesUploadWS.DigitalizacionWS oDigitalizacionWS = new ServPubSitio.AnsesUploadWS.DigitalizacionWS();
        //        oDigitalizacionWS.Credentials = CredentialCache.DefaultCredentials;
        //        filename = filename.Insert(filename.IndexOf("."), "_" + DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0') + DateTime.Now.Second.ToString().PadLeft(2, '0'));
        //        log.Debug("AltaFectura.ascx.cs - UploadFile() - volver a convertir filename: " + filename.ToString());

        //        //string oUploadFileRta = oDigitalizacionWS.UploadFile(oFileToSaveStr, oRuta + "\\", filename);

        //        log.Debug("AltaFectura.ascx.cs - UploadFile() - antes de usar PostedFile.SaveAs()");
        //        //Como lo utilizamos en BEFE/GESCOM
        //        FileUploadControl.PostedFile.SaveAs(oRuta + "\\" + filename);
        //        log.Debug("AltaFectura.ascx.cs - UploadFile() - después de usar PostedFile.SaveAs()");



        //        //log.Debug("AltaFectura.ascx.cs - UploadFile() - ruta completa para subir archivo: oUploadFileRta: " + oUploadFileRta.ToString());
        //        //if (oUploadFileRta == "OK") {
        //        //    //    imgPreview.Visible = true;
        //        //    //    imgDelete.Visible = true;
        //        //    //    // imgPreview.ImageUrl = oRuta + "\\" + filename;
        //        //    //    string oUrlRuta = "http://10.86.37.148/SERVPUB.SITE/Uploaded/";
        //        //    //    imgPreview.ImageUrl = oUrlRuta + filename;
        //        //    //    imgPreview.AlternateText = filename;
        //        //}
        //        #endregion
        //        Guid oGuid;
        //        oGuid = Guid.NewGuid();
        //        Guid oGuid_A_Traer;
        //        if (oPIdDigi != "")
        //        {
        //            DigiWeb.EDocumento oEDocumento = new DigiWeb.EDocumento();
        //            oEDocumento.Id = new Guid(oPIdDigi);
        //            oEDocumento.CodigoSistema = "3W-SERVPUB";
        //            oEDocumento.TipoEDocumentoId = 1054;
        //            oEDocumento.EstadoEDocumentoId = 1;
        //            oEDocumento.Entidad = "0";
        //            oEDocumento.PreCuil = 0;
        //            oEDocumento.NumeroDocumento = "0";
        //            oEDocumento.DigitoVerificador = 0;
        //            oEDocumento.TipoTramite = 0;
        //            oEDocumento.Secuencia = 0;
        //            oEDocumento.Nombre = filename;
        //            oEDocumento.Ruta = oRuta + "\\" + filename;
        //            oEDocumento.FechaIndexacion = DateTime.Now;
        //            log.Debug("AltaFectura.ascx.cs - UploadFile() - antes de service.ActualizarEDocumento - con oEDocumento.Id: " + oEDocumento.Id.ToString());
        //            service.ActualizarEDocumento(oEDocumento);
        //            oGuid_A_Traer = oEDocumento.Id;
        //        }
        //        else
        //        {
        //            DigiWeb.EDocumentoOriginal oEDocumentoOriginal = new DigiWeb.EDocumentoOriginal();
        //            oEDocumentoOriginal.Id = oGuid;
        //            oEDocumentoOriginal.CodigoSistema = "3W-SERVPUB";
        //            oEDocumentoOriginal.TipoEDocumentoId = 1054;
        //            oEDocumentoOriginal.EstadoEDocumentoId = 1;
        //            oEDocumentoOriginal.Entidad = "0";
        //            oEDocumentoOriginal.PreCuil = 0;
        //            oEDocumentoOriginal.NumeroDocumento = "0";
        //            oEDocumentoOriginal.DigitoVerificador = 0;
        //            oEDocumentoOriginal.TipoTramite = 0;
        //            oEDocumentoOriginal.Secuencia = 0;
        //            oEDocumentoOriginal.Nombre = filename;
        //            oEDocumentoOriginal.Ruta = oRuta + "\\" + filename;
        //            oEDocumentoOriginal.FechaIndexacion = DateTime.Now;
        //            log.Debug("AltaFectura.ascx.cs - UploadFile() - antes de service.GuardarEDocumentoV2 - con oGuid: " + oGuid.ToString());
        //            service.GuardarEDocumentoV2(oEDocumentoOriginal);
        //            oGuid_A_Traer = oEDocumentoOriginal.Id;
        //        }
        //        log.Debug("AltaFectura.ascx.cs - UploadFile() - pasó actualizar/guardar documento - antes de service.TraerEDocumento: oGuid_A_Traer: " + oGuid_A_Traer.ToString());
        //        DigiWeb.EDocumento oEDocumentoSubido = service.TraerEDocumento(oGuid_A_Traer);
        //        if (oEDocumentoSubido != null)
        //        {
        //            StatusLabel.Text = "Upload status: Documento Subido con Exito. " + oEDocumentoSubido.Nombre.ToString();
        //            log.Debug("AltaFectura.ascx.cs - UploadFile() - Documento Subido con Exito");
        //            imgPreview.Visible = true;
        //            imgDelete.Visible = true;
        //            //imgPreview.ImageUrl = oEDocumentoSubido.Ruta ;
        //            if (oEDocumentoSubido.Nombre.ToLower().Contains(".pdf") == true)
        //            {
        //                imgPreview.ImageUrl = "~/imagenes/Logo_PDF.png";
        //                imgPreview.ToolTip = Encriptar(oEDocumentoSubido.Ruta);
        //                imgPreview.AlternateText = Encriptar(oEDocumentoSubido.Ruta);
        //            }
        //            else
        //            {
        //                string oImageUrl = "verPdf.aspx" + "?Id=" + Encriptar(oEDocumentoSubido.Ruta);
        //                imgPreview.ImageUrl = oImageUrl;
        //                imgPreview.AlternateText = oEDocumentoSubido.Nombre;
        //            }
        //            imgPreview.ToolTip = oEDocumentoSubido.Nombre;
        //            oRta = oEDocumentoSubido.Id.ToString();
        //            return oRta;
        //        }
        //        else
        //        {
        //            log.Debug("AltaFectura.ascx.cs - UploadFile() - El documento no se pudo subir");
        //            ((PaginaBase)this.Page).Informar("No se pudo subir el documento");
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        StatusLabel.Text = "Upload status: No se pudo subir el archivo. Ocurrió el siguiente error: " + ex.Message;
        //        log.Error("AltaFactura.ascx.cs - UploadFile() - error: " + ex.Message + " - " + ex.InnerException + " - " + ex.StackTrace);
        //        return string.Empty;
        //    }
        //    return oRta;
        //}
        public SoapException manejoWebError(WebException exp)
        {
            WebResponse response = exp.Response;

            faultDetail = exp.InnerException != null ? exp.InnerException.Message : exp.Message;

            log.Error("Error en la ejecucion : " + faultDetail);

            if (response != null)
            {
                using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                {
                    result = sr.ReadToEnd();
                }
            }
            else
            {
                result = faultDetail;
            }

            log.Error("Error: " + result);
            soapError = Funciones.HandleWebException(result);

            if (soapError != null)
            {
                faultFactor = "Renappo";
                faultDetail = soapError.ErrorCode + " " + soapError.ErrorDescription;
            }

            node.InnerText = faultDetail;
            return(new SoapException(faultDetail, SoapException.ServerFaultCode, faultFactor, node));
        }
Example #2
0
        public SoapException HandleError(Exception ex)
        {
            SoapError error = Functions.SoapErrorFromException(ex);

            log.Error("Error en la ejecucion : " + error.FaultDetail);

            return(new SoapException(error.FaultDetail, SoapException.ServerFaultCode, error.FaultReason, error.FaultNode));
        }
Example #3
0
        public SoapException HandleError(WebException ex)
        {
            SoapError error = Functions.SoapErrorFromWebException(ex);

            log.Error("Error en la ejecucion : " + error.FaultDetail);

            log.Error("Respuesta ESIDIF - Servicio: " + Environment.NewLine + Functions.ParseXml(error.FaultResponse));

            return(new SoapException(error.FaultDetail, SoapException.ServerFaultCode, error.FaultReason, error.FaultNode));
        }
Example #4
0
        public SoapException HandleError(Exception ex)
        {
            SoapError error = Functions.SoapErrorFromException(ex);

            ex = Functions.FindXmlErrorDetail(ex);

            if (ex != null)
            {
                log.Error("Error en la ejecucion : " + ex.Message);
                return(new SoapException("Error", SoapException.ClientFaultCode, error.FaultDetail, ex));
            }
            else
            {
                log.Error("Error en la ejecucion : " + error.FaultDetail);
                return(new SoapException(error.FaultDetail, SoapException.ServerFaultCode, error.FaultReason, error.FaultNode));
            }
        }
Example #5
0
        public static SoapError SoapErrorFromWebException(WebException exp)
        {
            string msgResponse = string.Empty;

            WebResponse response = exp.Response;

            faultDetail = exp.InnerException != null ? exp.InnerException.Message : exp.Message;

            if (response != null)
            {
                using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                {
                    msgResponse = sr.ReadToEnd();
                }
            }
            else
            {
                msgResponse = faultDetail;
            }

            soapError = HandleWebExceptionXml(msgResponse);

            if (soapError != null)
            {
                soapError.FaultReason = "Economia";
                faultDetail           = soapError.ErrorCode + " " + soapError.ErrorDescription;
            }
            else
            {
                soapError = new SoapError();
            }

            nodeError.InnerText     = faultDetail;
            soapError.FaultResponse = msgResponse;
            soapError.FaultDetail   = faultDetail;

            return(soapError);
        }
Example #6
0
        public FaultException manejoWebError(WebException exp)
        {
            string msgResponse = string.Empty;

            WebResponse response = exp.Response;

            faultDetail = exp.InnerException != null ? exp.InnerException.Message : exp.Message;

            log.Error("Error en la ejecucion : " + faultDetail);

            if (response != null)
            {
                using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                {
                    msgResponse = sr.ReadToEnd();
                }
            }
            else
            {
                msgResponse = faultDetail;
            }

            log.Error("Respuesta ESIDIF - Servicio: " + Environment.NewLine + Functions.ParseXml(msgResponse));
            soapError = Functions.HandleWebExceptionXml(msgResponse);

            if (soapError != null)
            {
                faultFactor = "Economia";
                faultDetail = soapError.ErrorCode + " " + soapError.ErrorDescription;
            }

            node.InnerText = faultDetail;

            //return new FaultException(faultDetail, SoapException.ServerFaultCode, faultFactor, node);
            return(new FaultException(new FaultReason(faultDetail), new FaultCode(faultFactor), ""));
        }