Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Class.Business.clsMeters           oclsMeters  = new Class.Business.clsMeters();
            Class.Business.PropertiesDocuments oclsPropDoc = new Class.Business.PropertiesDocuments();
            LogErrorMedicion clsError = new LogErrorMedicion();

            if (!IsPostBack)
            {
                try
                {
                    string strEmail = (string)Session["email"];
                    if (string.IsNullOrEmpty(strEmail))
                    {
                        Response.Redirect("Default.aspx");
                    }

                    string strFile = (string)Request.QueryString["doc"];
                    if (!string.IsNullOrEmpty(strFile))
                    {
                        string strPathMeter = oclsMeters.GetPathUploadMeters();
                        strPathMeter = strPathMeter.Replace("~", "");
                        string strFileWithReplace = strFile.Replace(" ", "+");
                        oclsPropDoc = oclsMeters.DownloadFile(strFileWithReplace);
                        if (!string.IsNullOrEmpty(oclsPropDoc.strFileName.ToString()))
                        {
                            Boolean bmsg     = oclsMeters.InsertDownloadLogFile(strFileWithReplace, strEmail);
                            string  filePath = "\\" + strPathMeter + "\\" + oclsPropDoc.strRPU + "\\" + strFileWithReplace + oclsPropDoc.strFileExtension.ToString();
                            Response.ContentType = oclsPropDoc.strMimeType;
                            Response.AddHeader("Content-Disposition", "attachment;filename=\"" + oclsPropDoc.strFileName.ToString() + "\"");
                            Response.TransmitFile(Server.MapPath(filePath));
                            Response.End();
                        }
                    }
                }
                catch (Exception ex)
                {
                    clsError.logMessage = ex.ToString();
                    clsError.logModule  = "Page_Load";
                    clsError.LogWrite();
                }
            }
        }
Exemplo n.º 2
0
        public PropertiesDocuments DownloadFile(string strEncryptedFile)
        {
            PropertiesDocuments oclPropDoc = new PropertiesDocuments();

            LogError.LogErrorMedicion clsError = new LogError.LogErrorMedicion();
            DataTable dtData;

            try
            {
                string         query         = string.Format("spBuscarArchivoMedicion");
                SqlParameter[] sqlParameters = new SqlParameter[1];
                sqlParameters[0]       = new SqlParameter("@chrArchivo", SqlDbType.NVarChar);
                sqlParameters[0].Value = strEncryptedFile;
                con.dbConnection();
                dtData = con.executeStoreProcedure(query, sqlParameters);

                if (dtData.Rows.Count > 0)
                {
                    foreach (DataRow row in dtData.Rows)
                    {
                        oclPropDoc.strFileExtension = row["ExtensionArchivo"].ToString();
                        oclPropDoc.strFileName      = row["NombreArchivo"].ToString();
                        oclPropDoc.strMimeType      = row["TipoArchivo"].ToString();
                        oclPropDoc.strRPU           = row["RPU"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                clsError.logMessage = ex.ToString();
                clsError.logModule  = "GetFile";
                clsError.LogWrite();
                oclPropDoc = null;
            }

            return(oclPropDoc);
        }