protected InputFiles UploadFiles(HttpRequestBase Request, string _folderName) { try { //string _folderName = Guid.NewGuid().ToString(); var pathProcessor = new PathProcessor(_folderName); InputFiles _inputFiles = new InputFiles(); //foreach (string fileName in Request.Files) for (int i = 0; i < Request.Files.Count; i++) { HttpPostedFileBase postedFile = Request.Files[i]; if (postedFile != null) { // Check if File is available. if (postedFile != null && postedFile.ContentLength > 0) { string fn = System.IO.Path.GetFileName(postedFile.FileName); string _savepath = pathProcessor.SourceFolder + "\\" + fn; postedFile.SaveAs(_savepath); _inputFiles.Add(new InputFile(fn, _folderName, _savepath)); } } } return(_inputFiles); } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } }
public override bool IsValid() { if (!base.IsValid()) { return(false); } if (InputFiles == null || !InputFiles.Any()) { ValidationFailureList.Add("No input files found in report settings"); return(false); } if (Operations == null || !Operations.Any()) { ValidationFailureList.Add("No operations found in report settings"); return(false); } if (OutputFiles == null || !OutputFiles.Any()) { ValidationFailureList.Add("No output files found in report settings"); return(false); } return(true); }
public override bool Equals(object obj) { if (obj.GetType() != typeof(CommandLineOptions)) { return(false); } var other = (CommandLineOptions)obj; if (this.InputFiles.Count() != other.InputFiles.Count()) { return(false); } for (int i = 0; i < InputFiles.Count(); i++) { if (this.InputFiles.ElementAt(i) != other.InputFiles.ElementAt(i)) { return(false); } } return (this.Parser == other.Parser && this.DebugMode == other.DebugMode && this.UseOpenCover == other.UseOpenCover && this.CoverallsRepoToken == other.CoverallsRepoToken); }
public override bool Execute() { if (InputFiles == null) { Log.LogError("No input files!"); return(false); } try { var inputProjects = InputFiles .Select(file => file.GetMetadata("FullPath")) .Select(name => new ProjectReference(name, string.Empty, string.Empty)) .Select(reference => new ReferenceBundle(null, reference)); var processStack = new Stack <ReferenceBundle>(inputProjects); while (processStack.Count > 0) { var bundle = processStack.Pop(); Process(bundle.Parent, bundle.Reference, processStack); } Stream s = GenerateGraphVizOutput(); LogToConsole(s); LogToFile(s); } catch (Exception e) { Log.LogError("Exception: {0} at {1}", e, e.StackTrace); return(false); } return(true); }
/// <summary> /// Prepare upload files and return as documents /// </summary> /// <param name="inputType"></param> protected InputFiles UploadFiles(HttpRequestBase Request, string sourceFolder) { try { var pathProcessor = new PathProcessor(sourceFolder); InputFiles documents = new InputFiles(); for (int i = 0; i < Request.Files.Count; i++) { HttpPostedFileBase postedFile = Request.Files[i]; if (postedFile != null) { // Check if File is available. if (postedFile != null && postedFile.ContentLength > 0) { string _fileName = postedFile.FileName; string _savepath = pathProcessor.SourceFolder + "\\" + System.IO.Path.GetFileName(_fileName); postedFile.SaveAs(_savepath); documents.Add(new InputFile(_fileName, sourceFolder, _savepath)); } } } return(documents); } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } }
public override bool RunTask() { if (InputFiles == null || InputFiles.Count() == 0) { Log.LogCodedError("XA1020", Properties.Resources.XA1020); return(false); } if (References != null) { foreach (var path in References) { if (!Directory.Exists(path.ItemSpec) && !File.Exists(path.ItemSpec)) { Log.LogCodedError("XA1022", Properties.Resources.XA1022, path.ItemSpec); } } } if (Log.HasLoggedErrors) { return(false); } try { return(base.RunTask()); } finally { File.Delete(responseFilePath); } }
public override Exception Run(CancellationToken token) { LoadConfig("~/.config/taa/config.yml"); InputFiles = InputFiles.Any() ? InputFiles : Directory.EnumerateFiles(TargetDirectory); Logger.Info("Vtn:"); Logger.Info($"\tVoltage: {VtnVoltage}"); Logger.Info($"\tSigma: {VtnSigma}"); Logger.Info($"\tDeviation: {VtnDeviation}"); Logger.Info("Vtp:"); Logger.Info($"\tVoltage: {VtpVoltage}"); Logger.Info($"\tSigma: {VtpSigma}"); Logger.Info($"\tDeviation: {VtpDeviation}"); Logger.Info($"Total Files: {InputFiles.Count()}"); Logger.Info("Start push"); using (var bar = new ProgressBar(2, "Master", new ProgressBarOptions { ForegroundColor = ConsoleColor.DarkGreen, BackgroundCharacter = '-', ProgressCharacter = '>', CollapseWhenFinished = false })) { var opt = new ProgressBarOptions { ForegroundColor = ConsoleColor.DarkYellow, ProgressCharacter = '=', CollapseWhenFinished = false }; using (var pushBar = bar.Spawn(0, "Pushing...", opt)) using (var parseBar = bar.Spawn(InputFiles.Count(), "Parsing...", opt)) return(PushFiles(token, bar, parseBar, pushBar)); } }
public Response Protect(InputFiles files, string password) { if (files.Count == 0 || files.Count > MaximumUploadFiles) { return(MaximumFileLimitsResponse); } string outputType = ""; SetDefaultOptions(files, outputType); Opts.AppName = "Protect"; Opts.MethodName = "Protect"; Opts.FolderName = files[0].FolderName; Opts.ZipFileName = "Protect document"; return(Process((inFilePath, outPath, zipOutFolder) => { //DOC, DOCX, DOT, DOTX, Aspose.Words.Saving.SaveOptions saveOptions = new Aspose.Words.Saving.DocSaveOptions() { Password = password }; if (outputType.StartsWith("o")) //ODT, OTT { saveOptions = new Aspose.Words.Saving.OdtSaveOptions() { Password = password }; } Aspose.Words.Document document = new Aspose.Words.Document(inFilePath); document.Save(outPath, saveOptions); })); }
public void ValidateArguments() { if (argsCount % 2 != 0) { throw new Exception("Invalid number of arguments."); } if (!InputFiles.Any()) { throw new Exception("No input file specified."); } if (string.IsNullOrWhiteSpace(OutputFile)) { throw new Exception("No output file specified."); } foreach (var file in InputFiles) { if (!File.Exists(file)) { throw new Exception($"File [{file}] does not exist."); } } }
///<Summary> /// Convert method - NEW ///</Summary> public Response Convert(InputFiles docs, string sourceFolder, string outputType) { if (docs == null) { return(BadDocumentResponse); } if (docs.Count == 0 || docs.Count > MaximumUploadFiles) { return(MaximumFileLimitsResponse); } Opts.AppName = "ConversionApp"; Opts.MethodName = "Convert"; Opts.OutputType = outputType; //SetupQueryParameters(Opts.OutputType); Opts.ZipFileName = docs.Count == 1 ? Path.GetFileNameWithoutExtension(docs[0].FileName) : "Converted_Documents"; SetDefaultOptions(docs, outputType); Opts.ResultFileName = Opts.ZipFileName; Opts.FolderName = sourceFolder; List <string> FileNames = new List <string>(); foreach (InputFile inputFile in docs) { FileNames.Add(inputFile.LocalFileName); } return(Process((inFilePath, outPath, zipOutFolder) => { return ConvertFiles(FileNames.ToArray(), Opts.FolderName, Opts.OutputType); })); }
private void Init() { var javaDir = GetJavaDir(); if (javaDir == null) { return; } javaDir = Path.Combine(javaDir, "bin"); if (JavacPath == null) { JavacPath = Path.Combine(javaDir, "javac"); } if (JarPath == null) { JarPath = Path.Combine(javaDir, "jar"); } InputFiles = InputFiles.SelectMany(p => Directory.GetFiles(Path.GetDirectoryName(p), Path.GetFileName(p))) .ToArray(); if (JavacPath != null && (JarPath != null || NoJarBuild)) { return; } Console.Error.WriteLine("Could not determine java path. Please provide the javac Path and the jar Path."); Environment.Exit(1); }
public bool Execute() { var files = InputFiles .Select(x => x.ItemSpec) .Where(Generator.IsMetaSharpFile) .ToImmutableArray(); var buildConstants = new BuildConstants( intermediateOutputPath: IntermediateOutputPath, targetPath: OutDir, generatorMode: GeneratorMode.MsBuild ); var code = RealEnvironmentGenerator.Generate( files, buildConstants, error => BuildEngine.LogErrorEvent(ToBuildError(error)), output => OutputFiles = output.Select(x => new TaskItem(x)).ToArray() ); return(code == GeneratorResultCode.Success); //var type = compilation.GlobalNamespace.GetNamespaceMembers().ElementAt(0).GetNamespaceMembers().ElementAt(0).GetTypeMembers().Single(); //var tree = type.Locations.Single().SourceTree; //if(tree == compilation.SyntaxTrees.Single()) { //} //var node = compilation.SyntaxTrees.Single().GetRoot().DescendantNodes().OfType<ClassDeclarationSyntax>().First(); //var model = compilation.GetSemanticModel(compilation.SyntaxTrees.Single()); //var symbol = model.GetDeclaredSymbol(node); //if(symbol == type) { //} }
public override bool Execute() { var asyncCode = _rewriter.RewriteAndMerge(InputFiles.Select(f => f.ItemSpec).ToArray()); File.WriteAllText(OutputFile.ItemSpec, asyncCode); return(true); }
public bool IsDirty() { if (isDirtyOverride) { return(true); } var schemaFiles = InputFiles .Select(file => detailsStore.FileTree.GetFullPathForRelativeSchema(file)) .Select(path => fileSystem.GetFileInfo(path)) .ToList(); var existingFiles = OutputFiles .Select(entry => fileSystem.GetFileInfo(Path.Combine(OutputDirectory, entry))) .ToList(); if (schemaFiles.Count == 0 || existingFiles.Count == 0) { return(true); } //Ensure that all expected output files exist foreach (var file in existingFiles) { if (!file.Exists()) { return(true); } } var sortedSchemaFileInfo = schemaFiles.OrderByDescending(item => item.LastWriteTime).ToList(); var sortedExistingFiles = existingFiles.OrderByDescending(item => item.LastWriteTime).ToList(); return(sortedSchemaFileInfo.First().LastWriteTime > sortedExistingFiles.First().LastWriteTime); }
/// <summary> /// Gets the correct file path from the file input. /// </summary> /// <returns>Collection of file paths.</returns> private IEnumerable <string> GetFilesFromInput() { return(InputFiles.Select(x => new { Path = Path.GetDirectoryName(x), Filter = Path.GetFileName(x) }).SelectMany(x => Directory.EnumerateFiles(x.Path, x.Filter))); }
public override bool Execute() { var result = ExpressionComparerWriter.Write(InputFiles.Select(c => c.ItemSpec).ToArray()); File.WriteAllText(OutputFile.ItemSpec, result); return(true); }
///<Summary> /// Unlock method ///</Summary> public Response Unlock(InputFiles files, string outputType, string passw) { if (files.Count == 0 || files.Count > MaximumUploadFiles) { return(MaximumFileLimitsResponse); } SetDefaultOptions(files, outputType); Opts.AppName = "Unlock"; Opts.MethodName = "Unlock"; Opts.ZipFileName = "Unlocked documents"; Opts.FolderName = files[0].FolderName; var lck = new object(); var catchedException = false; var strError = new StringBuilder(); var docs = new Document[files.Count]; for (var i = 0; i < files.Count; i++) { try { docs[i] = new Document(files[i].FullFileName, new LoadOptions(passw)); } catch (IncorrectPasswordException ex) { lock (lck) { strError.Append($"File \"{files[i].FileName}\" - {ex.Message}"); catchedException = true; } } catch (Exception ex) { Console.WriteLine(ex.Message); lock (lck) catchedException = true; } } if (!catchedException) { return(Process((inFilePath, outPath, zipOutFolder) => { var tasks = docs.Select(doc => Task.Factory.StartNew(() => { SaveDocument(doc, outPath, zipOutFolder); })).ToArray(); Task.WaitAll(tasks); })); } return(new Response { Status = strError.Length > 0 ? strError.ToString() : "Exception during processing", StatusCode = 500 }); }
protected override void Execute(CodeActivityContext context) { var inputFiles = InputFiles.Get(context); var outputFile = OutputFile.Get(context); var mergeFiles = MergeFiles(inputFiles, outputFile, KeepHeaders, IgnoreColumnDifferences, AddFileNames); FilesMerged.Set(context, mergeFiles.FilesMerged.ToArray()); FilesSkiped.Set(context, mergeFiles.FilesSkiped.ToArray()); }
/// <summary> /// Executes the concatenate command. /// </summary> /// <param name="fileSystem">The file system on which the command is going to be executed.</param> public override void Execute(Models.FileSystem fileSystem) { var hasInputFiles = InputFiles.Any(); var hasOutputFile = !string.IsNullOrWhiteSpace(OutputFile); if (hasInputFiles && hasOutputFile) { try { var concatenatedContent = ConcatenateFiles(fileSystem); fileSystem.CreateContentFile(OutputFile, concatenatedContent); } catch (InvalidOperationException operationException) { Console.WriteLine(operationException.Message); } catch (ArgumentException argumentException) { Console.WriteLine(argumentException.Message); } } else if (hasInputFiles) { try { var concatenatedContent = ConcatenateFiles(fileSystem); Console.Write(concatenatedContent); } catch (InvalidOperationException operationException) { Console.WriteLine(operationException.Message); } } else if (hasOutputFile) { var userInput = ReadUserInput(); try { fileSystem.CreateContentFile(OutputFile, userInput); } catch (InvalidOperationException operationException) { Console.WriteLine(operationException.Message); } catch (ArgumentException argumentException) { Console.WriteLine(argumentException.Message); } } else { Console.WriteLine("Couldn't execute cat command. Please check the validity of the passed parameters."); } }
protected async Task ButtonFileClicked(string fieldName) { var inputFile = InputFiles.Get(fieldName); var type = inputFile.Variable.GetType(); if (type == typeof(AgnoInputFile) && ((AgnoInputFile)inputFile.Variable).InputFileElement.Id != null) { await jSRuntime.InvokeVoidAsync("gridJsFunctions.click", (ElementReference)((AgnoInputFile)inputFile.Variable).InputFileElement); } }
private IEnumerable <SourceToDestinationMap <FileInfoBase> > MapSourcesToDestination() { var fullOutputDir = _fileSystem.Path.GetFullPath(OutputDir); var alloutputs = InputFiles.Select(i => Path.Combine(fullOutputDir.TrimEnd('/', '\\'), i.ItemSpec.Trim('/', '\\'))); var something = alloutputs.ToArray(); var allOutputs = something.Select(s => _fileSystem.FileInfo.FromFileName(s)).ToArray(); return(allOutputs.Select(i => new SourceToDestinationMap <FileInfoBase> { Source = i, Destination = i })); }
public override bool Execute() { var items = InputFiles.Select(item => item.ItemSpec).ToList(); if (!Directory.Exists(OutputFiles.Trim())) { Directory.CreateDirectory(OutputFiles.Trim()); } Log.LogMessage($"Namespace: {Namespace}"); Log.LogMessage($"Input files: {string.Join(", ", items)}"); Log.LogMessage($"Output path: {OutputFiles}"); items.ForEach(x => Generate(x, OutputFiles)); return(true); }
private void PopulateInputData() { string[] filePaths = Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Input\\"); foreach (var epsFileName in filePaths.Where(n => n.Contains("EPS"))) { string[] words = epsFileName.Split('_'); if (words != null && words.Length > 0) { string hotelBedFileName = filePaths.FirstOrDefault(n => n.Contains(words[0]) && n.Contains("HB")); InputFiles.Add(new InputFile(Path.GetFileName(words[0]), epsFileName, hotelBedFileName)); } } }
public FakeFileSystem() { FileOperation = new FileOperation( readFile: file => InputFiles[file.NormalizeDirectorySeparators()], writeFile: (file, content) => OutputFiles[file.NormalizeDirectorySeparators()] = content, fileExists: file => InputFiles.ContainsKey(file.NormalizeDirectorySeparators()), createDirectory: dir => { }, fileCopy: (source, dest, overwrite) => { }); // Unfortunately DotLiquid uses a mutable static field for its reference to the root directory. // It's fine for non-test scenarios because the root won't change, but it makes unit testing // with different roots a bit of a pain. So we define the static field centrally so all unit tests // use the same root. Template.FileSystem = new NessieLiquidFileSystem(FileOperation, Root); }
private CommandLineOptions(Context context) { context.put(CONTEX_KEY, this); optionSet = new OptionSet { { "v|verbose", s => Verbose = true }, { "dump-tree", s => DumpTree = true }, { "pretty-print-tree", s => PrettyPrintTree = true }, { "h|help", s => ShowHelp = true }, { "<>", "Input files", s => InputFiles.Add(s), true }, { "o|output=", "Output file path", s => OutPath = s }, { "dump-ir", "Dump LLVM IR", s => DumpIR = true }, { "exec", "Execute inside the compiler", s => Execute = true } }; }
public override bool Execute() { try { bool firstFile = true; // iterate throught the input files string[] inputs = InputFiles.Split(new char[1] { ';' }); foreach (string inputFile in inputs) { if (!File.Exists(inputFile)) { // Log non-existent file Log.LogError("Cannot find file " + inputFile); return(false); } string outfile = OutputFileName(inputFile); if (outfile == null) { Log.LogError("Invalid output file from input " + inputFile, null); return(false); } if (MustRebuild(outfile, inputFile)) { File.Delete(outfile); if (!Process(inputFile, outfile, firstFile)) { Log.LogError("Build failed: " + inputFile, null); return(false); } } else { //Log.LogMessage("Nothing to be done for " + outfile); } firstFile = false; } } catch (Exception ex) { Console.WriteLine("CompileTask.Execute threw exception " + ex.Message); throw; } return(true); }
/// <summary> /// Combines all of the InputFiles and writes it to disk. /// </summary> /// <returns>The final video's output path.</returns> public VideoMergeOutput CombineAndWrite() { var output = new VideoMergeOutput(); try { output.FileOutputPath = Path.Combine(InputFiles.First().DirectoryName, Store.Data.Record.LastVideoName + ".mp4"); if (InputFiles.Count == 1) { // Remove _part 1 from the file name, but don't concatenate InputFiles.First().MoveTo(output.FileOutputPath); OutputFile = new FileInfo(output.FileOutputPath); return(output); } TempFileList = new FileInfo(Path.GetTempFileName()); using (var sw = new StreamWriter(TempFileList.FullName)) { foreach (FileInfo file in InputFiles) { sw.WriteLine($"file '{file.FullName}'"); } } FFMpegConverter ffMpegConverter = new FFMpegConverter(); OutputFile = new FileInfo(output.FileOutputPath); string ffmpegArgs = $"-f concat -safe 0 -i \"{TempFileList.FullName}\" -movflags +faststart -c copy \"{OutputFile.FullName}\""; ffMpegConverter.Invoke(ffmpegArgs); DeleteInputFiles(); DeleteTemporaryFiles(); } catch (Exception ex) { DeleteTemporaryFiles(); output.IsSuccessful = false; output.MergeFailureReason = ex.Message; } return(output); }
/// <summary> /// Run the task! /// </summary> /// <returns></returns> public override bool Execute() { /// /// Go through each of the input items and match them to output items, and parse them. /// var pairedFiles = InputFiles.Zip(OutputFiles, (i1, i2) => Tuple.Create(i1, i2)); foreach (var p in pairedFiles) { if (!RenderDataModel(p.Item1, p.Item2)) { return(false); } } return(true); }
/// <summary> /// Normalizes the input files. The <see cref="Compiler.NormalizeProject" /> method is invoked via reflection in order to /// control assembly loading behavior so that the compiler assembly is not locked on disk. /// </summary> private string[] Normalize() { var assembly = LoadAssembly("SafetySharp.Compiler"); if (assembly == null) { throw new InvalidOperationException("Unable to find the S# compiler."); } var compilerType = assembly.GetType("SafetySharp.Compiler.Compiler"); var compiler = Activator.CreateInstance(compilerType, new[] { Log }); var method = compilerType.GetMethod("NormalizeProject", BindingFlags.Instance | BindingFlags.Public); var normalize = (Normalizer)Delegate.CreateDelegate(typeof(Normalizer), compiler, method); return(normalize(InputFiles.Select(f => f.ItemSpec).ToArray(), References.Select(r => r.ItemSpec).ToArray(), IntermediateDirectory.ItemSpec)); }
public override bool Execute() { var filesToAdd = new List <ITaskItem>(); var projPath = Path.GetDirectoryName(CurrentProject.ItemSpec); var objPath = Path.Combine(projPath, "obj"); Directory.CreateDirectory(objPath); foreach (var filePath in InputFiles.Select(f => f.ItemSpec)) { var name = Path.GetFileNameWithoutExtension(filePath); var fullName = Path.Combine(objPath, $"{name}.g.cs"); /*if(!File.Exists(fullName))*/ filesToAdd.Add(new TaskItem(fullName)); string ns = GetNamespace(filePath); var generator = new CodeGeneratorForXaml(name, ns); using var file = File.Open(fullName, FileMode.OpenOrCreate, FileAccess.ReadWrite); file.SetLength(0); using StreamWriter writer = new (file); generator.Generate(writer); /*XamlReader r = new (filePath); * XamlObject obj = r.Parse(); * * CodeGenerator gen = new (name, "DotX.Sample"); * * using var file = File.Open(fullName, FileMode.OpenOrCreate, FileAccess.ReadWrite); * file.SetLength(0); * using StreamWriter writer = new (file); * * gen.GenerateCodeForObject(obj, writer);*/ } FilesToAdd = filesToAdd.ToArray(); return(true); }