public async Task <IActionResult> History(string id) { string ser = id; //string ser = "J0251"; ViewData["Serial"] = ser; string prefix = Startup.AppSettings["AzureUrlPrefix"]; string container = Startup.AppSettings["CalCertContainer"]; var history = _context.CalDateRepository.GetRecords(r => r.Serial == ser); foreach (var entry in history) { entry.KindOfCal = ""; if (entry.IsCal == true) { entry.KindOfCal = "Cal"; } else if (entry.IsCal == false) { entry.KindOfCal = "Safety"; } string filename = entry.PdfFileName; if (!string.IsNullOrWhiteSpace(filename)) { string folder = AppResources.GetCalCertFolder(filename); entry.urlToFile = $"{prefix}{container}/{folder}/{filename}"; } else { entry.PdfFileName = ""; } } //await _hubContext.Clients.Client(ConId).SendAsync("HistoryFinished"); return(View(history)); }
public async Task <IActionResult> ShowPdf(string id) { string filename = id; string connectionstring = Startup.AppSettings["AzureBlob"]; string containerName = Startup.AppSettings["CalCertContainer"]; string folder = AppResources.GetCalCertFolder(filename); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionstring); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference(containerName); CloudBlockBlob blockBlob = container.GetBlockBlobReference(folder + @"/" + filename); MemoryStream ms = new MemoryStream(); await blockBlob.DownloadToStreamAsync(ms); string ty = "application/pdf"; //return File(ms.ToArray(),ty,filename); return(File(ms.ToArray(), ty)); }