public PersonProcessor(List<string> lines) { var processor = new FileProcessor<Person>(); Persons = processor.ProcessLines(lines).ToList(); }
public void WhenTheFileCopierRuns() { string[] args = new string[3]; args[0] = "Source"; args[1] = _fileName; args[2] = _fileName; FileProcessor.Process(args); }
public void GetUploadUri() { FileProcessor sut = new FileProcessor(); string uri = sut.GetUploadUri(); //Assert.Equal("http://dontcodetired.com/", uri); Assert.Equal("http://dontcodetired.com/blog", uri); }
public void ZipFiles() { File.Delete(outputZipFile); FileProcessor sut = new FileProcessor(); sut.ZipDirectory(inputDirectory, outputZipFile); Assert.True(File.Exists(outputZipFile)); }
private static void ProcessSingleFile(string filePath) { Console.WriteLine("Gavau bylos varda {0}", filePath); var fileProcessor = new FileProcessor(filePath); fileProcessor.Process(); }
public void GetUploadUri() { FileProcessor sut = new FileProcessor(); string uri = sut.GetUploadUri(); //Assert.Equal("https://elixirhand.com/", uri); Assert.Equal("http://elixirhand.com/opinion", uri); }
public void TestNumberOfFilesFetched(int noOfFilesResult) { string testFolder = GetTestDataFolder(); IFileProcessor fileProcessor = new FileProcessor(); FileTypes fileTypes = FileTypes.GetFileTypes(); int fileCount = fileProcessor.FetchAllDataFiles(fileTypes, testFolder).Count(); Assert.AreEqual(noOfFilesResult, fileCount); }
public static FileProcessor readClass() { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(@"C:\Users\Biebem\Downloads\MyFile.bin", FileMode.Open, FileAccess.Read, FileShare.Read); FileProcessor obj = (FileProcessor)formatter.Deserialize(stream); stream.Close(); return(obj); }
public MockViewModel() { // todo: find a way to detect project dir at design time string path = @"C:\Dev\HotsStats\StatsDisplay\bin\Debug\"; App.Game = FileProcessor.ProcessLobbyFile(path + @"replay.server.battlelobby"); FileProcessor.ProcessReplayFile(path + @"replay.StormSave", App.Game); OnActivated(); }
public void ScanFolder() { string searchPattern = SearchPattern.Log; var repo = new DisconnectedRepository(); var fileProcessor = new FileProcessor(); LocalSetting setting = repo.GetLocalSettings(); string folderPath = @"" + setting.FolderPath; var filesToProcess = fileProcessor.FindNewFiles(folderPath, searchPattern); var ipDetails = repo.GetIpDetails(); List <string> ipNumbers = ipDetails.Select(p => p.IpNumber).ToList(); List <string> scannedIpNumbers = new List <string>(); Guid id = new Guid(); var logProcessor = new LogProcessor(); foreach (var logFile in filesToProcess) { var linesToProcess = logProcessor.FindNewlogLines(logFile); var fileInDatabase = repo.GetLogFileByFileName(logFile.FileName); if (fileInDatabase != null) { id = fileInDatabase.LogFileId; } else { id = logFile.LogFileId; repo.AddNewLogFile(logFile); } foreach (var logLine in linesToProcess) { scannedIpNumbers.Add(logLine.IpClient); logLine.LogFileId = id; repo.AddNewLogLine(logLine); } } var newIpNumbers = scannedIpNumbers.Except(ipNumbers); foreach (var item in newIpNumbers) { var ipDetail = new IpDetail(); ipDetail.IpNumber = item; repo.AddNewIpDetail(ipDetail); Console.WriteLine(item); } }
static void Main(string[] args) { Log("Starting Processing Images...\n"); string[] images = FileCrawler.GetAllFilesByExt("png", System.IO.Directory.GetCurrentDirectory() + @"\Sprites\"); if (FileProcessor.CreateFile("ImageData", System.IO.Directory.GetCurrentDirectory() + @"\Sprites\", images)) { Log(" Processing Images Complete!\n", System.ConsoleColor.Green); } System.Console.ReadKey(true); }
public void button3_Click(object sender, EventArgs e) { var res = string.Empty; openFileDialog1 = new OpenFileDialog(); if (openFileDialog1.ShowDialog() == DialogResult.OK) { FileProcessor.ReadFile(); } }
public void AddFile() { ZipFiles(); FileProcessor sut = new FileProcessor(); sut.AddToZip(outputZipFile, @"c:\psdata\AnExtraFile.txt"); // Asserts omitted }
public ActionResult DownloadUploadErrors(string id) { var downloadFile = FileProcessor.RetrieveUploadErrorsFile(id); if (downloadFile == null) { return(HttpNotFound()); } return(File(downloadFile.FileContentStream, ExcelWriter.ContentType, downloadFile.FileName)); }
public void RemoveFile() { ZipFiles(); FileProcessor sut = new FileProcessor(); sut.RemoveFromZip(outputZipFile, @"somefiles\text1.txt"); // Asserts omitted }
public void ReadFile() { string path = @"C:\Users\Björn\Google Drive\Företag och affärsidéer\DOC\Kunder\Aleris\"; path = path + @"Granskning Feb 2021 Röntgen Aleris Närsjukhus.xlsx"; DataSet ds = FileProcessor.ReadFile(path); Assert.NotNull(ds); }
public void TestCopyFilesWithEvent() { var processor = new FileProcessor(); processor.Processed += this.Processor_Processed; processor.CopyFiles(_tempFiles, new DirectoryInfo(Path.GetTempPath())); processor.Processed -= this.Processor_Processed; }
private void ScanDirectory() { if (!Directory.Exists(_parms.DistributionDirectory)) { throw new ApplicationException("Directory does not exist: " + _parms.DistributionDirectory); } FileProcessor.Process(_parms.DistributionDirectory, null, ScanFile, true); }
public void SetUp() { fileProcessor = new FileProcessor(); fileService = new FileService(fileProcessor); dataDirectory = @"..\\..\\data\"; files = Directory.GetFiles(dataDirectory); fileService.ProcessFile(files[0]); }
private static async Task <bool> GoOptimize(string dir, Config config) { var processingState = new FilesProcessingState(); var fileOptimizer = new FileOptimizerProcessor(config.FileOptimizerFullExePath, FolderHelperMethods.TempDirectoryForTests.Value); var fileProcessor = new FileProcessor(fileOptimizer, processingState); await fileProcessor.ProcessDirectory(dir); return(processingState.FailedFiles.Any()); }
public void TearDown() { fileProcessor = null; fileService = null; dataDirectory = string.Empty; for (var i = 0; i < files.Length; i++) { files[i] = string.Empty; } }
/// <summary> /// Adds the contents of a directory to the list of images to be opened. /// </summary> /// <param name="directory">The directory containing files to be opened.</param> /// <param name="recursive">True if the files of subdirectories should be recursively added; False otherwise.</param> public void AddDirectory(string directory, bool recursive) { Platform.CheckForNullReference(directory, "directory"); if (!Directory.Exists(directory)) { throw new ArgumentException("Invalid directory path.", "directory"); } FileProcessor.Process(directory, "*.*", _filenames.Add, recursive); }
public async Task ProcessFileAsync_ChangeTypeChange_Success() { FileTriggerAttribute attribute = new FileTriggerAttribute(attributeSubPath, "*.dat"); processor = CreateTestProcessor(attribute); string testFile = WriteTestFile("dat"); FunctionResult result = new FunctionResult(true); mockExecutor.Setup(p => p.TryExecuteAsync(It.IsAny <TriggeredFunctionData>(), It.IsAny <CancellationToken>())).ReturnsAsync(result); // first process a Create event string testFilePath = Path.GetDirectoryName(testFile); string testFileName = Path.GetFileName(testFile); FileSystemEventArgs eventArgs = new FileSystemEventArgs(WatcherChangeTypes.Created, testFilePath, testFileName); bool fileProcessedSuccessfully = await processor.ProcessFileAsync(eventArgs, CancellationToken.None); Assert.True(fileProcessedSuccessfully); // now process a Change event File.WriteAllText(testFile, "update"); eventArgs = new FileSystemEventArgs(WatcherChangeTypes.Changed, testFilePath, testFileName); fileProcessedSuccessfully = await processor.ProcessFileAsync(eventArgs, CancellationToken.None); Assert.True(fileProcessedSuccessfully); string expectedStatusFile = processor.GetStatusFile(testFile); Assert.True(File.Exists(testFile)); Assert.True(File.Exists(expectedStatusFile)); string[] lines = File.ReadAllLines(expectedStatusFile); Assert.Equal(4, lines.Length); StatusFileEntry entry = (StatusFileEntry)_serializer.Deserialize(new StringReader(lines[0]), typeof(StatusFileEntry)); Assert.Equal(ProcessingState.Processing, entry.State); Assert.Equal(WatcherChangeTypes.Created, entry.ChangeType); Assert.Equal(InstanceId.Substring(0, 20), entry.InstanceId); entry = (StatusFileEntry)_serializer.Deserialize(new StringReader(lines[1]), typeof(StatusFileEntry)); Assert.Equal(ProcessingState.Processed, entry.State); Assert.Equal(WatcherChangeTypes.Created, entry.ChangeType); Assert.Equal(InstanceId.Substring(0, 20), entry.InstanceId); entry = (StatusFileEntry)_serializer.Deserialize(new StringReader(lines[2]), typeof(StatusFileEntry)); Assert.Equal(ProcessingState.Processing, entry.State); Assert.Equal(WatcherChangeTypes.Changed, entry.ChangeType); Assert.Equal(InstanceId.Substring(0, 20), entry.InstanceId); entry = (StatusFileEntry)_serializer.Deserialize(new StringReader(lines[3]), typeof(StatusFileEntry)); Assert.Equal(ProcessingState.Processed, entry.State); Assert.Equal(WatcherChangeTypes.Changed, entry.ChangeType); Assert.Equal(InstanceId.Substring(0, 20), entry.InstanceId); }
private bool Open(string filename) { if (!FileProcessor.CanHandleFile(filename)) { // TODO: show message. } else { if (FileProcessor.ContainsMeshData(filename)) { if (filename.EndsWith(".ele") || DarkMessageBox.Show("Import mesh", Settings.ImportString, "Do you want to import the mesh?", MessageBoxButtons.YesNo) == DialogResult.OK) { input = null; try { mesh = FileProcessor.Import(filename); } catch (Exception e) { DarkMessageBox.Show("Import mesh error", e.Message, MessageBoxButtons.OK); return(false); } if (mesh != null) { statisticView.UpdateStatistic(mesh); // Update settings settings.CurrentFile = Path.GetFileName(filename); HandleMeshImport(); btnSmooth.Enabled = true; // TODO: Remove } // else Message return(true); } } input = FileProcessor.Read(filename); } if (input != null) { // Update settings settings.CurrentFile = Path.GetFileName(filename); HandleNewInput(); } // else Message return(true); }
public void createArchive_test() { //ARRANGE string local_folder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string metadataFilePath = @"Test_Docs\Trade_License_Sample.txt"; var mockDB_Context = new TestDBContext(); string expected_module = "TRADE_APP"; // "CDR_TRADELICENSE"; string expected_file_name = "13GTD1000 NEW TEMP 2013.PDF"; //ACTION - 1 setupdata int result = FileProcessor.loadMetadata(mockDB_Context, metadataFilePath); string result_module = mockDB_Context.Records.First().Hansen_Module; string result_file_name = mockDB_Context.Records.Single(r => r.B1_ALT_ID == "13GTD1000-TRD").Documents.Single(d => d.MSD_path == @"00\00\20\1078703").File_Name; //ASSERT Assert.AreEqual(expected_module, result_module); Assert.AreEqual(expected_file_name, result_file_name); //ARRANGE - 2 - load documents into documents database. foreach (var rec in mockDB_Context.Records) { foreach (var doc in rec.Documents) { mockDB_Context.Documents.Add(doc); } } int expected_files_archived = 10; // set in config string expected_dir = @"c:\TEST_TARGET"; // clean up system foreach (var filePath in System.IO.Directory.GetFiles(expected_dir)) { System.IO.File.Delete(filePath); } //action - 2 - run archive int result_files_archived = FileProcessor.createArchive(mockDB_Context, local_folder, expected_dir, 2); //ASSERT Assert.AreEqual(expected_files_archived, result_files_archived); Assert.IsTrue(System.IO.Directory.Exists(expected_dir)); Assert.AreEqual(2, System.IO.Directory.GetFiles(expected_dir).Count()); // clean up system foreach (var filePath in System.IO.Directory.GetFiles(expected_dir)) { System.IO.File.Delete(filePath); } Assert.AreEqual(0, System.IO.Directory.GetFiles(expected_dir).Count()); }
public void GetClosestCustomersTest() { var customers = TestCustomers; var closeCustomers = FileProcessor.GetClosestCustomers(customers, new Location(53.2779097, -6.1145984), 100); Assert.AreEqual(2, closeCustomers.Count); Assert.AreEqual(customers[1].Name, closeCustomers[0].Name); Assert.AreEqual(customers[0].Name, closeCustomers[1].Name); Assert.AreEqual(customers[1].UserId, closeCustomers[0].UserId); Assert.AreEqual(customers[0].UserId, closeCustomers[1].UserId); }
internal static void archive_data(int archive_count = 1, int files = 10) { for (int i = 0; i < archive_count; i++) { FileProcessor.createArchive2( new EbDocContext(), System.Configuration.ConfigurationManager.AppSettings["SourceLocation"], System.Configuration.ConfigurationManager.AppSettings["TargetLocation"], files); } }
public void GivenAnEmptyDirectoryParameter_WhenGetFilesToMoveIsCalled_ThenAnArgumentExceptionWillBeThrown() { //arrange var config = new TemplateConfig(); var prompts = new Dictionary <string, object>(); //act Assert.Throws <ArgumentException>(() => FileProcessor.GetFilesToMove("", config, prompts)); //assert }
internal async void ProcessReplayFile(string path) { await FileProcessor.ProcessReplayFile(path, Game); _currentWindow?.Close(); _currentWindow = new RecapStatsWindow(); if (Settings.AutoShow) { _currentWindow.Show(); } }
public void TestFileArchivalForPartialFolder() { Mock <IArchivalHandler> mockArchivalHandler = new Mock <IArchivalHandler>(); mockArchivalHandler.Setup(x => x.CreateDirectory(It.IsAny <string>())).Returns(true); mockArchivalHandler.Setup(x => x.MoveFile(It.IsAny <string>(), It.IsAny <string>())).Returns(FileProcessStatus.FileSuccessfullyMoved); FileProcessor fileProcessor = new FileProcessor(); FileProcessStatus fileProcessStatus = fileProcessor.ArchiveFile(It.IsAny <string>(), It.IsAny <string>(), FileArchivalType.PartiallyProccessed, mockArchivalHandler.Object); Assert.AreEqual(FileProcessStatus.FileSuccessfullyMoved, fileProcessStatus); }
static void Main(string[] args) { FileProcessor p = new FileProcessor(); var r = p.Process("C:\\Temp"); Console.WriteLine("TotalFileCount = {0}", r.TotalFileCount); Console.WriteLine("TotalDirectoryCount = {0}", r.TotalDirectoryCount); Console.WriteLine("HiddenFileCount = {0}", r.HiddenFileCount); Console.WriteLine("HiddenDirectoryCount = {0}", r.HiddenDirectoryCount); Console.WriteLine("There is {0} unaccessible file(s).", r.UnaccessibleFileCount); }
/// <summary> /// Initializes a new instance of the <see cref="MainWindow"/> class. /// </summary> public MainWindow() { InitializeComponent(); Build = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); //windowTitle = "Bat Log File Processor " + Build; this.Title = windowTitle + Build; this.InvalidateArrange(); fileBrowser = new FileBrowser(); fileProcessor = new FileProcessor(); batSummary = new BatSummary(); }
public DebugGameManager(string debugServerIndex) { processor= Global.Require<FileProcessor>("./uglify5.js"); myServerManager = new DebugGameClientManager(debugServerIndex); myServerManager.OnGameCreate += CreateGame; myServerManager.OnHandleDebugResponse += HandleDebugResponse; myServerManager.OnGameDestroy += GameDestroy; myServerManager.OnUserAnswerQuestion += UserAnswerQuestion; myServerManager.OnUserDisconnect += UserDisconnect; myServerManager.OnUserLeave += UserLeave; rooms = new List<DebugGameRoom>(); gameData = new DebugGameData(); dataManager = new DataManager(); Global.SetInterval(flushQueue, 50); }
public static void Initialise(MainWindowViewModel model) { // bootstrap dependenties // TODO: use IoC container for that var logger = new FileLogger(); // load plugins FileLoaderConfigurationSection config = FileLoaderConfigurationSection.GetConfig(); var plugins = new List<Tuple<string, string, string>>(); foreach (PluginConfig pluginConf in config.Plugins) { plugins.Add(new Tuple<string, string, string>(pluginConf.ExtType, pluginConf.ClassName, pluginConf.FileName)); } var plm = new PluginsLoadersManager(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), plugins, logger); // bootstrap dependenties // TODO: use IoC container for that var fp = new FileProcessor(plm, model); new PeriodicalFileWatcher(new FileWatcherOptions(ConfigurationManager.AppSettings["DirectoryToMonitor"], plm.SupportedExtensions, Convert.ToInt32(ConfigurationManager.AppSettings["DirectoryMonitorFrequencyMs"])), fp, logger).SartWatch(); }
static void Main(string[] args) { var p = new FileProcessor(); p.StartConsole(); }
/// <summary> /// Helper method for serving static files from the disk. /// /// Example usage: /// class App : HttpServer { /// public App (int port) : base(int port) { /// ServeFiles("/slides/(?<path>\d+).jpg$", "image/jpeg", "C:\\slides\\", (n) => "that-slide-" + n + ".jpg"); /// // GET /slides/1.jpg will serve C:\slides\that-slide-1.jpg /// // GET /slides/230912/1.jpg will serrve C:\slides\230912\1.jpg /// } /// } /// </summary> /// <param name="path">Regular expression capturing the desired URL. Should have only one capture group named "path"</param> /// <param name="mimeType">MIME type of file(s) to be served</param> /// <param name="source_dir">Source directory (on the disk)</param> public void ServeFiles(string path, string mimeType, string source_dir, FileProcessor processor) { GET(path, (m, p) => { string filename = m["path"].Value; string abspath = source_dir + "\\" + processor.Invoke(filename); if(File.Exists(abspath)) { System.Diagnostics.Debug.WriteLine("meh: serving " + abspath); p.outputStream.WriteLine("HTTP/1.0 200 OK"); p.outputStream.WriteLine("Conent-Type: " + mimeType); p.outputStream.WriteLine("Connection: close"); using(var fs = new FileStream(abspath, FileMode.Open, FileAccess.Read)) { int size = (int)fs.Length; p.outputStream.WriteLine("Content-Length: " + size.ToString()); p.outputStream.WriteLine(" "); var buffer = new byte[size]; fs.Read(buffer, 0, size); p.outputStream.BaseStream.Write(buffer, 0, size); } } else { p.Respond(HttpStatusCode.NotFound); } }); }
public ImportBatchJob(AppModule module, FileProcessor file, Action action) : base(module, action) { _file = file; }
public async Task<HttpResponseMessage> Upload() { if (!Request.Content.IsMimeMultipartContent("form-data")) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count <= 0) { throw new HttpResponseException(HttpStatusCode.NoContent); } try { foreach (var postedFile in from string file in httpRequest.Files select httpRequest.Files[file]) { using (var reader = new StreamReader(postedFile.InputStream)) { var fileContents = reader.ReadToEnd(); var fileProcessor = new FileProcessor( CloudConfigurationManager.GetSetting("storageAccountName"), CloudConfigurationManager.GetSetting("storageAccountKey")); await fileProcessor.Process(fileContents); } } } catch (Exception e) { throw new HttpResponseException(HttpStatusCode.NoContent); } return Request.CreateResponse(HttpStatusCode.Created); }
// Call processFile on all files below f that have the given extension public static void doFile(string root, string ext, FileProcessor processFile, IList<string> excludes) { string canonicalPath = Path.GetFullPath(root); // If this is a directory, walk each file/dir in that directory if (excludes == null || !excludes.Contains(canonicalPath.TrimEnd(Path.DirectorySeparatorChar))) { if (Directory.Exists(canonicalPath)) { string[] files = Directory.GetFileSystemEntries(canonicalPath); for (int i = 0; i < files.Length; i++) doFile(Path.Combine(canonicalPath, files[i]), ext, processFile, excludes); } else if ((Path.GetFileName(canonicalPath).Length > ext.Length) && canonicalPath.Substring(canonicalPath.Length - ext.Length).Equals(ext)) { if (cfg.Verbosity >= 2) Console.WriteLine(" " + canonicalPath); try { processFile(canonicalPath); } catch (Exception e) { Console.Error.WriteLine("\nCannot process file: " + canonicalPath); Console.Error.WriteLine("exception: " + e); } } } }