public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureAppConfiguration(config => config.AddUserSecrets(Assembly.GetExecutingAssembly())) .ConfigureServices((hostContext, services) => { var uploadProcessor = new UploadProcessor(new UploadProcessorOptions { UploadDirectory = hostContext.Configuration.GetSection("App:UploadDirectory").Value, OutputDirectory = hostContext.Configuration.GetSection("App:OutputDirectory").Value }); uploadProcessor.Process(); });
static void Main(string[] args) { var fileSystemWatcher = new FileSystemWatcher("../Data/uploads", "metadata.json"); fileSystemWatcher.IncludeSubdirectories = true; while (true) { var result = fileSystemWatcher.WaitForChanged(WatcherChangeTypes.Created); Console.WriteLine($"New Metadata file {result.Name}"); var fullMetadataFilePath = Path.Combine("../Data/uploads", result.Name); var subfolder = Path.GetDirectoryName(fullMetadataFilePath); var processor = new UploadProcessor(subfolder); processor.Process(); } }
static void Main(string[] args) { int counter = 0; Parallel.ForEach( Directory.GetDirectories("../../uploads"), subFolder => { var uploadProcessor = new UploadProcessor(subFolder); uploadProcessor.Process(); ++counter; }); string msg = $"{counter} uploads were processed."; GtkHelper.DisplayAlert(msg); }
static void Main(string[] args) { int i = 0; foreach (var subfolder in Directory.GetDirectories("../Data/uploads")) { var uploadProcessor = new UploadProcessor(subfolder); uploadProcessor.Process(); i++; } var message = $"{i} uploads were processed"; if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { AppKitHelper.DisplayAlert(message); } }
static void Main(string[] args) { var i = 0; //iterate through subfolders of /mnt/uploads foreach (var subfolder in Directory.GetDirectories("../../../../uploads")) { var uploadProcessor = new UploadProcessor(subfolder); uploadProcessor.Process(); i++; } var message = $"{i} uploads were processed"; if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { GtkHelper.DisplayAlert(message); } }
static void Main(string[] args) { Console.WriteLine("Starting service."); string uploadPath = "../../uploads"; var fileSystemWatcher = new FileSystemWatcher(uploadPath, "metadata.json"); fileSystemWatcher.IncludeSubdirectories = true; while (true) { Console.WriteLine("Waiting..."); var result = fileSystemWatcher.WaitForChanged(WatcherChangeTypes.Created); Console.WriteLine($"New metadata file {result.Name}"); var fullMetadataFilePath = Path.Combine(uploadPath, result.Name); var subFolder = Path.GetDirectoryName(fullMetadataFilePath); var processor = new UploadProcessor(subFolder); Console.WriteLine("Starting Process."); processor.Process(); } }