Ejemplo n.º 1
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);
        }
 public void InitializeTest()
 {
     TestData = new TestData();
     AssignedServiceOfferingTemplatePath = Path.GetFullPath(ConfigurationManager.AppSettings["FileUploadTemplatePath"] + "Templates/" + ServiceOfferingController.TemplateFile);
     Target = new ExcelWriter();
 }
 public DownloadFileModel CreateTemplateDownload(EducationSecurityPrincipal user, string templatePath, int serviceOfferingId)
 {
     var offering = ServiceOfferingRepository.Items.Include(s => s.Provider).
                                                    Include(s => s.ServiceType).
                                                    Include(s => s.Program).
                                                    SingleOrDefault(s => s.Id == serviceOfferingId);
     if (offering == null)
     {
         return null;
     }
     if (!GrantUserAccessToUploadOffering(user, offering))
     {
         throw new EntityAccessUnauthorizedException("You are not have the appropriate rights to download this service offering.");
     }
     var processor = new WorksheetWriter(offering, ServiceOfferingSheetName);
     var fileName = string.Format(CultureInfo.InvariantCulture, "{0}{1}", offering.Name.GetSafeFileName(), ".xlsx");
     var downloadFile = new DownloadFileModel
     {
         FileName = fileName,
         BlobAddress = string.Empty
     };
     ExcelWriter writer = new ExcelWriter();
     writer.InitializeFrom(templatePath, processor);
     downloadFile.FileContentStream = writer.FileContentStream;
     downloadFile.FileContentStream.Position = 0;
     return downloadFile;
 }
 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);
 }
Ejemplo n.º 5
0
 public void InitializeTest()
 {
     TestData = new TestData();
     AssignedServiceOfferingTemplatePath = Path.GetFullPath(ConfigurationManager.AppSettings["FileUploadTemplatePath"] + "Templates/" + ServiceOfferingController.TemplateFile);
     Target = new ExcelWriter();
 }