Пример #1
0
 public override void Process(CmdTrigger <AuthServerCmdArgs> trigger)
 {
     trigger.Reply("Recreating Database Schema...");
     DatabaseUtil.CreateSchema();
     AccountMgr.Instance.ResetCache();
     trigger.Reply("Done.");
 }
Пример #2
0
        public static bool Initialize()
        {
            if (!RealmDBMgr.Initialized)
            {
                RealmDBMgr.Initialized        = true;
                DatabaseUtil.DBErrorHook      = (Predicate <Exception>)(exception => CharacterRecord.GetCount() < 100);
                DatabaseUtil.DBType           = RealmServerConfiguration.DatabaseType;
                DatabaseUtil.ConnectionString = RealmServerConfiguration.DBConnectionString;
                DatabaseUtil.DefaultCharset   = RealmDBMgr.DefaultCharset;
                Assembly assembly = typeof(RealmDBMgr).Assembly;
                try
                {
                    if (!DatabaseUtil.InitAR(assembly))
                    {
                        return(false);
                    }
                }
                catch (Exception ex1)
                {
                    RealmDBMgr.OnDBError(ex1);
                    try
                    {
                        if (!DatabaseUtil.InitAR(assembly))
                        {
                            return(false);
                        }
                    }
                    catch (Exception ex2)
                    {
                        LogUtil.ErrorException(ex2, true, "Failed to initialize the Database.", new object[0]);
                    }
                }
            }

            int num = 0;

            try
            {
                num = CharacterRecord.GetCount();
            }
            catch
            {
            }

            if (num == 0)
            {
                DatabaseUtil.CreateSchema();
            }
            NHIdGenerator.InitializeCreators(new Action <Exception>(RealmDBMgr.OnDBError));
            ServerApp <WCell.RealmServer.RealmServer> .InitMgr.SignalGlobalMgrReady(typeof(RealmDBMgr));

            return(true);
        }
Пример #3
0
        public static void ResetDB()
        {
            RealmDBMgr.Initialize();

            int count = CharacterRecord.GetCount();

            if (count > 500)
            {
                throw new Exception("Cannot run tests on production servers since it requires to drop the complete Database. " +
                                    "Test run aborted because " + count + " Characters were found (must not be more than 500). Drop the Database manually to proceed.");
            }

            DatabaseUtil.DropSchema();
            DatabaseUtil.CreateSchema();
        }
Пример #4
0
        public static bool Initialize()
        {
            DatabaseUtil.DBErrorHook = exception => AccountMgr.Instance.Count < 100;

            DatabaseUtil.DBType           = AuthServerConfiguration.DBType;
            DatabaseUtil.ConnectionString = AuthServerConfiguration.DBConnectionString;
            DatabaseUtil.DefaultCharset   = DefaultCharset;

            var asm = typeof(AuthDBMgr).Assembly;

            try
            {
                if (!DatabaseUtil.InitAR(asm))
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                OnDBError(e);

                // repeat init
                DatabaseUtil.InitAR(asm);
            }


            // create tables if not already existing
            var count = 0;

            try
            {
                count = Account.GetCount();
            }
            catch
            {
            }

            if (count == 0)
            {
                // in case that the CharacterRecord table does not exist -> Recreate schema
                DatabaseUtil.CreateSchema();
            }

            NHIdGenerator.InitializeCreators(OnDBError);

            return(true);
        }
Пример #5
0
 public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
 {
     trigger.Reply("Recreating Database Schema...");
     DatabaseUtil.CreateSchema();
     trigger.Reply("Done.");
 }
Пример #6
0
        public static bool Initialize()
        {
            if (!Initialized)
            {
                Initialized = true;
                DatabaseUtil.DBErrorHook = exception => CharacterRecord.GetCount() < 100;

                DatabaseUtil.DBType           = RealmServerConfiguration.DatabaseType;
                DatabaseUtil.ConnectionString = RealmServerConfiguration.DBConnectionString;
                DatabaseUtil.DefaultCharset   = DefaultCharset;

                var asm = typeof(RealmDBMgr).Assembly;

                try
                {
                    if (!DatabaseUtil.InitAR(asm))
                    {
                        return(false);
                    }
                }
                catch (Exception e)
                {
                    // repeat init
                    OnDBError(e);
                    try
                    {
                        if (!DatabaseUtil.InitAR(asm))
                        {
                            return(false);
                        }
                    }
                    catch (Exception e2)
                    {
                        LogUtil.ErrorException(e2, true, "Failed to initialize the Database.");
                    }
                }
            }

            // Create tables if not already existing:
            // NHibernate wraps up all added Persistors once the first connection to the DB is established
            // which again happens during the first query to the DB - The line to check for any existing Characters.

            // After the first query, you cannot register any further types.
            var count = 0;

            try
            {
                count = CharacterRecord.GetCount();
            }
            catch
            {
            }

            if (count == 0)
            {
                // in case that the CharacterRecord table does not exist -> Recreate schema
                DatabaseUtil.CreateSchema();
            }

            NHIdGenerator.InitializeCreators(OnDBError);

            RealmServer.InitMgr.SignalGlobalMgrReady(typeof(RealmDBMgr));
            return(true);
        }
Пример #7
0
 public static void TearDown()
 {
     // make sure we get rid of the Characters again (since we create so many)
     DatabaseUtil.DropSchema();
     DatabaseUtil.CreateSchema();
 }