private void cmdUpload_Click(object sender, System.EventArgs e) { if (fiUpload.PostedFile.FileName.Length == 0) { DisplayMessage("Please select a file to upload"); return; } FileSystem fs = new FileSystem(Globals.CurrentIdentity); string name = Path.GetFileName(fiUpload.PostedFile.FileName); SingleFileSource sfs = new SingleFileSource(name); try { sfs.CreateSource(fiUpload.PostedFile.InputStream); fs.ImportData(GetCurrentPath(), sfs, true, false); } catch (FileOperationException er) { DisplayMessage(er.Message); } BindFileGrid(); }
protected override int DoExecute(ITaskContextInternal context) { if (_sourcePackagingInfos.Count == 0) { return(0); } if (string.IsNullOrEmpty(_destinationRootDir)) { _destinationRootDir = context.Properties.GetOutputDir(); } FullPath df = new FullPath(_destinationRootDir); ICopier copier = new Copier(context, _logFiles); IZipper zipper = new Zipper(context); IDirectoryFilesLister directoryFilesLister = new DirectoryFilesLister(); StandardPackageDef packageDef = new StandardPackageDef(); CopyProcessor copyProcessor = new CopyProcessor(context, copier, df); List <string> sourceIds = new List <string>(); foreach (var sourceToPackage in _sourcePackagingInfos) { string sourceId; if (sourceToPackage.SourceType == SourceType.Directory) { var sourceFullPath = new FullPath(sourceToPackage.SourcePath); sourceId = sourceFullPath.GetHashCode().ToString(); DirectorySource directorySource = new DirectorySource(context, directoryFilesLister, sourceId, sourceFullPath, sourceToPackage.Recursive, sourceToPackage.DirectoryFilters); directorySource.SetFileFilter(sourceToPackage.FileFilters); packageDef.AddFilesSource(directorySource); } else { var fileFullPath = new FileFullPath(sourceToPackage.SourcePath); sourceId = fileFullPath.GetHashCode().ToString(); SingleFileSource fileSource = new SingleFileSource(sourceId, fileFullPath); packageDef.AddFilesSource(fileSource); } copyProcessor.AddTransformation(sourceId, sourceToPackage.DestinationPath); sourceIds.Add(sourceId); } IPackageDef copiedPackageDef = copyProcessor.Process(packageDef); if (ShouldPackageBeZipped) { string zipFile = _zipFileName; if (string.IsNullOrEmpty(zipFile)) { zipFile = _zipPrefix; _addVersionAsPostFixToZipFileName = true; _versionFieldCount = 3; } if (zipFile.EndsWith(".zip", StringComparison.OrdinalIgnoreCase)) { zipFile = zipFile.Substring(0, zipFile.Length - 4); } string tmp = _addVersionAsPostFixToZipFileName ? $"{zipFile}_{context.Properties.GetBuildVersion().Version.ToString(_versionFieldCount)}.zip" : $"{zipFile}.zip"; zipFile = Path.Combine(_destinationRootDir, tmp); DoLogInfo($"Creating zip file {zipFile}"); ZipProcessor zipProcessor = new ZipProcessor(context, zipper, new FileFullPath(zipFile), df, _optimizeZip, sourceIds, _logFiles); zipProcessor.Process(copiedPackageDef); } return(0); }