FreakOut.classes.DatabaseConnector.DatabaseConnector C# (CSharp) Method

DatabaseConnector() public method

public DatabaseConnector ( Logger Logfacility ) : System
Logfacility Logger
return System
        public DatabaseConnector(Logger Logfacility)
        {
            LogInstance = Logfacility;
            LogInstance.WriteToFile(4, "Connecting to database with the following Connection-String: " + "ServerType=1;User=SYSDBA;Password=masterkey;Dialect=3;Database=database.fdb", LogSource);
            DBConnector = new FbConnection("ServerType=1;User=SYSDBA;Password=masterkey;Dialect=3;Database=database.fdb");

            //Check for existing database. If no avail., create a new one

            if (!System.IO.File.Exists("Database.fdb"))
            {
                LogInstance.WriteToFile(1, "No DB found! Creating database and initializing tables.", LogSource);
                FbConnection.CreateDatabase("ServerType=1;User=SYSDBA;Password=masterkey;Dialect=3;Database=database.fdb");
                //initialize the connection and create the tables
                this.InitializeDatabase();
            }
            else
            {
                if (!CheckTables)
                {
                    LogInstance.WriteToFile(1, "Backing up old database since the current one didn't pass the sanity checks.", LogSource);

                    if (File.Exists("database.fdb.backup"))
                    {
                        LogInstance.WriteToFile(2, "There is already a database backed up. I will move it to the Folder 'BACKUP' then.", LogSource);
                        if (!Directory.Exists("BACKUP"))
                            Directory.CreateDirectory("BACKUP");

                        File.Move("database.fdb.backup", "BACKUP\\database.fdb.backup." + DateTime.Now.ToFileTime());
                        LogInstance.WriteToFile(2, "New location for database.fdb.backup:\nBACKUP\\database.fdb.backup." + DateTime.Now.ToFileTime() + "\n", LogSource);
                        File.Move("database.fdb", "database.fdb.backup");
                    }
                    else
                        File.Move("database.fdb", "database.fdb.backup");

                    FbConnection.CreateDatabase("ServerType=1;User=SYSDBA;Password=masterkey;Dialect=3;Database=database.fdb");
                    //initialize the connection and create the tables
                    DBConnector = new FbConnection("ServerType=1;User=SYSDBA;Password=masterkey;Dialect=3;Database=database.fdb");
                    this.InitializeDatabase();
                }
            }
        }