static async Task MainTask(AppSettings conf, FetchAndPublish fetcher) { TrayNotify notify = new TrayNotify(fetcher); await fetcher.republish(); DateTime bc = await fetcher.fetchAndPublish(DateTime.UtcNow); }
static async Task MainTask() { AppSettings conf = new AppSettings(); conf.LoadAppSettings(); conf.SaveAppSettings(); Directory.CreateDirectory(conf.PublishFolder); Directory.CreateDirectory(conf.Archive); HttpClientHandler httpClientHandler = new HttpClientHandler() { Proxy = WebRequest.GetSystemWebProxy() }; HttpClient hc = new HttpClient(httpClientHandler); FetchAndPublish fetcher = new FetchAndPublish(conf, hc); fetcher.listenForTerseMessages(new TerseMessageDelegate(Console.WriteLine)); fetcher.listenForChattyMessages(new ChattyMessageDelegate(Console.WriteLine)); fetcher.listenForEditionStatus(new ShowEditionStatusDelegate(Console.WriteLine)); fetcher.addLogListener(new LogDelegate(Console.WriteLine)); await fetcher.republish(); try { DateTime bc = await fetcher.fetchAndPublish(DateTime.UtcNow); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private async void buttonExitOrStart_Click(object sender, EventArgs e) { if (conf.RunInForeground) { if (taskInstalled) { deleteTask(new ScheduleInstaller(conf)); } await fetcher.republish(); while (true) { DateTime bc = await fetcher.fetchAndPublish(DateTime.UtcNow); // wait until after broadcast date before trying for next edition await fetcher.waitUntil(bc); } } else { if (taskInstalled) { MessageBox.Show("Files will be fetched in the background", "BBC Ingest"); Application.Exit(); } else { MessageBox.Show("Install task to fetch files in the background", "BBC Ingest"); } } }
static async Task MainTask() { AppSettings conf = new AppSettings(); conf.LoadAppSettings(); conf.SaveAppSettings(); Directory.CreateDirectory(conf.PublishFolder); Directory.CreateDirectory(conf.Archive); Directory.CreateDirectory(conf.Logfolder); FetchAndPublish fetcher = new FetchAndPublish(conf); fetcher.listenForTerseMessages(new TerseMessageDelegate(Console.WriteLine)); fetcher.listenForChattyMessages(new ChattyMessageDelegate(Console.WriteLine)); fetcher.listenForEditionStatus(new ShowEditionStatusDelegate(Console.WriteLine)); await fetcher.republish(); try { DateTime bc = await fetcher.fetchAndPublish(DateTime.UtcNow); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private async void OnLoad(object sender, EventArgs e) { Version version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version; Text = Text + " " + version.ToString(); Schedule schedule = new Schedule(conf); fetcher.listenForTerseMessages(new TerseMessageDelegate(setLine1)); fetcher.listenForChattyMessages(new ChattyMessageDelegate(setLine1)); fetcher.listenForEditionStatus(new ShowEditionStatusDelegate(setLine2)); if (conf.RunInForeground) { buttonRfTS.Visible = false; buttonRemoveTasks.Visible = false; buttonExitOrStart.Text = "Start"; buttonExitOrStart.Visible = false; await getLatest(schedule); await fetcher.republish(); while (true) { DateTime bc = await fetcher.fetchAndPublish(DateTime.UtcNow); // wait until after broadcast date before trying for next edition await fetcher.waitUntil(bc); } } else { IScheduleInstaller si = getScheduleInstaller(schedule); taskInstalled = si.IsInstalled; if (taskInstalled) { buttonRfTS.Text = "Update Task Scheduler"; } else { buttonRfTS.Text = "Install Task"; } buttonExitOrStart.Text = "Exit"; } }