Пример #1
0
        static async Task Main(string[] args)
        {
            NLog.LogManager.LoadConfiguration("nlog.config");
            starter = new AutoStarter(ApplicationLogging.LoggerFactory, "FreeAgent App", args);
            starter.LoggerFactory.AddNLog();
            starter.RegisterCommand <DownloadCommand, DownloadConfig>("download");
            source = new CancellationTokenSource();
            task   = starter.StartAsync(source.Token);
            System.Console.WriteLine("Please press CTRL+C to break...");
            System.Console.CancelKeyPress += ConsoleOnCancelKeyPress;
            await starter.Status.LastOrDefaultAsync();

            System.Console.WriteLine("Exiting...");
        }
Пример #2
0
        static async Task Main(string[] args)
        {
            NLog.LogManager.LoadConfiguration("nlog.config");
            starter = new AutoStarter(ApplicationLogging.LoggerFactory, "Instagram Bot", args);
            starter.LoggerFactory.AddNLog();
            starter.RegisterCommand <DiscoveryCommand, BasicConfig>("discovery");
            starter.RegisterCommand <EnrichCommand, EnrichConfig>("enrich");
            starter.RegisterCommand <RemoveFollowersCommand, RemoveFollowConfig>("remove");
            source = new CancellationTokenSource();
            task   = starter.StartAsync(source.Token);
            System.Console.WriteLine("Please press CTRL+C to break...");
            System.Console.CancelKeyPress += ConsoleOnCancelKeyPress;
            await starter.Status.LastOrDefaultAsync();

            System.Console.WriteLine("Exiting...");
        }
Пример #3
0
        public static async Task Main(string[] args)
        {
            NLog.LogManager.LoadConfiguration("nlog.config");
            starter = new AutoStarter(ApplicationLogging.LoggerFactory, "Sentiment analysis", args);
            starter.LoggerFactory.AddNLog();
            starter.RegisterCommand <TestingCommand, TestingConfig>("test");
            starter.RegisterCommand <TrainCommand, TrainingConfig>("train");
            starter.RegisterCommand <BoostrapCommand, BootsrapConfig>("boot");

            var configuration = new ConfigurationHandler();
            var resourcesPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), configuration.GetConfiguration("Resources"));

            if (Directory.Exists(resourcesPath))
            {
                log.LogInformation("Resources folder {0} found.", resourcesPath);
            }
            else
            {
                var  dataDownloader = new DataDownloader(ApplicationLogging.LoggerFactory);
                Task download       = dataDownloader.DownloadFile(new Uri(configuration.GetConfiguration("dataset")), resourcesPath);
                await download.ConfigureAwait(false);
            }


#if NET472
            var fPreviousExecutionState = NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS | NativeMethods.ES_SYSTEM_REQUIRED);
            if (fPreviousExecutionState == 0)
            {
                log.LogError("SetThreadExecutionState failed.");
                return;
            }
#endif
            try
            {
                source = new CancellationTokenSource();
                task   = starter.StartAsync(source.Token);
                System.Console.WriteLine("Please press CTRL+C to break...");
                System.Console.CancelKeyPress += ConsoleOnCancelKeyPress;
                await starter.Status.LastOrDefaultAsync();

                System.Console.WriteLine("Exiting...");
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e);
            }
        }
Пример #4
0
        public static async Task Main(string[] args)
        {
            NLog.LogManager.LoadConfiguration("nlog.config");
            starter = new AutoStarter(ApplicationLogging.LoggerFactory, "Twitter Bot", args);
            starter.LoggerFactory.AddNLog();
            starter.RegisterCommand <DiscoveryCommand, DiscoveryConfig>("Discovery");
            starter.RegisterCommand <EnrichCommand, EnrichConfig>("Enrich");
            starter.RegisterCommand <DownloadMessagesCommand, DownloadMessagesConfig>("DownloadMessages");
            starter.RegisterCommand <TwitterLoadCommand, TwitterLoadConfig>("load");
            starter.RegisterCommand <TwitterMonitorCommand, TwitterMonitorConfig>("monitor");
            starter.RegisterCommand <TestPublishCommand, TestPublishConfig>("publish");

            source = new CancellationTokenSource();
            task   = starter.StartAsync(source.Token);
            System.Console.WriteLine("Please press CTRL+C to break...");
            System.Console.CancelKeyPress += ConsoleOnCancelKeyPress;
            await starter.Status.LastOrDefaultAsync();

            System.Console.WriteLine("Exiting...");
        }
Пример #5
0
        public static async Task Main(string[] args)
        {
            NLog.LogManager.LoadConfiguration("nlog.config");
            ApplicationLogging.LoggerFactory = LoggerFactory.Create(builder =>
            {
                builder.SetMinimumLevel(LogLevel.Trace);
                builder.AddNLog();
            });

            starter = new AutoStarter(ApplicationLogging.LoggerFactory, "Sentiment analysis", args);
            starter.RegisterCommand <TestingCommand, TestingConfig>("test");
            starter.RegisterCommand <TrainCommand, TrainingConfig>("train");
            starter.RegisterCommand <BoostrapCommand, BootsrapConfig>("boot");

            starter.Init = async provider =>
            {
                var downloader = provider.GetRequiredService <ConfigDownloader <ILexiconConfig> >();
                await downloader.Download(item => item.Model).ConfigureAwait(false);

                await downloader.Download(item => item.Lexicons, always : true).ConfigureAwait(false);
            };

            try
            {
                source = new CancellationTokenSource();
                task   = starter.StartAsync(source.Token);
                System.Console.WriteLine("Please press CTRL+C to break...");
                System.Console.CancelKeyPress += ConsoleOnCancelKeyPress;
                await starter.Status.LastOrDefaultAsync();

                System.Console.WriteLine("Exiting...");
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e);
            }
        }