Пример #1
0
        public static void Load()
        {
            var reader = DatabaseManager.Provider.ExecuteReader("SELECT * FROM characters_guild");
            int br     = 0;

            while (reader.Read())
            {
                var guild = GuildTable.GetGuild(reader.GetInt32("guild"));
                if (guild != null)
                {
                    var member = new Models.CharacterGuild()
                    {
                        ID                = reader.GetInt64("guid"),
                        Name              = reader.GetString("name"),
                        Guild             = reader.GetInt32("guild"),
                        Level             = reader.GetInt32("level"),
                        Gfx               = reader.GetInt32("look"),
                        Grade             = reader.GetInt32("rank"),
                        ExperiencePercent = reader.GetInt32("xpdone"),
                        Experience        = reader.GetInt64("xpdone"),
                        Restriction       = reader.GetInt32("rights"),
                        Alignement        = reader.GetInt32("align"),
                        lastConnection    = CDateTimeUtil.MySqlToNet(reader.GetMySqlDateTime("lastConnection")),
                    };
                    guild.CharactersGuildCache.Add(member);
                    br++;
                }
            }
            reader.Close();

            Logger.Info("Loaded @'" + br + "'@ Characters Guild");
        }
Пример #2
0
        public static AccountModel FindFirst(string username)
        {
            AccountModel    account = null;
            MySqlDataReader reader  = null;

            try
            {
                MySqlCommand Command = new MySqlCommand()
                {
                    Connection  = DatabaseManager.Provider.getConnection(),
                    CommandText =
                        "SELECT guid,username,pass,banned,level,pseudo,logged,question,answer,lastip,lastConnectionDate FROM accounts WHERE username=@user",
                };
                Command.Prepare();
                Command.Parameters.AddWithValue("@user", username);

                reader = DatabaseManager.Provider.ExecuteCommand(Command);
                if (reader.Read())
                {
                    account = new Models.AccountModel()
                    {
                        ID                 = reader.GetInt32("guid"),
                        Username           = reader.GetString("username"),
                        Password           = reader.GetString("pass"),
                        Pseudo             = reader.GetString("pseudo"),
                        Level              = reader.GetInt32("level"),
                        Banned             = reader.GetInt64("banned"),
                        Logged             = reader.GetInt32("logged"),
                        LastIP             = reader.GetString("lastip"),
                        SecretQuestion     = reader.GetString("question"),
                        SecretAnswer       = reader.GetString("answer"),
                        LastConnectionDate = CDateTimeUtil.MySqlToNet(reader.GetMySqlDateTime("lastConnectionDate")),
                    };
                }
                reader.Close();
                if (account != null)
                {
                    FindCharacters(account);
                }
                Command = null;
            }
            catch (Exception e)
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
                Logger.Error(e);
            }
            return(account);
        }
Пример #3
0
        public int getHoursFromLastCo()
        {
            DateTime now = DateTime.Now;

            return(CDateTimeUtil.GetDaysBetweenDates(this.lastConnection, now) * 24);
        }