Пример #1
0
        public DownloadFileModel RetrieveUploadErrorsFile(string blobAddress)
        {
            var memoryStream = new MemoryStream();
            var container    = BlobClient.CreateContainer(ServiceFileContainerName);

            container.DownloadToStream(blobAddress, memoryStream);
            var downloadFile = new DownloadFileModel
            {
                FileName          = blobAddress,
                FileContentStream = memoryStream
            };

            downloadFile.FileContentStream.Position = 0;
            return(downloadFile);
        }
Пример #2
0
        private void ProcessErrorFile(EducationSecurityPrincipal user, ServiceOffering offering, ServiceUploadModel model, string templatePath)
        {
            var fileName    = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", offering.Name.GetSafeFileName(), DateTime.Now.Ticks, ".xlsx");
            var blobAddress = string.Format("{0}-{1}-{2}", user.Identity.User.DisplayName, user.Identity.User.Id, fileName);

            model.ErrorDownloadFile = new DownloadFileModel
            {
                FileName    = fileName,
                BlobAddress = blobAddress
            };
            var         worksheetWriter = CreateWorksheetWriter(offering);
            ExcelWriter writer          = new ExcelWriter();

            writer.InitializeFrom(templatePath, worksheetWriter);
            foreach (var error in model.RowErrorValues)
            {
                worksheetWriter.ErrorRows.Add(error);
            }
            writer.AppendErrorRows(ServiceOfferingSheetName, worksheetWriter);
            writer.Write(BlobClient.CreateContainer(ServiceFileContainerName), model.ErrorDownloadFile.BlobAddress);
        }