Esempio n. 1
0
        public static void Main(string[] args)
        {
            CliUtil.WriteHeader(Properties.Resources.ConsoleTitle);

            Console.WriteLine("Test of database connection");
            var db = new PastorsDeskDb();
            try
            {
                db.Init("127.0.0.1", "root", "dwilliams378007!", "pastorsdesk");
            }
            catch (Exception)
            {
                System.Windows.MessageBox.Show("Error with database!");
            }

            Console.ReadLine();
        }
Esempio n. 2
0
 /// <summary>
 /// Tries to initialize database with the information from conf,
 /// exits on error.
 /// </summary>
 public virtual void InitDatabase(PastorsDeskDb db, BaseConf conf)
 {
     using (var t = new ChangingOutput("Initializing database..."))
     {
         try
         {
             Log.ToFile("Initializing database...", LogLevel.Info);
             db.Init(conf.Database.Host, conf.Database.User, conf.Database.Pass, conf.Database.Db);
             t.PrintResult(true);
         }
         catch (Exception ex)
         {
             t.PrintResult(false);
             Log.Error("Unable to open database connection. ({0})", ex.Message);
             CliUtil.Exit(1);
         }
     }
 }