예제 #1
0
        static void Main(string[] args)
        {
            IConfiguration config = new ConfigurationBuilder()
                                    .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                                    .Build();

            // Common logging
            LogConfiguration logConfiguration = new LogConfiguration();

            config.GetSection("LogConfiguration").Bind(logConfiguration);
            LogManager.Configure(logConfiguration);

            // Serilog
            var log = new LoggerConfiguration()
                      .ReadFrom.Configuration(config) // Serilog.Settings.Configuration
                      .WriteTo.ColoredConsole()
                                                      //.WriteTo.File("Logs/log.txt", rollingInterval: RollingInterval.Day) // reading from appsetting.json
                      .CreateLogger();

            Log.Logger = log;

            ExtMigrationRunner.Initialize().Process();

            log.Error("Test error message");
            log.Information("test information message");

            log.Information("===================================================================");
        }
        private static void Main(string[] args)
        {
            Logger.Info(ApplicationConstants.AppName);

            var p = new FluentCommandLineParser <ApplicationArguments>();

            p.SetupHelp("?", "help").Callback(text => System.Console.WriteLine(text));
            p.Setup(arg => arg.ForceApplyScripts).As('f', "force").SetDefault(false);
            // p.Setup(arg => arg.Databases).As('d', "db").SetDefault(new List<string> { "W", "R", "L" });

            var result = p.Parse(args);

            if (result.EmptyArgs)
            {
                for (int i = 0; i < 3; i++)
                {
                    System.Threading.Thread.Sleep(1000);
                    Logger.Info(string.Join("", Enumerable.Repeat(".", (i + 1)).ToList()));
                }
            }

            if (!result.HasErrors && !result.HelpCalled)
            {
                ExtMigrationRunner.Initialize().Process(p.Object.ForceApplyScripts);
            }

            Logger.Info("Done!");

            if (result.EmptyArgs)
            {
                System.Threading.Thread.Sleep(3000);
            }
        }
예제 #3
0
        private static void Main()
        {
            Logger.Info(@"
  ____        _        _                    __  __ _                 _             
 |  _ \  __ _| |_ __ _| |__   __ _ ___  ___|  \/  (_) __ _ _ __ __ _| |_ ___  _ __ 
 | | | |/ _` | __/ _` | '_ \ / _` / __|/ _ \ |\/| | |/ _` | '__/ _` | __/ _ \| '__|
 | |_| | (_| | || (_| | |_) | (_| \__ \  __/ |  | | | (_| | | | (_| | || (_) | |   
 |____/ \__,_|\__\__,_|_.__/ \__,_|___/\___|_|  |_|_|\__, |_|  \__,_|\__\___/|_|   
                                                     |___/                         ");
            try
            {
                #region Run migrate with default values
                //ExtMigrationRunner.Initialize().Process();
                //Console.ReadKey();

                #endregion

                #region Run migrate with custom values

                //var runner = ExtMigrationRunner.Initialize();
                //runner.ForDatabases(new SortedList<int, string> { { 1, "MovieStore" }, { 2, "InventoryDb" } });
                //runner.ForRootNamespace("DatabaseMigrateRunner.Migrations");
                //runner.ForDatabaseLayers(new SortedList<int, DatabaseScriptType>
                //{
                //    {2, DatabaseScriptType.SqlFunction},
                //    {3, DatabaseScriptType.SqlStoredProcedure},
                //    {1, DatabaseScriptType.SqlDataAndStructure}
                //});
                //runner.ForMigrationAssembly(typeof(Program).Assembly);
                //runner.Process();
                //Console.ReadKey();

                #endregion

                #region Run migrate with some tricks [THIS'S THE RECOMMENDED]

                var runner = ExtMigrationRunner.Initialize();

                Console.WriteLine();
                Console.WriteLine("**********************************************************************************");
                Console.WriteLine("*                              FOR TESTING PURPOSE                               *");
                Console.WriteLine("*    I ADDED SOME INVAILD SCRIPTS INSIDE [TestInvalidScripts_DELETEME] FOLDER    *");
                Console.WriteLine("*               ONCE YOU KNOW HOW IT WORKS YOU SHOULD DELETE IT                  *");
                Console.WriteLine("**********************************************************************************");
                Console.WriteLine();

                while (true)
                {
                    Logger.Info("Do you really want to run <type 'yes' to run>: ");
                    var result = Console.ReadLine();
                    if (!string.IsNullOrWhiteSpace(result))
                    {
                        Logger.Info("Your answer: " + result);
                        Logger.Info("");
                        Logger.Info("");
                        switch (result.ToLower().Trim())
                        {
                        case "ok":
                        case "yes":
                            runner.Process(true);
                            Logger.Info("Completed!");
                            break;

                        case "exit":
                        case "quit":
                        case "close":
                            Logger.Info("\n---------------------------------");
                            Logger.Info("System is closing, please wait...");
                            return;
                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                Logger.Info("Something happenned: " + ex.Message);
                Console.ReadKey();
            }
        }