Пример #1
0
        public ActionResult Detalle(int Email_ID)
        {
            try { this.EmailProxy = new ADESCOMBUSINESS.Areas.Email.Methods.EmailBusiness((ADESCOMBUSINESS.DataAccess.Models.LoginRS)Session["InfoUser"]); }
            catch (Exception ex) { return(RedirectToAction("SesionExpired", "Inicio", new { Area = "", Mensaje = ex.Message })); }
            ADESCOMBUSINESS.Areas.Email.Models.VwEMA_Emails Email = new ADESCOMBUSINESS.Areas.Email.Models.VwEMA_Emails();
            Email = EmailProxy.GetViewByEmail_ID(Email_ID);

            ViewBag.AdjuntoName = Email.EMA_AdjuntoName;
            ViewBag.AdjuntoFile = Email.EMA_AdjuntoURL;

            ADESCOMBUSINESS.DataAccess.Models.CompanyInfo CompanyInfo = (ADESCOMBUSINESS.DataAccess.Models.CompanyInfo)Session["CompanyInfo"];

            int cantLlaves = CompanyInfo.CantLlaves;

            ViewBag.DescLlave1 = CompanyInfo.LabelLlave1;
            ViewBag.DescLlave2 = CompanyInfo.LabelLlave2;
            ViewBag.DescLlave3 = CompanyInfo.LabelLlave3;

            switch (cantLlaves)
            {
            case 1:
                return(View("Detalle1", Email));

            case 2:
                return(View("Detalle2", Email));

            case 3:
                return(View("Detalle3", Email));
            }

            return(null);
        }
Пример #2
0
        public ActionResult Descargar(int Email_ID)
        {
            try { this.EmailProxy = new ADESCOMBUSINESS.Areas.Email.Methods.EmailBusiness((ADESCOMBUSINESS.DataAccess.Models.LoginRS)Session["InfoUser"]); }
            catch (Exception ex) { return(RedirectToAction("SesionExpired", "Inicio", new { Area = "", Mensaje = ex.Message })); }
            ADESCOMBUSINESS.Areas.Email.Models.VwEMA_Emails Email = new ADESCOMBUSINESS.Areas.Email.Models.VwEMA_Emails();
            Email = EmailProxy.GetViewByEmail_ID(Email_ID);

            try
            {
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);

                // Create the blob client.
                var blobClient = storageAccount.CreateCloudBlobClient();

                // Get a reference to a container, which may or may not exist.
                var container = blobClient.GetContainerReference("archivosadjuntos");

                // Get a reference to a blob, which may or may not exist.
                var blob = container.GetBlockBlobReference(Email.EMA_AdjuntoName);

                var fileStream = new System.IO.MemoryStream();
                blob.DownloadToStream(fileStream);

                //var imgPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + Email.EMA_AdjuntoName);
                //blob.DownloadToFile(imgPath, FileMode.Create);

                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Email.EMA_AdjuntoName);
                fileStream.WriteTo(Response.OutputStream);
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
            }

            return(null);
        }