static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var form = new MainForm(); var configuration = new Configuration("config.ini"); var logger = new Logger(form); var input = new Input(configuration.InputFile); var delayedInput = new DelayedInput(input, configuration); var output = new Output(configuration.DownloadDirectory); var activeDownloads = new ActiveDownloads(logger); var directoryMonitor = new DirectoryMonitor(configuration.UploadDirectory, input); var PdfGenerator = new HtmlToPdfGenerator(output, configuration, activeDownloads, directoryMonitor); activeDownloads.OnChange = (item) => { var lines = activeDownloads.GetActiveItems() .Select(x => string.Format("{0} {1}", x.Id, x.Uri)) .ToArray(); form.SetActiveList(lines); }; //#if DEBUG //// remove this line in production //Directory.CreateDirectory(configuration.DownloadDirectory); //Directory.CreateDirectory(configuration.UploadDirectory); //#endif var DownloadManager = new DownloadManager(delayedInput, output, configuration, activeDownloads, logger, directoryMonitor, PdfGenerator); Application.Run(form); }
public DownloadManager(DelayedInput input, Output output, Configuration configuration, ActiveDownloads activeDownloads, Logger logger, DirectoryMonitor directoryMonitor, HtmlToPdfGenerator pdfgenerator) { ActiveDownloads = activeDownloads; Output = output; DelayedInput = input; DirectoryMonitor = directoryMonitor; Configuration = configuration; PdfGenerator = pdfgenerator; StartTimer(100, StartDownloads); // start new downloads if possible (check every 100 msec) StartTimer(30000, ReportStatus); // write the status every 30 secs StartTimer(5000, AddNewItems); // check the directory for new downloads at run time (check every 5 secs) }