Example #1
0
        static async Task MainTask(AppSettings conf, FetchAndPublish fetcher)
        {
            TrayNotify notify = new TrayNotify(fetcher);
            await fetcher.republish();

            DateTime bc = await fetcher.fetchAndPublish(DateTime.UtcNow);
        }
Example #2
0
        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);
            }
        }
Example #3
0
 public MainForm(AppSettings conf, FetchAndPublish fetcher)
 {
     this.conf    = conf;
     this.fetcher = fetcher;
     line1        = new ConcurrentQueue <string>();
     InitializeComponent();
 }
Example #4
0
        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);
            }
        }
Example #5
0
 public MainForm(AppSettings conf)
 {
     this.conf = conf;
     line1     = new ConcurrentQueue <string>();
     InitializeComponent();
     fetcher = new FetchAndPublish(conf);
     fetcher.listenForTerseMessages(new TerseMessageDelegate(setLine1));
     fetcher.listenForChattyMessages(new ChattyMessageDelegate(setLine1));
     fetcher.listenForEditionStatus(new ShowEditionStatusDelegate(setLine2));
 }
Example #6
0
        public TrayNotify(FetchAndPublish fetcher)
        {
            MyContainer components = new MyContainer();

            notifyIcon = new NotifyIcon(components)
            {
                Icon           = Properties.Resources.main,
                Text           = "BBC Ingest",
                BalloonTipText = "BBC Ingest",
                Visible        = showicon
            };
            fetcher.listenForTerseMessages(new TerseMessageDelegate(terse));
            fetcher.listenForChattyMessages(new ChattyMessageDelegate(chatty));
            fetcher.listenForEditionStatus(new ShowEditionStatusDelegate(chatty));
        }
Example #7
0
        static void Main(String[] args)
        {
            String arg = "";

            if (args.Length > 0)
            {
                arg = args[0];
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            AppSettings conf = new AppSettings();

            if (args.Length == 2)
            {
                conf.SettingsPath = args[1];
            }
            conf.LoadAppSettings();
            Directory.CreateDirectory(conf.PublishFolder);
            Directory.CreateDirectory(conf.Archive);
            //MessageBox.Show(arg, "BBCIngest", MessageBoxButtons.OK);
            if (arg.Equals("install"))
            {
                if (File.Exists(init_file))
                {
                    foreach (var row in File.ReadAllLines(init_file))
                    {
                        string[] s = row.Split('=');
                        if (s[0].Equals("postLogs"))
                        {
                            conf.PostLogs = s[1].Equals("1");
                        }
                        if (s[0].Equals("city"))
                        {
                            conf.City = s[1];
                        }
                        if (s[0].Equals("station"))
                        {
                            conf.Station = s[1];
                        }
                        if (s[0].Equals("logUrl"))
                        {
                            conf.LogUrl = s[1];
                        }
                    }
                }
                conf.SaveAppSettings();
            }
            else if (arg.Equals("uninstall"))
            {
                Schedule           schedule = new Schedule(conf);
                IScheduleInstaller si;
                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    si = new ScheduleInstaller(schedule);
                }
                else
                {
                    si = new Win32ScheduleInstaller(schedule);
                }
                si.deleteTaskAndTriggers();
            }
            else
            {
                HttpClientHandler httpClientHandler = new HttpClientHandler()
                {
                    Proxy = WebRequest.GetSystemWebProxy()
                };
                HttpClient      hc      = new HttpClient(httpClientHandler);
                Logging         log     = new Logging(conf, hc);
                FetchAndPublish fetcher = new FetchAndPublish(conf, hc);
                LogDelegate     ld      = new LogDelegate(log.WriteLine);
                fetcher.addLogListener(ld);
                if (arg.Equals("once"))
                {
                    MainTask(conf, fetcher).Wait();
                }
                else
                {
                    if (arg.Equals("fg"))
                    {
                        conf.RunInForeground = true;
                    }
                    if (arg.Equals("bg"))
                    {
                        conf.RunInForeground = false;
                    }
                    MainForm mf = new MainForm(conf, fetcher);
                    mf.addLogListener(ld);
                    Application.Run(mf);
                }
            }
        }