public void AddFile() { try { var file = SourceFiles[CurrentFile]; var srcFile = file.Key; var destFile = file.Value; // We can only save files if (srcFile.IsFile && !srcFile.EntityName.StartsWith(".") && destFile.IsFile) { ZipArchiveEntry archiveEntry = Archive.CreateEntry(destFile.Path.Substring(1), compressionLevel); using (Stream entryStream = archiveEntry.Open()) { var stream = new MemoryStream(FileLoadHelper.ReadAllBytes(srcFile.Path)); stream.CopyTo(entryStream); } } CurrentFile++; StepCompleted(); } catch (Exception e) { Response["error"] = e.Message; Response["success"] = false; // Finish running the exporter since there was an error currentStep = totalSteps; } }
public override void LoadSourceData() { if (FileLoadHelper != null) { JsonString = Encoding.UTF8.GetString(FileLoadHelper.ReadAllBytes(SourcePath)); } StepCompleted(); }
/// <summary> /// Parses a list of biological sequence data from a file. /// </summary> /// <param name="filename">The name of a biological sequence file.</param> /// <param name="isReadOnly"> /// Flag to indicate whether the resulting QualitativeSequences should be in readonly mode or not. /// If this flag is set to true then the resulting QualitativeSequences's isReadOnly property /// will be set to true, otherwise it will be set to false. /// </param> /// <returns>The list of parsed IQualitativeSequence objects.</returns> new public IList <IQualitativeSequence> Parse(string filename, bool isReadOnly) { _fileName = filename; //check DV is requried if (filename != null) { _fileLoadHelper = new FileLoadHelper(filename); _blockSize = _fileLoadHelper.BlockSize; _maxNumberOfBlocks = _fileLoadHelper.MaxNumberOfBlocks; if (_isDataVirtualizationForced) { _blockSize = FileLoadHelper.DefaultBlockSize; } } else { _blockSize = FileLoadHelper.DefaultFullLoadBlockSize; _maxNumberOfBlocks = 0; } SidecarFileProvider indexedProvider = null; // Check for sidecar if (IsDataVirtualizationEnabled) { try { indexedProvider = SidecarFileProvider.GetProvider(filename); } catch (OperationCanceledException) { indexedProvider = null; } } if (indexedProvider != null) { // Create virtual list and return return(new VirtualQualitativeSequenceList(indexedProvider, this, indexedProvider.Count) { CreateSequenceAsReadOnly = isReadOnly }); } else { using (BioTextReader bioReader = new BioTextReader(filename)) { return(Parse(bioReader, isReadOnly)); } } }