public CVScraperInvocable(ScrapeCache scrapeCache, ScrapeConfig scrapeConfig)
 {
     this._scrapeCache  = scrapeCache;
     this._scrapeConfig = scrapeConfig;
     _ctx    = new RabbitContext().Create(scrapeConfig.CoronaVirusScrape.GetConfigFile());
     _sender = new RmqSender(_ctx);
 }
示例#2
0
 public TestReceiver(RabbitContext ctx) : base(ctx)
 {
     this.Register();
     WriteLine("started import receiver");
     WriteLine(" Press [enter] to exit.");
     ReadLine();
 }
示例#3
0
        static void Main(string[] args)
        {
            RabbitContext ctx      = new RabbitContext().Create("cv.scraper.json");
            var           receiver = new apiDataReceiver(ctx);

            receiver.Run();
        }
        public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .ConfigureServices((hostContext, services) =>
        {
            // services.AddHostedService<Worker>();

            services.AddHostedService <ApiTrackerConsumer>();
            services.AddSingleton <IConfiguration>(Program.Configuration);

            services.AddDbContext <CvContext>(cfg =>
            {
                cfg.UseSqlServer(hostContext.Configuration.GetConnectionString("cvConnectionString"));
            });

            var cvCfg = new cvConfig(Program.Configuration);
            services.AddSingleton <cvConfig>(cvCfg);

            var cvp = new cvParsers(cvCfg);
            services.AddSingleton <cvParsers>(cvp);

            // rabbitmq
            var ctxCloudAmqp = new RabbitContext().Create("cv.scraper.json");
            var ctxLocal     = new RabbitContext().Create("cv.localhost.json");
            services.AddSingleton(ctxCloudAmqp);
            services.AddSingleton(ctxLocal);
        });
示例#5
0
        static void Main(string[] args)
        {
            // var ctx = new RabbitContext().Create("cv.scraper.json");
            var ctx    = new RabbitContext().Create("test.json");
            var sender = new Sender(ctx);

            sender.Send("test");
        }
示例#6
0
        public ScrapeServiceWorkerReceive(RabbitContext ctx) : base(ctx)
        {
            ctx.Binder.RoutingKey = "doscrape";
            ctx.Binder.QueueName  = "";
            ctx.Queue.Name        = "";

            this.Register();
        }
示例#7
0
 public Worker(ILogger <Worker> logger,
               RabbitContext ctxCloudAmqp,
               RabbitContext ctxLocal)
 {
     this._ctxCloudAmqp = ctxCloudAmqp;
     this._ctxLocal     = ctxLocal;
     this._logger       = logger;
 }
示例#8
0
        static void Main(string[] args)
        {
            RabbitContext ctx          = new RabbitContext().Create("cv.scraper.json");
            var           receiverJson = new cvMessageReceive(ctx);

            WriteLine("started receiver");
            WriteLine(" Press [enter] to exit.");
            ReadLine();
        }
        public void Run()
        {
            RabbitContext ctx          = new RabbitContext().Create("cv.scraper.json");
            var           receiverJson = new ScrapeFileWatcherReceive(ctx, _importData, _cvConfig);

            WriteLine("started import receiver");
            WriteLine(" Press [enter] to exit.");
            ReadLine();
        }
        static void Main(string[] args)
        {
            RabbitContext ctxLog      = new RabbitContext().Create("logging.json");
            var           receiverLog = new LogMessageReceive(ctxLog);

            WriteLine("started receiver");
            WriteLine(" Press [enter] to exit.");
            ReadLine();
        }
示例#11
0
 public ApiTrackerConsumer(ILogger <Worker> logger,
                           RabbitContext ctxCloudAmqp,
                           RabbitContext ctxLocal,
                           IServiceScopeFactory serviceScopeFactory)
 {
     _logger              = logger;
     _ctxCloudAmqp        = ctxCloudAmqp;
     _ctxLocal            = ctxLocal;
     _serviceScopeFactory = serviceScopeFactory ?? throw new ArgumentNullException(nameof(serviceScopeFactory));
 }
        public ScrapeFileWatcherReceive(RabbitContext ctx,
                                        ImportScrapeData importData,
                                        cvConfig cvConfig) : base(ctx)
        {
            this._cvConfig   = cvConfig;
            this._importData = importData;
            var scrapeDataMessage = new CoronaVirusScrapeDataMessage();

            ctx.Binder.RoutingKey = scrapeDataMessage.RoutingKey;
            this.Register();
        }
示例#13
0
        static void Main(string[] args)
        {
            ctx = new RabbitContext().Create("cv.test.json");
            RmqSender sender = new RmqSender(ctx);

            while (true)
            {
                WriteLine("enter a msg to send");
                string msg = ReadLine();
                sender.Send(msg);
            }
        }
示例#14
0
        static void fanoutSender()
        {
            _ctx    = new RabbitContext().Create("logs", "fanout");
            _sender = new RmqSender(_ctx);
            int cnt = 0;

            while (true)
            {
                cnt++;
                _sender.Send("info: Hello World! " + cnt.ToString());
                Console.WriteLine("press enter to send another message...");
                Console.ReadLine();
            }
        }
示例#15
0
        static void apiTrackerSender()
        {
            _ctx    = new RabbitContext().Create("cv.localhost.json");
            _sender = new RmqSender(_ctx);
            _session.Sender.SetRoutingKey("cvApiTracker", "cvApiTracker");

            while (true)
            {
                Console.WriteLine("(apiTrackerSender) press enter to send another message...");
                Console.ReadLine();
                CoronaVirusApiTrackerMessage msg = CallApi().Result;
                // _session.Sender.Send(msg);
                _sender.SendMessage(msg);
            }
        }
示例#16
0
        static void sendScrapeMessage()
        {
            _ctx    = new RabbitContext().Create("cv.scraper.json");
            _sender = new RmqSender(_ctx);

            int cnt = 0;

            while (true)
            {
                cnt++;
                _sender.SendMessage(new CoronaVirusScrapeMessage());
                Console.WriteLine("press enter to send another message...", cnt.ToString());;
                Console.ReadLine();
            }
        }
示例#17
0
        static void sendJsonMessages()
        {
            var ctx = new RabbitContext().Create("cv.scraper.json");
            cvJsonMessageSend cvJsonMsg = new cvJsonMessageSend();

            while (true)
            {
                WriteLine(" enter a message");
                var msg = ReadLine();
                cvJsonMsg.Publish(msg);
                //RabbitMessage rGenMsg = new RabbitMessage("cv.general", msg);
                //cvJsonMsg.Publish(rGenMsg);
                WriteLine(" sent");
                WriteLine("");
            }
        }
示例#18
0
        public Task Execute(RabbitContext rabbitContext, EventMessage eventMessage)
        {
            RabbitMessageHandler next = null;
            int counter        = 0;
            var currentMethods = methods;

            next = () =>
            {
                if (counter < currentMethods.Length)
                {
                    return(currentMethods[counter++].Invoke(rabbitContext, next));
                }
                return(Task.CompletedTask);
            };
            return(next());
        }
 public Task HandleReceive(RabbitContext rabbitContext, RabbitMessageHandler next)
 {
     try
     {
         //rabbitContext.Serializer(null);
         //rabbitContext.ReceivedMessage.Body
         //rabbitContext.ReceivedMessage.Body = new []
         return(next());
     }
     catch (Exception)
     {
         var properties = rabbitContext.BasicPropertyCreator();
         rabbitContext.WriteMessageToPublish(rabbitContext.ReceivedMessage.Body, properties);
         return(Task.CompletedTask);
     }
 }
示例#20
0
        static void directSender()
        {
            string exchange     = "direct_logs";
            string exchangeType = "direct";
            string routingKey   = "info";

            _ctx    = new RabbitContext().Create(exchange, exchangeType, routingKey);
            _sender = new RmqSender(_ctx);
            int cnt = 0;

            while (true)
            {
                cnt++;
                _sender.Send("info: Hello World! " + cnt.ToString());
                Console.WriteLine("press enter to send another message...");
                Console.ReadLine();
            }
        }
示例#21
0
        static void emailSender()
        {
            _ctx    = new RabbitContext().Create("cv.localhost.json");
            _sender = new RmqSender(_ctx);

            var message = new EmailMessage()
            {
                Subject    = "subject here",
                Body       = "new email body",
                IsBodyHtml = false,
                Recipients = new List <string>
                {
                    { "*****@*****.**" },
                    { "*****@*****.**" },
                }
            };

            _sender.SendMessage(message);
        }
        static void Main(string[] args)
        {
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(string.Format(" {0,2} {1,10} {2,5} {3,5}", "arg0", "arg1", "arg2", "arg3"));
            }
            string exchange     = "direct_logs";
            string exchangeType = "direct";
            string routingKey   = "info";

            // direct
            // RabbitContext ctx = new RabbitContext().Create("logs", "fanout");
            // var receiver = new LogFanoutReceiver(ctx);

            // fanout
            RabbitContext ctx      = new RabbitContext().Create(exchange, exchangeType, routingKey);
            var           receiver = new LogDirectReceiver(ctx);
            // receiver.Run();
        }
示例#23
0
        public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .ConfigureServices((hostContext, services) =>
        {
            services.AddHostedService <Worker>();
            //services.AddDbContext<CvContext>(options =>
            //{
            //    options.UseSqlServer(Configuration.GetConnectionString("cvConnectionString"));
            //});

            // rabbitmq
            var ctxCloudAmqp = new RabbitContext().Create("cv.scraper.json");
            var ctxLocal     = new RabbitContext().Create("cv.localhost.json");
            services.AddSingleton(ctxCloudAmqp);
            services.AddSingleton(ctxLocal);
            services.AddSingleton <IConfiguration>(Program.Configuration);

            // services.AddTransient<ScrapeImportReceiver>();
            //services.AddTransient<cvConfig>();
            //services.AddTransient<cvParsers>();
            //services.AddTransient<ImportScrapeData>();
        });
 public LogMessageReceive(RabbitContext ctx) : base(ctx)
 {
     this.Register();
 }
 public LogDirectReceiver(RabbitContext ctx) :
     base(ctx)
 {
     _ctx = ctx;
 }
示例#26
0
 public LogFanoutReceiver(RabbitContext ctx) :
     base(ctx)
 {
     _ctx = ctx;
 }
 public cvJsonMessageReceive(RabbitContext ctx) : base(ctx)
 {
     ctx.Binder.RoutingKey = "importscrape";
     this.Register();
 }
 public MessageListener(RabbitContext ctx) :
     base(ctx)
 {
 }
示例#29
0
 public LogMessage()
 {
     ctx = new RabbitContext().Create("logging.json");
 }
示例#30
0
 public BaseMessageSend(RabbitContext ctx)
 {
     _ctx    = ctx;
     _sender = new RmqSender(_ctx);
 }