Exemple #1
0
 private void LoadItems()
 {
     try
     {
         m_loadedItems = ItemRecord.LoadItems(EntityLowId);
     }
     catch (Exception e)
     {
         RealmDBMgr.OnDBError(e);
         m_loadedItems = ItemRecord.LoadItems(EntityLowId);
     }
 }
Exemple #2
0
 /// <summary>
 /// Retrieves a CharacterRecord based on the character name
 /// </summary>
 /// <param name="name">the character name</param>
 /// <returns>the corresponding <seealso cref="CharacterRecord"/></returns>
 public static CharacterRecord GetRecordByName(string name)
 {
     try
     {
         return(FindOne(Restrictions.Like("Name", name)));
     }
     catch (Exception ex)
     {
         RealmDBMgr.OnDBError(ex);
         return(null);
     }
 }
Exemple #3
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);
        }
Exemple #4
0
 /// <summary>
 /// Checks if a character with the given Id already exists.
 /// </summary>
 public static bool Exists(uint entityLowId)
 {
     try
     {
         return(Exists((ICriterion)Restrictions.Eq("Guid", (long)entityLowId)));
     }
     catch (Exception ex)
     {
         RealmDBMgr.OnDBError(ex);
         return(false);
     }
 }
Exemple #5
0
 /// <summary>
 /// Checks if a character with the given name already exists.
 /// </summary>
 /// <param name="characterName">the name to check for</param>
 /// <returns>true if the character exists; false otherwise</returns>
 public static bool Exists(string characterName)
 {
     try
     {
         return(Exists((ICriterion)Restrictions.Like("Name", characterName)));
     }
     catch (Exception ex)
     {
         RealmDBMgr.OnDBError(ex);
         return(false);
     }
 }
Exemple #6
0
 private void LoadFastItemSlots()
 {
     try
     {
         _asda2LoadedFastItemSlots = Asda2FastItemSlotRecord.LoadItems(EntityLowId);
     }
     catch (Exception e)
     {
         RealmDBMgr.OnDBError(e);
         _asda2LoadedFastItemSlots = Asda2FastItemSlotRecord.LoadItems(EntityLowId);
     }
 }
Exemple #7
0
 private void LoadFastItemSlots()
 {
     try
     {
         this._asda2LoadedFastItemSlots =
             (ICollection <Asda2FastItemSlotRecord>)Asda2FastItemSlotRecord.LoadItems(this.EntityLowId);
     }
     catch (Exception ex)
     {
         RealmDBMgr.OnDBError(ex);
         this._asda2LoadedFastItemSlots =
             (ICollection <Asda2FastItemSlotRecord>)Asda2FastItemSlotRecord.LoadItems(this.EntityLowId);
     }
 }
Exemple #8
0
 /// <summary>
 /// Checks if a character with the given Id already exists.
 /// </summary>
 public static bool Exists(uint entityLowId)
 {
     try
     {
         return(ActiveRecordBase <CharacterRecord> .Exists(new ICriterion[1]
         {
             (ICriterion)Restrictions.Eq("Guid", (object)(long)entityLowId)
         }));
     }
     catch (Exception ex)
     {
         RealmDBMgr.OnDBError(ex);
         return(false);
     }
 }
Exemple #9
0
 /// <summary>
 /// Checks if a character with the given name already exists.
 /// </summary>
 /// <param name="characterName">the name to check for</param>
 /// <returns>true if the character exists; false otherwise</returns>
 public static bool Exists(string characterName)
 {
     try
     {
         return(ActiveRecordBase <CharacterRecord> .Exists(new ICriterion[1]
         {
             (ICriterion)Restrictions.Like("Name", (object)characterName)
         }));
     }
     catch (Exception ex)
     {
         RealmDBMgr.OnDBError(ex);
         return(false);
     }
 }
Exemple #10
0
 /// <summary>
 /// Retrieves a CharacterRecord based on the character name
 /// </summary>
 /// <param name="name">the character name</param>
 /// <returns>the corresponding <seealso cref="T:WCell.RealmServer.Database.CharacterRecord" /></returns>
 public static CharacterRecord GetRecordByName(string name)
 {
     try
     {
         return(ActiveRecordBase <CharacterRecord> .FindOne(new ICriterion[1]
         {
             (ICriterion)Restrictions.Like("Name", (object)name)
         }));
     }
     catch (Exception ex)
     {
         RealmDBMgr.OnDBError(ex);
         return((CharacterRecord)null);
     }
 }
Exemple #11
0
 /// <summary>
 /// Gets the characters for the given account.
 /// </summary>
 /// <param name="account">the account</param>
 /// <returns>a collection of character objects of the characters on the given account</returns>
 public static CharacterRecord[] FindAllOfAccount(RealmAccount account)
 {
     CharacterRecord[] chrs;
     try
     {
         chrs = FindAllByProperty("Created", "AccountId", account.AccountId);
         //var chrs = FindAllByProperty("Created", "AccountId", account.AccountId);
         //chrs.Reverse();
         //return chrs;
     }
     catch (Exception ex)
     {
         RealmDBMgr.OnDBError(ex);
         chrs = FindAllByProperty("Created", "AccountId", account.AccountId);
     }
     //chrs.Reverse();
     return(chrs);
 }
Exemple #12
0
        /// <summary>Gets the characters for the given account.</summary>
        /// <param name="account">the account</param>
        /// <returns>a collection of character objects of the characters on the given account</returns>
        public static CharacterRecord[] FindAllOfAccount(int accId)
        {
            CharacterRecord[] allByProperty;
            try
            {
                allByProperty =
                    FindAllByProperty("Created", "AccountId", accId);
                foreach (CharacterRecord characterRecord in allByProperty)
                {
                    characterRecord.LoadItems();
                }
            }
            catch (Exception ex)
            {
                RealmDBMgr.OnDBError(ex);
                allByProperty =
                    FindAllByProperty("Created", "AccountId", accId);
            }

            return(allByProperty);
        }
Exemple #13
0
        /// <summary>Gets the characters for the given account.</summary>
        /// <param name="account">the account</param>
        /// <returns>a collection of character objects of the characters on the given account</returns>
        public static CharacterRecord[] FindAllOfAccount(RealmAccount account)
        {
            CharacterRecord[] allByProperty;
            try
            {
                allByProperty =
                    ActiveRecordBase <CharacterRecord> .FindAllByProperty("Created", "AccountId",
                                                                          (object)account.AccountId);

                foreach (CharacterRecord characterRecord in allByProperty)
                {
                    characterRecord.LoadItems();
                }
            }
            catch (Exception ex)
            {
                RealmDBMgr.OnDBError(ex);
                allByProperty =
                    ActiveRecordBase <CharacterRecord> .FindAllByProperty("Created", "AccountId",
                                                                          (object)account.AccountId);
            }

            return(allByProperty);
        }