Example #1
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(50, 30);
            ConsoleAppHelper.PrintHeader("Header.txt");

            var _rabbitBusControl = Bus.Factory.CreateUsingRabbitMq(sbc =>
            {
                var host = sbc.Host(new Uri(RabbitMqAddress), h =>
                {
                    h.Username(RabbitUsername);
                    h.Password(RabbitPassword);
                });

                sbc.ReceiveEndpoint(host, "Heartbeat", ep =>
                {
                    ep.Consumer(() => new HeartbeatConsumer());
                });
            });

            _rabbitBusControl.Start();


            Timer timer = new Timer(2000);

            timer.Elapsed += TimerTick;
            timer.Start();

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();

            timer.Stop();

            _rabbitBusControl.Stop();
        }
Example #2
0
        static void Main(string[] args)
        {
            //string exchangeName = "_DatabaseRegistry";
            Console.SetWindowSize(80, 20);
            ConsoleAppHelper.PrintHeader("Header.txt");

            var bus = Bus.Factory.CreateUsingRabbitMq(sbc =>
            {
                var host = sbc.Host(new Uri(RabbitMqAddress), h =>
                {
                    h.Username(RabbitUsername);
                    h.Password(RabbitPassword);
                });

                sbc.ReceiveEndpoint(host, "DatabaseRegistered", ep =>
                {
                    //      ep.Bind(exchangeName);
                    ep.Consumer(() => new DatabaseRegisteredConsumer());
                });

                sbc.ReceiveEndpoint(host, "SchemaChanged", ep =>
                {
                    //    ep.Bind(exchangeName);
                    ep.Consumer <SchemaUpdateConsumer>();
                });
            });

            bus.Start();
        }
Example #3
0
        static void Main(string[] args)
        {
            string exchangeName = "Formatting";
            string queueName    = "FormatScript";

            ConsoleAppHelper.PrintHeader("Header.txt");

            var bus = Bus.Factory.CreateUsingRabbitMq(sbc =>
            {
                var host = sbc.Host(new Uri("rabbitmq://localhost"), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                sbc.ReceiveEndpoint(host, queueName, ep =>
                {
                    //ep.Bind(exchangeName);
                    ep.Consumer(() => new FormatScriptConsumer());
                });
            });

            bus.Start();

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();

            bus.Stop();
        }
        public Task Consume(ConsumeContext <SchemaChanged> context)
        {
            ConsoleAppHelper.PrintHeader("Header.txt");
            Console.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss"));

            var sensitiveColumnNames = new List <string>
            {
                "firstname",
                "name",
                "address",
                "email"
            };

            var atRiskColumns = new List <Column>();

            var schema = context.Message.Database;

            foreach (var table in schema.Tables)
            {
                foreach (var tableColumn in table.Columns)
                {
                    if (sensitiveColumnNames.Contains(tableColumn.Name, StringComparer.OrdinalIgnoreCase))
                    {
                        atRiskColumns.Add(tableColumn);
                        Console.WriteLine($"Sensitive column name found : {table.Name} - {tableColumn.Name}");
                    }
                }
            }

            return(Task.CompletedTask);
        }
        static void Main(string[] args)
        {
            Console.SetWindowSize(80, 20);
            ConsoleAppHelper.PrintHeader("Header.txt");

            RunMassTransitReceiverWithRabbit();
        }
//        public FormatScriptConsumer()
//        {
//            bus = Bus.Factory.CreateUsingRabbitMq(sbc =>
//            {
//                var host = sbc.Host(new Uri("rabbitmq://localhost"), h =>
//                {
//                    h.Username("guest");
//                    h.Password("guest");
//                });
//
//            });
//
//            bus.Start();
//        }

        public Task Consume(ConsumeContext <FormatScript> context)
        {
            ConsoleAppHelper.PrintHeader("Header.txt");

            var script = context.Message.Script;

            Console.WriteLine(script);

            Console.WriteLine("");
            Console.WriteLine("--FORMATTING--");
            Console.WriteLine("");

            var formattedSql = NSQLFormatter.Formatter.Format(script);

            Console.WriteLine(formattedSql);

            var message = new ScriptFormattedMessage
            {
                FormattedScript = formattedSql
            };

            bus.Publish <ScriptFormatted>(message);

            Console.WriteLine($"Formatted script complete");

            return(Task.CompletedTask);
        }
        static void Main(string[] args)
        {
            ConsoleAppHelper.PrintHeader("Header.txt");

            var bus = Bus.Factory.CreateUsingRabbitMq(sbc =>
            {
                var host = sbc.Host(new Uri(RabbitMqAddress), h =>
                {
                    h.Username(RabbitUsername);
                    h.Password(RabbitPassword);
                });

                sbc.ReceiveEndpoint(host, "FormatScript", ep =>
                {
                    //ep.Bind(exchangeName);
                    ep.Consumer(() => new FormatScriptConsumer());
                });
            });

            bus.Start();

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();

            bus.Stop();
        }
Example #8
0
        static void Monitor(Object obj, ElapsedEventArgs e)
        {
            Console.Clear();
            ConsoleAppHelper.PrintHeader("Header.txt");
            Console.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss"));

            var storeLocation = $@"C:\dev\Stores\monitor\";

            var servers = RetrieveRegisteredServers(storeLocation);

            AnalyseServers(servers);
        }
Example #9
0
        public Task Consume(ConsumeContext <DatabaseRegistered> context)
        {
            ConsoleAppHelper.PrintHeader("Header.txt");

            var schema = context.Message.Schema;

            foreach (var table in schema.Tables)
            {
                Console.WriteLine(table.Name);
            }

            StorageHelper.StoreDatabaseDefinition(context.Message.Database, schema.Tables, "Dashboard");

            return(Task.CompletedTask);
        }
Example #10
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(80, 20);
            ConsoleAppHelper.PrintHeader("Header.txt");

            var baseAddress = "http://localhost:9111/api/registry/";

            using (WebApp.Start <Startup>(url: baseAddress))
            {
                HttpClient client = new HttpClient();

                Console.WriteLine(string.Empty);
                Console.WriteLine($"The api is live on {baseAddress}");
                Console.ReadLine();
            }
        }
Example #11
0
        public static void PrintTL(string file, ConsoleColor colour)
        {
            Console.Clear();

            Console.ForegroundColor = ConsoleColor.White;
            ConsoleAppHelper.PrintHeader("Header.txt");

            Console.ForegroundColor = colour;

            String line;

            try
            {
                //Pass the file path and file name to the StreamReader constructor
                StreamReader sr = new StreamReader(file);

                //Read the first line of text
                line = sr.ReadLine();

                //Continue to read until you reach end of file
                while (line != null)
                {
                    //write the lie to console window
                    Console.WriteLine(line);
                    //Read the next line
                    line = sr.ReadLine();
                }
                Console.WriteLine(string.Empty);

                //close the file
                sr.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.GetBaseException());
            }
            finally
            {
                ///Console.WriteLine("Executing finally block.");
            }

            Console.ForegroundColor = ConsoleColor.White;
        }
Example #12
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(80, 20);
            ConsoleAppHelper.PrintHeader("Header.txt");

            RunMassTransitReceiverWithRabbit();

            Monitor(null, null);
            Pulse(null, null);

            ConfigureCheckInterval();
            ConfigurePulseInterval();

            Console.ReadKey();

            _checkIntervalTimer.Stop();
            _pulseIntervalTimer.Stop();

            _rabbitBusControl.Stop();
        }
Example #13
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(80, 20);
            ConsoleAppHelper.PrintHeader("Header.txt");

            var _rabbitBusControl = Bus.Factory.CreateUsingRabbitMq(sbc =>
            {
                var host = sbc.Host(new Uri("rabbitmq://localhost"), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

//                sbc.ReceiveEndpoint(host, "ProtectorQueue", ep =>
//                {
//                    ep.Bind("DatabaseRegistered");
//                    ep.Consumer(() => new DatabaseRegisteredConsumer());
//                });
//
//                sbc.ReceiveEndpoint(host, "ProtectorQueue", ep =>
//                {
//                    ep.Bind("DatabaseRegistered");
//                    ep.Consumer(() => new DatabaseRegisteredConsumer());
//                });

                sbc.ReceiveEndpoint(host, "DatabaseRegistered", ep =>
                {
                    ep.Consumer(() => new DatabaseRegisteredConsumer());
                });
            });

            _rabbitBusControl.Start();


            Console.WriteLine("Press any key to exit");
            Console.ReadKey();


            _rabbitBusControl.Stop();
        }
Example #14
0
        public Task Consume(ConsumeContext <RegisterDatabase> context)
        {
            ConsoleAppHelper.PrintHeader("Header.txt");

            var connectionDetails = context.Message.ConnectionDetails;

            var schema = Helper.GetSchemaInfo(connectionDetails);

            StorageHelper.StoreDatabaseDefinition(connectionDetails, schema.Tables, "monitor");

            var message = new DatabaseRegisteredMessage
            {
                Database = connectionDetails,
                Schema   = schema
            };

            context.Publish <DatabaseRegistered>(message);

            Console.WriteLine($"Registered database with {schema.Tables.Count} tables at {DateTime.Now}");

            return(Task.CompletedTask);
        }
Example #15
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight);
            ShowWindow(ThisConsole, MAXIMIZE);

            ConsoleAppHelper.PrintHeader("Header.txt");

            Cleanup();

            System.IO.DirectoryInfo di = new DirectoryInfo(@"C:\dev\Stores\");
            foreach (FileInfo file in di.GetFiles())
            {
                file.Delete();
            }
            foreach (DirectoryInfo dir in di.GetDirectories())
            {
                Console.WriteLine($"Removing {dir.FullName}");
                dir.Delete(true);
            }

            Console.WriteLine("Finished");
            Console.ReadLine();
        }
Example #16
0
        static void TimerTick(Object obj, ElapsedEventArgs e)
        {
            ConsoleAppHelper.PrintHeader("Header.txt");

            GetStatuses();
        }